From f6291545fb8140466315c4af8c5aec66b47d2b76 Mon Sep 17 00:00:00 2001 From: Jesse Yang Date: Thu, 17 Mar 2022 21:51:47 -0700 Subject: [PATCH] chore: turn on SQLLAB_BACKEND_PERSISTENCE by default (#19107) * chore: turn on SQLLAB_BACKEND_PERSISTENCE by default * Rewrite SQL tabs test to make it more rerunnable --- .github/workflows/bashlib.sh | 14 ++-- UPDATING.md | 4 +- .../cypress/integration/sqllab/tabs.test.js | 65 ------------------- .../cypress/integration/sqllab/tabs.test.ts | 60 +++++++++++++++++ .../components/TabbedSqlEditors/index.jsx | 4 +- .../src/components/Checkbox/Checkbox.tsx | 4 +- .../src/components/Dropdown/index.tsx | 2 +- superset/config.py | 2 +- ...test_config_sqllab_backend_persist_off.py} | 2 +- 9 files changed, 74 insertions(+), 83 deletions(-) delete mode 100644 superset-frontend/cypress-base/cypress/integration/sqllab/tabs.test.js create mode 100644 superset-frontend/cypress-base/cypress/integration/sqllab/tabs.test.ts rename tests/integration_tests/{superset_test_config_sqllab_backend_persist.py => superset_test_config_sqllab_backend_persist_off.py} (94%) diff --git a/.github/workflows/bashlib.sh b/.github/workflows/bashlib.sh index 0f9a8fd10e01..32e89be43174 100644 --- a/.github/workflows/bashlib.sh +++ b/.github/workflows/bashlib.sh @@ -38,10 +38,10 @@ default-setup-command() { } apt-get-install() { - say "::group::apt-get install dependencies" - sudo apt-get update && sudo apt-get install --yes \ - libsasl2-dev - say "::endgroup::" + say "::group::apt-get install dependencies" + sudo apt-get update && sudo apt-get install --yes \ + libsasl2-dev + say "::endgroup::" } pip-upgrade() { @@ -161,7 +161,7 @@ cypress-run() { if [[ -z $CYPRESS_KEY ]]; then $cypress --spec "cypress/integration/$page" --browser "$browser" else - export CYPRESS_RECORD_KEY=`echo $CYPRESS_KEY | base64 --decode` + export CYPRESS_RECORD_KEY=$(echo $CYPRESS_KEY | base64 --decode) # additional flags for Cypress dashboard recording $cypress --spec "cypress/integration/$page" --browser "$browser" \ --record --group "$group" --tag "${GITHUB_REPOSITORY},${GITHUB_EVENT_NAME}" \ @@ -190,8 +190,8 @@ cypress-run-all() { cat "$flasklog" say "::endgroup::" - # Rerun SQL Lab tests with backend persist enabled - export SUPERSET_CONFIG=tests.integration_tests.superset_test_config_sqllab_backend_persist + # Rerun SQL Lab tests with backend persist disabled + export SUPERSET_CONFIG=tests.integration_tests.superset_test_config_sqllab_backend_persist_off # Restart Flask with new configs kill $flaskProcessId diff --git a/UPDATING.md b/UPDATING.md index 8d17dab043d8..07193a462d3b 100644 --- a/UPDATING.md +++ b/UPDATING.md @@ -35,10 +35,10 @@ assists people when migrating to a new version. - [17984](https://github.com/apache/superset/pull/17984): Default Flask SECRET_KEY has changed for security reasons. You should always override with your own secret. Set `PREVIOUS_SECRET_KEY` (ex: PREVIOUS_SECRET_KEY = "\2\1thisismyscretkey\1\2\\e\\y\\y\\h") with your previous key and use `superset re-encrypt-secrets` to rotate you current secrets - [15254](https://github.com/apache/superset/pull/15254): Previously `QUERY_COST_FORMATTERS_BY_ENGINE`, `SQL_VALIDATORS_BY_ENGINE` and `SCHEDULED_QUERIES` were expected to be defined in the feature flag dictionary in the `config.py` file. These should now be defined as a top-level config, with the feature flag dictionary being reserved for boolean only values. - [17539](https://github.com/apache/superset/pull/17539): all Superset CLI commands (init, load_examples and etc) require setting the FLASK_APP environment variable (which is set by default when `.flaskenv` is loaded) -- [18970](https://github.com/apache/superset/pull/18970): Changes feature -flag for the legacy datasource editor (DISABLE_LEGACY_DATASOURCE_EDITOR) in config.py to True, thus disabling the feature from being shown in the client. +- [18970](https://github.com/apache/superset/pull/18970): Changes feature flag for the legacy datasource editor (DISABLE_LEGACY_DATASOURCE_EDITOR) in config.py to True, thus disabling the feature from being shown in the client. - [19017](https://github.com/apache/superset/pull/19017): Removes Python 3.7 support. - [19142](https://github.com/apache/superset/pull/19142): Changes feature flag for versioned export(VERSIONED_EXPORT) to be true. +- [19107](https://github.com/apache/superset/pull/19107): Feature flag `SQLLAB_BACKEND_PERSISTENCE` is now on by default, which enables persisting SQL Lab tabs in the backend instead of the browser's `localStorage`. ### Potential Downtime diff --git a/superset-frontend/cypress-base/cypress/integration/sqllab/tabs.test.js b/superset-frontend/cypress-base/cypress/integration/sqllab/tabs.test.js deleted file mode 100644 index 24dd074992b0..000000000000 --- a/superset-frontend/cypress-base/cypress/integration/sqllab/tabs.test.js +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -describe('SqlLab query tabs', () => { - beforeEach(() => { - cy.login(); - cy.visit('/superset/sqllab'); - }); - - it('allows you to create a tab', () => { - cy.get('[data-test="sql-editor-tabs"]').then(tabList => { - const initialTabCount = tabList.length; - // add tab - cy.get('[data-test="add-tab-icon"]').first().click(); - // wait until we find the new tab - cy.get('[data-test="sql-editor-tabs"]') - .children() - .eq(0) - .contains(`Untitled Query ${initialTabCount}`); - cy.get('[data-test="sql-editor-tabs"]') - .children() - .eq(0) - .contains(`Untitled Query ${initialTabCount + 1}`); - }); - }); - - it('allows you to close a tab', () => { - cy.get('[data-test="sql-editor-tabs"]') - .children() - .then(tabListA => { - const initialTabCount = tabListA.length; - - // open the tab dropdown to remove - cy.get('[data-test="dropdown-toggle-button"]') - .children() - .first() - .click({ - force: true, - }); - - // first item is close - cy.get('[data-test="close-tab-menu-option"]').click(); - - cy.get('[data-test="sql-editor-tabs"]').should( - 'have.length', - initialTabCount - 1, - ); - }); - }); -}); diff --git a/superset-frontend/cypress-base/cypress/integration/sqllab/tabs.test.ts b/superset-frontend/cypress-base/cypress/integration/sqllab/tabs.test.ts new file mode 100644 index 000000000000..0e85664cb785 --- /dev/null +++ b/superset-frontend/cypress-base/cypress/integration/sqllab/tabs.test.ts @@ -0,0 +1,60 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +describe('SqlLab query tabs', () => { + beforeEach(() => { + cy.login(); + cy.visit('/superset/sqllab'); + }); + + it('allows you to create and close a tab', () => { + const tablistSelector = '[data-test="sql-editor-tabs"] > [role="tablist"]'; + const tabSelector = `${tablistSelector} [role="tab"]`; + cy.get(tabSelector).then(tabs => { + const initialTabCount = tabs.length; + const initialUntitledCount = Math.max( + 0, + ...tabs + .map((i, tabItem) => + Number(tabItem.textContent?.match(/Untitled Query (\d+)/)?.[1]), + ) + .toArray(), + ); + + // add two new tabs + cy.get('[data-test="add-tab-icon"]:visible:last').click(); + cy.contains('[role="tab"]', `Untitled Query ${initialUntitledCount + 1}`); + cy.get(tabSelector).should('have.length', initialTabCount + 1); + + cy.get('[data-test="add-tab-icon"]:visible:last').click(); + cy.contains('[role="tab"]', `Untitled Query ${initialUntitledCount + 2}`); + cy.get(tabSelector).should('have.length', initialTabCount + 2); + + // close the tabs + cy.get(`${tabSelector}:last [data-test="dropdown-trigger"]`).click({ + force: true, + }); + cy.get('[data-test="close-tab-menu-option"]').click(); + cy.get(tabSelector).should('have.length', initialTabCount + 1); + cy.contains('[role="tab"]', `Untitled Query ${initialUntitledCount + 1}`); + + cy.get(`${tablistSelector} [aria-label="remove"]:last`).click(); + cy.get(tabSelector).should('have.length', initialTabCount); + }); + }); +}); diff --git a/superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.jsx b/superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.jsx index 11c6fa8b6c09..8c20a493b087 100644 --- a/superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.jsx +++ b/superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.jsx @@ -386,9 +386,7 @@ class TabbedSqlEditors extends React.PureComponent { ); const tabHeader = ( -
- -
+ {qe.title} {' '}
); diff --git a/superset-frontend/src/components/Checkbox/Checkbox.tsx b/superset-frontend/src/components/Checkbox/Checkbox.tsx index a256677be616..7162929a967f 100644 --- a/superset-frontend/src/components/Checkbox/Checkbox.tsx +++ b/superset-frontend/src/components/Checkbox/Checkbox.tsx @@ -20,7 +20,7 @@ import React from 'react'; import { styled } from '@superset-ui/core'; import { CheckboxChecked, CheckboxUnchecked } from 'src/components/Checkbox'; -interface CheckboxProps { +export interface CheckboxProps { checked: boolean; onChange: (val?: boolean) => void; style?: React.CSSProperties; @@ -49,5 +49,3 @@ export default function Checkbox({ checked, onChange, style }: CheckboxProps) { ); } - -export type { CheckboxProps }; diff --git a/superset-frontend/src/components/Dropdown/index.tsx b/superset-frontend/src/components/Dropdown/index.tsx index fdfa9f945c6c..e5d5f9f8526c 100644 --- a/superset-frontend/src/components/Dropdown/index.tsx +++ b/superset-frontend/src/components/Dropdown/index.tsx @@ -72,7 +72,7 @@ export interface DropdownProps { export const Dropdown = ({ overlay, ...rest }: DropdownProps) => ( - + diff --git a/superset/config.py b/superset/config.py index efb5178679d4..775765d08f0a 100644 --- a/superset/config.py +++ b/superset/config.py @@ -391,7 +391,7 @@ def _try_json_readsha(filepath: str, length: int) -> Optional[str]: "REMOVE_SLICE_LEVEL_LABEL_COLORS": False, "SHARE_QUERIES_VIA_KV_STORE": False, "TAGGING_SYSTEM": False, - "SQLLAB_BACKEND_PERSISTENCE": False, + "SQLLAB_BACKEND_PERSISTENCE": True, "LISTVIEWS_DEFAULT_CARD_VIEW": False, # Enables the replacement React views for all the FAB views (list, edit, show) with # designs introduced in https://github.com/apache/superset/issues/8976 diff --git a/tests/integration_tests/superset_test_config_sqllab_backend_persist.py b/tests/integration_tests/superset_test_config_sqllab_backend_persist_off.py similarity index 94% rename from tests/integration_tests/superset_test_config_sqllab_backend_persist.py rename to tests/integration_tests/superset_test_config_sqllab_backend_persist_off.py index 41a720deb695..9f6dd2ead1fa 100644 --- a/tests/integration_tests/superset_test_config_sqllab_backend_persist.py +++ b/tests/integration_tests/superset_test_config_sqllab_backend_persist_off.py @@ -21,4 +21,4 @@ from .superset_test_config import * -FEATURE_FLAGS = {"SQLLAB_BACKEND_PERSISTENCE": True} +FEATURE_FLAGS = {"SQLLAB_BACKEND_PERSISTENCE": False}