Skip to content

Commit 66f0256

Browse files
committed
update root level icons
1 parent fa796b4 commit 66f0256

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/plugins/driveBrowserPlugin.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,43 @@ export const driveFileBrowser: JupyterFrontEndPlugin<void> = {
196196
restorer.add(driveBrowser, 'drive-file-browser');
197197
}
198198

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);
228+
});
229+
driveBrowser.model.refreshed.connect(() => {
230+
setTimeout(updateRootIcons, 50);
231+
});
232+
233+
// Initial update
234+
setTimeout(updateRootIcons, 50);
235+
199236
// Register status bar widget
200237
if (statusBar) {
201238
const driveStatusWidget = new DriveStatusWidget();

0 commit comments

Comments
 (0)