Skip to content

Commit ad6b127

Browse files
committed
override new notebook command
1 parent 3e0026a commit ad6b127

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

schema/drives-file-browser.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,19 @@
5959
"command": "drives:create-new-directory",
6060
"selector": ".jp-DirListing-content",
6161
"rank": 55
62+
},
63+
{
64+
"command": "notebook:create-new",
65+
"selector": ".jp-DirListing-content",
66+
"args": {
67+
"isContextMenu": true
68+
},
69+
"disabled": true
70+
},
71+
{
72+
"command": "drives:create-new-notebook",
73+
"selector": ".jp-DirListing-content",
74+
"rank": 54
6275
}
6376
]
6477
},

src/plugins/driveBrowserPlugin.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ import {
2424
FilenameSearcher,
2525
IScore,
2626
newFolderIcon,
27-
fileIcon
27+
fileIcon,
28+
notebookIcon
2829
} from '@jupyterlab/ui-components';
2930
import { CommandRegistry } from '@lumino/commands';
3031
import { Widget } from '@lumino/widgets';
@@ -379,7 +380,6 @@ namespace Private {
379380
return browser.model.path !== 's3:';
380381
},
381382
execute: () => {
382-
console.log('NEW COMMAND DIR');
383383
app.commands.execute('filebrowser:create-new-directory');
384384
},
385385
icon: newFolderIcon.bindprops({ stylesheet: 'menuItem' }),
@@ -396,5 +396,16 @@ namespace Private {
396396
icon: fileIcon.bindprops({ stylesheet: 'menuItem' }),
397397
label: 'New File'
398398
});
399+
400+
app.commands.addCommand(CommandIDs.createNewNotebook, {
401+
isVisible: () => {
402+
return browser.model.path !== 's3:';
403+
},
404+
execute: () => {
405+
app.commands.execute('notebook:create-new');
406+
},
407+
icon: notebookIcon.bindprops({ stylesheet: 'menuItem' }),
408+
label: 'New Notebook'
409+
});
399410
}
400411
}

src/token.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export namespace CommandIDs {
1212
export const toggleFileFilter = 'drives:toggle-file-filter';
1313
export const createNewDirectory = 'drives:create-new-directory';
1414
export const createNewFile = 'drives:create-new-file';
15+
export const createNewNotebook = 'drives:create-new-notebook';
1516
}
1617

1718
/**

0 commit comments

Comments
 (0)