Copilot commented on code in PR #7043:
URL: https://github.com/apache/texera/pull/7043#discussion_r3678506980


##########
frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.ts:
##########
@@ -421,6 +429,35 @@ export class DatasetDetailComponent implements OnInit {
     }
   }
 
+  // Fetches the latest version independently of the current selection and 
derives
+  // the Data Card's latest-version facts from that single response: the file 
name
+  // and created date directly, and the total size via a follow-up file-tree 
fetch
+  // for the latest version's dvid (mirroring onVersionSelected's size lookup).
+  retrieveLatestVersionFile() {
+    if (this.did) {
+      const did = this.did;
+      this.datasetService
+        .retrieveDatasetLatestVersion(did)
+        .pipe(untilDestroyed(this))
+        .subscribe(version => {
+          const firstFile = this.getFirstFileNode(version.fileNodes ?? []);
+          this.latestVersionFileName = firstFile ? 
getFullPathFromDatasetFileNode(firstFile) : "";
+          this.latestVersionCreationTime =
+            typeof version.creationTime === "number"
+              ? format(new Date(version.creationTime), "MM/dd/yyyy HH:mm:ss")
+              : "";
+          if (version.dvid) {
+            this.datasetService
+              .retrieveDatasetVersionFileTree(did, version.dvid, this.isLogin)
+              .pipe(untilDestroyed(this))
+              .subscribe(data => {
+                this.latestVersionSize = data.size;
+              });
+          }

Review Comment:
   `retrieveLatestVersionFile()` can be invoked multiple times (initial load, 
after uploads). The nested `retrieveDatasetVersionFileTree` subscription can 
race: a slower response from an earlier invocation can overwrite 
`latestVersionSize` after a newer latest-version fetch has already updated 
`latestVersionCreationTime/latestVersionFileName`. Also, when the latest 
version has no `dvid`, `latestVersionSize` is never cleared and can remain 
stale.



##########
frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.spec.ts:
##########
@@ -301,7 +312,14 @@ describe("DatasetDetailComponent upload queue", () => {
 
   it("renders the virtualized pending list and re-measures viewports on panel 
expand", async () => {
     dropFiles("f1.txt", "f2.txt", "f3.txt", "f4.txt", "f5.txt");
+
+    // The upload UI lives in the "Versions & Files" tab; nz-tabs does not 
render a
+    // tab's content into the DOM until it has been selected at least once.
+    const tabButtons: NodeListOf<HTMLElement> = 
fixture.nativeElement.querySelectorAll(".ant-tabs-tab-btn");
+    const versionsTab = Array.from(tabButtons).find(tab => 
tab.textContent?.includes("Versions & Files"));
+    versionsTab?.click();

Review Comment:
   This test uses optional chaining for the tab click (`versionsTab?.click()`), 
which can silently skip selecting the tab if the query fails (e.g., label text 
change), making the test pass/fail for the wrong reason. Assert the tab button 
exists before clicking so the test reliably validates the intended behavior.



##########
frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.html:
##########
@@ -82,375 +82,415 @@ <h2>Dataset: {{datasetName}}</h2>
         [src]="coverImageUrl"
         alt="Dataset cover" />
     </div>
-
-    <div class="description-section">
-      <texera-markdown-description
-        [description]="datasetDescription"
-        [editable]="false"
-        [enableViewMore]="true">
-      </texera-markdown-description>
-    </div>
   </nz-card>
 </div>
-
 <nz-tabs>
   <nz-tab nzTitle="Data Card">
-    <nz-layout>
-      <nz-content
-        [ngClass]="{'grayed-out': false, 'disabled-click': false}"
-        style="background-color: white">
-        <nz-card>
-          <div style="display: flex; justify-content: space-between; 
align-items: center">
-            <div class="file-info">
-              <h3 class="file-title">
-                <span class="file-title-main">
-                  <b>{{ currentDisplayedFileName }}</b>
-
-                  <button
-                    nz-button
-                    nzType="text"
-                    nzSize="small"
-                    class="copy-path-btn"
-                    nz-tooltip
-                    nzTooltipTitle="Copy file path"
-                    *ngIf="currentDisplayedFileName"
-                    (click)="copyCurrentFilePath()">
-                    <i
-                      nz-icon
-                      nzType="copy"
-                      nzTheme="twotone">
-                    </i>
-                  </button>
-                </span>
+    <div class="data-card-tab-content">
+      <div class="data-card-columns">
+        <nz-card class="data-card data-card-main">
+          <h3 class="data-card-heading">Description</h3>
+          <div class="data-card-description">
+            <texera-markdown-description
+              *ngIf="datasetDescription; else noDescription"
+              [description]="datasetDescription"
+              [editable]="false"
+              [enableViewMore]="true">
+            </texera-markdown-description>
+            <ng-template #noDescription>
+              <span class="empty-description">No description provided</span>
+            </ng-template>
+          </div>
+        </nz-card>
 
-                <span
-                  *ngIf="currentFileSize"
-                  class="file-size">
-                  <i
-                    nz-icon
-                    nzType="file"
-                    nzTheme="outline"
-                    class="icon-file"></i>
-                  {{ formatSize(currentFileSize) }}
-                </span>
-              </h3>
+        <nz-card class="data-card data-card-details">
+          <div class="data-card-stats">
+            <div class="stat-row">
+              <span class="stat-label">Created</span>
+              <span class="stat-value">{{ datasetCreationTime }}</span>
+            </div>
+            <div class="stat-row">
+              <span class="stat-label">Last updated</span>
+              <span class="stat-value">{{ latestVersionCreationTime }}</span>
+            </div>
+            <div class="stat-row">
+              <span class="stat-label">Versions</span>
+              <span class="stat-value">{{ versions.length }}</span>
             </div>
-            <div style="display: flex">
-              <button
-                nz-button
-                *ngIf="selectedVersion"
-                nz-tooltip="Download the file"
-                [disabled]="!isLogin || !isDownloadAllowed()"
-                (click)="onClickDownloadCurrentFile()">
-                <i
-                  nz-icon
-                  nzTheme="outline"
-                  nzType="download">
-                </i>
-              </button>
-              <button
-                nz-button
-                *ngIf="!isMaximized && selectedVersion"
-                nz-tooltip="Maximize View"
-                (click)="onClickScaleTheView()">
-                <i
-                  nz-icon
-                  nzTheme="outline"
-                  nzType="expand">
-                </i>
-              </button>
-              <button
-                nz-button
-                *ngIf="isMaximized && selectedVersion"
-                nz-tooltip="Minimize View"
-                (click)="onClickScaleTheView()">
-                <i
-                  nz-icon
-                  nzTheme="outline"
-                  nzType="compress">
-                </i>
-              </button>
-              <button
-                *ngIf="!isRightBarCollapsed"
-                nz-button
-                nz-tooltip="Hide the right bar"
-                (click)="onClickHideRightBar()">
-                <i
-                  nz-icon
-                  nzTheme="outline"
-                  nzType="right">
-                </i>
-              </button>
-              <button
-                *ngIf="isRightBarCollapsed"
-                nz-button
-                nz-tooltip="Show Tree"
-                (click)="onClickHideRightBar()">
-                <i
-                  nz-icon
-                  nzTheme="outline"
-                  nzType="left">
-                </i>
-              </button>
+            <div class="stat-row">
+              <span class="stat-label">Latest version file</span>
+              <span class="stat-value">{{ latestVersionFileName }}</span>
+            </div>
+            <div class="stat-row">
+              <span class="stat-label">Latest version size</span>
+              <span class="stat-value">{{ formatSize(latestVersionSize) 
}}</span>
             </div>

Review Comment:
   PR description says the Data Card should show the *selected version size*, 
but the template labels and binds this row as the *latest* version size 
(`latestVersionSize`). This is either a requirements mismatch or a UI bug; the 
label/data should be aligned with the intended behavior.



##########
frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.spec.ts:
##########
@@ -90,6 +90,17 @@ describe("DatasetDetailComponent upload queue", () => {
               })
             ),
             retrieveDatasetVersionList: vi.fn(() => of([])),
+            retrieveDatasetLatestVersion: vi.fn(() =>
+              of({
+                dvid: 1,
+                did: 1,
+                creatorUid: 1,

Review Comment:
   This test module stubs `retrieveDatasetLatestVersion` with a truthy `dvid`, 
so `ngOnInit` will also call `retrieveDatasetVersionFileTree(...)` via 
`retrieveLatestVersionFile()`. The `DatasetService` stub in this block does not 
define `retrieveDatasetVersionFileTree`, which will throw at runtime when 
`fixture.detectChanges()` runs.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to