From de4f5a7e4d7a162f5bd062f5f919b5429c864fdc Mon Sep 17 00:00:00 2001 From: DenisaCG Date: Fri, 8 Aug 2025 15:46:20 +0200 Subject: [PATCH 1/5] remove uneccessary error explanation --- jupyter_drives/manager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jupyter_drives/manager.py b/jupyter_drives/manager.py index 5af78db..705eba4 100644 --- a/jupyter_drives/manager.py +++ b/jupyter_drives/manager.py @@ -319,7 +319,7 @@ async def mount_drive(self, drive_name, provider): except Exception as e: raise tornado.web.HTTPError( status_code= httpx.codes.BAD_REQUEST, - reason= f"The following error occured when mouting the drive: {e}" + reason= f"{e}" ) return @@ -771,7 +771,7 @@ async def _get_drive_location(self, drive_name): except Exception as e: raise tornado.web.HTTPError( status_code= httpx.codes.BAD_REQUEST, - reason=f"The following error occured when retriving the drive location: {e}", + reason=f"{e}", ) return location From 170b8050a3fa16c0adeacf03702b4f5eef51adef Mon Sep 17 00:00:00 2001 From: DenisaCG Date: Fri, 8 Aug 2025 15:46:49 +0200 Subject: [PATCH 2/5] update mount function to return error message --- src/requests.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/requests.ts b/src/requests.ts index 1ed57d7..8891eb5 100644 --- a/src/requests.ts +++ b/src/requests.ts @@ -73,7 +73,15 @@ export async function mountDrive( drive_name: driveName, provider: options.provider }; - return await requestAPI('drives', 'POST', body); + try { + await requestAPI('drives', 'POST', body); + } catch (error: any) { + return { + error: error + }; + } + + return; } /** From 37c52674fb27ec2a8fc2d3560dbe6a82788f8f8b Mon Sep 17 00:00:00 2001 From: DenisaCG Date: Fri, 8 Aug 2025 15:47:31 +0200 Subject: [PATCH 3/5] update adding external drive component to show error --- src/plugins/drivelistmanager.tsx | 34 +++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/plugins/drivelistmanager.tsx b/src/plugins/drivelistmanager.tsx index fc47290..5b7ec4f 100644 --- a/src/plugins/drivelistmanager.tsx +++ b/src/plugins/drivelistmanager.tsx @@ -9,7 +9,8 @@ import { excludeDrive, getDrivesList, getExcludedDrives, - includeDrive + includeDrive, + mountDrive } from '../requests'; import { ISignal, Signal } from '@lumino/signaling'; import { driveBrowserIcon, addIcon, removeIcon } from '../icons'; @@ -27,6 +28,7 @@ export interface IDriveInputProps { onSubmit: () => void; isPublic: boolean; setIsPublic: (value: boolean) => void; + mountError: string; } export function DriveInputComponent({ @@ -36,7 +38,8 @@ export function DriveInputComponent({ setRegion, onSubmit, isPublic, - setIsPublic + setIsPublic, + mountError }: IDriveInputProps) { return (
@@ -75,6 +78,11 @@ export function DriveInputComponent({ /> )}
+ {mountError && ( +
+

{mountError}

+
+ )} ); } @@ -183,6 +191,7 @@ export function DriveListManagerComponent({ model }: IProps) { ); const [isPublic, setIsPublic] = useState(false); const [driveRegion, setDriveRegion] = useState(''); + const [mountError, setMountError] = useState(''); // Called after mounting. React.useEffect(() => { @@ -197,14 +206,24 @@ export function DriveListManagerComponent({ model }: IProps) { }, [model]); const onAddedPublicDrive = async () => { - if (isPublic) { - await addPublicDrive(publicDrive); + // Check if user has access to drive. + const result = await mountDrive(publicDrive, { + provider: 's3' + }); + if (result && result.error) { + // Show error in case of failure. + setMountError(result.error.message); } else { - await addExternalDrive(publicDrive, driveRegion); + // Proceed with adding the drive otherwise. + if (isPublic) { + await addPublicDrive(publicDrive); + } else { + await addExternalDrive(publicDrive, driveRegion); + setDriveRegion(''); + } setDriveRegion(''); + await model.refresh(); } - setPublicDrive(''); - await model.refresh(); }; return ( @@ -239,6 +258,7 @@ export function DriveListManagerComponent({ model }: IProps) { isPublic={isPublic} setIsPublic={setIsPublic} onSubmit={onAddedPublicDrive} + mountError={mountError} /> From 5cc7b1f6ab2befc2728c38a2e0721fa8fb837a05 Mon Sep 17 00:00:00 2001 From: DenisaCG Date: Fri, 8 Aug 2025 15:47:59 +0200 Subject: [PATCH 4/5] add style for mount error --- style/base.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/style/base.css b/style/base.css index da490ae..204e0f5 100644 --- a/style/base.css +++ b/style/base.css @@ -157,3 +157,8 @@ li { fill: var(--jp-ui-inverse-font-color0) !important; color: var(--jp-ui-inverse-font-color0) !important; } + +.error { + color: var(--md-red-600); + font-size: 0.7rem; +} From 7a6adce0c866caabaa9acb7dc7f00b4c5b697614 Mon Sep 17 00:00:00 2001 From: DenisaCG Date: Fri, 8 Aug 2025 15:51:06 +0200 Subject: [PATCH 5/5] reset mounting error upon input change --- src/plugins/drivelistmanager.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/drivelistmanager.tsx b/src/plugins/drivelistmanager.tsx index 5b7ec4f..5cc718a 100644 --- a/src/plugins/drivelistmanager.tsx +++ b/src/plugins/drivelistmanager.tsx @@ -29,6 +29,7 @@ export interface IDriveInputProps { isPublic: boolean; setIsPublic: (value: boolean) => void; mountError: string; + resetMountError: () => void; } export function DriveInputComponent({ @@ -39,7 +40,8 @@ export function DriveInputComponent({ onSubmit, isPublic, setIsPublic, - mountError + mountError, + resetMountError }: IDriveInputProps) { return (
@@ -48,6 +50,7 @@ export function DriveInputComponent({ className="drive-search-input" onInput={(event: any) => { setPublicDrive(event.target.value); + resetMountError(); }} placeholder="Enter drive name" value={driveValue} @@ -72,6 +75,7 @@ export function DriveInputComponent({ className="drive-region-input" onInput={(event: any) => { setRegion(event.target.value); + resetMountError(); }} placeholder="Region (e.g.: us-east-1)" value={regionValue} @@ -259,6 +263,7 @@ export function DriveListManagerComponent({ model }: IProps) { setIsPublic={setIsPublic} onSubmit={onAddedPublicDrive} mountError={mountError} + resetMountError={() => setMountError('')} />