fix(edge/template): validate app template env vars [EE-6743] (#11235)

pull/11253/head
Oscar Zhou 2024-02-26 09:00:12 +13:00 committed by GitHub
parent c622f6da4e
commit 3caf1ddb7d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 19 additions and 1 deletions

View File

@ -226,6 +226,10 @@ export default class CreateEdgeStackViewController {
return this.$async(async () => {
const name = this.formValues.Name;
if (!this.validateTemplate()) {
return;
}
let envVars = this.formValues.envVars;
if (this.state.Method === 'template' && this.state.templateValues.type === 'app') {
envVars = [...envVars, ...Object.entries(this.state.templateValues.envVars).map(([key, value]) => ({ name: key, value }))];
@ -363,12 +367,26 @@ export default class CreateEdgeStackViewController {
});
}
validateTemplate() {
if (this.state.Method === 'template' && this.state.templateValues.type === 'app') {
return Object.entries(this.state.templateValues.envVars).every(([, value]) => !!value);
}
if (this.state.Method === 'template' && this.state.templateValues.type === 'custom') {
return Object.entries(this.state.templateValues.variables).every(([, v]) => {
return !!v.value;
});
}
return true;
}
formIsInvalid() {
return (
this.form.$invalid ||
!this.formValues.Groups.length ||
(['template', 'editor'].includes(this.state.Method) && !this.formValues.StackFileContent) ||
('upload' === this.state.Method && !this.formValues.StackFile)
('upload' === this.state.Method && !this.formValues.StackFile) ||
!this.validateTemplate()
);
}
}