aglinxinyuan commented on code in PR #9267:
URL: https://github.com/apache/texera/pull/9267#discussion_r4464326489


##########
frontend/src/app/workspace/component/hugging-face-image-upload/hugging-face-image-upload.component.ts:
##########
@@ -71,14 +70,7 @@ export class HuggingFaceImageUploadComponent extends 
FieldType<FieldTypeConfig>
 
     try {
       const dataUrl = await this.compressImage(file);
-      this.fileName = file.name;
-      this.formControl.setValue(dataUrl);
-      if (typeof this.key === "string" && this.model) {
-        this.model[this.key] = dataUrl;
-      }
-      this.formControl.markAsDirty();
-      this.formControl.markAsTouched();
-      this.formControl.updateValueAndValidity();
+      this.setMediaValue(dataUrl, file.name);
     } catch {
       this.errorMessage = "Could not prepare this image. Try a smaller image 
file.";
       input.value = "";

Review Comment:
   Done in ccfa6a5436: both image rejection paths now call resetSelection, 
matching audio (a rejected file also clears a previously selected image; added 
a test for that).



##########
frontend/src/app/workspace/component/hugging-face-media-upload.base.ts:
##########
@@ -0,0 +1,65 @@
+/**
+ * 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 { Directive } from "@angular/core";
+import { FieldType, FieldTypeConfig } from "@ngx-formly/core";
+
+@Directive()
+export abstract class HuggingFaceMediaUploadBase extends 
FieldType<FieldTypeConfig> {
+  fileName = "";
+  errorMessage = "";
+
+  abstract get hasMedia(): boolean;
+  abstract get mediaFallbackLabel(): string;
+  abstract get previewSrc(): string;

Review Comment:
   Done in ccfa6a5436: the base now owns hasMedia and previewSrc, driven by 
abstract readonly dataUrlPrefix and mediaFallbackLabel fields; 
hasImage/hasAudio are removed.



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