Skip to content

Commit c86761d

Browse files
committed
Iterate
1 parent b2fe8d3 commit c86761d

File tree

8 files changed

+30
-12
lines changed

8 files changed

+30
-12
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ jobs:
125125
- name: Execute integration tests
126126
working-directory: ui-tests
127127
run: |
128-
jlpm playwright test --update-snapshots
128+
jlpm playwright test
129129
130130
- name: Upload Playwright Test report
131131
if: always()

src/index.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable @typescript-eslint/ban-ts-comment */
2+
13
import {
24
JupyterFrontEnd,
35
JupyterFrontEndPlugin
@@ -71,12 +73,13 @@ const fileBrowserFactory: JupyterFrontEndPlugin<IFileBrowserFactory> = {
7173
});
7274

7375
// check the url in iframe and open
74-
app.restored.then(() => {
76+
app.restored.then(async () => {
7577
const windowPathname = window.location.pathname;
7678
const treeIndex = windowPathname.indexOf('/tree/');
7779
let path = windowPathname.substring(treeIndex + '/tree/'.length);
7880
path = decodeURIComponent(path);
79-
if (path) {
81+
const content = await app.serviceManager.contents.get(path);
82+
if (content.type !== 'directory') {
8083
docManager.open(path);
8184
}
8285
});
@@ -87,6 +90,7 @@ const fileBrowserFactory: JupyterFrontEndPlugin<IFileBrowserFactory> = {
8790
return widget;
8891
};
8992

93+
// @ts-ignore: DirListing._onPathChanged is private upstream, need to change this so we can remove the ignore
9094
return { createFileBrowser, tracker };
9195
}
9296
};

src/unfold.ts

+23-9
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ export class FileTreeRenderer extends DirListing.Renderer {
191191
/**
192192
* A widget which hosts a filetree.
193193
*/
194+
// @ts-ignore: _onPathChanged is private upstream, need to change this
194195
export class DirTreeListing extends DirListing {
195196
constructor(options: DirTreeListing.IOptions) {
196197
super({ ...options, renderer: new FileTreeRenderer(options.model) });
@@ -229,6 +230,10 @@ export class DirTreeListing extends DirListing {
229230
}
230231
}
231232

233+
_onPathChanged(): void {
234+
// It's a no-op to overwrite the base class behavior
235+
}
236+
232237
private _eventDragEnter(event: IDragEvent): void {
233238
if (event.mimeData.hasData(CONTENTS_MIME)) {
234239
// @ts-ignore
@@ -428,19 +433,26 @@ export class FilterFileTreeBrowserModel extends FilterFileBrowserModel {
428433
}
429434

430435
set path(value: string) {
431-
this._path = value;
436+
let needsToEmit = false;
432437

433-
if (this._path === value) {
434-
return;
438+
if (this._path !== value) {
439+
needsToEmit = true;
435440
}
436441

437-
const pathChanged = this.pathChanged as Signal<this, IChangedArgs<string>>;
442+
this._path = value;
438443

439-
pathChanged.emit({
440-
name: 'path',
441-
oldValue: this._path,
442-
newValue: value
443-
});
444+
if (needsToEmit) {
445+
const pathChanged = this.pathChanged as Signal<
446+
this,
447+
IChangedArgs<string>
448+
>;
449+
450+
pathChanged.emit({
451+
name: 'path',
452+
oldValue: this._path,
453+
newValue: PathExt.dirname(this._path)
454+
});
455+
}
444456
}
445457

446458
/**
@@ -668,6 +680,7 @@ export class FileTreeBrowser extends FileBrowser {
668680
}
669681

670682
protected createDirListing(options: DirListing.IOptions): DirListing {
683+
// @ts-ignore: _onPathChanged is private upstream, need to change this
671684
return new DirTreeListing({
672685
model: this.model,
673686
translator: this.translator
@@ -680,5 +693,6 @@ export class FileTreeBrowser extends FileBrowser {
680693

681694
model: FilterFileTreeBrowserModel;
682695

696+
// @ts-ignore: _onPathChanged is private upstream, need to change this
683697
listing: DirTreeListing;
684698
}
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)