|
|
@ -1,16 +1,31 @@ |
|
|
|
import { FC } from 'react'; |
|
|
|
import { ReactElement } from 'react'; |
|
|
|
|
|
|
|
|
|
|
|
import Grid from '../Grid'; |
|
|
|
import Grid from '../Grid'; |
|
|
|
import InputWithRef from '../InputWithRef'; |
|
|
|
import InputWithRef from '../InputWithRef'; |
|
|
|
import OutlinedInputWithLabel from '../OutlinedInputWithLabel'; |
|
|
|
import OutlinedInputWithLabel from '../OutlinedInputWithLabel'; |
|
|
|
|
|
|
|
import { |
|
|
|
|
|
|
|
buildIPAddressTestBatch, |
|
|
|
|
|
|
|
buildPeacefulStringTestBatch, |
|
|
|
|
|
|
|
} from '../../lib/test_input'; |
|
|
|
|
|
|
|
|
|
|
|
const INPUT_ID_UPS_IP = 'common-ups-input-ip-address'; |
|
|
|
const INPUT_ID_UPS_IP = 'common-ups-input-ip-address'; |
|
|
|
const INPUT_ID_UPS_NAME = 'common-ups-input-host-name'; |
|
|
|
const INPUT_ID_UPS_NAME = 'common-ups-input-host-name'; |
|
|
|
|
|
|
|
|
|
|
|
const CommonUpsInputGroup: FC<CommonUpsInputGroupProps> = ({ |
|
|
|
const INPUT_LABEL_UPS_IP = 'IP address'; |
|
|
|
|
|
|
|
const INPUT_LABEL_UPS_NAME = 'Host name'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const CommonUpsInputGroup = < |
|
|
|
|
|
|
|
M extends { |
|
|
|
|
|
|
|
[K in typeof INPUT_ID_UPS_IP | typeof INPUT_ID_UPS_NAME]: string; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
>({ |
|
|
|
|
|
|
|
formUtils: { |
|
|
|
|
|
|
|
buildFinishInputTestBatchFunction, |
|
|
|
|
|
|
|
buildInputFirstRenderFunction, |
|
|
|
|
|
|
|
msgSetters, |
|
|
|
|
|
|
|
}, |
|
|
|
previous: { upsIPAddress: previousIpAddress, upsName: previousUpsName } = {}, |
|
|
|
previous: { upsIPAddress: previousIpAddress, upsName: previousUpsName } = {}, |
|
|
|
}) => ( |
|
|
|
}: CommonUpsInputGroupProps<M>): ReactElement => ( |
|
|
|
<> |
|
|
|
|
|
|
|
<Grid |
|
|
|
<Grid |
|
|
|
columns={{ xs: 1, sm: 2 }} |
|
|
|
columns={{ xs: 1, sm: 2 }} |
|
|
|
layout={{ |
|
|
|
layout={{ |
|
|
@ -20,10 +35,26 @@ const CommonUpsInputGroup: FC<CommonUpsInputGroupProps> = ({ |
|
|
|
input={ |
|
|
|
input={ |
|
|
|
<OutlinedInputWithLabel |
|
|
|
<OutlinedInputWithLabel |
|
|
|
id={INPUT_ID_UPS_NAME} |
|
|
|
id={INPUT_ID_UPS_NAME} |
|
|
|
label="Host name" |
|
|
|
label={INPUT_LABEL_UPS_NAME} |
|
|
|
value={previousUpsName} |
|
|
|
value={previousUpsName} |
|
|
|
/> |
|
|
|
/> |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
inputTestBatch={buildPeacefulStringTestBatch( |
|
|
|
|
|
|
|
INPUT_LABEL_UPS_NAME, |
|
|
|
|
|
|
|
() => { |
|
|
|
|
|
|
|
msgSetters[INPUT_ID_UPS_NAME](); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
onFinishBatch: |
|
|
|
|
|
|
|
buildFinishInputTestBatchFunction(INPUT_ID_UPS_NAME), |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
(message) => { |
|
|
|
|
|
|
|
msgSetters[INPUT_ID_UPS_NAME]({ |
|
|
|
|
|
|
|
children: message, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
)} |
|
|
|
|
|
|
|
onFirstRender={buildInputFirstRenderFunction(INPUT_ID_UPS_NAME)} |
|
|
|
required |
|
|
|
required |
|
|
|
/> |
|
|
|
/> |
|
|
|
), |
|
|
|
), |
|
|
@ -34,10 +65,26 @@ const CommonUpsInputGroup: FC<CommonUpsInputGroupProps> = ({ |
|
|
|
input={ |
|
|
|
input={ |
|
|
|
<OutlinedInputWithLabel |
|
|
|
<OutlinedInputWithLabel |
|
|
|
id={INPUT_ID_UPS_IP} |
|
|
|
id={INPUT_ID_UPS_IP} |
|
|
|
label="IP address" |
|
|
|
label={INPUT_LABEL_UPS_IP} |
|
|
|
value={previousIpAddress} |
|
|
|
value={previousIpAddress} |
|
|
|
/> |
|
|
|
/> |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
inputTestBatch={buildIPAddressTestBatch( |
|
|
|
|
|
|
|
INPUT_LABEL_UPS_IP, |
|
|
|
|
|
|
|
() => { |
|
|
|
|
|
|
|
msgSetters[INPUT_ID_UPS_IP](); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
onFinishBatch: |
|
|
|
|
|
|
|
buildFinishInputTestBatchFunction(INPUT_ID_UPS_IP), |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
(message) => { |
|
|
|
|
|
|
|
msgSetters[INPUT_ID_UPS_IP]({ |
|
|
|
|
|
|
|
children: message, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
)} |
|
|
|
|
|
|
|
onFirstRender={buildInputFirstRenderFunction(INPUT_ID_UPS_IP)} |
|
|
|
required |
|
|
|
required |
|
|
|
/> |
|
|
|
/> |
|
|
|
), |
|
|
|
), |
|
|
@ -45,9 +92,13 @@ const CommonUpsInputGroup: FC<CommonUpsInputGroupProps> = ({ |
|
|
|
}} |
|
|
|
}} |
|
|
|
spacing="1em" |
|
|
|
spacing="1em" |
|
|
|
/> |
|
|
|
/> |
|
|
|
</> |
|
|
|
|
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
export { INPUT_ID_UPS_IP, INPUT_ID_UPS_NAME }; |
|
|
|
export { |
|
|
|
|
|
|
|
INPUT_ID_UPS_IP, |
|
|
|
|
|
|
|
INPUT_ID_UPS_NAME, |
|
|
|
|
|
|
|
INPUT_LABEL_UPS_IP, |
|
|
|
|
|
|
|
INPUT_LABEL_UPS_NAME, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
export default CommonUpsInputGroup; |
|
|
|
export default CommonUpsInputGroup; |
|
|
|