diff --git a/schema/drives-file-browser.json b/schema/drives-file-browser.json index 3484989..5ec33a1 100644 --- a/schema/drives-file-browser.json +++ b/schema/drives-file-browser.json @@ -27,6 +27,12 @@ "command": "drives:toggle-file-filter", "label": "", "rank": 40 + }, + { + "name": "new-drive", + "command": "drives:create-new-drive", + "label": "", + "rank": 50 } ] }, diff --git a/src/plugins/driveBrowserPlugin.ts b/src/plugins/driveBrowserPlugin.ts index 8da3cf1..01ba119 100644 --- a/src/plugins/driveBrowserPlugin.ts +++ b/src/plugins/driveBrowserPlugin.ts @@ -147,6 +147,14 @@ export const driveFileBrowser: JupyterFrontEndPlugin = { } ); + const updateVisibility = () => { + // Visibility of command changed. + app.commands.notifyCommandChanged(CommandIDs.createNewDrive); + }; + + // Listen for path changes. + driveBrowser.model.pathChanged.connect(updateVisibility); + // Add commands Private.addCommands(app, drive, driveBrowser); @@ -318,6 +326,9 @@ namespace Private { browser: FileBrowser ): void { app.commands.addCommand(CommandIDs.createNewDrive, { + isVisible: () => { + return browser.model.path === 's3:'; + }, execute: async () => { return showDialog({ title: 'New Drive',