Skip to content

Commit

Permalink
fix(ui): Fix Destination Cluster URL/Name Drop down not updating dest…
Browse files Browse the repository at this point in the history
…ination field (argoproj#13813) (argoproj#14216)

* fix(ui): Fix Destination Cluster URL/Name Drop down not updating destination field (fixes argoproj#13813)

Signed-off-by: Kyle Purkiss <kyle.purkiss@procore.com>

* Address linting errors

Signed-off-by: Kyle Purkiss <kyle.purkiss@procore.com>

---------

Signed-off-by: Kyle Purkiss <kyle.purkiss@procore.com>
  • Loading branch information
Conrimaceogain authored and tesla59 committed Dec 16, 2023
1 parent fe39468 commit 4c18853
Showing 1 changed file with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,24 @@ export const ApplicationCreatePanel = (props: {
const [explicitPathType, setExplicitPathType] = React.useState<{path: string; type: models.AppSourceType}>(null);
const [destFormat, setDestFormat] = React.useState('URL');
const [retry, setRetry] = React.useState(false);
const app = deepMerge(DEFAULT_APP, props.app || {});

React.useEffect(() => {
if (app?.spec?.destination?.name && app.spec.destination.name !== '') {
setDestFormat('NAME');
} else {
setDestFormat('URL');
}
}, []);

function normalizeTypeFields(formApi: FormApi, type: models.AppSourceType) {
const app = formApi.getFormState().values;
const appToNormalize = formApi.getFormState().values;
for (const item of appTypes) {
if (item.type !== type) {
delete app.spec.source[item.field];
delete appToNormalize.spec.source[item.field];
}
}
formApi.setAllValues(app);
formApi.setAllValues(appToNormalize);
}

return (
Expand All @@ -132,16 +141,10 @@ export const ApplicationCreatePanel = (props: {
}>
{({projects, clusters, reposInfo}) => {
const repos = reposInfo.map(info => info.repo).sort();
const app = deepMerge(DEFAULT_APP, props.app || {});
const repoInfo = reposInfo.find(info => info.repo === app.spec.source.repoURL);
if (repoInfo) {
normalizeAppSource(app, repoInfo.type || 'git');
}
if (app?.spec?.destination?.name && app.spec.destination.name !== '') {
setDestFormat('NAME');
} else {
setDestFormat('URL');
}
return (
<div className='application-create-panel'>
{(yamlMode && (
Expand Down

0 comments on commit 4c18853

Please sign in to comment.