1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-23 15:29:42 +02:00

fix(edge/stacks): clear templates values on change method [EE-6390] (#10707)

This commit is contained in:
Chaim Lev-Ari 2023-11-30 07:13:01 +02:00 committed by GitHub
parent 5c59c53e91
commit 7a9436dad7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 5 deletions

View file

@ -13,6 +13,7 @@ import { StackType } from '@/react/common/stacks/types';
import { applySetStateAction } from '@/react-tools/apply-set-state-action'; import { applySetStateAction } from '@/react-tools/apply-set-state-action';
import { getVariablesFieldDefaultValues } from '@/react/portainer/custom-templates/components/CustomTemplatesVariablesField'; import { getVariablesFieldDefaultValues } from '@/react/portainer/custom-templates/components/CustomTemplatesVariablesField';
import { renderTemplate } from '@/react/portainer/custom-templates/components/utils'; import { renderTemplate } from '@/react/portainer/custom-templates/components/utils';
import { getInitialTemplateValues } from '@/react/edge/edge-stacks/CreateView/TemplateFieldset';
export default class CreateEdgeStackViewController { export default class CreateEdgeStackViewController {
/* @ngInject */ /* @ngInject */
@ -50,11 +51,7 @@ export default class CreateEdgeStackViewController {
endpointTypes: [], endpointTypes: [],
baseWebhookUrl: baseEdgeStackWebhookUrl(), baseWebhookUrl: baseEdgeStackWebhookUrl(),
isEdit: false, isEdit: false,
templateValues: { templateValues: getInitialTemplateValues(),
template: null,
variables: [],
file: '',
},
}; };
this.edgeGroups = null; this.edgeGroups = null;
@ -328,6 +325,7 @@ export default class CreateEdgeStackViewController {
this.formValues.DeploymentType = deploymentType; this.formValues.DeploymentType = deploymentType;
this.state.Method = 'editor'; this.state.Method = 'editor';
this.formValues.StackFileContent = ''; this.formValues.StackFileContent = '';
this.state.templateValues = getInitialTemplateValues();
}); });
} }

View file

@ -1,3 +1,4 @@
import { getInitialTemplateValues } from '@/react/edge/edge-stacks/CreateView/TemplateFieldset';
import { editor, git, edgeStackTemplate, upload } from '@@/BoxSelector/common-options/build-methods'; import { editor, git, edgeStackTemplate, upload } from '@@/BoxSelector/common-options/build-methods';
class DockerComposeFormController { class DockerComposeFormController {
@ -25,6 +26,7 @@ class DockerComposeFormController {
onChangeMethod(method) { onChangeMethod(method) {
this.state.Method = method; this.state.Method = method;
this.formValues.StackFileContent = ''; this.formValues.StackFileContent = '';
this.setTemplateValues(getInitialTemplateValues());
} }
onChangeFileContent(value) { onChangeFileContent(value) {

View file

@ -137,3 +137,11 @@ function TemplateSelector({
onChange(value); onChange(value);
} }
} }
export function getInitialTemplateValues() {
return {
template: null,
variables: [],
file: '',
};
}