Skip to content

Commit

Permalink
replace drives list provider plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisaCG committed Jan 8, 2025
1 parent 3121c8f commit 67a49d7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 28 deletions.
5 changes: 4 additions & 1 deletion src/contents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import {
countObjectNameAppearances,
renameObjects,
copyObjects,
presignedLink
presignedLink,
getDrivesList
} from './requests';

let data: Contents.IModel = {
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { JupyterFrontEndPlugin } from '@jupyterlab/application';
import {
driveFileBrowser,
drivesListProvider,
openDriveDialogPlugin,
launcherPlugin
} from './plugins';

const plugins: JupyterFrontEndPlugin<any>[] = [
driveFileBrowser,
drivesListProvider,
openDriveDialogPlugin,
launcherPlugin
];
Expand Down
29 changes: 4 additions & 25 deletions src/plugins/driveBrowserPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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<IDriveInfo[]> = {
id: 'jupyter-drives:drives-list',
description: 'The drives list provider.',
provides: IDrivesList,
activate: async (_: JupyterFrontEnd): Promise<IDriveInfo[]> => {
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.
*/
Expand All @@ -64,8 +46,7 @@ export const driveFileBrowser: JupyterFrontEndPlugin<void> = {
IFileBrowserFactory,
IToolbarWidgetRegistry,
ISettingRegistry,
ITranslator,
IDrivesList
ITranslator
],
optional: [
IRouter,
Expand All @@ -79,7 +60,6 @@ export const driveFileBrowser: JupyterFrontEndPlugin<void> = {
toolbarRegistry: IToolbarWidgetRegistry,
settingsRegistry: ISettingRegistry,
translator: ITranslator,
drivesList: IDriveInfo[],
router: IRouter | null,
tree: JupyterFrontEnd.ITreeResolver | null,
labShell: ILabShell | null,
Expand All @@ -92,8 +72,7 @@ export const driveFileBrowser: JupyterFrontEndPlugin<void> = {

// create drive for drive file browser
const drive = new Drive({
name: 's3',
drivesList: drivesList
name: 's3'
});

app.serviceManager.contents.addDrive(drive);
Expand Down

0 comments on commit 67a49d7

Please sign in to comment.