From 67a49d765c20250b1e5beac4f203d2a312ad94d7 Mon Sep 17 00:00:00 2001 From: DenisaCG Date: Wed, 8 Jan 2025 23:02:25 +0100 Subject: [PATCH 1/3] 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); From 7bce0d607977aa7944fd9601025c3ed9d0c4b1b4 Mon Sep 17 00:00:00 2001 From: DenisaCG Date: Mon, 13 Jan 2025 21:25:30 +0100 Subject: [PATCH 2/3] remove drives list plugin token --- src/token.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/token.ts b/src/token.ts index 33e0149..857ab5a 100644 --- a/src/token.ts +++ b/src/token.ts @@ -1,4 +1,3 @@ -import { Token } from '@lumino/coreutils'; import { Contents } from '@jupyterlab/services'; /** @@ -12,13 +11,6 @@ export namespace CommandIDs { export const launcher = 'launcher:create'; } -/** - * A token for the plugin that provides the list of drives. - */ -export const IDrivesList = new Token( - 'jupyter-drives:drives-list-provider' -); - /** * An interface that stores the drive information. */ From 7583a9b9de0bcb393350d18fe99ffbcb6978d9de Mon Sep 17 00:00:00 2001 From: DenisaCG Date: Mon, 13 Jan 2025 21:26:28 +0100 Subject: [PATCH 3/3] remove unused parameter --- src/plugins/driveBrowserPlugin.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/driveBrowserPlugin.ts b/src/plugins/driveBrowserPlugin.ts index 3da608a..86f66e4 100644 --- a/src/plugins/driveBrowserPlugin.ts +++ b/src/plugins/driveBrowserPlugin.ts @@ -245,7 +245,7 @@ namespace Private { /** * Create the node for a creating a new drive handler. */ - const createNewDriveNode = (newDriveName: string): HTMLElement => { + const createNewDriveNode = (): HTMLElement => { const body = document.createElement('div'); const drive = document.createElement('label'); @@ -274,7 +274,7 @@ namespace Private { * Construct a new "create-drive" dialog. */ constructor(newDriveName: string) { - super({ node: createNewDriveNode(newDriveName) }); + super({ node: createNewDriveNode() }); this.onAfterAttach(); }