@@ -162,7 +162,7 @@ export const driveFileBrowser: JupyterFrontEndPlugin<void> = {
162
162
console . log (
163
163
'JupyterLab extension jupyter-drives:drives-file-browser is activated!'
164
164
) ;
165
- const { commands } = app ;
165
+ const { commands, docRegistry } = app ;
166
166
167
167
// create drive for drive file browser
168
168
const drive = new Drive ( {
@@ -196,42 +196,17 @@ export const driveFileBrowser: JupyterFrontEndPlugin<void> = {
196
196
restorer . add ( driveBrowser , 'drive-file-browser' ) ;
197
197
}
198
198
199
- const updateRootIcons = ( ) => {
200
- const listing = driveBrowser . model ;
201
-
202
- if ( listing . items ) {
203
- // Get all items at root level
204
- const rootItems = Array . from ( listing . items ( ) ) . filter ( item => {
205
- return driveBrowser . model . path === 's3:' ;
206
- } ) ;
207
-
208
- rootItems . forEach ( item => {
209
- // Find the DOM element for this item
210
- const itemElements = driveBrowser . node . querySelectorAll ( 'li.jp-DirListing-item' ) ;
211
- itemElements . forEach ( element => {
212
- const itemName = element . querySelector ( '.jp-DirListing-itemText' ) ?. textContent ;
213
- if ( itemName === item . name ) {
214
- // Replace the icon
215
- const iconElement = element . querySelector ( '.jp-DirListing-itemIcon' ) ;
216
- if ( iconElement ) {
217
- iconElement . innerHTML = driveBrowserIcon . svgstr ;
218
- iconElement . classList . add ( 'jp-icon' , 'jp-icon-3' , 'icon-selectable' ) ;
219
- }
220
- }
221
- } ) ;
222
- } ) ;
223
- }
224
- } ;
225
-
226
- driveBrowser . model . pathChanged . connect ( ( ) => {
227
- setTimeout ( updateRootIcons , 50 ) ;
199
+ // Registering the custom directory file type
200
+ docRegistry . addFileType ( {
201
+ name : 'drive' ,
202
+ displayName : 'Drive' ,
203
+ contentType : 'directory' ,
204
+ fileFormat : 'json' ,
205
+ mimeTypes : [ 'text/directory' ] ,
206
+ extensions : [ ] ,
207
+ icon : driveBrowserIcon ,
208
+ pattern : '^'
228
209
} ) ;
229
- driveBrowser . model . refreshed . connect ( ( ) => {
230
- setTimeout ( updateRootIcons , 50 ) ;
231
- } ) ;
232
-
233
- // Initial update
234
- setTimeout ( updateRootIcons , 50 ) ;
235
210
236
211
// Register status bar widget
237
212
if ( statusBar ) {
0 commit comments