feat: Move SQLAlchemy url reference to config (#13182)

This commit is contained in:
Hugh A. Miles II 2021-02-18 12:42:15 -05:00 committed by GitHub
parent 1e17ef3410
commit 3c58fc5ef5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 2 deletions

View File

@ -57,6 +57,11 @@ const mockdatabases = [...new Array(3)].map((_, i) => ({
id: i,
}));
jest.mock('react-redux', () => ({
...jest.requireActual('react-redux'),
useSelector: jest.fn(),
}));
const mockUser = {
userId: 1,
};

View File

@ -43,6 +43,11 @@ const dbProps = {
},
};
jest.mock('react-redux', () => ({
...jest.requireActual('react-redux'),
useSelector: jest.fn(),
}));
const DATABASE_ENDPOINT = 'glob:*/api/v1/database/*';
fetchMock.get(DATABASE_ENDPOINT, {});

View File

@ -51,6 +51,7 @@ initFeatureFlags(bootstrap.common.feature_flags);
const store = createStore(
combineReducers({
messageToasts: messageToastReducer,
common: () => common,
}),
{},
compose(applyMiddleware(thunk), initEnhancer(false)),

View File

@ -17,6 +17,7 @@
* under the License.
*/
import React, { FunctionComponent, useState, useEffect } from 'react';
import { useSelector } from 'react-redux';
import { styled, t, SupersetClient } from '@superset-ui/core';
import InfoTooltip from 'src/common/components/InfoTooltip';
import { useSingleViewResource } from 'src/views/CRUD/hooks';
@ -39,8 +40,17 @@ interface DatabaseModalProps {
database?: DatabaseObject | null; // If included, will go into edit mode
}
const DEFAULT_TAB_KEY = '1';
// todo: define common type fully in types file
interface RootState {
common: {
conf: {
SQLALCHEMY_DOCS_URL: string;
};
};
messageToast: Array<Object>;
}
const DEFAULT_TAB_KEY = '1';
const StyledIcon = styled(Icon)`
margin: auto ${({ theme }) => theme.gridUnit * 2}px auto 0;
`;
@ -132,6 +142,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
const [db, setDB] = useState<DatabaseObject | null>(null);
const [isHidden, setIsHidden] = useState<boolean>(true);
const [tabKey, setTabKey] = useState<string>(DEFAULT_TAB_KEY);
const conf = useSelector((state: RootState) => state.common.conf);
const isEditMode = database !== null;
const defaultExtra =
@ -402,7 +413,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
<div className="helper">
{t('Refer to the ')}
<a
href="https://docs.sqlalchemy.org/en/rel_1_2/core/engines.html#"
href={conf?.SQLALCHEMY_DOCS_URL ?? ''}
target="_blank"
rel="noopener noreferrer"
>

View File

@ -1093,6 +1093,9 @@ GLOBAL_ASYNC_QUERIES_POLLING_DELAY = 500
# It will get executed each time when user open a chart's explore view.
DATASET_HEALTH_CHECK = None
# SQLalchemy link doc reference
SQLALCHEMY_DOCS_URL = "https://docs.sqlalchemy.org/en/13/core/engines.html"
# -------------------------------------------------------------------
# * WARNING: STOP EDITING HERE *
# -------------------------------------------------------------------

View File

@ -80,6 +80,7 @@ FRONTEND_CONF_KEYS = (
"DISPLAY_MAX_ROW",
"GLOBAL_ASYNC_QUERIES_TRANSPORT",
"GLOBAL_ASYNC_QUERIES_POLLING_DELAY",
"SQLALCHEMY_DOCS_URL",
)
logger = logging.getLogger(__name__)