|
|
@ -40,6 +40,7 @@ import RunManifestInputGroup, { |
|
|
|
} from './RunManifestInputGroup'; |
|
|
|
} from './RunManifestInputGroup'; |
|
|
|
import Spinner from '../Spinner'; |
|
|
|
import Spinner from '../Spinner'; |
|
|
|
import { BodyText, HeaderText } from '../Text'; |
|
|
|
import { BodyText, HeaderText } from '../Text'; |
|
|
|
|
|
|
|
import useChecklist from '../../hooks/useChecklist'; |
|
|
|
import useConfirmDialogProps from '../../hooks/useConfirmDialogProps'; |
|
|
|
import useConfirmDialogProps from '../../hooks/useConfirmDialogProps'; |
|
|
|
import useFormUtils from '../../hooks/useFormUtils'; |
|
|
|
import useFormUtils from '../../hooks/useFormUtils'; |
|
|
|
import useIsFirstRender from '../../hooks/useIsFirstRender'; |
|
|
|
import useIsFirstRender from '../../hooks/useIsFirstRender'; |
|
|
@ -200,6 +201,11 @@ const ManageManifestPanel: FC = () => { |
|
|
|
); |
|
|
|
); |
|
|
|
const { isFormInvalid: isRunFormInvalid } = runFormUtils; |
|
|
|
const { isFormInvalid: isRunFormInvalid } = runFormUtils; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { buildDeleteDialogProps, checks, getCheck, hasChecks, setCheck } = |
|
|
|
|
|
|
|
useChecklist({ |
|
|
|
|
|
|
|
list: manifestOverviews, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const { |
|
|
|
const { |
|
|
|
hostConfig: { hosts: mdetailHosts = {} } = {}, |
|
|
|
hostConfig: { hosts: mdetailHosts = {} } = {}, |
|
|
|
name: mdetailName, |
|
|
|
name: mdetailName, |
|
|
@ -229,16 +235,18 @@ const ManageManifestPanel: FC = () => { |
|
|
|
}: { |
|
|
|
}: { |
|
|
|
body: Record<string, unknown>; |
|
|
|
body: Record<string, unknown>; |
|
|
|
getErrorMsg: (parentMsg: ReactNode) => ReactNode; |
|
|
|
getErrorMsg: (parentMsg: ReactNode) => ReactNode; |
|
|
|
method: 'post' | 'put'; |
|
|
|
method: 'delete' | 'post' | 'put'; |
|
|
|
successMsg: ReactNode; |
|
|
|
successMsg?: ReactNode; |
|
|
|
url: string; |
|
|
|
url: string; |
|
|
|
}) => { |
|
|
|
}) => { |
|
|
|
setIsSubmittingForm(true); |
|
|
|
setIsSubmittingForm(true); |
|
|
|
|
|
|
|
|
|
|
|
api[method](url, body) |
|
|
|
api |
|
|
|
|
|
|
|
.request({ data: body, method, url }) |
|
|
|
.then(() => { |
|
|
|
.then(() => { |
|
|
|
setMessage(MSG_ID_MANIFEST_API, { |
|
|
|
setMessage(MSG_ID_MANIFEST_API, { |
|
|
|
children: successMsg, |
|
|
|
children: successMsg, |
|
|
|
|
|
|
|
type: 'info', |
|
|
|
}); |
|
|
|
}); |
|
|
|
}) |
|
|
|
}) |
|
|
|
.catch((apiError) => { |
|
|
|
.catch((apiError) => { |
|
|
@ -433,6 +441,7 @@ const ManageManifestPanel: FC = () => { |
|
|
|
<List |
|
|
|
<List |
|
|
|
allowEdit |
|
|
|
allowEdit |
|
|
|
allowItemButton={isEditManifests} |
|
|
|
allowItemButton={isEditManifests} |
|
|
|
|
|
|
|
disableDelete={!hasChecks} |
|
|
|
edit={isEditManifests} |
|
|
|
edit={isEditManifests} |
|
|
|
header |
|
|
|
header |
|
|
|
listEmpty="No manifest(s) registered." |
|
|
|
listEmpty="No manifest(s) registered." |
|
|
@ -440,9 +449,34 @@ const ManageManifestPanel: FC = () => { |
|
|
|
onAdd={() => { |
|
|
|
onAdd={() => { |
|
|
|
addManifestFormDialogRef.current.setOpen?.call(null, true); |
|
|
|
addManifestFormDialogRef.current.setOpen?.call(null, true); |
|
|
|
}} |
|
|
|
}} |
|
|
|
|
|
|
|
onDelete={() => { |
|
|
|
|
|
|
|
setConfirmDialogProps( |
|
|
|
|
|
|
|
buildDeleteDialogProps({ |
|
|
|
|
|
|
|
onProceedAppend: () => { |
|
|
|
|
|
|
|
submitForm({ |
|
|
|
|
|
|
|
body: { uuids: checks }, |
|
|
|
|
|
|
|
getErrorMsg: (parentMsg) => ( |
|
|
|
|
|
|
|
<>Delete manifest(s) failed. {parentMsg}</> |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
method: 'delete', |
|
|
|
|
|
|
|
url: `/manifest`, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
getConfirmDialogTitle: (count) => `Delete ${count} manifest(s)?`, |
|
|
|
|
|
|
|
renderEntry: (key) => ( |
|
|
|
|
|
|
|
<BodyText>{manifestOverviews?.[key].manifestName}</BodyText> |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
confirmDialogRef.current.setOpen?.call(null, true); |
|
|
|
|
|
|
|
}} |
|
|
|
onEdit={() => { |
|
|
|
onEdit={() => { |
|
|
|
setIsEditManifests((previous) => !previous); |
|
|
|
setIsEditManifests((previous) => !previous); |
|
|
|
}} |
|
|
|
}} |
|
|
|
|
|
|
|
onItemCheckboxChange={(key, event, checked) => { |
|
|
|
|
|
|
|
setCheck(key, checked); |
|
|
|
|
|
|
|
}} |
|
|
|
onItemClick={({ manifestName, manifestUUID }) => { |
|
|
|
onItemClick={({ manifestName, manifestUUID }) => { |
|
|
|
setManifestDetail({ |
|
|
|
setManifestDetail({ |
|
|
|
name: manifestName, |
|
|
|
name: manifestName, |
|
|
@ -451,6 +485,7 @@ const ManageManifestPanel: FC = () => { |
|
|
|
editManifestFormDialogRef.current.setOpen?.call(null, true); |
|
|
|
editManifestFormDialogRef.current.setOpen?.call(null, true); |
|
|
|
getManifestDetail(manifestUUID); |
|
|
|
getManifestDetail(manifestUUID); |
|
|
|
}} |
|
|
|
}} |
|
|
|
|
|
|
|
renderListItemCheckboxState={(key) => getCheck(key)} |
|
|
|
renderListItem={(manifestUUID, { manifestName }) => ( |
|
|
|
renderListItem={(manifestUUID, { manifestName }) => ( |
|
|
|
<FlexBox fullWidth row> |
|
|
|
<FlexBox fullWidth row> |
|
|
|
<IconButton |
|
|
|
<IconButton |
|
|
@ -471,7 +506,19 @@ const ManageManifestPanel: FC = () => { |
|
|
|
)} |
|
|
|
)} |
|
|
|
/> |
|
|
|
/> |
|
|
|
), |
|
|
|
), |
|
|
|
[getManifestDetail, isEditManifests, manifestOverviews, setManifestDetail], |
|
|
|
[ |
|
|
|
|
|
|
|
buildDeleteDialogProps, |
|
|
|
|
|
|
|
checks, |
|
|
|
|
|
|
|
getCheck, |
|
|
|
|
|
|
|
getManifestDetail, |
|
|
|
|
|
|
|
hasChecks, |
|
|
|
|
|
|
|
isEditManifests, |
|
|
|
|
|
|
|
manifestOverviews, |
|
|
|
|
|
|
|
setCheck, |
|
|
|
|
|
|
|
setConfirmDialogProps, |
|
|
|
|
|
|
|
setManifestDetail, |
|
|
|
|
|
|
|
submitForm, |
|
|
|
|
|
|
|
], |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
const panelContent = useMemo( |
|
|
|
const panelContent = useMemo( |
|
|
|