This is an automated email from the ASF dual-hosted git repository.

aicam pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/texera.git


The following commit(s) were added to refs/heads/main by this push:
     new 9e76865b2a feat: add inline edit modes for dataset description (#4232)
9e76865b2a is described below

commit 9e76865b2a11da8cbe2ebbab7bae33fed006775f
Author: Xuan Gu <[email protected]>
AuthorDate: Mon Feb 23 10:33:33 2026 -0800

    feat: add inline edit modes for dataset description (#4232)
    
    <!--
    Thanks for sending a pull request (PR)! Here are some tips for you:
    1. If this is your first time, please read our contributor guidelines:
    [Contributing to
    Texera](https://github.com/apache/texera/blob/main/CONTRIBUTING.md)
      2. Ensure you have added or run the appropriate tests for your PR
      3. If the PR is work in progress, mark it a draft on GitHub.
      4. Please write your PR title to summarize what this PR proposes, we
        are following Conventional Commits style for PR titles as well.
      5. Be sure to keep the PR description updated to reflect all changes.
    -->
    
    ### What changes were proposed in this PR?
    <!--
    Please clarify what changes you are proposing. The purpose of this
    section
    is to outline the changes. Here are some tips for you:
      1. If you propose a new API, clarify the use case for a new API.
      2. If you fix a bug, you can clarify why it is a bug.
      3. If it is a refactoring, clarify what has been changed.
      3. It would be helpful to include a before-and-after comparison using
         screenshots or GIFs.
      4. Please consider writing useful notes for better and faster reviews.
    -->
    This PR improves the Markdown Description component container by
    supporting two modes: preview mode and edit mode. It is used on the
    dataset detail page so users can switch between preview and inline
    editing without navigating away from the page.
    
    #### Demonstration
    Inline editor
    | Edit (new) | Preview |
    |---|---|
    | <img alt="inline-edit"
    
src="https://github.com/user-attachments/assets/45b1179b-6f38-4afe-8e5a-442586cd8ef8";
    /> | <img width="100%" alt="inline-preview"
    
src="https://github.com/user-attachments/assets/49184a96-bb62-45da-9046-29e3d8a6f100";
    /> |
    
    Existing modal editor (for comparison)
    | Edit | Preview (new) |
    |---|---|
    | <img alt="edit"
    
src="https://github.com/user-attachments/assets/8d86e101-08d5-4896-84a4-3dfe510b79d5";
    /> | <img width="100%" alt="cancel"
    
src="https://github.com/user-attachments/assets/6d406b15-a5e9-4478-8bfc-4e380c77b760";
    /> |
    
    ### Any related issues, documentation, discussions?
    <!--
    Please use this section to link other resources if not mentioned
    already.
    1. If this PR fixes an issue, please include `Fixes #1234`, `Resolves
    #1234`
    or `Closes #1234`. If it is only related, simply mention the issue
    number.
      2. If there is design documentation, please add the link.
      3. If there is a discussion in the mailing list, please add the link.
    -->
    Related to #4209
    
    ### How was this PR tested?
    <!--
    If tests were added, say they were added here. Or simply mention that if
    the PR
    is tested with existing test cases. Make sure to include/update test
    cases that
    check the changes thoroughly including negative and positive cases if
    possible.
    If it was tested in a way different from regular unit tests, please
    clarify how
    you tested step by step, ideally copy and paste-able, so that other
    reviewers can
    test and check, and descendants can verify in the future. If tests were
    not added,
    please describe why they were not added and/or why it was difficult to
    add.
    -->
    Manually tested
    
    ### Was this PR authored or co-authored using generative AI tooling?
    <!--
    If generative AI tooling has been used in the process of authoring this
    PR,
    please include the phrase: 'Generated-by: ' followed by the name of the
    tool
    and its version. If no, write 'No'.
    Please refer to the [ASF Generative Tooling
    Guidance](https://www.apache.org/legal/generative-tooling.html) for
    details.
    -->
    Generated-by: Claude Opus 4.6
---
 .../markdown-description.component.html            | 24 +++++++++++++--
 .../markdown-description.component.scss            |  3 +-
 .../markdown-description.component.ts              | 34 +++++++++++++++++++---
 .../dataset-detail.component.html                  |  6 +++-
 .../dataset-detail.component.ts                    | 21 +++++++++++++
 5 files changed, 80 insertions(+), 8 deletions(-)

diff --git 
a/frontend/src/app/dashboard/component/user/markdown-description/markdown-description.component.html
 
b/frontend/src/app/dashboard/component/user/markdown-description/markdown-description.component.html
index b1bfc94d46..d76163d59b 100644
--- 
a/frontend/src/app/dashboard/component/user/markdown-description/markdown-description.component.html
+++ 
b/frontend/src/app/dashboard/component/user/markdown-description/markdown-description.component.html
@@ -18,7 +18,21 @@
 -->
 
 <!-- Preview mode -->
-<ng-container *ngIf="!isEditing">
+<ng-container *ngIf="currentMode === 'preview'">
+  <div
+    *ngIf="editable"
+    class="md-actions">
+    <button
+      nz-button
+      nzType="text"
+      nzSize="small"
+      (click)="enterEditMode()">
+      <i
+        nz-icon
+        nzType="edit"></i>
+      Edit
+    </button>
+  </div>
   <div class="preview-box">
     <div
       *ngIf="renderedDescription; else noDescription"
@@ -31,7 +45,7 @@
 </ng-container>
 
 <!-- Edit mode -->
-<ng-container *ngIf="isEditing">
+<ng-container *ngIf="currentMode === 'edit'">
   <div class="md-split">
     <div class="md-left">
       <div class="md-toolbar">
@@ -66,6 +80,12 @@
   </div>
 
   <div class="md-actions">
+    <button
+      nz-button
+      nzSize="small"
+      (click)="cancel()">
+      Cancel
+    </button>
     <button
       nz-button
       nzType="primary"
diff --git 
a/frontend/src/app/dashboard/component/user/markdown-description/markdown-description.component.scss
 
b/frontend/src/app/dashboard/component/user/markdown-description/markdown-description.component.scss
index 27aad8bc9c..e9fe780a11 100644
--- 
a/frontend/src/app/dashboard/component/user/markdown-description/markdown-description.component.scss
+++ 
b/frontend/src/app/dashboard/component/user/markdown-description/markdown-description.component.scss
@@ -19,7 +19,7 @@
 
 .preview-box {
   position: relative;
-  margin-top: 10px;
+  margin-top: 8px;
   max-height: 50vh;
   overflow-y: auto;
 }
@@ -27,6 +27,7 @@
 .md-actions {
   display: flex;
   justify-content: flex-end;
+  gap: 10px;
 }
 
 .md-split {
diff --git 
a/frontend/src/app/dashboard/component/user/markdown-description/markdown-description.component.ts
 
b/frontend/src/app/dashboard/component/user/markdown-description/markdown-description.component.ts
index de4c0a9c84..ec9683bfb1 100644
--- 
a/frontend/src/app/dashboard/component/user/markdown-description/markdown-description.component.ts
+++ 
b/frontend/src/app/dashboard/component/user/markdown-description/markdown-description.component.ts
@@ -41,10 +41,12 @@ export class MarkdownDescriptionComponent implements 
OnInit, OnChanges {
   private modalData = inject(NZ_MODAL_DATA, { optional: true });
 
   @Input() description = "";
+  @Input() mode: "preview" | "edit" = "preview";
+  @Input() editable = false;
   @Output() descriptionChange = new EventEmitter<string>();
   @ViewChild("textarea") textareaRef!: ElementRef<HTMLTextAreaElement>;
 
-  isEditing = false;
+  currentMode: "preview" | "edit" = "preview";
   editingContent = "";
   renderedDescription = "";
 
@@ -74,15 +76,24 @@ export class MarkdownDescriptionComponent implements 
OnInit, OnChanges {
   ngOnInit(): void {
     if (this.modalData) {
       this.description = this.modalData.description ?? "";
-      this.isEditing = true;
+      this.editable = true;
     }
+    this.currentMode = this.modalData ? "edit" : this.mode;
     this.editingContent = this.description;
     this.renderMarkdown(this.description);
   }
 
   ngOnChanges(changes: SimpleChanges): void {
+    if (changes["mode"] && !changes["mode"].firstChange && !this.modalData) {
+      this.currentMode = this.mode;
+      if (this.currentMode === "edit") {
+        this.editingContent = this.description;
+        this.renderMarkdown(this.description);
+      }
+    }
+
     if (changes["description"] && !changes["description"].firstChange) {
-      if (this.isEditing) {
+      if (this.currentMode === "edit") {
         return;
       }
       this.editingContent = this.description;
@@ -90,11 +101,26 @@ export class MarkdownDescriptionComponent implements 
OnInit, OnChanges {
     }
   }
 
+  enterEditMode(): void {
+    if (!this.editable) {
+      return;
+    }
+    this.editingContent = this.description;
+    this.renderMarkdown(this.description);
+    this.currentMode = "edit";
+  }
+
   save(): void {
     this.description = this.editingContent;
     this.descriptionChange.emit(this.description);
     this.renderMarkdown(this.description);
-    this.isEditing = false;
+    this.currentMode = this.modalData ? "edit" : this.mode;
+  }
+
+  cancel(): void {
+    this.editingContent = this.description;
+    this.renderMarkdown(this.description);
+    this.currentMode = "preview";
   }
 
   insert(action: { prefix: string; suffix: string; default: string }): void {
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 16397793c6..c5780be7a7 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
@@ -32,7 +32,11 @@
         </span>
       </ng-template>
     </nz-card-meta>
-    <texera-markdown-description [description]="datasetDescription"> 
</texera-markdown-description>
+    <texera-markdown-description
+      [description]="datasetDescription"
+      [editable]="userDatasetAccessLevel === 'WRITE'"
+      (descriptionChange)="onDatasetDescriptionChange($event)">
+    </texera-markdown-description>
     <div
       class="workflow-panel"
       style="padding-top: 30px">
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 f7eb492a9c..5a7f005759 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
@@ -733,4 +733,25 @@ export class DatasetDetailComponent implements OnInit {
         },
       });
   }
+
+  onDatasetDescriptionChange(description: string): void {
+    const updatedDescription = description ?? "";
+    const previousDescription = this.datasetDescription;
+
+    if (!this.did || this.datasetDescription === updatedDescription) {
+      return;
+    }
+
+    this.datasetDescription = updatedDescription;
+
+    this.datasetService
+      .updateDatasetDescription(this.did, updatedDescription)
+      .pipe(untilDestroyed(this))
+      .subscribe({
+        error: () => {
+          this.datasetDescription = previousDescription;
+          this.notificationService.error("Failed to update dataset 
description");
+        },
+      });
+  }
 }

Reply via email to