Scaffolder: Enable buttons if template fails to execute

Signed-off-by: OscarDHdz <v-ohernandez@expediagroup.com>
This commit is contained in:
OscarDHdz
2021-10-22 08:23:43 -05:00
parent 86086e36c9
commit 5df2435892
3 changed files with 13 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder': patch
---
Scaffolder: Enable back Template action buttons if template fails to execute
@@ -44,7 +44,7 @@ type Props = {
formData: Record<string, any>;
onChange: (e: IChangeEvent) => void;
onReset: () => void;
onFinish: () => void;
onFinish: () => Promise<boolean>;
widgets?: FormProps<any>['widgets'];
fields?: FormProps<any>['fields'];
};
@@ -122,9 +122,12 @@ export const MultistepJsonForm = ({
setActiveStep(Math.min(activeStep + 1, steps.length));
};
const handleBack = () => setActiveStep(Math.max(activeStep - 1, 0));
const handleCreate = () => {
const handleCreate = async () => {
setDisableButtons(true);
onFinish();
const success = await onFinish();
if (!success) {
setDisableButtons(false);
}
};
return (
@@ -132,8 +132,10 @@ export const TemplatePage = ({
const id = await scaffolderApi.scaffold(templateName, formState);
navigate(generatePath(`${rootLink()}/tasks/:taskId`, { taskId: id }));
return true;
} catch (e) {
errorApi.post(e);
return false;
}
};