function HeadNode()

in frontend/src/pages/Configure/HeadNode.js [211:279]


function HeadNode() {
  const rootVolumeSizePath = [...headNodePath, 'LocalStorage', 'RootVolume', 'Size'];
  const rootVolumeSize = useState(rootVolumeSizePath);

  const rootVolumeEncryptedPath = [...headNodePath, 'LocalStorage', 'RootVolume', 'Encrypted'];
  const rootVolumeEncrypted = useState(rootVolumeEncryptedPath);

  const rootVolumeTypePath = [...headNodePath, 'LocalStorage', 'RootVolume', 'VolumeType'];
  const rootVolumeType = useState(rootVolumeTypePath);
  const volumeTypes = ['gp2', 'gp3', 'io1', 'io2', 'sc1', 'stl', 'standard'];

  const imdsSecuredPath = [...headNodePath, 'Imds', 'Secured'];
  const imdsSecured = useState(imdsSecuredPath);


  const subnetPath = [...headNodePath, 'Networking', 'SubnetId'];
  const instanceTypeErrors = useState([...errorsPath, 'instanceType'])
  const subnetErrors = useState([...errorsPath, 'subnet']);
  const rootVolumeErrors = useState([...errorsPath, 'rootVolume']);
  const subnetValue = useState(subnetPath) || "";
  const editing = useState(['app', 'wizard', 'editing']);

  const clearEmpty = () => {
    const headStorage = getState([...headNodePath, 'LocalStorage', 'RootVolume']) || {};
    if(Object.keys(headStorage).length === 0)
      clearState([...headNodePath, 'LocalStorage']);
    console.log("config: ", getState(headNodePath));
  }

  const setRootVolume = (size) => {
    if(size === '')
      clearState(rootVolumeSizePath);
    else
      setState(rootVolumeSizePath, parseInt(size));
    clearEmpty();
  }

  const toggleEncrypted = () => {
    const setEncrypted = !rootVolumeEncrypted;
    if(setEncrypted)
      setState(rootVolumeEncryptedPath, setEncrypted);
    else
      clearState(rootVolumeEncryptedPath);
    clearEmpty();
  }

  const toggleImdsSecured = () => {
    const setImdsSecured = !imdsSecured;
    if(setImdsSecured)
      setState(imdsSecuredPath, setImdsSecured);
    else
      clearState(imdsSecuredPath);
  }

  return (
    <SpaceBetween direction="vertical" size="xs">
      <ColumnLayout columns={2} borders="vertical">
        <Box>
          <FormField
            errorText={instanceTypeErrors}
            label="Head Node Instance Type">
            <InstanceSelect disabled={editing} selectId="head-node" path={[...headNodePath, 'InstanceType']} />
          </FormField>
        </Box>
        <FormField
          label="Subnet ID"
          errorText={subnetErrors}
          description="Subnet ID for HeadNode.">
          <SubnetSelect disabled={editing} value={subnetValue} onChange={(subnetId) => setState(subnetPath, subnetId)}/>