fix(striker-ui): reset checklist after delete in manage fences, manifests

main
Tsu-ba-me 1 year ago
parent cf4e4ff3f0
commit d7d7fcb039
  1. 16
      striker-ui/components/ManageFence/ManageFencePanel.tsx
  2. 20
      striker-ui/components/ManageManifest/ManageManifestPanel.tsx
  3. 4
      striker-ui/hooks/useChecklist.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<GetFormEntryLabelFunction>(
({ 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,

@ -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,

@ -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<SetAllChecksFunction>(
(checked) =>
setChecklist(
@ -89,6 +92,7 @@ const useChecklist = ({
hasAllChecks,
hasChecks,
multipleItems,
resetChecklist,
setAllChecks,
setCheck,
};

Loading…
Cancel
Save