@@ -333,6 +333,55 @@ namespace Private {
333333 }
334334 }
335335
336+ /**
337+ * Create the node for adding a public drive handler.
338+ */
339+ const addPublicDriveNode = ( ) : HTMLElement => {
340+ const body = document . createElement ( 'div' ) ;
341+
342+ const drive = document . createElement ( 'label' ) ;
343+ drive . textContent = 'Name' ;
344+ drive . className = CREATE_DRIVE_TITLE_CLASS ;
345+ const driveName = document . createElement ( 'input' ) ;
346+
347+ body . appendChild ( drive ) ;
348+ body . appendChild ( driveName ) ;
349+ return body ;
350+ } ;
351+
352+ /**
353+ * A widget used to add a public drive.
354+ */
355+ export class AddPublicDriveHandler extends Widget {
356+ /**
357+ * Construct a new "add-public-drive" dialog.
358+ */
359+ constructor ( newDriveName : string ) {
360+ super ( { node : addPublicDriveNode ( ) } ) ;
361+ this . onAfterAttach ( ) ;
362+ }
363+
364+ protected onAfterAttach ( ) : void {
365+ this . addClass ( FILE_DIALOG_CLASS ) ;
366+ const drive = this . driveInput . value ;
367+ this . driveInput . setSelectionRange ( 0 , drive . length ) ;
368+ }
369+
370+ /**
371+ * Get the input text node for drive name.
372+ */
373+ get driveInput ( ) : HTMLInputElement {
374+ return this . node . getElementsByTagName ( 'input' ) [ 0 ] as HTMLInputElement ;
375+ }
376+
377+ /**
378+ * Get the value of the widget.
379+ */
380+ getValue ( ) : string {
381+ return this . driveInput . value ;
382+ }
383+ }
384+
336385 export function addCommands (
337386 app : JupyterFrontEnd ,
338387 drive : Drive ,
@@ -380,7 +429,7 @@ namespace Private {
380429 execute : async ( ) => {
381430 return showDialog ( {
382431 title : 'Add Public Drive' ,
383- body : new Private . CreateDriveHandler ( drive . name ) ,
432+ body : new Private . AddPublicDriveHandler ( drive . name ) ,
384433 focusNodeSelector : 'input' ,
385434 buttons : [
386435 Dialog . cancelButton ( ) ,
0 commit comments