Skip to content

Commit 47c7aea

Browse files
committed
fix wizard actions
1 parent c0ad882 commit 47c7aea

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

shesha-reactjs/src/designer-components/wizard/hooks.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ import { useDeepCompareMemo } from '@/hooks';
99
import { useFormExpression } from '@/hooks';
1010
import { useFormDesignerComponents } from '@/providers/form/hooks';
1111
import { useValidator } from '@/providers/validateProvider';
12+
import { useClosestModal } from '@/providers/dynamicModal';
1213

1314
interface IWizardComponent {
1415
back: () => void;
16+
close: () => void;
1517
components: IConfigurableFormComponent[];
1618
current: number;
1719
currentStep: IWizardStepProps;
@@ -28,6 +30,7 @@ export const useWizard = (model: Omit<IWizardComponentProps, 'size'>): IWizardCo
2830
const allData = useAvailableConstantsData();
2931
const toolbox = useFormDesignerComponents();
3032
const validator = useValidator(false);
33+
const closestModal = useClosestModal();
3134

3235
const formMode = useForm(false).formMode;
3336

@@ -197,10 +200,15 @@ export const useWizard = (model: Omit<IWizardComponentProps, 'size'>): IWizardCo
197200
);
198201
};
199202

203+
const close = (): void => {
204+
closestModal?.close();
205+
};
206+
200207
const cancel = (): void =>
201208
executeActionIfConfigured(
202209
(tab) => tab.beforeCancelActionConfiguration,
203210
(tab) => tab.afterCancelActionConfiguration,
211+
() => close(),
204212
);
205213

206214
const done = (): void => {
@@ -265,6 +273,20 @@ export const useWizard = (model: Omit<IWizardComponentProps, 'size'>): IWizardCo
265273
actionDependencies,
266274
);
267275

276+
useConfigurableAction(
277+
{
278+
name: 'Close',
279+
owner: actionOwnerName,
280+
ownerUid: actionsOwnerId,
281+
hasArguments: false,
282+
executer: () => {
283+
close();
284+
return Promise.resolve();
285+
},
286+
},
287+
actionDependencies,
288+
);
289+
268290
useConfigurableAction(
269291
{
270292
name: 'Done',
@@ -313,5 +335,5 @@ export const useWizard = (model: Omit<IWizardComponentProps, 'size'>): IWizardCo
313335

314336
const content = getStepDescritpion(showStepStatus, sequence, current);
315337

316-
return { components, current, currentStep, visibleSteps, back, cancel, done, content, next, setStep };
338+
return { components, current, currentStep, visibleSteps, back, cancel, close, done, content, next, setStep };
317339
};

shesha-reactjs/src/designer-components/wizard/tabs.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const Tabs: FC<Omit<IWizardComponentProps, 'size'>> = ({ form, ...model }
2929
const { executeBooleanExpression } = useFormExpression();
3030
const onChangeContextData = useDataContextManager()?.onChangeContextData;
3131

32-
const { components, current, currentStep, visibleSteps, back, cancel, content, done, next, setStep } = useWizard(model);
32+
const { components, current, currentStep, visibleSteps, back, cancel, close, content, done, next, setStep } = useWizard(model);
3333
useEffect(() => onChangeContextData(), [current]);
3434

3535
const contextData = useMemo(
@@ -101,7 +101,7 @@ export const Tabs: FC<Omit<IWizardComponentProps, 'size'>> = ({ form, ...model }
101101
type="control"
102102
metadata={contextMetadata}
103103
data={contextData}
104-
api={{ back, cancel, content, done, next, setStep }}
104+
api={{ back, cancel, close, content, done, next, setStep }}
105105
>
106106
<ParentProvider model={model}>
107107
<div className={styles.shaWizard}>

shesha-reactjs/src/publicJsApis/wizardApi.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export interface IWizardActions {
22
next: () => Promise<void>;
33
back: () => void;
44
cancel: () => void;
5+
close: () => void;
56
done: () => Promise<void>;
67
setStep: (stepIndex) => void;
78
content: (description: string, index: number) => string;

0 commit comments

Comments
 (0)