Skip to content

Commit

Permalink
adding new feature flag for datasource editor
Browse files Browse the repository at this point in the history
  • Loading branch information
AAfghahi committed Jan 12, 2022
1 parent d1ece46 commit 92578d5
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 11 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
2 changes: 0 additions & 2 deletions superset-frontend/src/SqlLab/components/App/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ import QuerySearch from '../QuerySearch';
class App extends React.PureComponent {
constructor(props) {
super(props);
console.log('this is App');
console.log(props);
this.state = {
hash: window.location.hash,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,6 @@ class SqlEditor extends React.PureComponent {
)}
</Menu>
);

return (
<StyledToolbar className="sql-toolbar" id="js-sql-toolbar">
<div className="leftItems">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ const userOS = detectOS();
class TabbedSqlEditors extends React.PureComponent {
constructor(props) {
super(props);
console.log('this is the tabbed', props);
const sqlLabUrl = '/superset/sqllab';
this.state = {
sqlLabUrl,
Expand All @@ -94,8 +93,6 @@ class TabbedSqlEditors extends React.PureComponent {

componentDidMount() {
// migrate query editor and associated tables state to server
console.log('we here boys');
console.log(this.props);
if (isFeatureEnabled(FeatureFlag.SQLLAB_BACKEND_PERSISTENCE)) {
const localStorageTables = this.props.tables.filter(
table => table.inLocalStorage,
Expand Down Expand Up @@ -437,7 +434,6 @@ TabbedSqlEditors.propTypes = propTypes;
TabbedSqlEditors.defaultProps = defaultProps;

function mapStateToProps({ sqlLab, common, requestedQuery }) {
console.log(sqlLab);
return {
databases: sqlLab.databases,
queryEditors: sqlLab.queryEditors,
Expand Down
1 change: 0 additions & 1 deletion superset-frontend/src/SqlLab/reducers/getInitialState.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ export default function getInitialState({
functionNames: [],
schema: activeTab.schema,
queryLimit: activeTab.query_limit,
remoteId: activeTab.remoteId,
validationResult: {
id: null,
errors: [],
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 92578d5

Please sign in to comment.