diff --git a/striker-ui/components/ManageFence/ManageFencePanel.tsx b/striker-ui/components/ManageFence/ManageFencePanel.tsx index 87008c87..4bef8a18 100644 --- a/striker-ui/components/ManageFence/ManageFencePanel.tsx +++ b/striker-ui/components/ManageFence/ManageFencePanel.tsx @@ -155,8 +155,14 @@ const ManageFencePanel: FC = () => { const formUtils = useFormUtils([INPUT_ID_FENCE_AGENT], messageGroupRef); const { isFormInvalid, isFormSubmitting, submitForm } = formUtils; - const { buildDeleteDialogProps, checks, getCheck, hasChecks, setCheck } = - useChecklist({ list: fenceOverviews }); + const { + buildDeleteDialogProps, + checks, + getCheck, + hasChecks, + resetChecklist, + setCheck, + } = useChecklist({ list: fenceOverviews }); const getFormSummaryEntryLabel = useCallback( ({ cap, depth, key }) => (depth === 0 ? cap(key) : key), @@ -238,7 +244,10 @@ const ManageFencePanel: FC = () => { <>Failed to delete fence device(s). {parentMsg} ), method: 'delete', - onSuccess: () => getFenceOverviews(), + onSuccess: () => { + getFenceOverviews(); + resetChecklist(); + }, url: '/fence', }); }, @@ -373,6 +382,7 @@ const ManageFencePanel: FC = () => { getFormSummaryEntryLabel, hasChecks, isEditFences, + resetChecklist, setCheck, setConfirmDialogProps, setFormDialogProps, diff --git a/striker-ui/components/ManageManifest/ManageManifestPanel.tsx b/striker-ui/components/ManageManifest/ManageManifestPanel.tsx index 5f59beba..40412546 100644 --- a/striker-ui/components/ManageManifest/ManageManifestPanel.tsx +++ b/striker-ui/components/ManageManifest/ManageManifestPanel.tsx @@ -212,10 +212,16 @@ const ManageManifestPanel: FC = () => { submitForm: submitRunForm, } = runFormUtils; - const { buildDeleteDialogProps, checks, getCheck, hasChecks, setCheck } = - useChecklist({ - list: manifestOverviews, - }); + const { + buildDeleteDialogProps, + checks, + getCheck, + hasChecks, + resetChecklist, + setCheck, + } = useChecklist({ + list: manifestOverviews, + }); const { hostConfig: { hosts: mdetailHosts = {} } = {}, @@ -437,7 +443,10 @@ const ManageManifestPanel: FC = () => { <>Delete manifest(s) failed. {parentMsg} ), method: 'delete', - onSuccess: () => getManifestOverviews(), + onSuccess: () => { + getManifestOverviews(); + resetChecklist(); + }, url: `/manifest`, }); }, @@ -494,6 +503,7 @@ const ManageManifestPanel: FC = () => { hasChecks, isEditManifests, manifestOverviews, + resetChecklist, setCheck, setConfirmDialogProps, setManifestDetail, diff --git a/striker-ui/hooks/useChecklist.tsx b/striker-ui/hooks/useChecklist.tsx index c30cef71..cf71bcdf 100644 --- a/striker-ui/hooks/useChecklist.tsx +++ b/striker-ui/hooks/useChecklist.tsx @@ -16,6 +16,7 @@ const useChecklist = ({ hasAllChecks: boolean; hasChecks: boolean; multipleItems: boolean; + resetChecklist: () => void; setAllChecks: SetAllChecksFunction; setCheck: SetCheckFunction; } => { @@ -61,6 +62,8 @@ const useChecklist = ({ [checklist], ); + const resetChecklist = useCallback(() => setChecklist({}), []); + const setAllChecks = useCallback( (checked) => setChecklist( @@ -89,6 +92,7 @@ const useChecklist = ({ hasAllChecks, hasChecks, multipleItems, + resetChecklist, setAllChecks, setCheck, };