From eb53d28f6fa9e67996284d30c3f134f3819cb471 Mon Sep 17 00:00:00 2001 From: Arash Date: Tue, 8 Jun 2021 11:07:05 -0400 Subject: [PATCH 1/5] centralized headers with conditional logic --- .../DatabaseModal/DatabaseConnectionForm.tsx | 198 ++++++++++-------- .../data/database/DatabaseModal/index.tsx | 161 +++++++++----- .../data/database/DatabaseModal/styles.ts | 2 - 3 files changed, 208 insertions(+), 153 deletions(-) diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx index 1eac5de10e057..dba212f69376c 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx @@ -16,18 +16,18 @@ * specific language governing permissions and limitations * under the License. */ -import React, { FormEvent, useEvent } from 'react'; +import React, { FormEvent } from 'react'; import { SupersetTheme, JsonObject, t } from '@superset-ui/core'; import { InputProps } from 'antd/lib/input'; import { Switch, Select, Button } from 'src/common/components'; import InfoTooltip from 'src/components/InfoTooltip'; import ValidatedInput from 'src/components/Form/LabeledErrorBoundInput'; import { DeleteFilled } from '@ant-design/icons'; +import Label from 'src/components/Label'; import { formScrollableStyles, validatedFormStyles, CredentialInfoForm, - StyledFormHeader, toggleStyle, infoTooltip, } from './styles'; @@ -49,8 +49,12 @@ export const FormFieldOrder = [ 'credentials_info', ]; +const selectedFile = document.getElementById('selectedFile'); + interface FieldPropTypes { required: boolean; + onParametersChange: (value: any) => string; + onParametersUploadFileChange: (value: any) => string; changeMethods: { onParametersChange: (value: any) => string } & { onChange: (value: any) => string; } & { onParametersUploadFileChange: (value: any) => string }; @@ -59,92 +63,96 @@ interface FieldPropTypes { db?: DatabaseObject; isEditMode?: boolean; sslForced?: boolean; + uploadOption?: string | null; + setUploadOption: (obj: any) => void; + fileToUpload?: string; + setFileToUpload: (obj: any) => void; } const credentialsInfo = ({ - required, changeMethods, - getValidation, - validationErrors, -}: FieldPropTypes) => { - const [uploadOption, setUploadOption] = useState('upload'); - const [fileToUpload, setFileToUpload] = useState(null); - return ( - - - - {uploadOption === 'paste' ? ( -
- Service Account -