This is an automated email from the ASF dual-hosted git repository. hugh pushed a commit to branch hugh/allow-imgs-via-s2text in repository https://gitbox.apache.org/repos/asf/superset.git
commit 7d8dae79489c378a2331cbe63c09d4f7d7b2f556 Author: hughhhh <[email protected]> AuthorDate: Mon Jun 7 15:05:05 2021 -0400 add database images --- .../src/views/CRUD/data/database/DatabaseModal/index.tsx | 12 +++--------- superset-frontend/src/views/CRUD/hooks.ts | 4 ++++ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx index 1e43b04..67ad8ea 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx @@ -40,9 +40,9 @@ import { useSingleViewResource, useAvailableDatabases, useDatabaseValidation, + getDatabaseImages, } from 'src/views/CRUD/hooks'; import { useCommonConf } from 'src/views/CRUD/data/database/state'; -import SupersetText from 'src/utils/textUtils'; import { DatabaseObject, DatabaseForm, @@ -129,13 +129,6 @@ type DBReducerActionType = payload: { configuration_method: CONFIGURATION_METHOD }; }; -const getPreferredImage = async (engine) => { - const config = await SupersetText; - return config.DATABASE_CONNECTION.images[engine]; -}; - -getPreferredImage('postgresql'); - function dbReducer( state: Partial<DatabaseObject> | null, action: DBReducerActionType, @@ -221,6 +214,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({ const [dbName, setDbName] = useState(''); const [isLoading, setLoading] = useState<boolean>(false); const conf = useCommonConf(); + const dbImages = getDatabaseImages(); const isEditMode = !!databaseId; const sslForced = isFeatureEnabled( FeatureFlag.FORCE_DATABASE_CONNECTIONS_SSL, @@ -367,7 +361,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({ className="preferred-item" onClick={() => setDatabaseModel(database.engine)} buttonText={database.name} - icon={getPreferredImage('postgresql')} + icon={dbImages[database.engine]} /> ))} </div> diff --git a/superset-frontend/src/views/CRUD/hooks.ts b/superset-frontend/src/views/CRUD/hooks.ts index aaa3599..0c2b342 100644 --- a/superset-frontend/src/views/CRUD/hooks.ts +++ b/superset-frontend/src/views/CRUD/hooks.ts @@ -26,6 +26,8 @@ import { FilterValue } from 'src/components/ListView/types'; import Chart, { Slice } from 'src/types/Chart'; import copyTextToClipboard from 'src/utils/copy'; import { getClientErrorObject } from 'src/utils/getClientErrorObject'; +import SupersetText from 'src/utils/textUtils'; +import supersetText from 'src/utils/textUtils'; import { FavoriteStatus, ImportResourceName, DatabaseObject } from './types'; interface ListViewResourceState<D extends object = any> { @@ -625,6 +627,8 @@ export const copyQueryLink = ( }); }; +export const getDatabaseImages = () => SupersetText.DB_IMAGES; + export const testDatabaseConnection = ( connection: DatabaseObject, handleErrorMsg: (errorMsg: string) => void,
