fix(striker-ui): enable confirm dialog for submit run manifest

main
Tsu-ba-me 2 years ago
parent 1b4a5baeb5
commit 39e3623085
  1. 63
      striker-ui/components/ManageManifest/ManageManifestPanel.tsx

@ -149,18 +149,20 @@ const ManageManifestPanel: FC = () => {
const runManifestFormDialogRef = useRef<ConfirmDialogForwardedRefContent>({}); const runManifestFormDialogRef = useRef<ConfirmDialogForwardedRefContent>({});
const messageGroupRef = useRef<MessageGroupForwardedRefContent>({}); const messageGroupRef = useRef<MessageGroupForwardedRefContent>({});
const [confirmDialogProps] = useConfirmDialogProps(); const [confirmDialogProps, setConfirmDialogProps] = useConfirmDialogProps();
const [hostOverviews, setHostOverviews] = useProtectedState< const [hostOverviews, setHostOverviews] = useProtectedState<
APIHostOverviewList | undefined APIHostOverviewList | undefined
>(undefined); >(undefined);
const [isEditManifests, setIsEditManifests] = useState<boolean>(false); const [isEditManifests, setIsEditManifests] = useState<boolean>(false);
const [isLoadingHostOverviews, setIsLoadingHostOverviews] = const [isLoadingHostOverviews, setIsLoadingHostOverviews] =
useState<boolean>(true); useProtectedState<boolean>(true);
const [isLoadingManifestDetail, setIsLoadingManifestDetail] = const [isLoadingManifestDetail, setIsLoadingManifestDetail] =
useProtectedState<boolean>(true); useProtectedState<boolean>(true);
const [isLoadingManifestTemplate, setIsLoadingManifestTemplate] = const [isLoadingManifestTemplate, setIsLoadingManifestTemplate] =
useState<boolean>(true); useProtectedState<boolean>(true);
const [isSubmittingManifestExecution, setIsSubmittingManifestExecution] =
useProtectedState<boolean>(false);
const [manifestDetail, setManifestDetail] = useProtectedState< const [manifestDetail, setManifestDetail] = useProtectedState<
APIManifestDetail | undefined APIManifestDetail | undefined
>(undefined); >(undefined);
@ -196,11 +198,14 @@ const ManageManifestPanel: FC = () => {
); );
const { isFormInvalid: isRunFormInvalid } = runFormUtils; const { isFormInvalid: isRunFormInvalid } = runFormUtils;
const { hostConfig: { hosts: mdetailHosts = {} } = {}, name: mdetailName } = const {
useMemo<Partial<APIManifestDetail>>( hostConfig: { hosts: mdetailHosts = {} } = {},
() => manifestDetail ?? {}, name: mdetailName,
[manifestDetail], uuid: mdetailUuid,
); } = useMemo<Partial<APIManifestDetail>>(
() => manifestDetail ?? {},
[manifestDetail],
);
const { const {
domain: mtemplateDomain, domain: mtemplateDomain,
fences: knownFences, fences: knownFences,
@ -283,19 +288,42 @@ const ManageManifestPanel: FC = () => {
), ),
loading: isLoadingManifestDetail, loading: isLoadingManifestDetail,
onSubmitAppend: (...args) => { onSubmitAppend: (...args) => {
getRunFormData(mdetailHosts, ...args); const body = getRunFormData(mdetailHosts, ...args);
setConfirmDialogProps({
actionProceedText: 'Run',
content: <></>,
onProceedAppend: () => {
setIsSubmittingManifestExecution(true);
api
.put(`/command/run-manifest/${mdetailUuid}`, body)
.catch((apiError) => {
handleAPIError(apiError);
})
.finally(() => {
setIsSubmittingManifestExecution(false);
});
},
titleText: `Are you sure you want to run manifest ${mdetailName}?`,
});
confirmDialogRef.current.setOpen?.call(null, true);
}, },
titleText: `Run install manifest ${mdetailName}`, titleText: `Run install manifest ${mdetailName}`,
}), }),
[ [
mdetailName, runFormUtils,
hostOverviews,
mdetailHosts,
isLoadingManifestDetail,
knownFences, knownFences,
hostOverviews,
knownUpses, knownUpses,
manifestDetail, manifestDetail,
runFormUtils, isLoadingManifestDetail,
mdetailName,
mdetailHosts,
setConfirmDialogProps,
setIsSubmittingManifestExecution,
mdetailUuid,
], ],
); );
@ -446,11 +474,16 @@ const ManageManifestPanel: FC = () => {
<FormDialog <FormDialog
{...runManifestFormDialogProps} {...runManifestFormDialogProps}
disableProceed={isRunFormInvalid} disableProceed={isRunFormInvalid}
loadingAction={isSubmittingManifestExecution}
preActionArea={messageArea} preActionArea={messageArea}
ref={runManifestFormDialogRef} ref={runManifestFormDialogRef}
scrollContent scrollContent
/> />
<ConfirmDialog {...confirmDialogProps} ref={confirmDialogRef} /> <ConfirmDialog
closeOnProceed
{...confirmDialogProps}
ref={confirmDialogRef}
/>
</> </>
); );
}; };

Loading…
Cancel
Save