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


##########
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();

Review Comment:
   Clearing the input (or entering only whitespace) makes `sanitizedName` an 
empty string, which is then persisted as the dataset name. I recommend 
returning an error rather than calling the service: 
   ```suggestion
       const sanitizedName = this.editedDatasetName
         .trimStart()
         .replace(/[^a-zA-Z0-9]+/g, "-")
         .toLowerCase();
       if (!sanitizedName) {
         this.notificationService.error("Dataset name cannot be empty");
         return;
       }
   ```
   
   
   Also, if this block is a copy of `datasetNameSanitization()` in 
`user-dataset-version-creator.component.ts` (as described in the PR). Consider 
extracting it into a shared util so the two paths do not drift.



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