Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Move SQLAlchemy url reference to config #13182

Merged
merged 9 commits into from
Feb 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, {});
Expand Down
1 change: 1 addition & 0 deletions superset-frontend/src/views/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ initFeatureFlags(bootstrap.common.feature_flags);
const store = createStore(
combineReducers({
messageToasts: messageToastReducer,
common: () => common,
}),
{},
compose(applyMiddleware(thunk), initEnhancer(false)),
Expand Down
15 changes: 13 additions & 2 deletions superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
`;
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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"
>
Expand Down
3 changes: 3 additions & 0 deletions superset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,9 @@ class CeleryConfig: # pylint: disable=too-few-public-methods
# 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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noice!


# -------------------------------------------------------------------
# * WARNING: STOP EDITING HERE *
# -------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions superset/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"DISPLAY_MAX_ROW",
"GLOBAL_ASYNC_QUERIES_TRANSPORT",
"GLOBAL_ASYNC_QUERIES_POLLING_DELAY",
"SQLALCHEMY_DOCS_URL",
)
logger = logging.getLogger(__name__)

Expand Down