Skip to content

Commit 5039c3a

Browse files
committed
Hide status widget when not loading
1 parent 2e5bbfe commit 5039c3a

File tree

3 files changed

+18
-22
lines changed

3 files changed

+18
-22
lines changed

src/contents.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,4 +1082,4 @@ export namespace Drive {
10821082
*/
10831083
apiEndpoint?: string;
10841084
}
1085-
}
1085+
}

src/plugins/driveBrowserPlugin.ts

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,17 @@ import { CommandIDs } from '../token';
4646
class DriveStatusWidget extends Widget {
4747
constructor() {
4848
super();
49-
this.addClass('jp-drive-status-widget');
49+
this.node.classList.add(
50+
'jp-drive-status-widget',
51+
'jp-drive-status-loading',
52+
'lm-mod-hidden'
53+
);
5054
this.node.textContent = '';
5155
this._isLoading = false;
5256
}
5357

5458
updateStatus(text: string) {
55-
this.node.textContent = `Drives: ${text}`;
59+
this.node.textContent = `${text}`;
5660
}
5761

5862
/**
@@ -64,21 +68,20 @@ class DriveStatusWidget extends Widget {
6468
if (type === 'directory') {
6569
const displayPath =
6670
path === '' ? 'Root' : path.split('/').pop() || 'Directory';
67-
this.updateStatus(displayPath);
71+
this.updateStatus(`Opening: ${displayPath}`);
6872
} else {
6973
const fileName = path.split('/').pop() || 'File';
70-
this.updateStatus(fileName);
74+
this.updateStatus(`Opening: ${fileName}`);
7175
}
72-
73-
this.addClass('jp-drive-status-loading');
76+
this.removeClass('lm-mod-hidden');
7477
}
7578

7679
/**
7780
* Clear loading state and show current status
7881
*/
7982
setLoaded(path?: string) {
8083
this._isLoading = false;
81-
this.removeClass('jp-drive-status-loading');
84+
this.addClass('lm-mod-hidden');
8285

8386
this.updateStatus('');
8487
}
@@ -195,27 +198,21 @@ export const driveFileBrowser: JupyterFrontEndPlugin<void> = {
195198
isActive: () => true
196199
});
197200

198-
// Item being opened
201+
// Item/dir being opened
199202
//@ts-expect-error listing is protected
200203
driveBrowser.listing.onItemOpened.connect((_, args) => {
201-
console.log('[search] PLEASE]', args);
202204
const { path, type } = args;
203205
driveStatusWidget.setLoading(path, type);
204-
console.log('loaded');
205206
});
206207

207-
// Item done opening
208-
docWidgetOpener.opened.connect((_, args) => {
209-
console.log('[search] opened signal', args);
210-
211-
const { context } = args;
212-
213-
const { contentsModel } = context;
214-
console.log('contentsModel', contentsModel);
208+
const doneLoading = (_: any, args: any) => {
215209
driveStatusWidget.setLoaded();
216-
});
210+
};
211+
// Item done opening
212+
docWidgetOpener.opened.connect(doneLoading);
217213

218-
driveStatusWidget.updateStatus('Connected');
214+
// Directory done opening
215+
driveBrowser.model.pathChanged.connect(doneLoading);
219216
}
220217

221218
const uploader = new Uploader({ model: driveBrowser.model, translator });

style/base.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ li {
183183
.jp-drive-status-loading {
184184
color: var(--jp-ui-font-color1);
185185
background-color: var(--jp-layout-color3);
186-
border-color: var(--jp-brand-color1);
187186
animation: pulse 1.5s ease-in-out infinite;
188187
}
189188

0 commit comments

Comments
 (0)