From 5af4e61affb554c0f6c29f63a5f4e4ac77644989 Mon Sep 17 00:00:00 2001 From: Beto Dealmeida Date: Mon, 3 Mar 2025 12:55:54 -0500 Subject: [PATCH] feat: improve GSheets OAuth2 (#32048) --- .../DatabaseConnectionForm/EncryptedField.tsx | 66 ++++--------------- .../OAuth2ClientField.test.tsx | 11 +++- .../OAuth2ClientField.tsx | 41 +++++++++--- .../DatabaseConnectionForm/TableCatalog.tsx | 9 ++- .../DatabaseConnectionForm/constants.ts | 6 +- .../databases/DatabaseModal/styles.ts | 27 +++++--- .../src/features/databases/types.ts | 2 +- superset/commands/database/validate.py | 2 +- superset/db_engine_specs/gsheets.py | 42 ++++++++---- superset/models/core.py | 11 +++- superset/sqllab/sql_json_executer.py | 1 - .../integration_tests/databases/api_tests.py | 16 +++++ .../commands/databases/validate_test.py | 1 + tests/unit_tests/databases/api_test.py | 15 +++++ .../db_engine_specs/test_gsheets.py | 33 ++++++++-- .../migrations/shared/catalogs_test.py | 29 +++++++- 16 files changed, 211 insertions(+), 101 deletions(-) diff --git a/superset-frontend/src/features/databases/DatabaseModal/DatabaseConnectionForm/EncryptedField.tsx b/superset-frontend/src/features/databases/DatabaseModal/DatabaseConnectionForm/EncryptedField.tsx index ad80699802e..6bddee3c922 100644 --- a/superset-frontend/src/features/databases/DatabaseModal/DatabaseConnectionForm/EncryptedField.tsx +++ b/superset-frontend/src/features/databases/DatabaseModal/DatabaseConnectionForm/EncryptedField.tsx @@ -19,11 +19,10 @@ import { useRef, useState } from 'react'; import { SupersetTheme, t } from '@superset-ui/core'; import { Button, AntdSelect } from 'src/components'; -import InfoTooltip from 'src/components/InfoTooltip'; import FormLabel from 'src/components/Form/FormLabel'; import Icons from 'src/components/Icons'; import { DatabaseParameters, FieldPropTypes } from '../../types'; -import { infoTooltip, labelMarginBottom, CredentialInfoForm } from '../styles'; +import { infoTooltip, CredentialInfoForm } from '../styles'; enum CredentialInfoOptions { JsonUpload, @@ -38,8 +37,6 @@ export const encryptedCredentialsMap = { bigquery: 'credentials_info', }; -const castStringToBoolean = (optionValue: string) => optionValue === 'true'; - export const EncryptedField = ({ changeMethods, isEditMode, @@ -53,10 +50,7 @@ export const EncryptedField = ({ const [fileToUpload, setFileToUpload] = useState( null, ); - const [isPublic, setIsPublic] = useState(true); - const showCredentialsInfo = - db?.engine === 'gsheets' ? !isEditMode && !isPublic : !isEditMode; - const isEncrypted = isEditMode && db?.masked_encrypted_extra !== '{}'; + const showCredentialsInfo = !isEditMode; const encryptedField = db?.engine && encryptedCredentialsMap[db.engine as keyof typeof encryptedCredentialsMap]; @@ -68,33 +62,9 @@ export const EncryptedField = ({ : paramValue; return ( - {db?.engine === 'gsheets' && ( -
- labelMarginBottom(theme)} - required - > - {t('Type of Google Sheets allowed')} - - - setIsPublic(castStringToBoolean(value)) - } - > - - {t('Publicly shared sheets only')} - - - {t('Public and privately shared sheets')} - - -
- )} {showCredentialsInfo && ( <> - + {t('How do you want to enter service account credentials?')} - {t('Service Account')} + {t('Service Account')}