fix(striker-ui): connect prepare network submission with endpoint

main
Tsu-ba-me 1 year ago
parent 9728f56927
commit e436b4de11
  1. 3
      striker-ui/components/NetworkInitForm.tsx
  2. 15
      striker-ui/components/PrepareNetworkForm.tsx

@ -84,7 +84,7 @@ type NetworkInitFormValues = {
networks: Omit<NetworkInput, 'ipAddressInputRef' | 'subnetMaskInputRef'>[]; networks: Omit<NetworkInput, 'ipAddressInputRef' | 'subnetMaskInputRef'>[];
}; };
type NetworkInitFormForwardedRefContent = { type NetworkInitFormForwardedRefContent = MessageGroupForwardedRefContent & {
get?: () => NetworkInitFormValues; get?: () => NetworkInitFormValues;
}; };
@ -1271,6 +1271,7 @@ const NetworkInitForm = forwardRef<
useImperativeHandle( useImperativeHandle(
ref, ref,
() => ({ () => ({
...messageGroupRef.current,
get: () => ({ get: () => ({
dns: dnsCSVInputRef.current.getValue?.call(null), dns: dnsCSVInputRef.current.getValue?.call(null),
gateway: gatewayInputRef.current.getValue?.call(null), gateway: gatewayInputRef.current.getValue?.call(null),

@ -123,6 +123,7 @@ const PrepareNetworkForm: FC<PrepareNetworkFormProps> = ({
isFormInvalid, isFormInvalid,
setMessage, setMessage,
setValidity, setValidity,
submitForm,
} = useFormUtils( } = useFormUtils(
[INPUT_ID_PREP_NET_HOST_NAME, INPUT_GROUP_ID_PREP_NET_NETCONF], [INPUT_ID_PREP_NET_HOST_NAME, INPUT_GROUP_ID_PREP_NET_NETCONF],
generalInputMessageGroupRef, generalInputMessageGroupRef,
@ -204,6 +205,18 @@ const PrepareNetworkForm: FC<PrepareNetworkFormProps> = ({
} }
/> />
), ),
onProceedAppend: () => {
submitForm({
body,
getErrorMsg: (parentMsg) => (
<>Failed to prepare network. {parentMsg}</>
),
method: 'put',
setMsg: netconfFormRef?.current?.setMessage,
successMsg: `Initiated prepare network on ${hostDetail?.shortHostName}`,
url: `/host/${hostUUID}?handler=subnode-network`,
});
},
titleText: `Prepare ${hostDetail?.shortHostName} network?`, titleText: `Prepare ${hostDetail?.shortHostName} network?`,
}); });
@ -265,6 +278,8 @@ const PrepareNetworkForm: FC<PrepareNetworkFormProps> = ({
netconfForm, netconfForm,
isFormInvalid, isFormInvalid,
setConfirmDialogProps, setConfirmDialogProps,
submitForm,
hostUUID,
setMessage, setMessage,
]); ]);

Loading…
Cancel
Save