Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions jupyter_drives/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,17 @@ 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:
drive_name: name of drive to mount
"""
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)
Expand Down
11 changes: 8 additions & 3 deletions src/plugins/drivelistmanager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ export function DriveInputComponent({
<input
type="checkbox"
checked={isPublic}
onChange={event => setIsPublic(event.target.checked)}
onChange={event => {
setIsPublic(event.target.checked);
setRegion('');
}}
/>
{!isPublic && (
<input
Expand Down Expand Up @@ -212,7 +215,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: driveRegion
});
if (result && result.error) {
// Show error in case of failure.
Expand All @@ -223,9 +227,10 @@ export function DriveListManagerComponent({ model }: IProps) {
await addPublicDrive(publicDrive);
} else {
await addExternalDrive(publicDrive, driveRegion);
setDriveRegion('');
}
setPublicDrive('');
setDriveRegion('');
setIsPublic(false);
await model.refresh();
}
};
Expand Down
5 changes: 3 additions & 2 deletions src/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>('drives', 'POST', body);
Expand Down
Loading