@@ -51,7 +51,7 @@ import { CommandIDs } from './commands';
5151
5252import { ReadonlyJSONObject } from '@lumino/coreutils' ;
5353
54- import { DashboardLayout } from './custom_layout ' ;
54+ import { DashboardLayout } from './layout ' ;
5555
5656import { Widgetstore } from './widgetstore' ;
5757
@@ -120,6 +120,9 @@ const extension: JupyterFrontEndPlugin<IDashboardTracker> = {
120120
121121 app . docRegistry . addModelFactory ( modelFactory ) ;
122122 app . docRegistry . addWidgetFactory ( widgetFactory ) ;
123+
124+ // Add newly created dashboards to the tracker, set their icon and label,
125+ // and set the default width, height, and scrollMode.
123126 widgetFactory . widgetCreated . connect ( ( _sender , widget ) => {
124127 void dashboardTracker . add ( widget . content ) ;
125128
@@ -128,6 +131,7 @@ const extension: JupyterFrontEndPlugin<IDashboardTracker> = {
128131 widget . title . iconLabel = dashboardFiletype . iconLabel || '' ;
129132
130133 const model = widget . content . model ;
134+ // TODO: Make scrollMode changable in JL. Default 'infinite' for now.
131135 model . scrollMode = 'infinite' ;
132136 model . width = Dashboard . DEFAULT_WIDTH ;
133137 model . height = Dashboard . DEFAULT_HEIGHT ;
@@ -152,36 +156,24 @@ const extension: JupyterFrontEndPlugin<IDashboardTracker> = {
152156 rank : 2 ,
153157 } ) ;
154158
155- // app.contextMenu.addItem({
156- // command: CommandIDs.toggleMode,
157- // selector: '.pr-JupyterDashboard',
158- // rank: 3,
159- // });
160-
161159 app . contextMenu . addItem ( {
162160 command : CommandIDs . cut ,
163161 selector : '.pr-JupyterDashboard' ,
164- rank : 4 ,
162+ rank : 3 ,
165163 } ) ;
166164
167165 app . contextMenu . addItem ( {
168166 command : CommandIDs . copy ,
169167 selector : '.pr-JupyterDashboard' ,
170- rank : 5 ,
168+ rank : 4 ,
171169 } ) ;
172170
173171 app . contextMenu . addItem ( {
174172 command : CommandIDs . paste ,
175173 selector : '.pr-JupyterDashboard' ,
176- rank : 6 ,
174+ rank : 5 ,
177175 } ) ;
178176
179- // app.contextMenu.addItem({
180- // command: CommandIDs.enableGrid,
181- // selector: '.pr-JupyterDashboard',
182- // rank: 7,
183- // });
184-
185177 app . contextMenu . addItem ( {
186178 command : CommandIDs . deleteOutput ,
187179 selector : '.pr-EditableWidget' ,
@@ -222,13 +214,6 @@ const extension: JupyterFrontEndPlugin<IDashboardTracker> = {
222214 selector : '.pr-JupyterDashboard' ,
223215 } ) ;
224216
225- // app.commands.addKeyBinding({
226- // command: CommandIDs.toggleMode,
227- // args: {},
228- // keys: ['I'],
229- // selector: '.pr-JupyterDashboard',
230- // });
231-
232217 app . commands . addKeyBinding ( {
233218 command : CommandIDs . cut ,
234219 args : { } ,
@@ -263,7 +248,7 @@ const extension: JupyterFrontEndPlugin<IDashboardTracker> = {
263248 command : CommandIDs . setDimensions ,
264249 } ,
265250 {
266- command : CommandIDs . setGridSize ,
251+ command : CommandIDs . setTileSize ,
267252 } ,
268253 ] ) ;
269254
@@ -283,6 +268,21 @@ const extension: JupyterFrontEndPlugin<IDashboardTracker> = {
283268 } ,
284269} ;
285270
271+ /**
272+ * Add commands to the main JupyterLab command registry.
273+ *
274+ * @param app - the JupyterLab instance.
275+ *
276+ * @param dashboardTracker - a tracker for dashboards.
277+ *
278+ * @param outputTracker - a tracker for dashboard outputs.
279+ *
280+ * @param clipboard - a set used to keep track of widgets for copy/pasting.
281+ *
282+ * @param docManager - a document manager used to create/rename files.
283+ *
284+ * @param notebookTracker - a tracker for notebooks.
285+ */
286286function addCommands (
287287 app : JupyterFrontEnd ,
288288 dashboardTracker : WidgetTracker < Dashboard > ,
@@ -395,14 +395,6 @@ function addCommands(
395395 } ,
396396 } ) ;
397397
398- commands . addCommand ( CommandIDs . enableGrid , {
399- label : 'Enable Tiled Layout (EXPERIMENTAL)' ,
400- execute : ( args ) => {
401- const dashboard = dashboardTracker . currentWidget ;
402- dashboard . model . mode = 'grid' ;
403- } ,
404- } ) ;
405-
406398 commands . addCommand ( CommandIDs . runOutput , {
407399 label : ( args ) => ( inToolbar ( args ) ? '' : 'Run Output' ) ,
408400 icon : runIcon ,
@@ -452,15 +444,15 @@ function addCommands(
452444 isEnabled : hasDashboard ,
453445 } ) ;
454446
455- commands . addCommand ( CommandIDs . setGridSize , {
447+ commands . addCommand ( CommandIDs . setTileSize , {
456448 label : 'Set Grid Dimensions' ,
457449 execute : async ( args ) => {
458450 const newSize = await InputDialog . getNumber ( {
459451 title : 'Enter Grid Size' ,
460452 } ) ;
461453 if ( newSize . value ) {
462454 const layout = dashboardTracker . currentWidget . layout as DashboardLayout ;
463- layout . gridSize = newSize . value ;
455+ layout . setTileSize ( newSize . value ) ;
464456 }
465457 } ,
466458 isEnabled : hasDashboard ,
@@ -549,14 +541,19 @@ function addCommands(
549541 icon : saveIcon ,
550542 execute : ( args ) => {
551543 const dashboard = dashboardTracker . currentWidget ;
552- dashboard . model . path ;
553544 dashboard . context . save ( ) ;
554545 } ,
555546 isEnabled : ( args ) => inToolbar ( args ) || hasDashboard ( ) ,
556547 } ) ;
557548}
558549
550+ /**
551+ * A namespace for private functionality.
552+ */
559553namespace Private {
554+ /**
555+ * A dialog with two boxes for setting a dashboard's width and height.
556+ */
560557 export class ResizeHandler extends Widget {
561558 constructor ( oldWidth : number , oldHeight : number ) {
562559 const node = document . createElement ( 'div' ) ;
@@ -575,8 +572,6 @@ namespace Private {
575572 height . required = true ;
576573 width . placeholder = `Width (${ oldWidth } )` ;
577574 height . placeholder = `Height (${ oldHeight } )` ;
578- // width.value = oldWidth.toString();
579- // height.value = oldHeight.toString();
580575
581576 node . appendChild ( name ) ;
582577 node . appendChild ( width ) ;
0 commit comments