// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance // with the License. A copy of the License is located at // // http://aws.amazon.com/apache2.0/ // // or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES // OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and // limitations under the License. // Fameworks import * as React from 'react' // UI Elements import { Button, Container, ExpandableSection, FormField, Header, Input, Link, SpaceBetween, Checkbox, } from '@cloudscape-design/components' // State import {setState, useState, getState, clearState} from '../../store' // Components import {HelpTextInput} from './Components' import {Trans, useTranslation} from 'react-i18next' import TitleDescriptionHelpPanel from '../../components/help-panel/TitleDescriptionHelpPanel' import InfoLink from '../../components/InfoLink' // Constants const errorsPath = ['app', 'wizard', 'errors', 'multiUser'] const dsPath = ['app', 'wizard', 'config', 'DirectoryService'] function multiUserValidate() { let valid = true const checkRequired = (key: any) => { const value = getState([...dsPath, key]) if (!value || value === '') { console.log('invalid: ', key, 'setting: ', [...errorsPath, key]) setState([...errorsPath, key], `You must specify a value for ${key}.`) valid = false } else { clearState([...errorsPath, key]) } } checkRequired('DomainName') checkRequired('DomainAddr') checkRequired('PasswordSecretArn') checkRequired('DomainReadOnlyUser') return valid } function HelpToggle({name, configKey, description, help, defaultValue}: any) { let value = useState([...dsPath, configKey]) let error = useState([...errorsPath, configKey]) return ( } /> } >
setState([...dsPath, configKey], !value)} />
) } function AdditionalSssdOptions() { let additionalSssdConfigsErrors = useState([ ...errorsPath, 'additionalSssdConfigs', ]) let additionalSssdConfigs = useState([...dsPath, 'AdditionalSssdConfigs']) || {} let key = useState(['app', 'wizard', 'multiUser', 'key']) let value = useState(['app', 'wizard', 'multiUser', 'value']) const addConfig = () => { if (!key || !value || key === '' || value === '') { setState( [...errorsPath, 'additionalSssdConfigs'], 'You must specify a value for both the key and value.', ) } else { setState([...dsPath, 'AdditionalSssdConfigs', key || ''], value || '') clearState([...errorsPath, 'additionalSssdConfigs']) } } const removeConfig = (key: any) => { let config = {...additionalSssdConfigs} delete config[key] if (Object.keys(config).length === 0) clearState([...dsPath, 'AdditionalSssdConfigs']) else setState([...dsPath, 'AdditionalSssdConfigs'], config) } return ( <>
setState(['app', 'wizard', 'multiUser', 'key'], detail.value) } /> setState(['app', 'wizard', 'multiUser', 'value'], detail.value) } />
{Object.keys(additionalSssdConfigs).map((key, index) => (
{key}: {String(additionalSssdConfigs[key])}
))}
) } function MultiUser() { const {t} = useTranslation() return ( {t('wizard.cluster.multiUser.title')} } > Description link { setState([...dsPath, 'DomainName'], detail.value) multiUserValidate() }} /> { setState([...dsPath, 'DomainAddr'], detail.value) multiUserValidate() }} /> { setState([...dsPath, 'PasswordSecretArn'], detail.value) multiUserValidate() }} /> { setState([...dsPath, 'DomainReadOnlyUser'], detail.value) multiUserValidate() }} /> { setState([...dsPath, 'LdapTlsCaCert'], detail.value) multiUserValidate() }} /> { setState([...dsPath, 'LdapTlsReqCert'], detail.value) multiUserValidate() }} /> { setState([...dsPath, 'LdapAccessFilter'], detail.value) multiUserValidate() }} /> ) } export {MultiUser, multiUserValidate}