Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@ <h6 style="font-weight: lighter; font-size: 0.9em">Choose a Version:</h6>
<div class="select-and-button-container">
<nz-select
nzShowSearch
nzAllowClear
nzPlaceHolder="Select a version"
(ngModelChange)="onVersionSelected($event)"
[(ngModel)]="selectedVersion">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,16 @@ describe("DatasetDetailComponent behavior", () => {
expect(component.selectedVersionCreationTime).toMatch(/^\d{2}\/\d{2}\/\d{4} \d{2}:\d{2}:\d{2}$/);
});

it("survives the version select being emptied", () => {
createComponent();
component.did = 5;

expect(() => component.onVersionSelected(undefined)).not.toThrow();

expect(component.selectedVersion).toBeUndefined();
expect(datasetServiceStub.retrieveDatasetVersionFileTree).not.toHaveBeenCalled();
});

it("does not fetch a file tree for a version without a dvid", () => {
createComponent();
component.did = 5;
Expand Down Expand Up @@ -2422,6 +2432,11 @@ describe("DatasetDetailComponent rendered template", () => {
expect(datasetService.retrieveDatasetVersionFileTree).toHaveBeenCalledWith(5, 13, true);
});

it("offers no way to empty the selection", () => {
// Clearing it used to reach onVersionSelected as null and throw.
expect(fixture.nativeElement.querySelector("nz-select-clear, .ant-select-clear")).toBeNull();
});

it("loads a picked version over the anonymous endpoint when nobody is signed in", () => {
render({ isLogin: false });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,11 +424,11 @@ export class DatasetDetailComponent implements OnInit {
this.isRightBarCollapsed = !this.isRightBarCollapsed;
}

onVersionSelected(version: DatasetVersion): void {
onVersionSelected(version: DatasetVersion | undefined): void {
this.selectedVersion = version;
if (this.did && this.selectedVersion.dvid)
if (this.did && version?.dvid)
this.datasetService
.retrieveDatasetVersionFileTree(this.did, this.selectedVersion.dvid, this.isLogin)
.retrieveDatasetVersionFileTree(this.did, version.dvid, this.isLogin)
.pipe(untilDestroyed(this))
.subscribe(data => {
this.fileTreeNodeList = data.fileNodes;
Expand Down
Loading