From 67a49d765c20250b1e5beac4f203d2a312ad94d7 Mon Sep 17 00:00:00 2001 From: DenisaCG Date: Wed, 8 Jan 2025 23:02:25 +0100 Subject: [PATCH] replace drives list provider plugin --- src/contents.ts | 5 ++++- src/index.ts | 2 -- src/plugins/driveBrowserPlugin.ts | 29 ++++------------------------- 3 files changed, 8 insertions(+), 28 deletions(-) diff --git a/src/contents.ts b/src/contents.ts index d430c36..c0b7c3f 100644 --- a/src/contents.ts +++ b/src/contents.ts @@ -19,7 +19,8 @@ import { countObjectNameAppearances, renameObjects, copyObjects, - presignedLink + presignedLink, + getDrivesList } from './requests'; let data: Contents.IModel = { @@ -245,6 +246,8 @@ export class Drive implements Contents.IDrive { // retriving list of contents from root // in our case: list available drives const drivesList: Contents.IModel[] = []; + // fetch list of available drives + this._drivesList = await getDrivesList(); for (const drive of this._drivesList) { drivesList.push({ name: drive.name, diff --git a/src/index.ts b/src/index.ts index 680438a..b25c60d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,14 +1,12 @@ import { JupyterFrontEndPlugin } from '@jupyterlab/application'; import { driveFileBrowser, - drivesListProvider, openDriveDialogPlugin, launcherPlugin } from './plugins'; const plugins: JupyterFrontEndPlugin[] = [ driveFileBrowser, - drivesListProvider, openDriveDialogPlugin, launcherPlugin ]; diff --git a/src/plugins/driveBrowserPlugin.ts b/src/plugins/driveBrowserPlugin.ts index eca6cde..adafe9c 100644 --- a/src/plugins/driveBrowserPlugin.ts +++ b/src/plugins/driveBrowserPlugin.ts @@ -22,8 +22,8 @@ import { CommandRegistry } from '@lumino/commands'; import { driveBrowserIcon } from '../icons'; import { Drive } from '../contents'; -import { getDrivesList, setListingLimit } from '../requests'; -import { IDriveInfo, IDrivesList, CommandIDs } from '../token'; +import { setListingLimit } from '../requests'; +import { CommandIDs } from '../token'; /** * The file browser factory ID. @@ -35,24 +35,6 @@ const FILE_BROWSER_FACTORY = 'DriveBrowser'; */ const FILTERBOX_CLASS = 'jp-drive-browser-search-box'; -/** - * The drives list provider. - */ -export const drivesListProvider: JupyterFrontEndPlugin = { - id: 'jupyter-drives:drives-list', - description: 'The drives list provider.', - provides: IDrivesList, - activate: async (_: JupyterFrontEnd): Promise => { - let drives: IDriveInfo[] = []; - try { - drives = await getDrivesList(); - } catch (error) { - console.log('Failed loading available drives list, with error: ', error); - } - return drives; - } -}; - /** * The drive file browser factory provider. */ @@ -64,8 +46,7 @@ export const driveFileBrowser: JupyterFrontEndPlugin = { IFileBrowserFactory, IToolbarWidgetRegistry, ISettingRegistry, - ITranslator, - IDrivesList + ITranslator ], optional: [ IRouter, @@ -79,7 +60,6 @@ export const driveFileBrowser: JupyterFrontEndPlugin = { toolbarRegistry: IToolbarWidgetRegistry, settingsRegistry: ISettingRegistry, translator: ITranslator, - drivesList: IDriveInfo[], router: IRouter | null, tree: JupyterFrontEnd.ITreeResolver | null, labShell: ILabShell | null, @@ -92,8 +72,7 @@ export const driveFileBrowser: JupyterFrontEndPlugin = { // create drive for drive file browser const drive = new Drive({ - name: 's3', - drivesList: drivesList + name: 's3' }); app.serviceManager.contents.addDrive(drive);