/* * Copyright OpenSearch Contributors * * 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://www.apache.org/licenses/LICENSE-2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ import { EuiButton, EuiButtonEmpty, EuiModal, EuiModalBody, EuiModalFooter, EuiModalHeader, EuiModalHeaderTitle, EuiOverlayMask, EuiForm, EuiTextArea, EuiHorizontalRule, } from '@elastic/eui'; import React, { useState } from 'react'; import { Action } from '../../types'; import { FormRow } from '../../utils/form-row'; import { NameRow } from '../../utils/name-row'; interface TenantEditModalDeps { tenantName: string; tenantDescription: string; action: Action; handleClose: () => void; handleSave: (tenantName: string, tenantDescription: string) => Promise; } const TITLE_DICT: { [key: string]: string } = { [Action.create]: 'Create tenant', [Action.edit]: 'Edit tenant', [Action.duplicate]: 'Duplicate tenant', }; export function TenantEditModal(props: TenantEditModalDeps) { const [tenantName, setTenantName] = useState(props.tenantName); const [tenantDescription, setTenantDescription] = React.useState(props.tenantDescription); const [isFormValid, setIsFormValid] = useState(true); const handleTenantDescriptionChange = (e: React.ChangeEvent) => { setTenantDescription(e.target.value); }; return ( {TITLE_DICT[props.action]} Cancel { await props.handleSave(tenantName, tenantDescription); }} fill disabled={!isFormValid} > {props.action === Action.create ? 'Create' : 'Save'} ); }