Prevent old presets format from throwing errors

This commit is contained in:
Shweelan Samson authored and Zaid Abdulla committed 2019-07-17 19:07:43 -07:00
1 parent b92f547b26
commit 461950749f
2 files changed
+15 -6

No files matched your search

+7 -6
View File
@@ -560,16 +560,17 @@ export function flattenPreset(preset): {} {
const provision = p.configurations[0]; const provision = p.configurations[0];
if ( if (
p.configurations.length !== 1 || p.configurations.length === 1 &&
provision.type !== "provision" || provision.type === "provision" &&
!provision.name || provision.name &&
!provision.name.length provision.name.length
) ) {
throw new Error("Invalid preset provision");
p.provision = provision.name; p.provision = provision.name;
p.provisionArgs = provision.args p.provisionArgs = provision.args
? JSON.stringify(provision.args).slice(1, -1) ? JSON.stringify(provision.args).slice(1, -1)
: ""; : "";
}
delete p.configurations; delete p.configurations;
return p; return p;
} }
+8
View File
@@ -286,6 +286,14 @@ export const component: ClosureComponent = (): Component => {
{ {
onclick: () => { onclick: () => {
const cb = (): Children => { const cb = (): Children => {
if (!preset.provision) {
return m(
"div",
{ style: "margin:20px" },
"This UI only supports presets with a single 'provision' configuraiton. If this preset was originally created from the old UI (genieacs-gui), you must edit it there."
);
}
return m( return m(
putFormComponent, putFormComponent,
Object.assign( Object.assign(