rbelavadi commented on code in PR #6493:
URL: https://github.com/apache/texera/pull/6493#discussion_r3616662877


##########
frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.ts:
##########
@@ -908,6 +915,50 @@ export class DatasetDetailComponent implements OnInit {
       });
   }
 
+  onSaveDatasetName(): void {
+    if (!this.did) {
+      return;
+    }
+    // Sanitize using the same rules as dataset creation: trim leading 
whitespace,
+    // collapse runs of non-alphanumeric characters to a single "-", then 
lowercase.
+    const sanitizedName = this.editedDatasetName
+      .trimStart()
+      .replace(/[^a-zA-Z0-9]+/g, "-")
+      .toLowerCase();
+
+    this.datasetService
+      .updateDatasetName(this.did, sanitizedName)
+      .pipe(untilDestroyed(this))
+      .subscribe({
+        next: () => {
+          this.datasetName = sanitizedName;
+          this.editedDatasetName = sanitizedName;
+          this.notificationService.success(`Dataset name updated to 
'${sanitizedName}'`);
+        },
+        error: (err: unknown) => {
+          this.notificationService.error("Failed to update dataset name");

Review Comment:
   Updated. Now uses extractErrorMessage(err) matching the pattern in 
user-dataset-list-item.component.ts. Also updated the corresponding spec 
assertion.



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