mirror of
https://github.com/portainer/portainer.git
synced 2025-07-22 14:59:41 +02:00
fix(stack/template): web editor error shows for changing between same mustache templates [EE-6563] (#10976)
This commit is contained in:
parent
1676fefd97
commit
fa63432695
4 changed files with 8 additions and 3 deletions
|
@ -85,7 +85,11 @@ export default class CreateEdgeStackViewController {
|
||||||
await this.onChangeTemplate(newTemplateValues.template);
|
await this.onChangeTemplate(newTemplateValues.template);
|
||||||
}
|
}
|
||||||
|
|
||||||
const newFile = renderTemplate(this.state.templateValues.file, this.state.templateValues.variables, this.state.templateValues.template.Variables);
|
let definitions = [];
|
||||||
|
if (this.state.templateValues.template) {
|
||||||
|
definitions = this.state.templateValues.template.Variables;
|
||||||
|
}
|
||||||
|
const newFile = renderTemplate(this.state.templateValues.file, this.state.templateValues.variables, definitions);
|
||||||
|
|
||||||
this.formValues.StackFileContent = newFile;
|
this.formValues.StackFileContent = newFile;
|
||||||
});
|
});
|
||||||
|
|
|
@ -33,7 +33,7 @@ function validateYAML(yaml, containerNames, originalContainersNames = []) {
|
||||||
let yamlObject;
|
let yamlObject;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
yamlObject = YAML.parse(yaml);
|
yamlObject = YAML.parse(yaml, { mapAsMap: true });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return 'There is an error in the yaml syntax: ' + err;
|
return 'There is an error in the yaml syntax: ' + err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ class VariablesFieldController implements IComponentController {
|
||||||
}
|
}
|
||||||
|
|
||||||
$onChanges({ value }: IOnChangesObject) {
|
$onChanges({ value }: IOnChangesObject) {
|
||||||
if (value.currentValue) {
|
if (value?.currentValue) {
|
||||||
this.checkValidity(value.currentValue);
|
this.checkValidity(value.currentValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -328,6 +328,7 @@ angular
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const rendered = renderTemplate($scope.state.templateContent, $scope.formValues.Variables, $scope.state.selectedTemplate.Variables);
|
const rendered = renderTemplate($scope.state.templateContent, $scope.formValues.Variables, $scope.state.selectedTemplate.Variables);
|
||||||
|
$scope.state.editorYamlValidationError = StackHelper.validateYAML(rendered, $scope.containerNames);
|
||||||
onChangeFormValues({ StackFileContent: rendered });
|
onChangeFormValues({ StackFileContent: rendered });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue