Skip to content

Commit 8b7939c

Browse files
committed
additional check for public drive and error handling
1 parent 46b57a8 commit 8b7939c

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/plugins/driveBrowserPlugin.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import {
1919
IToolbarWidgetRegistry,
2020
setToolbar,
2121
showDialog,
22-
Dialog
22+
Dialog,
23+
Notification
2324
} from '@jupyterlab/apputils';
2425
import { ISettingRegistry } from '@jupyterlab/settingregistry';
2526
import {
@@ -39,8 +40,9 @@ import { Widget } from '@lumino/widgets';
3940

4041
import { driveBrowserIcon, removeIcon } from '../icons';
4142
import { Drive } from '../contents';
42-
import { getContents, setListingLimit } from '../requests';
43+
import { getContents, mountDrive, setListingLimit } from '../requests';
4344
import { CommandIDs } from '../token';
45+
import { DrivesResponseError } from '../handler';
4446

4547
/**
4648
* Status bar widget for displaying drive information
@@ -535,9 +537,23 @@ namespace Private {
535537
ariaLabel: 'Add Drive'
536538
})
537539
]
538-
}).then(result => {
540+
}).then(async result => {
539541
if (result.value) {
540-
drive.addPublicDrive(result.value);
542+
const response = await mountDrive(result.value, {
543+
provider: 's3'
544+
});
545+
if (response && response.error) {
546+
// Show error in case of failure.
547+
Notification.emit(
548+
(response.error as DrivesResponseError).message,
549+
'error',
550+
{
551+
autoClose: 5000
552+
}
553+
);
554+
} else {
555+
drive.addPublicDrive(result.value);
556+
}
541557
}
542558
});
543559
},

0 commit comments

Comments
 (0)