|
|
@ -49,8 +49,8 @@ import periodicFetch from '../lib/fetchers/periodicFetch'; |
|
|
|
import SelectWithLabel from './SelectWithLabel'; |
|
|
|
import SelectWithLabel from './SelectWithLabel'; |
|
|
|
import Spinner from './Spinner'; |
|
|
|
import Spinner from './Spinner'; |
|
|
|
import sumstring from '../lib/sumstring'; |
|
|
|
import sumstring from '../lib/sumstring'; |
|
|
|
import { testInput, testNotBlank } from '../lib/test_input'; |
|
|
|
import { createTestInputFunction, testNotBlank } from '../lib/test_input'; |
|
|
|
import { InputTestBatches } from '../types/TestInputFunction'; |
|
|
|
import { InputTestBatches, InputTestInputs } from '../types/TestInputFunction'; |
|
|
|
import { BodyText, DataGridCellText } from './Text'; |
|
|
|
import { BodyText, DataGridCellText } from './Text'; |
|
|
|
|
|
|
|
|
|
|
|
type NetworkInput = { |
|
|
|
type NetworkInput = { |
|
|
@ -264,7 +264,6 @@ const NetworkForm: FC<{ |
|
|
|
interfaceIndex: number, |
|
|
|
interfaceIndex: number, |
|
|
|
) => MUIBoxProps['onMouseUp']; |
|
|
|
) => MUIBoxProps['onMouseUp']; |
|
|
|
getNetworkTypeCount: (targetType: string, lastIndex?: number) => number; |
|
|
|
getNetworkTypeCount: (targetType: string, lastIndex?: number) => number; |
|
|
|
inputTests: InputTestBatches; |
|
|
|
|
|
|
|
networkIndex: number; |
|
|
|
networkIndex: number; |
|
|
|
networkInput: NetworkInput; |
|
|
|
networkInput: NetworkInput; |
|
|
|
networkInputs: NetworkInput[]; |
|
|
|
networkInputs: NetworkInput[]; |
|
|
@ -274,12 +273,10 @@ const NetworkForm: FC<{ |
|
|
|
setNetworkInterfaceInputMap: Dispatch< |
|
|
|
setNetworkInterfaceInputMap: Dispatch< |
|
|
|
SetStateAction<NetworkInterfaceInputMap> |
|
|
|
SetStateAction<NetworkInterfaceInputMap> |
|
|
|
>; |
|
|
|
>; |
|
|
|
testAllInputs: (...excludeTestIds: string[]) => boolean; |
|
|
|
testInputSeparate: (id: string, input: InputTestInputs[string]) => void; |
|
|
|
toggleSubmitDisabled?: ToggleSubmitDisabledFunction; |
|
|
|
|
|
|
|
}> = ({ |
|
|
|
}> = ({ |
|
|
|
createDropMouseUpHandler, |
|
|
|
createDropMouseUpHandler, |
|
|
|
getNetworkTypeCount, |
|
|
|
getNetworkTypeCount, |
|
|
|
inputTests, |
|
|
|
|
|
|
|
networkIndex, |
|
|
|
networkIndex, |
|
|
|
networkInput, |
|
|
|
networkInput, |
|
|
|
networkInputs, |
|
|
|
networkInputs, |
|
|
@ -287,8 +284,7 @@ const NetworkForm: FC<{ |
|
|
|
optionalNetworkInputsLength, |
|
|
|
optionalNetworkInputsLength, |
|
|
|
setNetworkInputs, |
|
|
|
setNetworkInputs, |
|
|
|
setNetworkInterfaceInputMap, |
|
|
|
setNetworkInterfaceInputMap, |
|
|
|
testAllInputs, |
|
|
|
testInputSeparate, |
|
|
|
toggleSubmitDisabled, |
|
|
|
|
|
|
|
}) => { |
|
|
|
}) => { |
|
|
|
const theme = useTheme(); |
|
|
|
const theme = useTheme(); |
|
|
|
const breakpointMedium = useMediaQuery(theme.breakpoints.up('md')); |
|
|
|
const breakpointMedium = useMediaQuery(theme.breakpoints.up('md')); |
|
|
@ -418,19 +414,9 @@ const NetworkForm: FC<{ |
|
|
|
?.call(null, interfaces, networkInterfaceIndex) |
|
|
|
?.call(null, interfaces, networkInterfaceIndex) |
|
|
|
?.call(null, ...args); |
|
|
|
?.call(null, ...args); |
|
|
|
|
|
|
|
|
|
|
|
const isLocalValid = testInput({ |
|
|
|
testInputSeparate(interfacesInputTestId, { |
|
|
|
inputs: { |
|
|
|
|
|
|
|
[interfacesInputTestId]: { |
|
|
|
|
|
|
|
value: getFilled(interfaces).length, |
|
|
|
value: getFilled(interfaces).length, |
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
tests: inputTests, |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
toggleSubmitDisabled?.call( |
|
|
|
|
|
|
|
null, |
|
|
|
|
|
|
|
isLocalValid && testAllInputs(interfacesInputTestId), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}} |
|
|
|
}} |
|
|
|
> |
|
|
|
> |
|
|
|
{networkInterface ? ( |
|
|
|
{networkInterface ? ( |
|
|
@ -445,20 +431,9 @@ const NetworkForm: FC<{ |
|
|
|
setNetworkInterfaceInputMap({ |
|
|
|
setNetworkInterfaceInputMap({ |
|
|
|
...networkInterfaceInputMap, |
|
|
|
...networkInterfaceInputMap, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
testInputSeparate(interfacesInputTestId, { |
|
|
|
const isLocalValid = testInput({ |
|
|
|
|
|
|
|
inputs: { |
|
|
|
|
|
|
|
[interfacesInputTestId]: { |
|
|
|
|
|
|
|
value: getFilled(interfaces).length, |
|
|
|
value: getFilled(interfaces).length, |
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
tests: inputTests, |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
toggleSubmitDisabled?.call( |
|
|
|
|
|
|
|
null, |
|
|
|
|
|
|
|
isLocalValid && testAllInputs(interfacesInputTestId), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}} |
|
|
|
}} |
|
|
|
/> |
|
|
|
/> |
|
|
|
) : ( |
|
|
|
) : ( |
|
|
@ -475,19 +450,7 @@ const NetworkForm: FC<{ |
|
|
|
inputLabelProps={{ isNotifyRequired: true }} |
|
|
|
inputLabelProps={{ isNotifyRequired: true }} |
|
|
|
label="IP address" |
|
|
|
label="IP address" |
|
|
|
onChange={({ target: { value } }) => { |
|
|
|
onChange={({ target: { value } }) => { |
|
|
|
const isLocalValid = testInput({ |
|
|
|
testInputSeparate(ipAddressInputTestId, { value }); |
|
|
|
inputs: { |
|
|
|
|
|
|
|
[ipAddressInputTestId]: { |
|
|
|
|
|
|
|
value, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
tests: inputTests, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
toggleSubmitDisabled?.call( |
|
|
|
|
|
|
|
null, |
|
|
|
|
|
|
|
isLocalValid && testAllInputs(ipAddressInputTestId), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}} |
|
|
|
}} |
|
|
|
value={ipAddress} |
|
|
|
value={ipAddress} |
|
|
|
/> |
|
|
|
/> |
|
|
@ -501,17 +464,7 @@ const NetworkForm: FC<{ |
|
|
|
inputLabelProps={{ isNotifyRequired: true }} |
|
|
|
inputLabelProps={{ isNotifyRequired: true }} |
|
|
|
label="Subnet mask" |
|
|
|
label="Subnet mask" |
|
|
|
onChange={({ target: { value } }) => { |
|
|
|
onChange={({ target: { value } }) => { |
|
|
|
const isLocalValid = testInput({ |
|
|
|
testInputSeparate(subnetMaskInputTestId, { value }); |
|
|
|
inputs: { |
|
|
|
|
|
|
|
[subnetMaskInputTestId]: { value }, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
tests: inputTests, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
toggleSubmitDisabled?.call( |
|
|
|
|
|
|
|
null, |
|
|
|
|
|
|
|
isLocalValid && testAllInputs(subnetMaskInputTestId), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}} |
|
|
|
}} |
|
|
|
value={subnetMask} |
|
|
|
value={subnetMask} |
|
|
|
/> |
|
|
|
/> |
|
|
@ -525,7 +478,6 @@ const NetworkForm: FC<{ |
|
|
|
|
|
|
|
|
|
|
|
NetworkForm.defaultProps = { |
|
|
|
NetworkForm.defaultProps = { |
|
|
|
createDropMouseUpHandler: undefined, |
|
|
|
createDropMouseUpHandler: undefined, |
|
|
|
toggleSubmitDisabled: undefined, |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const NetworkInitForm = forwardRef< |
|
|
|
const NetworkInitForm = forwardRef< |
|
|
@ -722,15 +674,24 @@ const NetworkInitForm = forwardRef< |
|
|
|
setNetworkIPAddressInputMessage, |
|
|
|
setNetworkIPAddressInputMessage, |
|
|
|
setNetworkSubnetMaskInputMessage, |
|
|
|
setNetworkSubnetMaskInputMessage, |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
const testInput = useMemo( |
|
|
|
|
|
|
|
() => createTestInputFunction(inputTests), |
|
|
|
|
|
|
|
[inputTests], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
const testAllInputs = useCallback( |
|
|
|
const testAllInputs = useCallback( |
|
|
|
(...excludeTestIds: string[]) => |
|
|
|
(...excludeTestIds: string[]) => |
|
|
|
testInput({ |
|
|
|
testInput({ excludeTestIds, isIgnoreOnCallbacks: true }), |
|
|
|
excludeTestIds, |
|
|
|
[testInput], |
|
|
|
isIgnoreOnCallbacks: true, |
|
|
|
); |
|
|
|
tests: inputTests, |
|
|
|
const testInputSeparate = useCallback( |
|
|
|
}), |
|
|
|
(id: string, input: InputTestInputs[string]) => { |
|
|
|
[inputTests], |
|
|
|
const isLocalValid = testInput({ |
|
|
|
|
|
|
|
inputs: { [id]: input }, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
toggleSubmitDisabled?.call(null, isLocalValid && testAllInputs(id)); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
[testInput, testAllInputs, toggleSubmitDisabled], |
|
|
|
); |
|
|
|
); |
|
|
|
const clearNetworkInterfaceHeld = useCallback(() => { |
|
|
|
const clearNetworkInterfaceHeld = useCallback(() => { |
|
|
|
setNetworkInterfaceHeld(undefined); |
|
|
|
setNetworkInterfaceHeld(undefined); |
|
|
@ -997,7 +958,6 @@ const NetworkInitForm = forwardRef< |
|
|
|
{...{ |
|
|
|
{...{ |
|
|
|
createDropMouseUpHandler, |
|
|
|
createDropMouseUpHandler, |
|
|
|
getNetworkTypeCount, |
|
|
|
getNetworkTypeCount, |
|
|
|
inputTests, |
|
|
|
|
|
|
|
networkIndex, |
|
|
|
networkIndex, |
|
|
|
networkInput, |
|
|
|
networkInput, |
|
|
|
networkInputs, |
|
|
|
networkInputs, |
|
|
@ -1005,8 +965,7 @@ const NetworkInitForm = forwardRef< |
|
|
|
optionalNetworkInputsLength, |
|
|
|
optionalNetworkInputsLength, |
|
|
|
setNetworkInputs, |
|
|
|
setNetworkInputs, |
|
|
|
setNetworkInterfaceInputMap, |
|
|
|
setNetworkInterfaceInputMap, |
|
|
|
testAllInputs, |
|
|
|
testInputSeparate, |
|
|
|
toggleSubmitDisabled, |
|
|
|
|
|
|
|
}} |
|
|
|
}} |
|
|
|
/> |
|
|
|
/> |
|
|
|
); |
|
|
|
); |
|
|
@ -1023,15 +982,7 @@ const NetworkInitForm = forwardRef< |
|
|
|
id="network-init-gateway" |
|
|
|
id="network-init-gateway" |
|
|
|
inputLabelProps={{ isNotifyRequired: true }} |
|
|
|
inputLabelProps={{ isNotifyRequired: true }} |
|
|
|
onChange={({ target: { value } }) => { |
|
|
|
onChange={({ target: { value } }) => { |
|
|
|
const isLocalValid = testInput({ |
|
|
|
testInputSeparate(INPUT_TEST_IDS.gateway, { value }); |
|
|
|
inputs: { [INPUT_TEST_IDS.gateway]: { value } }, |
|
|
|
|
|
|
|
tests: inputTests, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
toggleSubmitDisabled?.call( |
|
|
|
|
|
|
|
null, |
|
|
|
|
|
|
|
isLocalValid && testAllInputs(INPUT_TEST_IDS.gateway), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}} |
|
|
|
}} |
|
|
|
label="Gateway" |
|
|
|
label="Gateway" |
|
|
|
/> |
|
|
|
/> |
|
|
@ -1044,15 +995,7 @@ const NetworkInitForm = forwardRef< |
|
|
|
id="network-init-dns-csv" |
|
|
|
id="network-init-dns-csv" |
|
|
|
inputLabelProps={{ isNotifyRequired: true }} |
|
|
|
inputLabelProps={{ isNotifyRequired: true }} |
|
|
|
onChange={({ target: { value } }) => { |
|
|
|
onChange={({ target: { value } }) => { |
|
|
|
const isLocalValid = testInput({ |
|
|
|
testInputSeparate(INPUT_TEST_IDS.dnsCSV, { value }); |
|
|
|
inputs: { [INPUT_TEST_IDS.dnsCSV]: { value } }, |
|
|
|
|
|
|
|
tests: inputTests, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
toggleSubmitDisabled?.call( |
|
|
|
|
|
|
|
null, |
|
|
|
|
|
|
|
isLocalValid && testAllInputs(INPUT_TEST_IDS.dnsCSV), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}} |
|
|
|
}} |
|
|
|
label="Domain name server(s)" |
|
|
|
label="Domain name server(s)" |
|
|
|
/> |
|
|
|
/> |
|
|
|