Skip to content

Commit 67a49d7

Browse files
committed
replace drives list provider plugin
1 parent 3121c8f commit 67a49d7

File tree

3 files changed

+8
-28
lines changed

3 files changed

+8
-28
lines changed

src/contents.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import {
1919
countObjectNameAppearances,
2020
renameObjects,
2121
copyObjects,
22-
presignedLink
22+
presignedLink,
23+
getDrivesList
2324
} from './requests';
2425

2526
let data: Contents.IModel = {
@@ -245,6 +246,8 @@ export class Drive implements Contents.IDrive {
245246
// retriving list of contents from root
246247
// in our case: list available drives
247248
const drivesList: Contents.IModel[] = [];
249+
// fetch list of available drives
250+
this._drivesList = await getDrivesList();
248251
for (const drive of this._drivesList) {
249252
drivesList.push({
250253
name: drive.name,

src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import { JupyterFrontEndPlugin } from '@jupyterlab/application';
22
import {
33
driveFileBrowser,
4-
drivesListProvider,
54
openDriveDialogPlugin,
65
launcherPlugin
76
} from './plugins';
87

98
const plugins: JupyterFrontEndPlugin<any>[] = [
109
driveFileBrowser,
11-
drivesListProvider,
1210
openDriveDialogPlugin,
1311
launcherPlugin
1412
];

src/plugins/driveBrowserPlugin.ts

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import { CommandRegistry } from '@lumino/commands';
2222

2323
import { driveBrowserIcon } from '../icons';
2424
import { Drive } from '../contents';
25-
import { getDrivesList, setListingLimit } from '../requests';
26-
import { IDriveInfo, IDrivesList, CommandIDs } from '../token';
25+
import { setListingLimit } from '../requests';
26+
import { CommandIDs } from '../token';
2727

2828
/**
2929
* The file browser factory ID.
@@ -35,24 +35,6 @@ const FILE_BROWSER_FACTORY = 'DriveBrowser';
3535
*/
3636
const FILTERBOX_CLASS = 'jp-drive-browser-search-box';
3737

38-
/**
39-
* The drives list provider.
40-
*/
41-
export const drivesListProvider: JupyterFrontEndPlugin<IDriveInfo[]> = {
42-
id: 'jupyter-drives:drives-list',
43-
description: 'The drives list provider.',
44-
provides: IDrivesList,
45-
activate: async (_: JupyterFrontEnd): Promise<IDriveInfo[]> => {
46-
let drives: IDriveInfo[] = [];
47-
try {
48-
drives = await getDrivesList();
49-
} catch (error) {
50-
console.log('Failed loading available drives list, with error: ', error);
51-
}
52-
return drives;
53-
}
54-
};
55-
5638
/**
5739
* The drive file browser factory provider.
5840
*/
@@ -64,8 +46,7 @@ export const driveFileBrowser: JupyterFrontEndPlugin<void> = {
6446
IFileBrowserFactory,
6547
IToolbarWidgetRegistry,
6648
ISettingRegistry,
67-
ITranslator,
68-
IDrivesList
49+
ITranslator
6950
],
7051
optional: [
7152
IRouter,
@@ -79,7 +60,6 @@ export const driveFileBrowser: JupyterFrontEndPlugin<void> = {
7960
toolbarRegistry: IToolbarWidgetRegistry,
8061
settingsRegistry: ISettingRegistry,
8162
translator: ITranslator,
82-
drivesList: IDriveInfo[],
8363
router: IRouter | null,
8464
tree: JupyterFrontEnd.ITreeResolver | null,
8565
labShell: ILabShell | null,
@@ -92,8 +72,7 @@ export const driveFileBrowser: JupyterFrontEndPlugin<void> = {
9272

9373
// create drive for drive file browser
9474
const drive = new Drive({
95-
name: 's3',
96-
drivesList: drivesList
75+
name: 's3'
9776
});
9877

9978
app.serviceManager.contents.addDrive(drive);

0 commit comments

Comments
 (0)