Scaffolder: Enable buttons if template fails to execute
Signed-off-by: OscarDHdz <v-ohernandez@expediagroup.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user