@@ -11,7 +11,13 @@ import { INotebookTracker, NotebookActions } from "@jupyterlab/notebook";
11
11
12
12
import { CommandRegistry } from '@lumino/commands' ;
13
13
14
- import { Menu } from '@lumino/widgets' ;
14
+ import {
15
+ MenuSvg ,
16
+ pythonIcon ,
17
+ terminalIcon ,
18
+ textEditorIcon ,
19
+ folderIcon ,
20
+ } from '@jupyterlab/ui-components' ;
15
21
16
22
import { listSnippets , Snippet , fetchSnippet } from "./snippets" ;
17
23
@@ -52,7 +58,7 @@ function toTree(snippets: Snippet[]) {
52
58
* @param path The current path in the tree.
53
59
*/
54
60
function createMenu ( commands : CommandRegistry , tree : Tree , path : string [ ] = [ ] ) {
55
- const menu = new Menu ( { commands } ) ;
61
+ const menu = new MenuSvg ( { commands } ) ;
56
62
for ( const [ name , map ] of tree . entries ( ) ) {
57
63
const fullpath = path . concat ( name ) ;
58
64
if ( map . size === 0 ) {
@@ -63,6 +69,7 @@ function createMenu(commands: CommandRegistry , tree: Tree, path: string[] = [])
63
69
} else {
64
70
const submenu = createMenu ( commands , map , path . concat ( name ) ) ;
65
71
submenu . title . label = name ;
72
+ submenu . title . icon = folderIcon ;
66
73
menu . addItem ( { type : 'submenu' , submenu} ) ;
67
74
}
68
75
}
@@ -91,9 +98,16 @@ const extension: JupyterFrontEndPlugin<void> = {
91
98
}
92
99
93
100
commands . addCommand ( CommandIDs . open , {
94
- label : args => {
95
- const label = args [ 'label' ] as string ;
96
- return PathExt . basename ( label , PathExt . extname ( label ) ) ;
101
+ label : args => args [ 'label' ] as string ,
102
+ icon : args => {
103
+ const ext = PathExt . extname ( args [ 'label' ] as string ) ;
104
+ if ( ext === '.py' ) {
105
+ return pythonIcon ;
106
+ }
107
+ if ( ext === '.sh' ) {
108
+ return terminalIcon ;
109
+ }
110
+ return textEditorIcon ;
97
111
} ,
98
112
execute : async args => {
99
113
const path = args [ 'path' ] as string [ ] ;
0 commit comments