fix(striker-ui): reload manifests after add, edit, or delete

main
Tsu-ba-me 1 year ago
parent 2100829083
commit cf4e4ff3f0
  1. 18
      striker-ui/components/ManageManifest/ManageManifestPanel.tsx

@ -163,6 +163,9 @@ const ManageManifestPanel: FC = () => {
useProtectedState<boolean>(true); useProtectedState<boolean>(true);
const [isLoadingManifestTemplate, setIsLoadingManifestTemplate] = const [isLoadingManifestTemplate, setIsLoadingManifestTemplate] =
useProtectedState<boolean>(true); useProtectedState<boolean>(true);
const [manifestOverviews, setManifestOverviews] = useProtectedState<
APIManifestOverviewList | undefined
>(undefined);
const [manifestDetail, setManifestDetail] = useProtectedState< const [manifestDetail, setManifestDetail] = useProtectedState<
APIManifestDetail | undefined APIManifestDetail | undefined
>(undefined); >(undefined);
@ -170,11 +173,18 @@ const ManageManifestPanel: FC = () => {
APIManifestTemplate | undefined APIManifestTemplate | undefined
>(undefined); >(undefined);
const { data: manifestOverviews, isLoading: isLoadingManifestOverviews } = const { isLoading: isLoadingManifestOverviews } =
periodicFetch<APIManifestOverviewList>(`${API_BASE_URL}/manifest`, { periodicFetch<APIManifestOverviewList>(`${API_BASE_URL}/manifest`, {
onSuccess: (data) => setManifestOverviews(data),
refreshInterval: 60000, refreshInterval: 60000,
}); });
const getManifestOverviews = useCallback(() => {
api.get('/manifest').then(({ data }) => {
setManifestOverviews(data);
});
}, [setManifestOverviews]);
const formUtils = useFormUtils( const formUtils = useFormUtils(
[ [
INPUT_ID_AI_DOMAIN, INPUT_ID_AI_DOMAIN,
@ -254,6 +264,7 @@ const ManageManifestPanel: FC = () => {
<>Failed to add install manifest. {parentMsg}</> <>Failed to add install manifest. {parentMsg}</>
), ),
method: 'post', method: 'post',
onSuccess: () => getManifestOverviews(),
successMsg: 'Successfully added install manifest', successMsg: 'Successfully added install manifest',
url: '/manifest', url: '/manifest',
}); });
@ -267,6 +278,7 @@ const ManageManifestPanel: FC = () => {
}), }),
[ [
formUtils, formUtils,
getManifestOverviews,
knownFences, knownFences,
knownUpses, knownUpses,
mtemplateDomain, mtemplateDomain,
@ -301,6 +313,7 @@ const ManageManifestPanel: FC = () => {
<>Failed to update install manifest. {parentMsg}</> <>Failed to update install manifest. {parentMsg}</>
), ),
method: 'put', method: 'put',
onSuccess: () => getManifestOverviews(),
successMsg: `Successfully updated install manifest ${mdetailName}`, successMsg: `Successfully updated install manifest ${mdetailName}`,
url: `/manifest/${mdetailUuid}`, url: `/manifest/${mdetailUuid}`,
}); });
@ -323,6 +336,7 @@ const ManageManifestPanel: FC = () => {
setConfirmDialogProps, setConfirmDialogProps,
submitForm, submitForm,
mdetailUuid, mdetailUuid,
getManifestOverviews,
], ],
); );
@ -423,6 +437,7 @@ const ManageManifestPanel: FC = () => {
<>Delete manifest(s) failed. {parentMsg}</> <>Delete manifest(s) failed. {parentMsg}</>
), ),
method: 'delete', method: 'delete',
onSuccess: () => getManifestOverviews(),
url: `/manifest`, url: `/manifest`,
}); });
}, },
@ -475,6 +490,7 @@ const ManageManifestPanel: FC = () => {
checks, checks,
getCheck, getCheck,
getManifestDetail, getManifestDetail,
getManifestOverviews,
hasChecks, hasChecks,
isEditManifests, isEditManifests,
manifestOverviews, manifestOverviews,

Loading…
Cancel
Save