@@ -49,53 +49,29 @@ class DriveStatusWidget extends Widget {
4949 this . node . textContent = 'Drives: Ready' ;
5050 this . _currentPath = '' ;
5151 this . _isLoading = false ;
52-
53- // Listen for custom events from getContents
54- window . addEventListener ( 'drive-status-update' , ( event : Event ) => {
55- const customEvent = event as CustomEvent ;
56- this . handleStatusUpdate ( customEvent . detail ) ;
57- } ) ;
5852 }
5953
6054 updateStatus ( text : string ) {
6155 this . node . textContent = `Drives: ${ text } ` ;
6256 }
6357
64- setDriveCount ( count : number ) {
65- this . node . textContent = `Drives: ${ count } connected` ;
66- }
67-
68- setError ( message : string ) {
69- this . node . textContent = `Drives: ${ message } ` ;
70- this . addClass ( 'jp-drive-status-error' ) ;
71- }
72-
73- clearError ( ) {
74- this . removeClass ( 'jp-drive-status-error' ) ;
75- }
76-
7758 /**
78- * Update status when navigating to a directory
59+ * Update status when loading a directory or file
7960 */
80- setDirectoryLoading ( path : string ) {
81- console . log ( '[DEBUG] Setting directory loading:' , path ) ;
61+ setLoading ( path : string , type : 'directory' | 'file' = 'directory' ) {
62+ console . log ( '[DEBUG] Setting loading:' , path , 'type:' , type ) ;
8263 this . _isLoading = true ;
8364 this . _currentPath = path ;
84- const displayPath =
85- path === '' ? 'Root' : path . split ( '/' ) . pop ( ) || 'Directory' ;
86- this . node . textContent = `Drives: Opening ${ displayPath } ...` ;
87- this . addClass ( 'jp-drive-status-loading' ) ;
88- }
8965
90- /**
91- * Update status when a file is being opened
92- */
93- setFileLoading ( path : string ) {
94- console . log ( '[DEBUG] Setting file loading:' , path ) ;
95- this . _isLoading = true ;
96- this . _currentPath = path ;
97- const fileName = path . split ( '/' ) . pop ( ) || 'File' ;
98- this . node . textContent = `Drives: Opening ${ fileName } ...` ;
66+ if ( type === 'directory' ) {
67+ const displayPath =
68+ path === '' ? 'Root' : path . split ( '/' ) . pop ( ) || 'Directory' ;
69+ this . node . textContent = `Drives: Opening ${ displayPath } ...` ;
70+ } else {
71+ const fileName = path . split ( '/' ) . pop ( ) || 'File' ;
72+ this . node . textContent = `Drives: Opening ${ fileName } ...` ;
73+ }
74+
9975 this . addClass ( 'jp-drive-status-loading' ) ;
10076 }
10177
@@ -131,31 +107,6 @@ class DriveStatusWidget extends Widget {
131107 return this . _isLoading ;
132108 }
133109
134- /**
135- * Handle status updates from getContents function
136- */
137- private handleStatusUpdate ( detail : any ) {
138- console . log ( '[DEBUG] Status update received:' , detail ) ;
139-
140- if ( detail . type === 'loading' ) {
141- const fullPath = detail . driveName + '/' + detail . path ;
142- if ( detail . path === '' ) {
143- this . setDirectoryLoading ( '' ) ;
144- } else {
145- // Determine if it's a directory or file based on path
146- const isDirectory = detail . path . endsWith ( '/' ) || detail . path === '' ;
147- if ( isDirectory ) {
148- this . setDirectoryLoading ( fullPath ) ;
149- } else {
150- this . setFileLoading ( fullPath ) ;
151- }
152- }
153- } else if ( detail . type === 'loaded' ) {
154- const fullPath = detail . driveName + '/' + detail . path ;
155- this . setLoaded ( fullPath , detail . itemType ) ;
156- }
157- }
158-
159110 private _currentPath : string ;
160111 private _isLoading : boolean ;
161112}
@@ -265,23 +216,14 @@ export const driveFileBrowser: JupyterFrontEndPlugin<void> = {
265216
266217 // Listen for drive changes and update status
267218 drive . loadingContents . connect ( ( sender , args ) => {
268- const path = driveBrowser . model . path ;
219+ const { path, type , itemType } = args ;
269220 console . log ( '[DEBUG] Path changed:' , path , 'args:' , args ) ;
270- if ( args . type === 'loading' ) {
271- driveStatusWidget . setDirectoryLoading ( path ) ;
272- } else if ( args . type === 'loaded' ) {
221+ if ( type === 'loading' ) {
222+ driveStatusWidget . setLoading ( path , itemType ) ;
223+ } else if ( type === 'loaded' ) {
273224 console . log ( 'loaded' ) ;
274- // driveStatusWidget.setLoaded(path, args. itemType);
225+ // driveStatusWidget.setLoaded(path, itemType);
275226 }
276- // Status updates are now handled by custom events from getContents
277- } ) ;
278-
279- // Listen for model changes to update drive count
280- drive . loadingContents . connect ( ( ) => {
281- console . log ( '[DEBUG] Model refreshed' ) ;
282- // const items = driveBrowser.model.items();
283- // const driveCount = Array.from(items).length;
284- // driveStatusWidget.setDriveCount(driveCount);
285227 } ) ;
286228 }
287229
0 commit comments