in frontend/src/old-pages/Configure/Cluster.tsx [345:435]
function Cluster() {
const {t} = useTranslation()
const editing = useState(['app', 'wizard', 'editing'])
let config = useState(configPath)
let clusterConfig = useState(['app', 'wizard', 'clusterConfigYaml']) || ''
let wizardLoaded = useState(['app', 'wizard', 'loaded'])
let multiUserEnabled = useState(['app', 'wizard', 'multiUser']) || false
let defaultRegion = useState(['aws', 'region']) || ''
const loading = !!useState(loadingPath)
const region = useState(['app', 'selectedRegion']) || defaultRegion
const isMultiuserClusterActive = useFeatureFlag('multiuser_cluster')
const isMultipleInstanceTypesActive = useFeatureFlag(
'queues_multiple_instance_types',
)
useHelpPanel(<ClusterPropertiesHelpPanel />)
React.useEffect(() => {
// Don't overwrite the config if we go back, still gets overwritten
// after going forward so need to consider better way of handling this
if (clusterConfig) return
// Load these values once when creating the component
if (!wizardLoaded) {
setState(['app', 'wizard', 'loaded'], true)
if (!config) {
initWizardState(config, region, isMultipleInstanceTypesActive)
}
}
}, [
region,
config,
clusterConfig,
wizardLoaded,
isMultipleInstanceTypesActive,
])
const handleMultiUserChange: NonCancelableEventHandler<
CheckboxProps.ChangeDetail
> = ({detail}) => {
if (!detail.checked) {
clearState(['app', 'wizard', 'config', 'DirectoryService'])
}
setState(['app', 'wizard', 'multiUser'], detail.checked)
}
return loading ? (
<Loading />
) : (
<SpaceBetween direction="vertical" size="l">
<Container
header={
<Header
variant="h2"
info={<InfoLink helpPanel={<ClusterPropertiesHelpPanel />} />}
>
{t('wizard.cluster.clusterProperties.title')}
</Header>
}
>
<SpaceBetween direction="vertical" size="m">
<ClusterNameField />
<RegionSelect />
<OsFormField />
<CustomAMISettings
basePath={configPath}
appPath={['app', 'wizard']}
errorsPath={errorsPath}
validate={clusterValidate}
/>
<VpcSelect />
<ImdsSupportFormField />
{isMultiuserClusterActive && (
<FormField>
<CheckboxWithHelpPanel
disabled={editing}
checked={multiUserEnabled}
onChange={handleMultiUserChange}
helpPanel={<MultiUserHelpPanel />}
>
<Trans i18nKey="wizard.cluster.multiUser.checkbox.label" />
</CheckboxWithHelpPanel>
</FormField>
)}
</SpaceBetween>
</Container>
{multiUserEnabled && <MultiUser />}
<SlurmSettings />
</SpaceBetween>
)
}