diff --git a/frontend/src/app/dashboard/component/user/_resource-detail-shared.scss b/frontend/src/app/dashboard/component/user/_resource-detail-shared.scss new file mode 100644 index 00000000000..b7640f360d8 --- /dev/null +++ b/frontend/src/app/dashboard/component/user/_resource-detail-shared.scss @@ -0,0 +1,330 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +@mixin version-storage { + .version-storage { + padding: 0 15px; + margin-bottom: 25px; + } + + .version-storage nz-select { + width: 100%; + margin: 0; + } +} + +@mixin browser-pane { + .right-sider { + height: 100%; + overflow-y: auto; + position: relative; + z-index: 0; + } + + .sider-resize-line { + display: flex; + align-items: center; + justify-content: center; + height: 100%; + width: 5px; + border-right: 1px solid #e8e8e8; + } + + .sider-resize-handle { + background: #fff; + border: 1px solid #ddd; + text-align: center; + font-size: 12px; + height: 20px; + line-height: 20px; + } + + .file-renderer { + width: 95%; + height: 80%; + margin: auto; + } +} + +@mixin browser-toolbar($include-select: true) { + .select-and-button-container { + display: flex; + align-items: stretch; + gap: 10px; + } + + .spaced-button { + flex-shrink: 0; + width: 30px; + height: 24px; + } + + @if $include-select { + nz-select { + flex-grow: 1; + } + } +} + +@mixin version-list($include-status-row: true) { + .file-size, + .version-size, + .version-date { + font-size: 12px; + color: #8c8c8c; + display: inline-flex; + align-items: center; + gap: 4px; + } + + .version-date { + display: flex; + } + + .version-size { + margin-top: 8px; + } + + .icon-database, + .icon-file { + font-size: 14px; + } + + .empty-version-indicator { + margin-top: 15%; + } + + @if $include-status-row { + .status-tag-row { + margin-top: 16px; + display: flex; + align-items: center; + gap: 5px; + } + } +} + +@mixin status-tags { + .status-tag { + padding: 3px 10px 3px 3px; + font-size: 13px; + display: inline-flex; + align-items: center; + gap: 5px; + background: #fff; + border-radius: 5px; + + i { + width: 22px; + height: 22px; + display: inline-flex; + align-items: center; + justify-content: center; + border-radius: 4px; + background: #f0f0f0; + } + } + + .tag-public i { + color: #3b82f6; + background: #eff6ff; + } + + .tag-downloadable i { + color: #22c55e; + background: #f0fdf4; + } +} + +@mixin like-states { + .like-tag { + cursor: pointer; + } + + .like-tag.liked { + i { + color: #ef4444; + background: #fef2f2; + } + } + + .like-tag.disabled { + cursor: not-allowed; + opacity: 0.55; + } +} + +@mixin file-path-title { + .file-title { + display: flex; + align-items: center; + flex-wrap: wrap; + gap: 8px; + margin-bottom: 0; + } + + .file-title-main { + display: inline-flex; + align-items: center; + gap: 6px; + min-width: 0; + } + + .copy-path-btn { + padding: 0 4px; + height: auto; + line-height: 1; + display: inline-flex; + align-items: center; + justify-content: center; + } +} + +@mixin tab-bar { + nz-tabs { + margin-top: 6px; + } + + ::ng-deep .ant-tabs-nav { + padding-left: 16px; + } +} + +@mixin data-card { + // Two side-by-side cards filling the full tab width: a wide description card + // and a narrower stats card. The flex grow ratio is the single source of + // truth for their proportions (basis 0), so no width/max-width competes. + .data-card-columns { + display: flex; + align-items: flex-start; + gap: 20px; + margin-top: 24px; + width: 100%; + // Match the tab bar's left inset (.ant-tabs-nav padding-left) so the cards + // line up with the tab labels above, not the page's outer edge. + padding-left: 16px; + } + + .data-card { + border-radius: 8px; + border: 1px solid #d9d9d9; + // Let each card shrink to its flex share regardless of content width; without + // this the default min-width:auto keeps them from shrinking, skewing the + // ratio and leaving odd empty gaps. + min-width: 0; + } + + // Left card takes ~3/4 of the row, stats card ~1/4 — grow ratio with basis 0 + // so the split is exact and content-independent. + .data-card-main { + flex: 3 1 0; + } + + .data-card-details { + flex: 1 1 0; + } + + // Stack the two cards full-width on narrow viewports. + @media (max-width: 768px) { + .data-card-columns { + flex-direction: column; + align-items: stretch; + } + } + + // Matches the app's standard card-section heading convention (e.g. the + // Settings tab's "General" card title): bold, dark, slightly larger than + // body text, with a clear gap before the content below. + .data-card-heading { + font-size: 18px; + font-weight: 600; + color: rgba(0, 0, 0, 0.85); + margin: 0 0 20px; + } + + // Plain text, no box/border styling — larger size keeps it readable as prose. + .data-card-description { + font-size: 16px; + line-height: 1.6; + margin-bottom: 32px; + } + + // Empty state: muted grey italic so it reads as "nothing here yet", not broken. + .empty-description { + color: rgba(0, 0, 0, 0.4); + font-style: italic; + } + + // Stats as a full-width vertical list, one fact per row, avoiding the awkward + // wrapping of the previous cramped horizontal layout. + .data-card-stats { + display: flex; + flex-direction: column; + } + + .stat-row { + display: flex; + justify-content: space-between; + align-items: baseline; + gap: 16px; + padding: 12px 0; + border-bottom: 1px solid #f0f0f0; + + &:last-child { + border-bottom: none; + } + } + + .stat-label { + font-size: 13px; + font-weight: 600; + color: rgba(0, 0, 0, 0.85); + flex-shrink: 0; + } + + .stat-value { + font-weight: 400; + color: rgba(0, 0, 0, 0.45); + text-align: right; + word-break: break-word; + } +} + +@mixin header($kind) { + .#{$kind}-header { + display: flex; + gap: 24px; + } + + .#{$kind}-header-meta { + flex: 1; + } + + .#{$kind}-cover-image { + width: 280px; + height: 120px; + object-fit: cover; + border-radius: 8px; + margin-right: 80px; + } +} + +@mixin scrollable-tab { + height: 100%; + overflow-y: auto; + padding-bottom: 24px; +} diff --git a/frontend/src/app/dashboard/component/user/formly-modal-test-fixture.ts b/frontend/src/app/dashboard/component/user/formly-modal-test-fixture.ts new file mode 100644 index 00000000000..5f79c180567 --- /dev/null +++ b/frontend/src/app/dashboard/component/user/formly-modal-test-fixture.ts @@ -0,0 +1,51 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { Component, Type } from "@angular/core"; +import { ComponentFixture, TestBed, TestModuleMetadata } from "@angular/core/testing"; +import { ReactiveFormsModule } from "@angular/forms"; +import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; +import { FieldType, FieldTypeConfig, FormlyModule } from "@ngx-formly/core"; +import { NzModalRef } from "ng-zorro-antd/modal"; +import { commonTestProviders } from "../../../common/testing/test-utils"; + +// Formly still creates real controls and attaches the declared validators. +@Component({ template: "", standalone: true }) +class StubFormlyFieldComponent extends FieldType {} + +/** Creates a TestBed component fixture with stubbed Formly field types and an NzModalRef close spy. */ +export async function createFormlyModalFixture( + component: Type, + fieldNames: readonly string[], + close: ReturnType, + { imports = [], providers = [] }: Pick = {} +): Promise> { + await TestBed.configureTestingModule({ + imports: [ + component, + BrowserAnimationsModule, + ReactiveFormsModule, + FormlyModule.forRoot({ types: fieldNames.map(name => ({ name, component: StubFormlyFieldComponent })) }), + ...imports, + ], + providers: [{ provide: NzModalRef, useValue: { close } }, ...providers, ...commonTestProviders], + }).compileComponents(); + + return TestBed.createComponent(component); +} diff --git a/frontend/src/app/dashboard/component/user/resource-creator-form/resource-creator-form.component.ts b/frontend/src/app/dashboard/component/user/resource-creator-form/resource-creator-form.component.ts index ad14b21d9ba..8b6d4487fce 100644 --- a/frontend/src/app/dashboard/component/user/resource-creator-form/resource-creator-form.component.ts +++ b/frontend/src/app/dashboard/component/user/resource-creator-form/resource-creator-form.component.ts @@ -26,6 +26,14 @@ import { NzButtonComponent } from "ng-zorro-antd/button"; import { NzWaveDirective } from "ng-zorro-antd/core/wave"; import { ɵNzTransitionPatchDirective } from "ng-zorro-antd/core/transition-patch"; +/** Builds fresh required `name` and optional `description` Formly configs for resource creator modals. */ +export function resourceNameAndDescriptionFields(): FormlyFieldConfig[] { + return [ + { key: "name", type: "input", templateOptions: { label: "Name", required: true } }, + { key: "description", type: "input", defaultValue: "", templateOptions: { label: "Description" } }, + ]; +} + /** * The creation form shared by the dataset and model creators: the Formly fields, the visibility * and downloadability switches, and the Create and Cancel buttons. The parent keeps the state and diff --git a/frontend/src/app/dashboard/component/user/resource-detail-settings.component.ts b/frontend/src/app/dashboard/component/user/resource-detail-settings.component.ts new file mode 100644 index 00000000000..ed81e143f34 --- /dev/null +++ b/frontend/src/app/dashboard/component/user/resource-detail-settings.component.ts @@ -0,0 +1,214 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { NgIf, TitleCasePipe } from "@angular/common"; +import { Component, EventEmitter, Input, Output } from "@angular/core"; +import { FormsModule } from "@angular/forms"; +import { NzButtonComponent } from "ng-zorro-antd/button"; +import { NzCardComponent } from "ng-zorro-antd/card"; +import { NzDividerComponent } from "ng-zorro-antd/divider"; +import { NzInputDirective } from "ng-zorro-antd/input"; +import { NzSwitchComponent } from "ng-zorro-antd/switch"; +import { MarkdownDescriptionComponent } from "./markdown-description/markdown-description.component"; + +/** + * Shared Settings-tab cards (General and Access & visibility) for dataset and model detail pages, + * with a projection slot for resource-specific middle cards and trailing sections. + */ +@Component({ + // eslint-disable-next-line @angular-eslint/component-selector -- Keep the existing settings scroll container as the host. + selector: "div[texeraResourceDetailSettings]", + imports: [ + FormsModule, + MarkdownDescriptionComponent, + NgIf, + NzButtonComponent, + NzCardComponent, + NzDividerComponent, + NzInputDirective, + NzSwitchComponent, + TitleCasePipe, + ], + template: ` + +

General

+ +
+
+ +

{{ nameHints[resourceType] }}

+

+ An upload is in progress — finish or cancel it in Versions & Files first, or it will be left incomplete. +

+
+
+ + +
+
+ + + +
+ +
Shown on cards.
+ + +
+
+ + + + +

Access & visibility

+ +
+
+ +

+ {{ + isPublic + ? "Public — anyone can view this " + resourceType + "." + : "Private — only you and invited collaborators can see this " + resourceType + "." + }} +

+
+
+ +
+
+ + + +
+
+ +

+ {{ + isDownloadable + ? "Viewers can download this " + resourceType + "." + : "Viewers can browse files but cannot download them." + }} +

+
+
+ +
+
+
+ + + `, + styles: [ + ` + :host ::ng-deep .settings-general-card { + max-width: 700px; + margin: 24px auto 0; + border-radius: 16px; + border: 1px solid #d9d9d9; + } + :host ::ng-deep .settings-general-card .settings-card-title { + font-weight: 600; + margin-bottom: 20px; + } + :host ::ng-deep .settings-general-card .settings-field-label { + display: block; + font-weight: 600; + } + :host ::ng-deep .settings-general-card .settings-field-hint { + color: rgba(0, 0, 0, 0.45); + font-size: 12px; + margin-bottom: 8px; + } + :host ::ng-deep .settings-general-card .settings-name-row { + display: flex; + justify-content: space-between; + align-items: center; + gap: 16px; + } + :host ::ng-deep .settings-general-card .settings-name-row .settings-name-label label { + font-weight: 600; + } + :host ::ng-deep .settings-general-card .settings-name-row .settings-hint { + color: rgba(0, 0, 0, 0.45); + font-size: 12px; + margin: 4px 0 0; + } + :host ::ng-deep .settings-general-card .settings-name-row .settings-name-controls { + display: flex; + gap: 8px; + flex-shrink: 0; + } + :host ::ng-deep .settings-general-card .settings-name-row .settings-name-controls > input, + :host ::ng-deep .settings-general-card .settings-name-row .settings-name-controls > button { + border-radius: 8px; + } + :host ::ng-deep .settings-general-card .settings-select { + min-width: 200px; + } + `, + ], +}) +export class ResourceDetailSettingsComponent { + protected readonly nameHints = { + dataset: "Lowercase letters, numbers and hyphens.", + model: "Letters, numbers, underscores and hyphens.", + }; + + @Input({ required: true }) resourceType!: "dataset" | "model"; + @Input() editedName = ""; + @Input() uploadsInFlight = false; + @Input() description = ""; + @Input() canEdit = true; + @Input() isPublic = false; + @Input() isDownloadable = true; + @Input() isOwner = false; + + @Output() editedNameChange = new EventEmitter(); + @Output() saveName = new EventEmitter(); + @Output() descriptionChange = new EventEmitter(); + @Output() publicChange = new EventEmitter(); + @Output() downloadableChange = new EventEmitter(); +} diff --git a/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-creator/user-dataset-creator.component.spec.ts b/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-creator/user-dataset-creator.component.spec.ts index 14f70d2e5b1..bd9ce5dc979 100644 --- a/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-creator/user-dataset-creator.component.spec.ts +++ b/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-creator/user-dataset-creator.component.spec.ts @@ -17,25 +17,15 @@ * under the License. */ -import { Component } from "@angular/core"; -import { ComponentFixture, TestBed } from "@angular/core/testing"; +import { ComponentFixture } from "@angular/core/testing"; import { By } from "@angular/platform-browser"; -import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; -import { FormsModule, ReactiveFormsModule } from "@angular/forms"; -import { FieldType, FieldTypeConfig, FormlyModule } from "@ngx-formly/core"; +import { FormsModule } from "@angular/forms"; import { HttpClientTestingModule } from "@angular/common/http/testing"; -import { NzModalRef } from "ng-zorro-antd/modal"; import { of, Subject, throwError } from "rxjs"; import { UserDatasetCreatorComponent } from "./user-dataset-creator.component"; import { DatasetService } from "../../../../service/user/dataset/dataset.service"; import { NotificationService } from "../../../../../common/service/notification/notification.service"; -import { commonTestProviders } from "../../../../../common/testing/test-utils"; - -// Minimal stand-in for the "input" formly type (the real one comes from the app's -// UI formly module). Registering it lets formly materialize the declared fields -// into real form controls — with their validators — on render. -@Component({ template: "", standalone: true }) -class StubFormlyInputComponent extends FieldType {} +import { createFormlyModalFixture } from "../../formly-modal-test-fixture"; describe("UserDatasetCreatorComponent", () => { let modalClose: ReturnType; @@ -49,34 +39,28 @@ describe("UserDatasetCreatorComponent", () => { notifySuccess = vi.fn(); notifyError = vi.fn(); - await TestBed.configureTestingModule({ - imports: [ - UserDatasetCreatorComponent, - BrowserAnimationsModule, - FormsModule, - ReactiveFormsModule, - FormlyModule.forRoot({ - types: ["input", "checkbox", "textarea", "array"].map(name => ({ - name, - component: StubFormlyInputComponent, - })), - }), - HttpClientTestingModule, - ], - providers: [ - { provide: NzModalRef, useValue: { close: modalClose } }, - { provide: DatasetService, useValue: { createDataset } }, - { provide: NotificationService, useValue: { success: notifySuccess, error: notifyError } }, - ...commonTestProviders, - ], - }).compileComponents(); - - return TestBed.createComponent(UserDatasetCreatorComponent); + return createFormlyModalFixture( + UserDatasetCreatorComponent, + ["input", "checkbox", "textarea", "array"], + modalClose, + { + imports: [FormsModule, HttpClientTestingModule], + providers: [ + { provide: DatasetService, useValue: { createDataset } }, + { provide: NotificationService, useValue: { success: notifySuccess, error: notifyError } }, + ], + } + ); } - it("should create and render the formly form", async () => { + async function render() { const fixture = await createFixture(); fixture.detectChanges(); + return fixture; + } + + it("should create and render the formly form", async () => { + const fixture = await render(); expect(fixture.componentInstance).toBeTruthy(); // Formly materializes the declared fields into real form controls on render. @@ -84,15 +68,13 @@ describe("UserDatasetCreatorComponent", () => { }); it("ngOnInit builds the name, description and contributors fields", async () => { - const fixture = await createFixture(); - fixture.detectChanges(); + const fixture = await render(); expect(fixture.componentInstance.fields.map(f => f.key)).toEqual(["name", "description", "contributors"]); }); it("onClickCreate does nothing when the required name is empty (invalid form)", async () => { - const fixture = await createFixture(); - fixture.detectChanges(); + const fixture = await render(); const component = fixture.componentInstance; expect(component.form.valid).toBe(false); // name is required and empty @@ -103,8 +85,7 @@ describe("UserDatasetCreatorComponent", () => { }); it("onClickCreate creates a dataset with a sanitized name and closes the modal on success", async () => { - const fixture = await createFixture(); - fixture.detectChanges(); + const fixture = await render(); const component = fixture.componentInstance; component.form.get("name")?.setValue("My Dataset"); component.form.get("description")?.setValue("desc"); @@ -126,8 +107,7 @@ describe("UserDatasetCreatorComponent", () => { }); it("onClickCreate reports both the typed and the sanitized name when the name had to be rewritten", async () => { - const fixture = await createFixture(); - fixture.detectChanges(); + const fixture = await render(); const component = fixture.componentInstance; // Padded on both sides, and the only junk at the end is the whitespace itself. // That is what separates the four candidate trims: only stripping the leading @@ -151,8 +131,7 @@ describe("UserDatasetCreatorComponent", () => { }); it("onClickCreate reports a name that needed no rewriting just once", async () => { - const fixture = await createFixture(); - fixture.detectChanges(); + const fixture = await render(); const component = fixture.componentInstance; // Already lower-case, alphanumeric and hyphenated: sanitization is a no-op. component.form.get("name")?.setValue("already-clean-1"); @@ -165,8 +144,7 @@ describe("UserDatasetCreatorComponent", () => { }); it("onClickCreate notifies with the stored name and closes with null when dataset creation fails", async () => { - const fixture = await createFixture(); - fixture.detectChanges(); + const fixture = await render(); const component = fixture.componentInstance; component.form.get("name")?.setValue("My Dataset"); createDataset.mockReturnValue(throwError(() => ({ error: { message: "duplicate name" } }))); @@ -182,8 +160,7 @@ describe("UserDatasetCreatorComponent", () => { }); it("onClickCreate locks the form while the creation request is still outstanding", async () => { - const fixture = await createFixture(); - fixture.detectChanges(); + const fixture = await render(); const component = fixture.componentInstance; component.form.get("name")?.setValue("My Dataset"); // Never emits: the request is still in flight when we look at the flag. @@ -198,8 +175,7 @@ describe("UserDatasetCreatorComponent", () => { }); it("onClickCancel closes the modal with null", async () => { - const fixture = await createFixture(); - fixture.detectChanges(); + const fixture = await render(); fixture.componentInstance.onClickCancel(); diff --git a/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-creator/user-dataset-creator.component.ts b/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-creator/user-dataset-creator.component.ts index 763065dd973..0164d24fd4a 100644 --- a/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-creator/user-dataset-creator.component.ts +++ b/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-creator/user-dataset-creator.component.ts @@ -27,7 +27,10 @@ import { NotificationService } from "../../../../../common/service/notification/ import { HttpErrorResponse } from "@angular/common/http"; import { NzModalRef } from "ng-zorro-antd/modal"; import { contributorFieldGroup } from "../user-dataset-explorer/user-dataset-contributor-editor/contributor-form-fields"; -import { ResourceCreatorFormComponent } from "../../resource-creator-form/resource-creator-form.component"; +import { + ResourceCreatorFormComponent, + resourceNameAndDescriptionFields, +} from "../../resource-creator-form/resource-creator-form.component"; @UntilDestroy() @Component({ @@ -61,22 +64,7 @@ export class UserDatasetCreatorComponent implements OnInit { private setFormFields() { this.fields = [ - { - key: "name", - type: "input", - templateOptions: { - label: "Name", - required: true, - }, - }, - { - key: "description", - type: "input", - defaultValue: "", - templateOptions: { - label: "Description", - }, - }, + ...resourceNameAndDescriptionFields(), { key: "contributors", type: "array", diff --git a/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.html b/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.html index 7ef75951fa0..f8ceb115949 100644 --- a/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.html +++ b/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.html @@ -105,26 +105,12 @@

Description

+ @for (stat of overviewStatistics; track stat.label) {
- Created - {{ datasetCreationTime }} -
-
- Last updated - {{ latestVersionCreationTime || "—" }} -
-
- Versions - {{ versions.length }} -
-
- Latest version file - {{ latestVersionFileName || "—" }} -
-
- Latest version size - {{ formatSize(latestVersionSize) }} + {{ stat.label }} + {{ stat.value }}
+ }
@@ -285,92 +271,21 @@

Metadata

-
- -

General

- -
-
- -

Lowercase letters, numbers and hyphens.

-

- An upload is in progress — finish or cancel it in Versions & Files first, or it will be left - incomplete. -

-
-
- - -
-
- - - -
- -
Shown on cards.
- - -
-
- - -

Access & visibility

- -
-
- -

- {{ datasetIsPublic ? "Public — anyone can view this dataset." : "Private — only you and invited - collaborators can see this dataset." }} -

-
-
- -
-
- - - -
-
- -

- {{ datasetIsDownloadable ? "Viewers can download this dataset." : "Viewers can browse files but cannot - download them." }} -

-
-
- -
-
-
- +

Delete

diff --git a/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.scss b/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.scss index 093ee1801eb..db4e9757ba5 100644 --- a/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.scss +++ b/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.scss @@ -17,15 +17,9 @@ * under the License. */ -.version-storage { - padding: 0 15px; - margin-bottom: 25px; -} +@use "../../resource-detail-shared" as detail; -.version-storage nz-select { - width: 100%; - margin: 0; -} +@include detail.version-storage; nz-layout { height: 100%; @@ -38,36 +32,7 @@ body { padding: 0; } -.right-sider { - height: 100%; - overflow-y: auto; - position: relative; - z-index: 0; -} - -.sider-resize-line { - display: flex; - align-items: center; - justify-content: center; - height: 100%; - width: 5px; - border-right: 1px solid #e8e8e8; -} - -.sider-resize-handle { - background: #fff; - border: 1px solid #ddd; - text-align: center; - font-size: 12px; - height: 20px; - line-height: 20px; -} - -.file-renderer { - width: 95%; - height: 80%; - margin: auto; -} +@include detail.browser-pane; .grayed-out { filter: grayscale(1) opacity(0.7); @@ -78,21 +43,7 @@ body { pointer-events: none; } -.select-and-button-container { - display: flex; - align-items: stretch; - gap: 10px; -} - -.spaced-button { - flex-shrink: 0; - width: 30px; - height: 24px; -} - -nz-select { - flex-grow: 1; -} +@include detail.browser-toolbar; .file-title { display: flex; @@ -100,109 +51,13 @@ nz-select { gap: 10px; } -.file-size, -.version-size, -.version-date { - font-size: 12px; - color: #8c8c8c; - display: inline-flex; - align-items: center; - gap: 4px; -} - -.version-date { - display: flex; -} - -.version-size { - margin-top: 8px; -} - -.icon-database, -.icon-file { - font-size: 14px; -} - -.empty-version-indicator { - margin-top: 15%; -} - -.status-tag-row { - margin-top: 16px; - display: flex; - align-items: center; - gap: 5px; -} - -.status-tag { - padding: 3px 10px 3px 3px; - font-size: 13px; - display: inline-flex; - align-items: center; - gap: 5px; - background: #fff; - border-radius: 5px; - - i { - width: 22px; - height: 22px; - display: inline-flex; - align-items: center; - justify-content: center; - border-radius: 4px; - background: #f0f0f0; - } -} +@include detail.version-list; -.tag-public i { - color: #3b82f6; - background: #eff6ff; -} +@include detail.status-tags; -.tag-downloadable i { - color: #22c55e; - background: #f0fdf4; -} +@include detail.like-states; -.like-tag { - cursor: pointer; -} - -.like-tag.liked { - i { - color: #ef4444; - background: #fef2f2; - } -} - -.like-tag.disabled { - cursor: not-allowed; - opacity: 0.55; -} - -.file-title { - display: flex; - align-items: center; - flex-wrap: wrap; - gap: 8px; - margin-bottom: 0; -} - -.file-title-main { - display: inline-flex; - align-items: center; - gap: 6px; - min-width: 0; -} - -.copy-path-btn { - padding: 0 4px; - height: auto; - line-height: 1; - display: inline-flex; - align-items: center; - justify-content: center; -} +@include detail.file-path-title; .file-size { display: inline-flex; @@ -210,41 +65,16 @@ nz-select { gap: 4px; } -.dataset-header { - display: flex; - gap: 24px; -} - -.dataset-header-meta { - flex: 1; -} - -.dataset-cover-image { - width: 280px; - height: 120px; - object-fit: cover; - border-radius: 8px; - margin-right: 80px; -} - -nz-tabs { - margin-top: 6px; -} +@include detail.header("dataset"); -::ng-deep .ant-tabs-nav { - padding-left: 16px; -} +@include detail.tab-bar; .versions-tab-content { - height: 100%; - overflow-y: auto; - padding-bottom: 24px; + @include detail.scrollable-tab; } .data-card-tab-content { - height: 100%; - overflow-y: auto; - padding-bottom: 24px; + @include detail.scrollable-tab; } // The Settings tab shares the tab area's bounded height with the Data Card @@ -253,162 +83,10 @@ nz-tabs { // be scrolled fully into view, with bottom padding for breathing room below // the last card. .settings-tab-content { - height: 100%; - overflow-y: auto; - padding-bottom: 24px; -} - -// Two side-by-side cards filling the full tab width: a wide description card -// and a narrower stats card. The flex grow ratio is the single source of -// truth for their proportions (basis 0), so no width/max-width competes. -.data-card-columns { - display: flex; - align-items: flex-start; - gap: 20px; - margin-top: 24px; - width: 100%; - // Match the tab bar's left inset (.ant-tabs-nav padding-left) so the cards - // line up with the tab labels above, not the page's outer edge. - padding-left: 16px; -} - -.data-card { - border-radius: 8px; - border: 1px solid #d9d9d9; - // Let each card shrink to its flex share regardless of content width; without - // this the default min-width:auto keeps them from shrinking, skewing the - // ratio and leaving odd empty gaps. - min-width: 0; -} - -// Left card takes ~3/4 of the row, stats card ~1/4 — grow ratio with basis 0 -// so the split is exact and content-independent. -.data-card-main { - flex: 3 1 0; -} - -.data-card-details { - flex: 1 1 0; -} - -// Stack the two cards full-width on narrow viewports. -@media (max-width: 768px) { - .data-card-columns { - flex-direction: column; - align-items: stretch; - } -} - -// Matches the app's standard card-section heading convention (e.g. the -// Settings tab's "General" card title): bold, dark, slightly larger than -// body text, with a clear gap before the content below. -.data-card-heading { - font-size: 18px; - font-weight: 600; - color: rgba(0, 0, 0, 0.85); - margin: 0 0 20px; -} - -// Plain text, no box/border styling — larger size keeps it readable as prose. -.data-card-description { - font-size: 16px; - line-height: 1.6; - margin-bottom: 32px; -} - -// Empty state: muted grey italic so it reads as "nothing here yet", not broken. -.empty-description { - color: rgba(0, 0, 0, 0.4); - font-style: italic; -} - -// Stats as a full-width vertical list, one fact per row, avoiding the awkward -// wrapping of the previous cramped horizontal layout. -.data-card-stats { - display: flex; - flex-direction: column; -} - -.stat-row { - display: flex; - justify-content: space-between; - align-items: baseline; - gap: 16px; - padding: 12px 0; - border-bottom: 1px solid #f0f0f0; - - &:last-child { - border-bottom: none; - } -} - -.stat-label { - font-size: 13px; - font-weight: 600; - color: rgba(0, 0, 0, 0.85); - flex-shrink: 0; + @include detail.scrollable-tab; } -.stat-value { - font-weight: 400; - color: rgba(0, 0, 0, 0.45); - text-align: right; - word-break: break-word; -} - -.settings-general-card { - max-width: 700px; - margin: 24px auto 0; - border-radius: 16px; - border: 1px solid #d9d9d9; - - .settings-card-title { - font-weight: 600; - margin-bottom: 20px; - } - - .settings-field-label { - display: block; - font-weight: 600; - } - - .settings-field-hint { - color: rgba(0, 0, 0, 0.45); - font-size: 12px; - margin-bottom: 8px; - } - - .settings-name-row { - display: flex; - justify-content: space-between; - align-items: center; - gap: 16px; - - .settings-name-label label { - font-weight: 600; - } - - .settings-hint { - color: rgba(0, 0, 0, 0.45); - font-size: 12px; - margin: 4px 0 0; - } - - .settings-name-controls { - display: flex; - gap: 8px; - flex-shrink: 0; - - input { - border-radius: 8px; - } - - button { - border-radius: 8px; - } - } - } -} +@include detail.data-card; ::ng-deep .settings-general-card button { border-radius: 8px; diff --git a/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.ts b/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.ts index f9d8f70c166..7ffdbe0f6a2 100644 --- a/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.ts +++ b/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.ts @@ -54,16 +54,13 @@ import { NzIconDirective } from "ng-zorro-antd/icon"; import { NzSpaceCompactItemDirective } from "ng-zorro-antd/space"; import { NzButtonComponent } from "ng-zorro-antd/button"; import { NzPopconfirmDirective } from "ng-zorro-antd/popconfirm"; -import { NzSwitchComponent } from "ng-zorro-antd/switch"; -import { FormsModule } from "@angular/forms"; import { MarkdownDescriptionComponent } from "../../markdown-description/markdown-description.component"; -import { NzWaveDirective } from "ng-zorro-antd/core/wave"; import { NzTabsComponent, NzTabComponent } from "ng-zorro-antd/tabs"; import { NzCollapseComponent, NzCollapsePanelComponent } from "ng-zorro-antd/collapse"; import { NzDividerComponent } from "ng-zorro-antd/divider"; import { DATASET_FILE_RESOURCE_ENDPOINT } from "../../../../service/user/file-resource/file-resource-endpoint"; -import { NzInputDirective } from "ng-zorro-antd/input"; import { VersionsFilesBrowserComponent } from "../../versions-files-browser/versions-files-browser.component"; +import { ResourceDetailSettingsComponent } from "../../resource-detail-settings.component"; export const THROTTLE_TIME_MS = 1000; @@ -83,22 +80,19 @@ export const THROTTLE_TIME_MS = 1000; NzSpaceCompactItemDirective, NzButtonComponent, NzPopconfirmDirective, - NzSwitchComponent, - FormsModule, MarkdownDescriptionComponent, - NzWaveDirective, NzTabsComponent, NzTabComponent, NzCollapseComponent, NzCollapsePanelComponent, NzDividerComponent, NgFor, - NzInputDirective, NzDropdownDirective, NzDropdownMenuComponent, NzMenuDirective, NzMenuItemComponent, VersionsFilesBrowserComponent, + ResourceDetailSettingsComponent, ], }) export class DatasetDetailComponent implements OnInit { @@ -459,8 +453,15 @@ export class DatasetDetailComponent implements OnInit { } } - // alias for formatSize - formatSize = formatSize; + protected get overviewStatistics() { + return [ + { label: "Created", value: this.datasetCreationTime }, + { label: "Last updated", value: this.latestVersionCreationTime || "—" }, + { label: "Versions", value: this.versions.length }, + { label: "Latest version file", value: this.latestVersionFileName || "—" }, + { label: "Latest version size", value: formatSize(this.latestVersionSize) }, + ]; + } formatCount = formatCount; diff --git a/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/user-dataset-contributor-editor/contributor-form-fields.ts b/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/user-dataset-contributor-editor/contributor-form-fields.ts index 106236daa91..c3c5d9f11db 100644 --- a/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/user-dataset-contributor-editor/contributor-form-fields.ts +++ b/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/user-dataset-contributor-editor/contributor-form-fields.ts @@ -20,21 +20,20 @@ import { Validators } from "@angular/forms"; import { FormlyFieldConfig } from "@ngx-formly/core"; +function contributorInput(key: string, options: FormlyFieldConfig["templateOptions"]): FormlyFieldConfig { + return { + key, + type: "input", + defaultValue: "", + templateOptions: { ...options, maxLength: 256 }, + }; +} + // Formly attaches per-form runtime state to field-config objects, so every // consumer must get a fresh copy instead of sharing one array. export function contributorFieldGroup(): FormlyFieldConfig[] { return [ - { - key: "name", - type: "input", - defaultValue: "", - templateOptions: { - label: "Name", - required: true, - placeholder: "Enter name", - maxLength: 256, - }, - }, + contributorInput("name", { label: "Name", required: true, placeholder: "Enter name" }), { key: "creator", type: "checkbox", @@ -44,15 +43,7 @@ export function contributorFieldGroup(): FormlyFieldConfig[] { }, }, { - key: "email", - type: "input", - defaultValue: "", - templateOptions: { - label: "Email", - type: "email", - placeholder: "Enter email", - maxLength: 256, - }, + ...contributorInput("email", { label: "Email", type: "email", placeholder: "Enter email" }), validators: { validation: [Validators.email], }, @@ -62,16 +53,7 @@ export function contributorFieldGroup(): FormlyFieldConfig[] { }, }, }, - { - key: "affiliation", - type: "input", - defaultValue: "", - templateOptions: { - label: "Affiliation", - placeholder: "Enter affiliation", - maxLength: 256, - }, - }, + contributorInput("affiliation", { label: "Affiliation", placeholder: "Enter affiliation" }), { key: "comments", type: "textarea", diff --git a/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/user-dataset-contributor-editor/user-dataset-contributor-editor.component.spec.ts b/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/user-dataset-contributor-editor/user-dataset-contributor-editor.component.spec.ts index d66712cdf07..e58fdd70111 100644 --- a/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/user-dataset-contributor-editor/user-dataset-contributor-editor.component.spec.ts +++ b/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/user-dataset-contributor-editor/user-dataset-contributor-editor.component.spec.ts @@ -17,51 +17,31 @@ * under the License. */ -import { Component } from "@angular/core"; -import { ComponentFixture, TestBed } from "@angular/core/testing"; -import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; -import { ReactiveFormsModule } from "@angular/forms"; -import { FieldType, FieldTypeConfig, FormlyModule } from "@ngx-formly/core"; -import { NZ_MODAL_DATA, NzModalRef } from "ng-zorro-antd/modal"; +import { NZ_MODAL_DATA } from "ng-zorro-antd/modal"; import { UserDatasetContributorEditorComponent } from "./user-dataset-contributor-editor.component"; import { Contributor } from "../../../../../../common/type/dataset"; -import { commonTestProviders } from "../../../../../../common/testing/test-utils"; - -@Component({ template: "", standalone: true }) -class StubFormlyFieldComponent extends FieldType {} +import { createFormlyModalFixture } from "../../../formly-modal-test-fixture"; describe("UserDatasetContributorEditorComponent", () => { let modalClose: ReturnType; - async function createFixture( - modalData: Contributor | null - ): Promise> { + async function render(modalData: Contributor | null): Promise { modalClose = vi.fn(); - await TestBed.configureTestingModule({ - imports: [ - UserDatasetContributorEditorComponent, - BrowserAnimationsModule, - ReactiveFormsModule, - FormlyModule.forRoot({ - types: ["input", "checkbox", "textarea"].map(name => ({ name, component: StubFormlyFieldComponent })), - }), - ], - providers: [ - { provide: NZ_MODAL_DATA, useValue: modalData }, - { provide: NzModalRef, useValue: { close: modalClose } }, - ...commonTestProviders, - ], - }).compileComponents(); - - return TestBed.createComponent(UserDatasetContributorEditorComponent); + const fixture = await createFormlyModalFixture( + UserDatasetContributorEditorComponent, + ["input", "checkbox", "textarea"], + modalClose, + { providers: [{ provide: NZ_MODAL_DATA, useValue: modalData }] } + ); + fixture.detectChanges(); + return fixture.componentInstance; } it("starts with an empty model when adding a new contributor", async () => { - const fixture = await createFixture(null); - fixture.detectChanges(); + const component = await render(null); - expect(fixture.componentInstance.model).toEqual({ + expect(component.model).toEqual({ name: "", creator: false, email: "", @@ -78,16 +58,13 @@ describe("UserDatasetContributorEditorComponent", () => { email: "contributor-a@test.com", comments: "collected the data", }; - const fixture = await createFixture(contributor); - fixture.detectChanges(); + const component = await render(contributor); - expect(fixture.componentInstance.model).toEqual(contributor); + expect(component.model).toEqual(contributor); }); it("submit closes the modal with a copy of the model when the form is valid", async () => { - const fixture = await createFixture(null); - fixture.detectChanges(); - const component = fixture.componentInstance; + const component = await render(null); component.contributorForm.get("name")?.setValue("Bob"); component.submit(); @@ -97,9 +74,7 @@ describe("UserDatasetContributorEditorComponent", () => { }); it("submit does nothing when the email is invalid", async () => { - const fixture = await createFixture(null); - fixture.detectChanges(); - const component = fixture.componentInstance; + const component = await render(null); component.contributorForm.get("name")?.setValue("Contributor A"); component.contributorForm.get("email")?.setValue("not-an-email"); @@ -114,19 +89,17 @@ describe("UserDatasetContributorEditorComponent", () => { }); it("submit does nothing when the required name is empty (invalid form)", async () => { - const fixture = await createFixture(null); - fixture.detectChanges(); + const component = await render(null); - fixture.componentInstance.submit(); + component.submit(); expect(modalClose).not.toHaveBeenCalled(); }); it("cancel closes the modal without a value", async () => { - const fixture = await createFixture(null); - fixture.detectChanges(); + const component = await render(null); - fixture.componentInstance.cancel(); + component.cancel(); expect(modalClose).toHaveBeenCalledWith(); }); diff --git a/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/user-dataset-version-filetree/user-dataset-version-filetree.component.browser.spec.ts b/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/user-dataset-version-filetree/user-dataset-version-filetree.component.browser.spec.ts index ae5429b244a..bdb87cd8f37 100644 --- a/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/user-dataset-version-filetree/user-dataset-version-filetree.component.browser.spec.ts +++ b/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/user-dataset-version-filetree/user-dataset-version-filetree.component.browser.spec.ts @@ -23,20 +23,17 @@ // These tests run in vitest's Playwright/Chromium browser mode to pin the // behaviors that need real geometry. -import { ComponentFixture, TestBed } from "@angular/core/testing"; +import { ComponentFixture } from "@angular/core/testing"; import { UserDatasetVersionFiletreeComponent } from "./user-dataset-version-filetree.component"; import { DatasetFileNode } from "../../../../../../common/type/datasetVersionFileTree"; -import { FILE_COUNT, makeFlatFileNodes } from "./user-dataset-version-filetree.test-utils"; +import { createFiletreeFixture, FILE_COUNT, makeFlatFileNodes } from "./user-dataset-version-filetree.test-utils"; describe("UserDatasetVersionFiletreeComponent (browser)", () => { let fixture: ComponentFixture; let component: UserDatasetVersionFiletreeComponent; beforeEach(() => { - TestBed.configureTestingModule({ - imports: [UserDatasetVersionFiletreeComponent], - }); - fixture = TestBed.createComponent(UserDatasetVersionFiletreeComponent); + fixture = createFiletreeFixture(); component = fixture.componentInstance; }); diff --git a/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/user-dataset-version-filetree/user-dataset-version-filetree.component.html b/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/user-dataset-version-filetree/user-dataset-version-filetree.component.html index d564c5edbde..1dca4f311dd 100644 --- a/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/user-dataset-version-filetree/user-dataset-version-filetree.component.html +++ b/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/user-dataset-version-filetree/user-dataset-version-filetree.component.html @@ -31,14 +31,8 @@ let-node> - {{ node.data.name }}
@@ -194,51 +172,23 @@

Description

-
- -

General

- -
-
- -

Letters, numbers, underscores and hyphens.

-

- An upload is in progress — finish or cancel it in Versions & Files first, or it will be left - incomplete. -

-
-
- - -
-
- - - -
- -
Shown on cards.
- - -
-
- - +
+

Model type

@@ -281,47 +231,6 @@

Model type

- - -

Access & visibility

- -
-
- -

- {{ modelIsPublic ? "Public — anyone can view this model." : "Private — only you and invited collaborators - can see this model." }} -

-
-
- -
-
- - - -
-
- -

- {{ modelIsDownloadable ? "Viewers can download this model." : "Viewers can browse files but cannot - download them." }} -

-
-
- -
-
-
diff --git a/frontend/src/app/dashboard/component/user/user-model/user-model-explorer/model-detail.component.scss b/frontend/src/app/dashboard/component/user/user-model/user-model-explorer/model-detail.component.scss index 8adfac83c37..bcf807f7c19 100644 --- a/frontend/src/app/dashboard/component/user/user-model/user-model-explorer/model-detail.component.scss +++ b/frontend/src/app/dashboard/component/user/user-model/user-model-explorer/model-detail.component.scss @@ -17,148 +17,25 @@ * under the License. */ -// Mirrors dataset-detail.component.scss; the two detail pages are the same layout. +@use "../../resource-detail-shared" as detail; -.version-storage { - padding: 0 15px; - margin-bottom: 25px; -} +// Mirrors dataset-detail.component.scss; the two detail pages are the same layout. -.version-storage nz-select { - width: 100%; - margin: 0; -} +@include detail.version-storage; nz-layout { height: 100%; } -.right-sider { - height: 100%; - overflow-y: auto; - position: relative; - z-index: 0; -} - -.sider-resize-line { - display: flex; - align-items: center; - justify-content: center; - height: 100%; - width: 5px; - border-right: 1px solid #e8e8e8; -} +@include detail.browser-pane; -.sider-resize-handle { - background: #fff; - border: 1px solid #ddd; - text-align: center; - font-size: 12px; - height: 20px; - line-height: 20px; -} +@include detail.browser-toolbar; -.file-renderer { - width: 95%; - height: 80%; - margin: auto; -} +@include detail.version-list; -.select-and-button-container { - display: flex; - align-items: stretch; - gap: 10px; -} +@include detail.like-states; -.spaced-button { - flex-shrink: 0; - width: 30px; - height: 24px; -} - -nz-select { - flex-grow: 1; -} - -.file-size, -.version-size, -.version-date { - font-size: 12px; - color: #8c8c8c; - display: inline-flex; - align-items: center; - gap: 4px; -} - -.version-date { - display: flex; -} - -.version-size { - margin-top: 8px; -} - -.icon-database, -.icon-file { - font-size: 14px; -} - -.empty-version-indicator { - margin-top: 15%; -} - -.status-tag-row { - margin-top: 16px; - display: flex; - align-items: center; - gap: 5px; -} - -.like-tag { - cursor: pointer; -} - -.like-tag.liked { - i { - color: #ef4444; - background: #fef2f2; - } -} - -.like-tag.disabled { - cursor: not-allowed; - opacity: 0.55; -} - -.status-tag { - padding: 3px 10px 3px 3px; - font-size: 13px; - display: inline-flex; - align-items: center; - gap: 5px; - background: #fff; - border-radius: 5px; - - i { - width: 22px; - height: 22px; - display: inline-flex; - align-items: center; - justify-content: center; - border-radius: 4px; - background: #f0f0f0; - } -} - -.tag-public i { - color: #3b82f6; - background: #eff6ff; -} - -.tag-downloadable i { - color: #22c55e; - background: #f0fdf4; -} +@include detail.status-tags; .tag-framework i { color: #a855f7; @@ -170,204 +47,19 @@ nz-select { background: #fffbeb; } -.file-title { - display: flex; - align-items: center; - flex-wrap: wrap; - gap: 8px; - margin-bottom: 0; -} - -.file-title-main { - display: inline-flex; - align-items: center; - gap: 6px; - min-width: 0; -} - -.copy-path-btn { - padding: 0 4px; - height: auto; - line-height: 1; - display: inline-flex; - align-items: center; - justify-content: center; -} - -.model-header { - display: flex; - gap: 24px; -} - -.model-header-meta { - flex: 1; -} - -.model-cover-image { - width: 280px; - height: 120px; - object-fit: cover; - border-radius: 8px; - margin-right: 80px; -} +@include detail.file-path-title; -nz-tabs { - margin-top: 6px; -} +@include detail.header("model"); -::ng-deep .ant-tabs-nav { - padding-left: 16px; -} +@include detail.tab-bar; .data-card-tab-content, .versions-tab-content { - height: 100%; - overflow-y: auto; - padding-bottom: 24px; + @include detail.scrollable-tab; } -// A wide description card beside a narrower stats card. The grow ratio with -// basis 0 is the only thing setting their proportions. -.data-card-columns { - display: flex; - align-items: flex-start; - gap: 20px; - margin-top: 24px; - width: 100%; - // Match the tab bar's left inset so the cards line up with the tab labels. - padding-left: 16px; -} - -.data-card { - border-radius: 8px; - border: 1px solid #d9d9d9; - // Without this the default min-width:auto keeps the cards from shrinking to - // their flex share, skewing the ratio. - min-width: 0; -} - -.data-card-main { - flex: 3 1 0; -} - -.data-card-details { - flex: 1 1 0; -} - -@media (max-width: 768px) { - .data-card-columns { - flex-direction: column; - align-items: stretch; - } -} - -.data-card-heading { - font-size: 18px; - font-weight: 600; - color: rgba(0, 0, 0, 0.85); - margin: 0 0 20px; -} - -.data-card-description { - font-size: 16px; - line-height: 1.6; - margin-bottom: 32px; -} - -.empty-description { - color: rgba(0, 0, 0, 0.4); - font-style: italic; -} - -.data-card-stats { - display: flex; - flex-direction: column; -} - -.stat-row { - display: flex; - justify-content: space-between; - align-items: baseline; - gap: 16px; - padding: 12px 0; - border-bottom: 1px solid #f0f0f0; - - &:last-child { - border-bottom: none; - } -} - -.stat-label { - font-size: 13px; - font-weight: 600; - color: rgba(0, 0, 0, 0.85); - flex-shrink: 0; -} - -.stat-value { - font-weight: 400; - color: rgba(0, 0, 0, 0.45); - text-align: right; - word-break: break-word; -} +@include detail.data-card; .settings-tab-content { - height: 100%; - overflow-y: auto; - padding-bottom: 24px; -} - -.settings-general-card { - max-width: 700px; - margin: 24px auto 0; - border-radius: 16px; - border: 1px solid #d9d9d9; - - .settings-card-title { - font-weight: 600; - margin-bottom: 20px; - } - - .settings-field-label { - display: block; - font-weight: 600; - } - - .settings-field-hint { - color: rgba(0, 0, 0, 0.45); - font-size: 12px; - margin-bottom: 8px; - } - - .settings-name-row { - display: flex; - justify-content: space-between; - align-items: center; - gap: 16px; - - .settings-name-label label { - font-weight: 600; - } - - .settings-hint { - color: rgba(0, 0, 0, 0.45); - font-size: 12px; - margin: 4px 0 0; - } - - .settings-name-controls { - display: flex; - gap: 8px; - flex-shrink: 0; - - input, - button { - border-radius: 8px; - } - } - } - - .settings-select { - min-width: 200px; - } + @include detail.scrollable-tab; } diff --git a/frontend/src/app/dashboard/component/user/user-model/user-model-explorer/model-detail.component.ts b/frontend/src/app/dashboard/component/user/user-model/user-model-explorer/model-detail.component.ts index 2b11761d93b..06b48d4e4ff 100644 --- a/frontend/src/app/dashboard/component/user/user-model/user-model-explorer/model-detail.component.ts +++ b/frontend/src/app/dashboard/component/user/user-model/user-model-explorer/model-detail.component.ts @@ -30,13 +30,9 @@ import { NzTooltipDirective } from "ng-zorro-antd/tooltip"; import { NzTagComponent } from "ng-zorro-antd/tag"; import { ɵNzTransitionPatchDirective } from "ng-zorro-antd/core/transition-patch"; import { NzIconDirective } from "ng-zorro-antd/icon"; -import { NzButtonComponent } from "ng-zorro-antd/button"; -import { NzWaveDirective } from "ng-zorro-antd/core/wave"; import { NzSelectComponent, NzOptionComponent } from "ng-zorro-antd/select"; import { NzTabsComponent, NzTabComponent } from "ng-zorro-antd/tabs"; import { NzDividerComponent } from "ng-zorro-antd/divider"; -import { NzInputDirective } from "ng-zorro-antd/input"; -import { NzSwitchComponent } from "ng-zorro-antd/switch"; import { MODEL_FORMATS, @@ -61,6 +57,7 @@ import { } from "../../../../../common/type/datasetVersionFileTree"; import { MarkdownDescriptionComponent } from "../../markdown-description/markdown-description.component"; import { VersionsFilesBrowserComponent } from "../../versions-files-browser/versions-files-browser.component"; +import { ResourceDetailSettingsComponent } from "../../resource-detail-settings.component"; @UntilDestroy() @Component({ @@ -77,17 +74,14 @@ import { VersionsFilesBrowserComponent } from "../../versions-files-browser/vers NzTagComponent, ɵNzTransitionPatchDirective, NzIconDirective, - NzButtonComponent, - NzWaveDirective, NzSelectComponent, NzOptionComponent, NzTabsComponent, NzTabComponent, NzDividerComponent, - NzInputDirective, - NzSwitchComponent, MarkdownDescriptionComponent, VersionsFilesBrowserComponent, + ResourceDetailSettingsComponent, ], }) export class ModelDetailComponent implements OnInit { @@ -145,7 +139,17 @@ export class ModelDetailComponent implements OnInit { // blocks it until the panel is idle. public uploadsInFlight = false; - formatSize = formatSize; + protected get overviewStatistics() { + return [ + { label: "Created", value: this.modelCreationTime }, + { label: "Last updated", value: this.latestVersionCreationTime || "—" }, + { label: "Versions", value: this.versions.length }, + { label: "Framework", value: this.modelFramework || "—" }, + { label: "Format", value: this.modelFormat || "—" }, + { label: "Latest version file", value: this.latestVersionFileName || "—" }, + { label: "Latest version size", value: formatSize(this.latestVersionSize) }, + ]; + } formatCount = formatCount; constructor( @@ -502,40 +506,44 @@ export class ModelDetailComponent implements OnInit { } onModelDescriptionChange(description: string): void { - const updatedDescription = description ?? ""; - const previousDescription = this.modelDescription; - - if (!this.mid || previousDescription === updatedDescription) { - return; - } - this.modelDescription = updatedDescription; - - this.modelService - .updateModelDescription(this.mid, updatedDescription) - .pipe(untilDestroyed(this)) - .subscribe({ - error: () => { - this.modelDescription = previousDescription; - this.notificationService.error("Failed to update model description"); - }, - }); + this.saveTextSetting( + "modelDescription", + description ?? "", + (id, value) => this.modelService.updateModelDescription(id, value), + { error: "Failed to update model description" } + ); } onFrameworkChange(framework: string): void { - const previous = this.modelFramework; - if (!this.mid || previous === framework) { + this.saveTextSetting( + "modelFramework", + framework, + (id, value) => this.modelService.updateModelFramework(id, value), + { success: `Framework set to '${framework}'` } + ); + } + + private saveTextSetting( + field: K, + value: ModelDetailComponent[K] & string, + save: (mid: number, value: string) => Observable, + { error, success }: { error?: string; success?: string } + ): void { + const model: ModelDetailComponent = this; + const previous = model[field]; + const mid = this.mid; + if (!mid || previous === value) { return; } - this.modelFramework = framework; - this.modelService - .updateModelFramework(this.mid, framework) + model[field] = value; + save(mid, value) .pipe(untilDestroyed(this)) .subscribe({ - next: () => this.notificationService.success(`Framework set to '${framework}'`), + next: success === undefined ? undefined : () => this.notificationService.success(success), error: (err: unknown) => { - this.modelFramework = previous; - this.notificationService.error(extractErrorMessage(err)); + model[field] = previous; + this.notificationService.error(error ?? extractErrorMessage(err)); }, }); } @@ -624,21 +632,8 @@ export class ModelDetailComponent implements OnInit { } onFormatChange(modelFormat: string): void { - const previous = this.modelFormat; - if (!this.mid || previous === modelFormat) { - return; - } - this.modelFormat = modelFormat; - - this.modelService - .updateModelFormat(this.mid, modelFormat) - .pipe(untilDestroyed(this)) - .subscribe({ - next: () => this.notificationService.success(`Format set to '${modelFormat}'`), - error: (err: unknown) => { - this.modelFormat = previous; - this.notificationService.error(extractErrorMessage(err)); - }, - }); + this.saveTextSetting("modelFormat", modelFormat, (id, value) => this.modelService.updateModelFormat(id, value), { + success: `Format set to '${modelFormat}'`, + }); } } diff --git a/frontend/src/app/dashboard/component/user/version-uploader/version-uploader.component.spec.ts b/frontend/src/app/dashboard/component/user/version-uploader/version-uploader.component.spec.ts index 499a84034ec..87b25c85dee 100644 --- a/frontend/src/app/dashboard/component/user/version-uploader/version-uploader.component.spec.ts +++ b/frontend/src/app/dashboard/component/user/version-uploader/version-uploader.component.spec.ts @@ -50,6 +50,7 @@ describe("VersionUploaderComponent", () => { let uploadedPaths: string[]; let multipartUploadSpy: ReturnType; let createVersionSpy: ReturnType; + let finalize: ReturnType; const asCreateVersion = (spy: ReturnType) => spy as unknown as (name: string) => Observable; const makeFileItem = (name: string): FileUploadItem => ({ @@ -66,6 +67,34 @@ describe("VersionUploaderComponent", () => { const finishUpload = (index: number, filePath: string, totalTime = 1) => uploadSubjects[index].next({ filePath, percentage: 100, status: "finished", totalTime }); + function stageFile(filePath: string): void { + const index = uploadSubjects.length; + dropFiles(filePath); + finishUpload(index, filePath); + } + + function mount(seed?: (c: VersionUploaderComponent) => void): void { + fixture = TestBed.createComponent(VersionUploaderComponent); + component = fixture.componentInstance; + component.resourceId = 1; + component.ownerEmail = "owner@texera.com"; + component.resourceName = "test-dataset"; + component.endpoint = DATASET_FILE_RESOURCE_ENDPOINT; + component.createVersion = asCreateVersion(createVersionSpy); + seed?.(component); + fixture.detectChanges(); + } + + function expectAbortRequest(path: string) { + expect(finalize).toHaveBeenCalledWith( + DATASET_FILE_RESOURCE_ENDPOINT, + "owner@texera.com", + "test-dataset", + path, + true + ); + } + beforeEach(() => { uploadSubjects = []; uploadedPaths = []; @@ -76,6 +105,7 @@ describe("VersionUploaderComponent", () => { return progress.asObservable(); }); createVersionSpy = vi.fn(() => of({})); + finalize = vi.fn(() => of({})); TestBed.configureTestingModule({ imports: [VersionUploaderComponent, ...commonTestImports], @@ -85,7 +115,7 @@ describe("VersionUploaderComponent", () => { provide: MultipartUploadService, useValue: { multipartUpload: multipartUploadSpy, - finalizeMultipartUpload: vi.fn(() => of({})), + finalizeMultipartUpload: finalize, listMultipartUploads: vi.fn(() => of([])), findExistingUploadFiles: vi.fn(() => of([])), }, @@ -98,14 +128,7 @@ describe("VersionUploaderComponent", () => { ], }); - fixture = TestBed.createComponent(VersionUploaderComponent); - component = fixture.componentInstance; - component.resourceId = 1; - component.ownerEmail = "owner@texera.com"; - component.resourceName = "test-dataset"; - component.endpoint = DATASET_FILE_RESOURCE_ENDPOINT; - component.createVersion = asCreateVersion(createVersionSpy); - fixture.detectChanges(); + mount(); }); describe("a failed upload", () => { @@ -234,11 +257,8 @@ describe("VersionUploaderComponent", () => { * and the caller's callback must fire exactly once down every one of those paths. */ describe("aborting an upload", () => { - let finalize: ReturnType; - beforeEach(() => { vi.useFakeTimers(); - finalize = TestBed.inject(MultipartUploadService).finalizeMultipartUpload as unknown as ReturnType; }); afterEach(() => { @@ -252,22 +272,20 @@ describe("VersionUploaderComponent", () => { return component.uploadTasks.find(t => t.filePath === name)!; } + function abortInFlight() { + const task = inFlight(); + const onAborted = vi.fn(); + component.onClickAbortUploadProgress(task as any, onAborted); + return onAborted; + } + const conflict = () => throwError(() => ({ status: 409 }) as any); const gone = () => throwError(() => ({ status: 404 }) as any); it("marks the task aborted and tells the caller once", () => { - const task = inFlight(); - const onAborted = vi.fn(); - - component.onClickAbortUploadProgress(task as any, onAborted); + const onAborted = abortInFlight(); - expect(finalize).toHaveBeenCalledWith( - DATASET_FILE_RESOURCE_ENDPOINT, - "owner@texera.com", - "test-dataset", - "a.txt", - true - ); + expectAbortRequest("a.txt"); expect(component.uploadTasks.find(t => t.filePath === "a.txt")!.status).toBe("aborted"); expect(onAborted).toHaveBeenCalledTimes(1); @@ -290,10 +308,7 @@ describe("VersionUploaderComponent", () => { it("treats a 404 as already aborted rather than an error", () => { finalize.mockReturnValueOnce(gone()); - const task = inFlight(); - const onAborted = vi.fn(); - - component.onClickAbortUploadProgress(task as any, onAborted); + const onAborted = abortInFlight(); expect(onAborted).toHaveBeenCalledTimes(1); expect(finalize).toHaveBeenCalledTimes(1); @@ -302,10 +317,7 @@ describe("VersionUploaderComponent", () => { it("retries a 409 after a backoff and finishes once the server catches up", () => { // The server is still finalizing the previous attempt; the abort has to wait it out. finalize.mockReturnValueOnce(conflict()); - const task = inFlight(); - const onAborted = vi.fn(); - - component.onClickAbortUploadProgress(task as any, onAborted); + const onAborted = abortInFlight(); expect(onAborted).not.toHaveBeenCalled(); vi.advanceTimersByTime(ABORT_RETRY_BACKOFF_BASE_MS); @@ -335,10 +347,7 @@ describe("VersionUploaderComponent", () => { it("gives up after the attempt limit but still reports the abort", () => { // Without the bound this would retry forever against a permanently conflicted server. finalize.mockReturnValue(conflict()); - const task = inFlight(); - const onAborted = vi.fn(); - - component.onClickAbortUploadProgress(task as any, onAborted); + const onAborted = abortInFlight(); vi.advanceTimersByTime(ABORT_RETRY_BACKOFF_BASE_MS * ABORT_RETRY_MAX_ATTEMPTS * (ABORT_RETRY_MAX_ATTEMPTS + 1)); expect(finalize).toHaveBeenCalledTimes(ABORT_RETRY_MAX_ATTEMPTS + 1); @@ -347,10 +356,7 @@ describe("VersionUploaderComponent", () => { it("reports the abort once even on an error the retry does not cover", () => { finalize.mockReturnValueOnce(throwError(() => ({ status: 500 }) as any)); - const task = inFlight(); - const onAborted = vi.fn(); - - component.onClickAbortUploadProgress(task as any, onAborted); + const onAborted = abortInFlight(); expect(onAborted).toHaveBeenCalledTimes(1); expect(finalize).toHaveBeenCalledTimes(1); @@ -375,13 +381,7 @@ describe("VersionUploaderComponent", () => { component.cancelExistingUpload("b.txt", onCanceled); - expect(finalize).toHaveBeenCalledWith( - DATASET_FILE_RESOURCE_ENDPOINT, - "owner@texera.com", - "test-dataset", - "b.txt", - true - ); + expectAbortRequest("b.txt"); expect(onCanceled).toHaveBeenCalledTimes(1); }); @@ -450,13 +450,7 @@ describe("VersionUploaderComponent", () => { component.cancelExistingUpload("b.txt", onCanceled); - expect(finalize).toHaveBeenCalledWith( - DATASET_FILE_RESOURCE_ENDPOINT, - "owner@texera.com", - "test-dataset", - "b.txt", - true - ); + expectAbortRequest("b.txt"); expect(component.uploadTasks.find(t => t.filePath === "b.txt")!.status).toBe("aborted"); // The slot goes back to the queue instead of being held by an attempt that // is no longer running. @@ -475,10 +469,7 @@ describe("VersionUploaderComponent", () => { throwError(() => ({ status: 500 }) as any) ) ); - const task = inFlight(); - const onAborted = vi.fn(); - - component.onClickAbortUploadProgress(task as any, onAborted); + const onAborted = abortInFlight(); expect(onAborted).toHaveBeenCalledTimes(1); }); @@ -489,13 +480,7 @@ describe("VersionUploaderComponent", () => { component.onClickAbortUploadProgress(task as any); - expect(finalize).toHaveBeenCalledWith( - DATASET_FILE_RESOURCE_ENDPOINT, - "owner@texera.com", - "test-dataset", - "a.txt", - true - ); + expectAbortRequest("a.txt"); // Writing "aborted" back at a missing index would leave a phantom "-1" property on // the array, which neither a throw nor `.length` would reveal. expect(component.uploadTasks).toEqual([]); @@ -509,15 +494,7 @@ describe("VersionUploaderComponent", () => { /** Rebuilds the fixture so a per-test settings stub is in place before ngOnInit runs. */ const rebuild = (seed?: (c: VersionUploaderComponent) => void): void => { fixture.destroy(); - fixture = TestBed.createComponent(VersionUploaderComponent); - component = fixture.componentInstance; - component.resourceId = 1; - component.ownerEmail = "owner@texera.com"; - component.resourceName = "test-dataset"; - component.endpoint = DATASET_FILE_RESOURCE_ENDPOINT; - component.createVersion = asCreateVersion(createVersionSpy); - seed?.(component); - fixture.detectChanges(); + mount(seed); }; /** The panel is the only thing that knows which resource family it is addressing. */ @@ -533,12 +510,8 @@ describe("VersionUploaderComponent", () => { }); it("reads its upload tuning from its own family's settings keys", () => { - const settings = TestBed.inject(AdminSettingsService) as unknown as { - getPublicSetting: ReturnType; - }; - // The last is the file picker's own per-file ceiling, which it reads off the same endpoint. - expect(settings.getPublicSetting.mock.calls.map(call => call[0])).toEqual([ + expect(settingsStub().getPublicSetting.mock.calls.map(call => call[0])).toEqual([ DATASET_FILE_RESOURCE_ENDPOINT.chunkSizeSettingKey, DATASET_FILE_RESOURCE_ENDPOINT.maxConcurrentChunksSettingKey, DATASET_FILE_RESOURCE_ENDPOINT.maxConcurrentFilesSettingKey, @@ -659,8 +632,7 @@ describe("VersionUploaderComponent", () => { it("clears the staged state, tells the host to reload, and re-enables the button", () => { const versionCreated = vi.fn(); component.versionCreated.subscribe(versionCreated); - dropFiles("a.csv"); - finishUpload(0, "a.csv"); + stageFile("a.csv"); expect(component.pendingChangesCount).toBe(1); component.onClickCreateVersion(); @@ -675,8 +647,7 @@ describe("VersionUploaderComponent", () => { createVersionSpy.mockReturnValue(throwError(() => new HttpErrorResponse({ status: 400 }))); const versionCreated = vi.fn(); component.versionCreated.subscribe(versionCreated); - dropFiles("a.csv"); - finishUpload(0, "a.csv"); + stageFile("a.csv"); component.onClickCreateVersion(); @@ -859,8 +830,7 @@ describe("VersionUploaderComponent", () => { }); it("does not double-count a finished upload already confirmed by a diff response", () => { - dropFiles("f1.txt"); - finishUpload(0, "f1.txt"); + stageFile("f1.txt"); component.onStagedObjectsUpdated([{ path: "f1.txt", pathType: "file", diffType: "added", sizeBytes: 1 }]); expect(component.pendingChangesCount).toBe(1); @@ -882,8 +852,7 @@ describe("VersionUploaderComponent", () => { }); it("clears the Finished count when a version is created", () => { - dropFiles("f1.txt"); - finishUpload(0, "f1.txt"); + stageFile("f1.txt"); expect(component.pendingChangesCount).toBe(1); component.versionName = "v1"; @@ -945,44 +914,41 @@ describe("VersionUploaderComponent", () => { expect(component.queuedFileNames).toEqual(["f5.txt"]); }); - describe("rendered progress", () => { - /** - * Puts one task on the panel in the given state and opens it. The panel is gated on the - * separate activeUploads counter rather than on uploadTasks, and ng-zorro collapses it by - * default, so both have to be arranged before its body exists. - */ - function withTask(over: Record): HTMLElement { - (component as any).activeUploads = 1; - component.uploadTasks = [ - { - filePath: "big.csv", - percentage: 40, - status: "uploading", - uploadSpeed: 1024, - totalTime: 12, - estimatedTimeRemaining: 30, - ...over, - } as any, - ]; - fixture.detectChanges(); - const el = fixture.nativeElement as HTMLElement; - const header = Array.from(el.querySelectorAll(".ant-collapse-header")).find(h => - (h.textContent || "").includes("Uploading:") - ); - header!.click(); - fixture.detectChanges(); - return el; - } + const host = (): HTMLElement => fixture.nativeElement as HTMLElement; + + /** Render the tasks after supplying the active count and opening the collapsed panel. */ + function withTasks(...tasks: Array>): HTMLElement { + component.uploadTasks = tasks.map(task => ({ + filePath: "big.csv", + percentage: 40, + status: "uploading", + uploadSpeed: 1024, + totalTime: 12, + estimatedTimeRemaining: 30, + ...task, + })); + (component as unknown as { activeUploads: number }).activeUploads = tasks.length; + fixture.detectChanges(); + const el = host(); + const header = Array.from(el.querySelectorAll(".ant-collapse-header")).find(h => + (h.textContent || "").includes("Uploading:") + ); + expect(header, 'expected a collapse panel headed "Uploading:"').toBeDefined(); + header!.click(); + fixture.detectChanges(); + return el; + } + describe("rendered progress", () => { it("shows no statistics while an upload is still initializing", () => { // There is nothing to report yet; showing a 0 B/s row reads as a stalled upload. - const el = withTask({ status: "initializing" }); + const el = withTasks({ status: "initializing" }); expect(el.querySelector(".upload-stats")).toBeNull(); }); it("reports speed and both timings while an upload runs", () => { - const el = withTask({ status: "uploading" }); + const el = withTasks({ status: "uploading" }); const stats = el.querySelector(".upload-stats")!; expect(stats.textContent).toContain("elapsed"); @@ -991,7 +957,7 @@ describe("VersionUploaderComponent", () => { }); it("replaces the live figures with a total once the upload finishes", () => { - const el = withTask({ status: "finished" }); + const el = withTasks({ status: "finished" }); const stats = el.querySelector(".upload-stats")!; expect(stats.textContent).toContain("Upload time:"); @@ -999,15 +965,13 @@ describe("VersionUploaderComponent", () => { }); it("reports a total for an aborted upload too", () => { - const el = withTask({ status: "aborted" }); + const el = withTasks({ status: "aborted" }); expect(el.querySelector(".upload-stats")!.textContent).toContain("Upload time:"); }); }); describe("rendered panel", () => { - const host = (): HTMLElement => fixture.nativeElement as HTMLElement; - const q = (root: ParentNode, selector: string): E => { const el = root.querySelector(selector); expect(el, `expected to find "${selector}"`).not.toBeNull(); @@ -1016,16 +980,6 @@ describe("VersionUploaderComponent", () => { const text = (el: Element | null | undefined): string => (el?.textContent ?? "").replace(/\s+/g, " ").trim(); - /** ng-zorro collapses every status panel by default, so its body has to be opened first. */ - const openPanel = (header: string): void => { - const found = Array.from(host().querySelectorAll(".ant-collapse-header")).find(h => - (h.textContent || "").includes(header) - ); - expect(found, `expected a collapse panel headed "${header}"`).toBeDefined(); - found!.click(); - fixture.detectChanges(); - }; - describe("upload panel", () => { it("starts an upload for a file the uploader hands over", () => { const el = host(); @@ -1053,22 +1007,6 @@ describe("VersionUploaderComponent", () => { expect(text(el)).toContain("Uploading: 1 file(s)"); }); - /** Renders the given in-flight tasks and expands the "Uploading" panel. */ - const withTasks = (...tasks: Array>): HTMLElement => { - component.uploadTasks = tasks.map(t => ({ - percentage: 40, - status: "uploading", - uploadSpeed: 1024, - totalTime: 12, - estimatedTimeRemaining: 30, - ...t, - })) as never; - (component as unknown as { activeUploads: number }).activeUploads = tasks.length; - fixture.detectChanges(); - openPanel("Uploading:"); - return host(); - }; - it("aborts the upload whose own row button was clicked", () => { withTasks({ filePath: "first.csv" }, { filePath: "second.csv" }); @@ -1088,17 +1026,8 @@ describe("VersionUploaderComponent", () => { abort.nativeElement.click(); fixture.detectChanges(); - const finalize = TestBed.inject(MultipartUploadService).finalizeMultipartUpload as unknown as ReturnType< - typeof vi.fn - >; expect(finalize).toHaveBeenCalledTimes(1); - expect(finalize).toHaveBeenCalledWith( - DATASET_FILE_RESOURCE_ENDPOINT, - "owner@texera.com", - "test-dataset", - "second.csv", - true - ); + expectAbortRequest("second.csv"); }); it("reports the elapsed time, the time remaining and the speed in their own slots", () => { diff --git a/frontend/src/app/dashboard/component/user/version-uploader/version-uploader.component.ts b/frontend/src/app/dashboard/component/user/version-uploader/version-uploader.component.ts index 860d3226a30..d6b4e2482ef 100644 --- a/frontend/src/app/dashboard/component/user/version-uploader/version-uploader.component.ts +++ b/frontend/src/app/dashboard/component/user/version-uploader/version-uploader.component.ts @@ -156,27 +156,20 @@ export class VersionUploaderComponent implements OnInit { // A missing key or failed fetch keeps the field defaults; NaN here would silently stall the // upload queue (`activeUploads < NaN` is always false). private loadUploadSettings(): void { - this.adminSettingsService - .getPublicSetting(this.endpoint.chunkSizeSettingKey) - .pipe(untilDestroyed(this)) - .subscribe({ - next: value => (this.chunkSizeMiB = parseIntOrDefault(value, this.chunkSizeMiB)), - error: () => {}, - }); - this.adminSettingsService - .getPublicSetting(this.endpoint.maxConcurrentChunksSettingKey) - .pipe(untilDestroyed(this)) - .subscribe({ - next: value => (this.maxConcurrentChunks = parseIntOrDefault(value, this.maxConcurrentChunks)), - error: () => {}, - }); - this.adminSettingsService - .getPublicSetting(this.endpoint.maxConcurrentFilesSettingKey) - .pipe(untilDestroyed(this)) - .subscribe({ - next: value => (this.maxConcurrentFiles = parseIntOrDefault(value, this.maxConcurrentFiles)), - error: () => {}, - }); + const settings = [ + ["chunkSizeSettingKey", "chunkSizeMiB"], + ["maxConcurrentChunksSettingKey", "maxConcurrentChunks"], + ["maxConcurrentFilesSettingKey", "maxConcurrentFiles"], + ] as const; + for (const [key, field] of settings) { + this.adminSettingsService + .getPublicSetting(this.endpoint[key]) + .pipe(untilDestroyed(this)) + .subscribe({ + next: value => (this[field] = parseIntOrDefault(value, this[field])), + error: () => {}, + }); + } } onNewUploadFilesChanged(files: FileUploadItem[]): void { diff --git a/frontend/src/app/dashboard/component/user/versions-files-browser/versions-files-browser.component.scss b/frontend/src/app/dashboard/component/user/versions-files-browser/versions-files-browser.component.scss index b1e2c96b268..b8845b9835e 100644 --- a/frontend/src/app/dashboard/component/user/versions-files-browser/versions-files-browser.component.scss +++ b/frontend/src/app/dashboard/component/user/versions-files-browser/versions-files-browser.component.scss @@ -17,120 +17,26 @@ * under the License. */ +@use "../resource-detail-shared" as detail; + .versions-tab-content { - height: 100%; - overflow-y: auto; - padding-bottom: 24px; + @include detail.scrollable-tab; } nz-layout { height: 100%; } -.version-storage { - padding: 0 15px; - margin-bottom: 25px; -} - -.version-storage nz-select { - width: 100%; - margin: 0; -} +@include detail.version-storage; nz-select { flex-grow: 1; } -.right-sider { - height: 100%; - overflow-y: auto; - position: relative; - z-index: 0; -} - -.sider-resize-line { - display: flex; - align-items: center; - justify-content: center; - height: 100%; - width: 5px; - border-right: 1px solid #e8e8e8; -} - -.sider-resize-handle { - background: #fff; - border: 1px solid #ddd; - text-align: center; - font-size: 12px; - height: 20px; - line-height: 20px; -} +@include detail.browser-pane; -.file-renderer { - width: 95%; - height: 80%; - margin: auto; -} - -.select-and-button-container { - display: flex; - align-items: stretch; - gap: 10px; -} +@include detail.browser-toolbar($include-select: false); -.spaced-button { - flex-shrink: 0; - width: 30px; - height: 24px; -} +@include detail.file-path-title; -.file-title { - display: flex; - align-items: center; - flex-wrap: wrap; - gap: 8px; - margin-bottom: 0; -} - -.file-title-main { - display: inline-flex; - align-items: center; - gap: 6px; - min-width: 0; -} - -.copy-path-btn { - padding: 0 4px; - height: auto; - line-height: 1; - display: inline-flex; - align-items: center; - justify-content: center; -} - -.file-size, -.version-size, -.version-date { - font-size: 12px; - color: #8c8c8c; - display: inline-flex; - align-items: center; - gap: 4px; -} - -.version-date { - display: flex; -} - -.version-size { - margin-top: 8px; -} - -.icon-database, -.icon-file { - font-size: 14px; -} - -.empty-version-indicator { - margin-top: 15%; -} +@include detail.version-list($include-status-row: false);