Skip to content

Commit

Permalink
chore(DatasourceEditor): Create Datasource Legacy Editor Feature Flag (
Browse files Browse the repository at this point in the history
…apache#18003)

* a lot of console logs

* adding new feature flag for datasource editor
  • Loading branch information
AAfghahi authored and bwang221 committed Feb 10, 2022
1 parent ebfde4b commit e1285d0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export enum FeatureFlag {
SQLLAB_BACKEND_PERSISTENCE = 'SQLLAB_BACKEND_PERSISTENCE',
THUMBNAILS = 'THUMBNAILS',
LISTVIEWS_DEFAULT_CARD_VIEW = 'LISTVIEWS_DEFAULT_CARD_VIEW',
DISABLE_LEGACY_DATASOURCE_EDITOR = 'DISABLE_LEGACY_DATASOURCE_EDITOR',
ENABLE_REACT_CRUD_VIEWS = 'ENABLE_REACT_CRUD_VIEWS',
DISABLE_DATASET_SOURCE_EDIT = 'DISABLE_DATASET_SOURCE_EDIT',
DISPLAY_MARKDOWN_HTML = 'DISPLAY_MARKDOWN_HTML',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { Provider } from 'react-redux';
import fetchMock from 'fetch-mock';
import thunk from 'redux-thunk';
import sinon from 'sinon';
import { supersetTheme, ThemeProvider } from '@superset-ui/core';
import { supersetTheme, ThemeProvider, FeatureFlag } from '@superset-ui/core';

import waitForComponentToPaint from 'spec/helpers/waitForComponentToPaint';
import Modal from 'src/components/Modal';
Expand Down Expand Up @@ -72,7 +72,9 @@ describe('DatasourceModal', () => {
beforeEach(async () => {
isFeatureEnabledMock = jest
.spyOn(featureFlags, 'isFeatureEnabled')
.mockReturnValue(true);
.mockImplementation(
featureFlag => featureFlag === FeatureFlag.ENABLE_REACT_CRUD_VIEWS,
);
fetchMock.reset();
wrapper = await mountAndWait();
});
Expand Down Expand Up @@ -117,6 +119,7 @@ describe('DatasourceModal', () => {
});

it('renders a legacy data source btn', () => {
featureFlags.DISABLE_LEGACY_DATASOURCE_EDITOR = false;
expect(
wrapper.find('button[data-test="datasource-modal-legacy-edit"]'),
).toExist();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ const DatasourceModal: FunctionComponent<DatasourceModalProps> = ({
});
};

const showLegacyDatasourceEditor =
isFeatureEnabled(FeatureFlag.ENABLE_REACT_CRUD_VIEWS) &&
!isFeatureEnabled(FeatureFlag.DISABLE_LEGACY_DATASOURCE_EDITOR);

return (
<StyledDatasourceModal
show={show}
Expand All @@ -195,7 +199,7 @@ const DatasourceModal: FunctionComponent<DatasourceModalProps> = ({
}
footer={
<>
{isFeatureEnabled(FeatureFlag.ENABLE_REACT_CRUD_VIEWS) && (
{showLegacyDatasourceEditor && (
<Button
buttonSize="small"
buttonStyle="default"
Expand Down
4 changes: 4 additions & 0 deletions superset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ def _try_json_readsha(filepath: str, length: int) -> Optional[str]:
# When using a recent version of Druid that supports JOINs turn this on
"DRUID_JOINS": False,
"DYNAMIC_PLUGINS": False,
# With Superset 2.0, we are updating the default so that the legacy datasource
# editor no longer shows. Currently this is set to false so that the editor
# option does show, but we will be depreciating it.
"DISABLE_LEGACY_DATASOURCE_EDITOR": False,
# For some security concerns, you may need to enforce CSRF protection on
# all query request to explore_json endpoint. In Superset, we use
# `flask-csrf <https://sjl.bitbucket.io/flask-csrf/>`_ add csrf protection
Expand Down

0 comments on commit e1285d0

Please sign in to comment.