Skip to content

Commit

Permalink
Merge pull request #64 from xuzhu-591/fix-history-default-config
Browse files Browse the repository at this point in the history
fix: get default app config from history state
  • Loading branch information
xuzhu-591 authored Jan 25, 2024
2 parents 62cc747 + 2a44955 commit 9e0f1bf
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/pages/instances/NewOrEdit/v2/GitImport/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default (props: any) => {
const [baseInfoValid, setBaseInfoValid] = useState<boolean>(false);
const [buildConfigValid, setBuildConfigValid] = useState<boolean>(true);
const [deployConfigValid, setDeployConfigValid] = useState<boolean>(false);
const [useHistoryConfig, setUseHistoryConfig] = useState<boolean>(false);

const pageOrders = useMemo(() => (editing ? [0, 1, 3, 4] : [0, 1, 2, 3, 4]), [editing]);

Expand All @@ -85,6 +86,7 @@ export default (props: any) => {
useEffect(() => {
const data = window.history.state?.defaultAppData;
if (data) {
setUseHistoryConfig(true);
fillDefaultConfig(data);
}
}, []);
Expand Down Expand Up @@ -160,7 +162,7 @@ export default (props: any) => {
setTemplateConfig(data!.application);
}
},
ready: creating,
ready: creating && !useHistoryConfig,
manual: true,
});

Expand All @@ -182,16 +184,9 @@ export default (props: any) => {
{ name: ResourceKey.GIT_REF_VALUE, value: gitRef },
]);

// basicTemplateInfo
const basicTemplateInfo = {
name: data!.templateInfo!.name,
release: data!.templateInfo!.release,
};
setBuildConfig(data!.buildConfig);
// todo(zx): remove
setTemplateBasic(basicTemplateInfo);
setReleaseName(data!.templateInfo!.release);
setTemplateConfig(data!.templateConfig);
if (!useHistoryConfig) {
fillDefaultConfig(data);
}
refreshAppEnvTemplate(envFromQuery);
} else {
// query source cluster if copying
Expand Down

0 comments on commit 9e0f1bf

Please sign in to comment.