kunwp1 commented on code in PR #9522:
URL: https://github.com/apache/texera/pull/9522#discussion_r4648914038


##########
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: `
+    <nz-card class="settings-general-card">
+      <h3 class="settings-card-title">General</h3>
+
+      <div class="settings-name-row">
+        <div class="settings-name-label">
+          <label>{{ resourceType | titlecase }} name</label>
+          <p class="settings-hint">{{ nameHints[resourceType] }}</p>
+          <p
+            *ngIf="uploadsInFlight"
+            class="settings-hint">
+            An upload is in progress — finish or cancel it in Versions &amp; 
Files first, or it will be left incomplete.
+          </p>
+        </div>
+        <div class="settings-name-controls">
+          <input
+            nz-input
+            [disabled]="uploadsInFlight"
+            [ngModel]="editedName"
+            (ngModelChange)="editedNameChange.emit($event)" />
+          <button
+            nz-button
+            nzType="primary"
+            [disabled]="uploadsInFlight"
+            (click)="saveName.emit()">
+            Save
+          </button>
+        </div>
+      </div>
+
+      <nz-divider></nz-divider>
+
+      <div class="settings-field">
+        <label class="settings-field-label">Description</label>
+        <div class="settings-field-hint">Shown on cards.</div>
+        <texera-markdown-description
+          [description]="description"
+          [editable]="canEdit"
+          [enableViewMore]="true"
+          (descriptionChange)="descriptionChange.emit($event)">
+        </texera-markdown-description>
+      </div>
+    </nz-card>
+
+    <ng-content select="[resourceSettingsBetweenCards]"></ng-content>
+
+    <nz-card class="settings-general-card">
+      <h3 class="settings-card-title">Access &amp; visibility</h3>
+
+      <div class="settings-name-row">
+        <div class="settings-name-label">
+          <label>Visibility</label>
+          <p class="settings-hint">
+            {{
+              isPublic
+                ? "Public — anyone can view this " + resourceType + "."
+                : "Private — only you and invited collaborators can see this " 
+ resourceType + "."
+            }}
+          </p>
+        </div>
+        <div class="settings-name-controls">
+          <nz-switch
+            [ngModel]="isPublic"
+            (ngModelChange)="publicChange.emit($event)"
+            [nzDisabled]="!canEdit"
+            nzCheckedChildren="public"
+            nzUnCheckedChildren="private"></nz-switch>
+        </div>
+      </div>
+
+      <nz-divider></nz-divider>
+
+      <div class="settings-name-row">
+        <div class="settings-name-label">
+          <label>Downloadable</label>
+          <p class="settings-hint">
+            {{
+              isDownloadable
+                ? "Viewers can download this " + resourceType + "."
+                : "Viewers can browse files but cannot download them."
+            }}
+          </p>
+        </div>
+        <div class="settings-name-controls">
+          <nz-switch
+            [ngModel]="isDownloadable"
+            (ngModelChange)="downloadableChange.emit($event)"
+            [nzDisabled]="!isOwner"
+            nzCheckedChildren="allowed"
+            nzUnCheckedChildren="blocked"></nz-switch>
+        </div>
+      </div>
+    </nz-card>
+
+    <ng-content></ng-content>
+  `,
+  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;
+      }

Review Comment:
   Only the model's Framework and Format selects use `.settings-select`. Since 
they sit in the model's own template, `.settings-general-card .settings-select 
{ min-width: 200px; }` can stay in `model-detail.component.scss`, where it was.



##########
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) {

Review Comment:
   `version-storage`, `browser-pane`, `browser-toolbar`, `version-list` and 
`file-path-title` style markup that only `versions-files-browser` renders. 
Under emulated encapsulation, the copies the two detail pages include match 
nothing, except `.status-tag-row` and the `nz-select { flex-grow: 1 }` that the 
model's Framework and Format selects rely on. The two flags only exist to trim 
those includes.
   
   Putting the five back in `versions-files-browser.component.scss`, moving 
`.status-tag-row` into `status-tags`, and giving the model stylesheet its 
`nz-select` rule drops both flags and about 120 lines from the partial. 



##########
frontend/src/app/dashboard/component/user/user-model/user-model-explorer/model-detail.component.ts:
##########
@@ -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<K extends "modelDescription" | "modelFramework" | 
"modelFormat">(
+    field: K,
+    value: ModelDetailComponent[K] & string,
+    save: (mid: number, value: string) => Observable<unknown>,
+    { error, success }: { error?: string; success?: string }
+  ): void {
+    const model: ModelDetailComponent = this;

Review Comment:
   This saves a few lines across three handlers in one file, but it needs the 
field-name generic, the `const model: ModelDetailComponent = this` alias and an 
option bag that switches between two behaviours. Meanwhile 
`onDatasetDescriptionChange` keeps the same optimistic-save-and-revert flow by 
hand. I'd either share one helper with the dataset page, or keep the three 
handlers as they were.



##########
frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.scss:
##########
@@ -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 {

Review Comment:
   Not new, but more visible now: this top-level `::ng-deep` is global. It 
rounds the buttons in every `.settings-general-card` once a dataset page has 
loaded, including the model's General card, which this PR makes the same 
component. If the rounding is wanted, it belongs in 
`ResourceDetailSettingsComponent` as `:host ::ng-deep .settings-general-card 
button`. Otherwise it can go. Either is a small visual change for the model, so 
it might fit better in a follow-up.



##########
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: `
+    <nz-card class="settings-general-card">
+      <h3 class="settings-card-title">General</h3>
+
+      <div class="settings-name-row">
+        <div class="settings-name-label">
+          <label>{{ resourceType | titlecase }} name</label>
+          <p class="settings-hint">{{ nameHints[resourceType] }}</p>
+          <p
+            *ngIf="uploadsInFlight"
+            class="settings-hint">
+            An upload is in progress — finish or cancel it in Versions &amp; 
Files first, or it will be left incomplete.
+          </p>
+        </div>
+        <div class="settings-name-controls">
+          <input
+            nz-input
+            [disabled]="uploadsInFlight"
+            [ngModel]="editedName"
+            (ngModelChange)="editedNameChange.emit($event)" />
+          <button
+            nz-button
+            nzType="primary"
+            [disabled]="uploadsInFlight"
+            (click)="saveName.emit()">
+            Save
+          </button>
+        </div>
+      </div>
+
+      <nz-divider></nz-divider>
+
+      <div class="settings-field">
+        <label class="settings-field-label">Description</label>
+        <div class="settings-field-hint">Shown on cards.</div>
+        <texera-markdown-description
+          [description]="description"
+          [editable]="canEdit"
+          [enableViewMore]="true"
+          (descriptionChange)="descriptionChange.emit($event)">
+        </texera-markdown-description>
+      </div>
+    </nz-card>
+
+    <ng-content select="[resourceSettingsBetweenCards]"></ng-content>
+
+    <nz-card class="settings-general-card">
+      <h3 class="settings-card-title">Access &amp; visibility</h3>
+
+      <div class="settings-name-row">
+        <div class="settings-name-label">
+          <label>Visibility</label>
+          <p class="settings-hint">
+            {{
+              isPublic
+                ? "Public — anyone can view this " + resourceType + "."
+                : "Private — only you and invited collaborators can see this " 
+ resourceType + "."
+            }}
+          </p>
+        </div>
+        <div class="settings-name-controls">
+          <nz-switch
+            [ngModel]="isPublic"
+            (ngModelChange)="publicChange.emit($event)"
+            [nzDisabled]="!canEdit"
+            nzCheckedChildren="public"
+            nzUnCheckedChildren="private"></nz-switch>
+        </div>
+      </div>
+
+      <nz-divider></nz-divider>
+
+      <div class="settings-name-row">
+        <div class="settings-name-label">
+          <label>Downloadable</label>
+          <p class="settings-hint">
+            {{
+              isDownloadable
+                ? "Viewers can download this " + resourceType + "."
+                : "Viewers can browse files but cannot download them."
+            }}
+          </p>
+        </div>
+        <div class="settings-name-controls">
+          <nz-switch
+            [ngModel]="isDownloadable"
+            (ngModelChange)="downloadableChange.emit($event)"
+            [nzDisabled]="!isOwner"
+            nzCheckedChildren="allowed"
+            nzUnCheckedChildren="blocked"></nz-switch>
+        </div>
+      </div>
+    </nz-card>
+
+    <ng-content></ng-content>
+  `,
+  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;

Review Comment:
   Both pages render this tab only under `userHasWriteAccess()`. The dataset 
passes that same WRITE check, and the model leaves this at `true`, so `canEdit` 
is always true here. Dropping the input, using `[editable]="true"` and removing 
`[nzDisabled]="!canEdit"` keeps the behaviour. It also avoids a shared input 
that defaults to editable for the next caller that forgets it.



-- 
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