|
|
@ -30,6 +30,7 @@ import FormSummary from '../FormSummary'; |
|
|
|
import handleAPIError from '../../lib/handleAPIError'; |
|
|
|
import handleAPIError from '../../lib/handleAPIError'; |
|
|
|
import IconButton from '../IconButton'; |
|
|
|
import IconButton from '../IconButton'; |
|
|
|
import List from '../List'; |
|
|
|
import List from '../List'; |
|
|
|
|
|
|
|
import MessageBox from '../MessageBox'; |
|
|
|
import MessageGroup, { MessageGroupForwardedRefContent } from '../MessageGroup'; |
|
|
|
import MessageGroup, { MessageGroupForwardedRefContent } from '../MessageGroup'; |
|
|
|
import { Panel, PanelHeader } from '../Panels'; |
|
|
|
import { Panel, PanelHeader } from '../Panels'; |
|
|
|
import periodicFetch from '../../lib/fetchers/periodicFetch'; |
|
|
|
import periodicFetch from '../../lib/fetchers/periodicFetch'; |
|
|
@ -243,6 +244,62 @@ const ManageManifestPanel: FC = () => { |
|
|
|
[manifestTemplate], |
|
|
|
[manifestTemplate], |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const countHostFences = useCallback( |
|
|
|
|
|
|
|
( |
|
|
|
|
|
|
|
body: APIBuildManifestRequestBody, |
|
|
|
|
|
|
|
): { counts: Record<string, number>; messages: React.ReactNode[] } => { |
|
|
|
|
|
|
|
const { |
|
|
|
|
|
|
|
hostConfig: { hosts }, |
|
|
|
|
|
|
|
} = body; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const counts = Object.values(hosts).reduce<Record<string, number>>( |
|
|
|
|
|
|
|
(previous, host) => { |
|
|
|
|
|
|
|
const { fences, hostType, hostNumber } = host; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const hostName = `${hostType.replace( |
|
|
|
|
|
|
|
/node/, |
|
|
|
|
|
|
|
'subnode', |
|
|
|
|
|
|
|
)}${hostNumber}`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!fences) { |
|
|
|
|
|
|
|
previous[hostName] = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return previous; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
previous[hostName] = Object.values(fences).reduce<number>( |
|
|
|
|
|
|
|
(count, fence) => { |
|
|
|
|
|
|
|
const { fencePort } = fence; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const diff = fencePort.length ? 1 : 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return count + diff; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return previous; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{}, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const messages = Object.entries(counts).map((entry) => { |
|
|
|
|
|
|
|
const [hostName, fenceCount] = entry; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return fenceCount ? ( |
|
|
|
|
|
|
|
<></> |
|
|
|
|
|
|
|
) : ( |
|
|
|
|
|
|
|
<MessageBox> |
|
|
|
|
|
|
|
No fence device port specified for {hostName}. |
|
|
|
|
|
|
|
</MessageBox> |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return { counts, messages }; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
[], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
const addManifestFormDialogProps = useMemo<ConfirmDialogProps>( |
|
|
|
const addManifestFormDialogProps = useMemo<ConfirmDialogProps>( |
|
|
|
() => ({ |
|
|
|
() => ({ |
|
|
|
actionProceedText: 'Add', |
|
|
|
actionProceedText: 'Add', |
|
|
@ -260,6 +317,7 @@ const ManageManifestPanel: FC = () => { |
|
|
|
), |
|
|
|
), |
|
|
|
onSubmitAppend: (...args) => { |
|
|
|
onSubmitAppend: (...args) => { |
|
|
|
const body = getFormData(...args); |
|
|
|
const body = getFormData(...args); |
|
|
|
|
|
|
|
const { messages } = countHostFences(body); |
|
|
|
|
|
|
|
|
|
|
|
setConfirmDialogProps({ |
|
|
|
setConfirmDialogProps({ |
|
|
|
actionProceedText: 'Add', |
|
|
|
actionProceedText: 'Add', |
|
|
@ -276,6 +334,7 @@ const ManageManifestPanel: FC = () => { |
|
|
|
url: '/manifest', |
|
|
|
url: '/manifest', |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
preActionArea: <FlexBox spacing=".3em">{messages}</FlexBox>, |
|
|
|
titleText: `Add install manifest?`, |
|
|
|
titleText: `Add install manifest?`, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -284,6 +343,7 @@ const ManageManifestPanel: FC = () => { |
|
|
|
titleText: 'Add an install manifest', |
|
|
|
titleText: 'Add an install manifest', |
|
|
|
}), |
|
|
|
}), |
|
|
|
[ |
|
|
|
[ |
|
|
|
|
|
|
|
countHostFences, |
|
|
|
formUtils, |
|
|
|
formUtils, |
|
|
|
getManifestOverviews, |
|
|
|
getManifestOverviews, |
|
|
|
knownFences, |
|
|
|
knownFences, |
|
|
@ -309,6 +369,7 @@ const ManageManifestPanel: FC = () => { |
|
|
|
), |
|
|
|
), |
|
|
|
onSubmitAppend: (...args) => { |
|
|
|
onSubmitAppend: (...args) => { |
|
|
|
const body = getFormData(...args); |
|
|
|
const body = getFormData(...args); |
|
|
|
|
|
|
|
const { messages } = countHostFences(body); |
|
|
|
|
|
|
|
|
|
|
|
setConfirmDialogProps({ |
|
|
|
setConfirmDialogProps({ |
|
|
|
actionProceedText: 'Edit', |
|
|
|
actionProceedText: 'Edit', |
|
|
@ -325,6 +386,7 @@ const ManageManifestPanel: FC = () => { |
|
|
|
url: `/manifest/${mdetailUuid}`, |
|
|
|
url: `/manifest/${mdetailUuid}`, |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
preActionArea: <FlexBox spacing=".3em">{messages}</FlexBox>, |
|
|
|
titleText: `Update install manifest ${mdetailName}?`, |
|
|
|
titleText: `Update install manifest ${mdetailName}?`, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -334,16 +396,17 @@ const ManageManifestPanel: FC = () => { |
|
|
|
titleText: `Update install manifest ${mdetailName}`, |
|
|
|
titleText: `Update install manifest ${mdetailName}`, |
|
|
|
}), |
|
|
|
}), |
|
|
|
[ |
|
|
|
[ |
|
|
|
|
|
|
|
countHostFences, |
|
|
|
formUtils, |
|
|
|
formUtils, |
|
|
|
|
|
|
|
getManifestOverviews, |
|
|
|
|
|
|
|
isLoadingManifestDetail, |
|
|
|
knownFences, |
|
|
|
knownFences, |
|
|
|
knownUpses, |
|
|
|
knownUpses, |
|
|
|
manifestDetail, |
|
|
|
manifestDetail, |
|
|
|
isLoadingManifestDetail, |
|
|
|
|
|
|
|
mdetailName, |
|
|
|
mdetailName, |
|
|
|
|
|
|
|
mdetailUuid, |
|
|
|
setConfirmDialogProps, |
|
|
|
setConfirmDialogProps, |
|
|
|
submitForm, |
|
|
|
submitForm, |
|
|
|
mdetailUuid, |
|
|
|
|
|
|
|
getManifestOverviews, |
|
|
|
|
|
|
|
], |
|
|
|
], |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|