Browse Source

Merge pull request #2199 from porter-dev/nico/stacks-fix-source-config-not-updating

Fix SourceEditorDocker not updating on revision change.
abelanger5 3 years ago
parent
commit
6d0ba4cd1d

+ 12 - 10
dashboard/src/main/home/cluster-dashboard/stacks/ExpandedStack/_SourceConfig.tsx

@@ -99,16 +99,18 @@ const _SourceConfig = ({
           </SourceConfigStyles.ItemContainer>
         );
       })}
-      <SourceConfigStyles.SaveButtonRow>
-        <SourceConfigStyles.SaveButton
-          onClick={handleSave}
-          text="Save"
-          clearPosition={true}
-          makeFlush={true}
-          status={buttonStatus}
-          statusPosition="left"
-        />
-      </SourceConfigStyles.SaveButtonRow>
+      {readOnly ? null : (
+        <SourceConfigStyles.SaveButtonRow>
+          <SourceConfigStyles.SaveButton
+            onClick={handleSave}
+            text="Save"
+            clearPosition={true}
+            makeFlush={true}
+            status={buttonStatus}
+            statusPosition="left"
+          />
+        </SourceConfigStyles.SaveButtonRow>
+      )}
     </SourceConfigStyles.Wrapper>
   );
 };

+ 8 - 1
dashboard/src/main/home/cluster-dashboard/stacks/ExpandedStack/components/SourceEditorDocker.tsx

@@ -37,6 +37,13 @@ const SourceEditorDocker = ({
     return image.replace(registry.url + "/", "");
   }, [image, registry]);
 
+  useEffect(() => {
+    if (sourceConfig.image_repo_uri) {
+      setImage(sourceConfig.image_repo_uri);
+      setTag(sourceConfig.image_tag);
+    }
+  }, [sourceConfig]);
+
   useEffect(() => {
     const newSourceConfig: SourceConfig = {
       ...sourceConfig,
@@ -126,7 +133,7 @@ const _DockerRepositorySelector = ({
         }
         setIsLoading(false);
       });
-  }, []);
+  }, [currentImageUrl]);
 
   const handleChange = (newRegistry: DockerRegistry) => {
     onChange(newRegistry);