From d3cac04b1d1f55c1955bb469cbd37d08187b446e Mon Sep 17 00:00:00 2001 From: DenisaCG Date: Mon, 11 Aug 2025 17:40:47 +0200 Subject: [PATCH 1/3] update mount function to allow location parameter --- jupyter_drives/manager.py | 6 ++++-- src/plugins/drivelistmanager.tsx | 3 ++- src/requests.ts | 5 +++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/jupyter_drives/manager.py b/jupyter_drives/manager.py index 705eba4..3d7a7c0 100644 --- a/jupyter_drives/manager.py +++ b/jupyter_drives/manager.py @@ -303,7 +303,7 @@ async def list_drives(self): } return response - async def mount_drive(self, drive_name, provider): + async def mount_drive(self, drive_name, provider, location=''): """Mount a drive. Args: @@ -311,7 +311,9 @@ async def mount_drive(self, drive_name, provider): """ try: if provider == 's3': - if drive_name in self._external_drives and self._external_drives[drive_name]["is_public"] is False: + if location: + region = location + elif drive_name in self._external_drives and self._external_drives[drive_name]["is_public"] is False: region = self._external_drives[drive_name]["location"] else: region = await self._get_drive_location(drive_name) diff --git a/src/plugins/drivelistmanager.tsx b/src/plugins/drivelistmanager.tsx index 5cc718a..6b83151 100644 --- a/src/plugins/drivelistmanager.tsx +++ b/src/plugins/drivelistmanager.tsx @@ -212,7 +212,8 @@ export function DriveListManagerComponent({ model }: IProps) { const onAddedPublicDrive = async () => { // Check if user has access to drive. const result = await mountDrive(publicDrive, { - provider: 's3' + provider: 's3', + location: isPublic ? '' : driveRegion }); if (result && result.error) { // Show error in case of failure. diff --git a/src/requests.ts b/src/requests.ts index 8891eb5..d9c2ce0 100644 --- a/src/requests.ts +++ b/src/requests.ts @@ -67,11 +67,12 @@ export async function getDrivesList() { */ export async function mountDrive( driveName: string, - options: { provider: string } + options: { provider: string; location?: string } ) { const body: ReadonlyJSONObject = { drive_name: driveName, - provider: options.provider + provider: options.provider, + location: options.location ?? '' }; try { await requestAPI('drives', 'POST', body); From 81885c4d68f2eadbdcfa5bfa4abb7e70175d4485 Mon Sep 17 00:00:00 2001 From: DenisaCG Date: Mon, 11 Aug 2025 17:45:22 +0200 Subject: [PATCH 2/3] reset fields after submission --- src/plugins/drivelistmanager.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/drivelistmanager.tsx b/src/plugins/drivelistmanager.tsx index 6b83151..885cac2 100644 --- a/src/plugins/drivelistmanager.tsx +++ b/src/plugins/drivelistmanager.tsx @@ -224,9 +224,10 @@ export function DriveListManagerComponent({ model }: IProps) { await addPublicDrive(publicDrive); } else { await addExternalDrive(publicDrive, driveRegion); - setDriveRegion(''); } + setPublicDrive(''); setDriveRegion(''); + setIsPublic(false); await model.refresh(); } }; From 160adec40f18ad066160fe2afacf6bbad14b1d07 Mon Sep 17 00:00:00 2001 From: DenisaCG Date: Mon, 11 Aug 2025 18:13:22 +0200 Subject: [PATCH 3/3] reset region when checking public box --- src/plugins/drivelistmanager.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plugins/drivelistmanager.tsx b/src/plugins/drivelistmanager.tsx index 885cac2..662599b 100644 --- a/src/plugins/drivelistmanager.tsx +++ b/src/plugins/drivelistmanager.tsx @@ -68,7 +68,10 @@ export function DriveInputComponent({ setIsPublic(event.target.checked)} + onChange={event => { + setIsPublic(event.target.checked); + setRegion(''); + }} /> {!isPublic && (