Skip to content

Commit ab2e322

Browse files
committed
override new directory command for drive browser
1 parent a19127b commit ab2e322

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

schema/drives-file-browser.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
{
1313
"name": "new-directory",
14-
"command": "filebrowser:create-new-directory",
14+
"command": "drives:create-new-directory",
1515
"label": "",
1616
"rank": 10
1717
},
@@ -36,6 +36,21 @@
3636
}
3737
]
3838
},
39+
"jupyter.lab.menus": {
40+
"context": [
41+
{
42+
"command": "filebrowser:create-new-directory",
43+
"selector": ".jp-DirListing-content",
44+
"rank": 55,
45+
"disabled": true
46+
},
47+
{
48+
"command": "drives:create-new-directory",
49+
"selector": ".jp-DirListing-content",
50+
"rank": 55
51+
}
52+
]
53+
},
3954
"jupyter.lab.setting-icon": "jupyter-drives:drive-browser",
4055
"jupyter.lab.setting-icon-label": "Drive Browser",
4156
"type": "object",

src/plugins/driveBrowserPlugin.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import { ISettingRegistry } from '@jupyterlab/settingregistry';
2222
import {
2323
filterIcon,
2424
FilenameSearcher,
25-
IScore
25+
IScore,
26+
newFolderIcon
2627
} from '@jupyterlab/ui-components';
2728
import { CommandRegistry } from '@lumino/commands';
2829
import { Widget } from '@lumino/widgets';
@@ -148,8 +149,9 @@ export const driveFileBrowser: JupyterFrontEndPlugin<void> = {
148149
);
149150

150151
const updateVisibility = () => {
151-
// Visibility of command changed.
152+
// Visibility of context menu and toolbar commands changed.
152153
app.commands.notifyCommandChanged(CommandIDs.createNewDrive);
154+
app.commands.notifyCommandChanged(CommandIDs.createNewDirectory);
153155
};
154156

155157
// Listen for path changes.
@@ -370,5 +372,17 @@ namespace Private {
370372
icon: filterIcon.bindprops({ stylesheet: 'menuItem' }),
371373
label: 'Toggle File Filter'
372374
});
375+
376+
app.commands.addCommand(CommandIDs.createNewDirectory, {
377+
isVisible: () => {
378+
return browser.model.path !== 's3:';
379+
},
380+
execute: () => {
381+
console.log('NEW COMMAND DIR');
382+
app.commands.execute('filebrowser:create-new-directory');
383+
},
384+
icon: newFolderIcon.bindprops({ stylesheet: 'menuItem' }),
385+
label: 'New Folder'
386+
});
373387
}
374388
}

src/token.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export namespace CommandIDs {
1010
export const createNewDrive = 'drives:create-new-drive';
1111
export const launcher = 'launcher:create';
1212
export const toggleFileFilter = 'drives:toggle-file-filter';
13+
export const createNewDirectory = 'drives:create-new-directory';
1314
}
1415

1516
/**

0 commit comments

Comments
 (0)