/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License 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 React, { FormEvent, useState } from 'react'; import { SupersetTheme, JsonObject, t } from '@superset-ui/core'; import { InputProps } from 'antd/lib/input'; import { Input, Switch, Select, Button } from 'src/common/components'; import InfoTooltip from 'src/components/InfoTooltip'; import ValidatedInput from 'src/components/Form/LabeledErrorBoundInput'; import FormLabel from 'src/components/Form/FormLabel'; import { DeleteFilled, CloseOutlined } from '@ant-design/icons'; import { formScrollableStyles, validatedFormStyles, CredentialInfoForm, toggleStyle, infoTooltip, StyledFooterButton, StyledCatalogTable, } from './styles'; import { CatalogObject, DatabaseForm, DatabaseObject } from '../types'; enum CredentialInfoOptions { jsonUpload, copyPaste, } export const FormFieldOrder = [ 'host', 'port', 'database', 'username', 'password', 'database_name', 'credentials_info', 'catalog', 'query', 'encryption', ]; interface FieldPropTypes { required: boolean; hasTooltip?: boolean; tooltipText?: (valuse: any) => string; onParametersChange: (value: any) => string; onParametersUploadFileChange: (value: any) => string; changeMethods: { onParametersChange: (value: any) => string } & { onChange: (value: any) => string; } & { onQueryChange: (value: any) => string; } & { onParametersUploadFileChange: (value: any) => string } & { onAddTableCatalog: () => void; onRemoveTableCatalog: (idx: number) => void; }; validationErrors: JsonObject | null; getValidation: () => void; db?: DatabaseObject; isEditMode?: boolean; sslForced?: boolean; defaultDBName?: string; editNewDb?: boolean; } const CredentialsInfo = ({ changeMethods, isEditMode, db, editNewDb, }: FieldPropTypes) => { const [uploadOption, setUploadOption] = useState( CredentialInfoOptions.jsonUpload.valueOf(), ); const [fileToUpload, setFileToUpload] = useState( null, ); return ( {!isEditMode && ( <> {t('How do you want to enter service account credentials?')} )} {uploadOption === CredentialInfoOptions.copyPaste || isEditMode || editNewDb ? (
{t('Service Account')}