parent
adf01f9bdd
commit
20aba7c559
5 changed files with 90 additions and 67 deletions
@ -1,34 +0,0 @@ |
||||
import { ReactElement } from 'react'; |
||||
|
||||
import AnvilIdInputGroup, { |
||||
INPUT_ID_ANVIL_ID_DOMAIN, |
||||
INPUT_ID_ANVIL_ID_PREFIX, |
||||
INPUT_ID_ANVIL_ID_SEQUENCE, |
||||
} from './AnvilIdInputGroup'; |
||||
import AnvilNetworkConfigInputGroup, { |
||||
INPUT_ID_ANVIL_NETWORK_CONFIG_DNS, |
||||
INPUT_ID_ANVIL_NETWORK_CONFIG_MTU, |
||||
INPUT_ID_ANVIL_NETWORK_CONFIG_NTP, |
||||
} from './AnvilNetworkConfigInputGroup'; |
||||
import FlexBox from '../FlexBox'; |
||||
|
||||
const AddAnvilManifestInputGroup = < |
||||
M extends { |
||||
[K in |
||||
| typeof INPUT_ID_ANVIL_ID_DOMAIN |
||||
| typeof INPUT_ID_ANVIL_ID_PREFIX |
||||
| typeof INPUT_ID_ANVIL_ID_SEQUENCE |
||||
| typeof INPUT_ID_ANVIL_NETWORK_CONFIG_DNS |
||||
| typeof INPUT_ID_ANVIL_NETWORK_CONFIG_MTU |
||||
| typeof INPUT_ID_ANVIL_NETWORK_CONFIG_NTP]: string; |
||||
}, |
||||
>({ |
||||
formUtils, |
||||
}: AddAnvilInputGroupProps<M>): ReactElement => ( |
||||
<FlexBox> |
||||
<AnvilIdInputGroup formUtils={formUtils} /> |
||||
<AnvilNetworkConfigInputGroup formUtils={formUtils} /> |
||||
</FlexBox> |
||||
); |
||||
|
||||
export default AddAnvilManifestInputGroup; |
@ -0,0 +1,69 @@ |
||||
import { ReactElement, useState } from 'react'; |
||||
|
||||
import AnvilIdInputGroup, { |
||||
INPUT_ID_ANVIL_ID_DOMAIN, |
||||
INPUT_ID_ANVIL_ID_PREFIX, |
||||
INPUT_ID_ANVIL_ID_SEQUENCE, |
||||
} from './AnvilIdInputGroup'; |
||||
import AnvilNetworkConfigInputGroup, { |
||||
INPUT_ID_ANVIL_NETWORK_CONFIG_DNS, |
||||
INPUT_ID_ANVIL_NETWORK_CONFIG_MTU, |
||||
INPUT_ID_ANVIL_NETWORK_CONFIG_NTP, |
||||
} from './AnvilNetworkConfigInputGroup'; |
||||
import FlexBox from '../FlexBox'; |
||||
|
||||
const DEFAULT_NETWORKS: AnvilNetworkConfigNetworkList = { |
||||
bcn1: { |
||||
networkMinIp: '', |
||||
networkNumber: 1, |
||||
networkSubnetMask: '', |
||||
networkType: 'bcn', |
||||
}, |
||||
sn1: { |
||||
networkMinIp: '', |
||||
networkNumber: 1, |
||||
networkSubnetMask: '', |
||||
networkType: 'sn', |
||||
}, |
||||
ifn1: { |
||||
networkMinIp: '', |
||||
networkNumber: 1, |
||||
networkSubnetMask: '', |
||||
networkType: 'ifn', |
||||
}, |
||||
}; |
||||
|
||||
const AddManifestInputGroup = < |
||||
M extends { |
||||
[K in |
||||
| typeof INPUT_ID_ANVIL_ID_DOMAIN |
||||
| typeof INPUT_ID_ANVIL_ID_PREFIX |
||||
| typeof INPUT_ID_ANVIL_ID_SEQUENCE |
||||
| typeof INPUT_ID_ANVIL_NETWORK_CONFIG_DNS |
||||
| typeof INPUT_ID_ANVIL_NETWORK_CONFIG_MTU |
||||
| typeof INPUT_ID_ANVIL_NETWORK_CONFIG_NTP]: string; |
||||
}, |
||||
>({ |
||||
formUtils, |
||||
previous: { networkConfig: previousNetworkConfig = {} } = {}, |
||||
}: AddManifestInputGroupProps<M>): ReactElement => { |
||||
const { networks: previousNetworkList = DEFAULT_NETWORKS } = |
||||
previousNetworkConfig; |
||||
|
||||
const [networkList, setNetworkList] = |
||||
useState<AnvilNetworkConfigNetworkList>(previousNetworkList); |
||||
|
||||
return ( |
||||
<FlexBox> |
||||
<AnvilIdInputGroup formUtils={formUtils} /> |
||||
<AnvilNetworkConfigInputGroup |
||||
formUtils={formUtils} |
||||
networkList={networkList} |
||||
previous={previousNetworkConfig} |
||||
setNetworkList={setNetworkList} |
||||
/> |
||||
</FlexBox> |
||||
); |
||||
}; |
||||
|
||||
export default AddManifestInputGroup; |
Loading…
Reference in new issue