Explorar el Código

Fixed source config not applying display name correctly

jnfrati hace 3 años
padre
commit
9785c3d6a9

+ 9 - 4
dashboard/src/main/home/cluster-dashboard/stacks/ExpandedStack/_SourceConfig.tsx

@@ -30,7 +30,12 @@ const _SourceConfig = ({
     const index = newSourceConfigArray.findIndex(
       (sc) => sc.id === sourceConfig.id
     );
-    newSourceConfigArray[index] = sourceConfig;
+
+    newSourceConfigArray[index] = {
+      ...sourceConfig,
+      display_name: sourceConfig.display_name || sourceConfig.name,
+    };
+
     setSourceConfigArrayCopy(newSourceConfigArray);
   };
 
@@ -136,19 +141,19 @@ const SourceConfigItem = ({
   disabled: boolean;
 }) => {
   const [editNameMode, toggleEditNameMode] = useReducer((prev) => !prev, false);
-  const prevName = useRef(sourceConfig.name);
+  const prevName = useRef(sourceConfig.display_name || sourceConfig.name);
   const [name, setName] = useState(
     sourceConfig.display_name || sourceConfig.name
   );
 
   const handleNameChange = (newName: string) => {
     setName(newName);
-    handleChange({ ...sourceConfig, name: newName });
+    handleChange({ ...sourceConfig, display_name: newName });
   };
 
   const handleNameChangeCancel = () => {
     setName(prevName.current);
-    handleChange({ ...sourceConfig, name: prevName.current });
+    handleChange({ ...sourceConfig, display_name: prevName.current });
     toggleEditNameMode();
   };
 

+ 1 - 1
dashboard/src/main/home/cluster-dashboard/stacks/launch/Store.tsx

@@ -96,11 +96,11 @@ const StacksLaunchContextProvider: React.FC<{}> = ({ children }) => {
       source_configs: [
         ...prev.source_configs,
         {
+          ...sourceConfig,
           display_name:
             sourceConfig.display_name ||
             newSourceConfigName(prev.source_configs.length),
           name: newSourceConfigName(prev.source_configs.length),
-          ...sourceConfig,
         },
       ],
     }));