You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2024/02/27 20:44:17 UTC

(superset) branch 3.1 updated (303b654a60 -> 38bc2d3b02)

This is an automated email from the ASF dual-hosted git repository.

michaelsmolina pushed a change to branch 3.1
in repository https://gitbox.apache.org/repos/asf/superset.git


    from 303b654a60 fix: setting important lower bounds versions on requirements (#27167)
     new 465bce1480 fix: bump FAB to 4.4.1 (perf issue) (#27233)
     new 51f3591139 chore: Removes Chromatic workflow and dependencies (#27232)
     new e687525524 fix(sqlglot): Address regressions introduced in #26476 (#27217)
     new a1ebdd70b1 fix(reports): fixing unit test  (#27236)
     new 744e403b0c fix(trino): bumping trino to fix hudi schema fetching (#27213)
     new 0d2cf7c938 fix: Sorting charts/dashboards makes the applied filters ineffective (#27258)
     new dc493fe7af fix(import-datasources): Use "admin" user as default for importing datasources (#27154)
     new 38bc2d3b02 fix: Inoperable dashboard filter slider when range is <= 1 (#27271)

The 8 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .github/workflows/chromatic-master.yml             | 72 ----------------------
 requirements/base.txt                              |  6 +-
 requirements/development.txt                       | 11 +---
 requirements/testing.txt                           |  2 +-
 setup.py                                           |  4 +-
 .../cypress/e2e/chart_list/list.test.ts            |  7 +++
 .../cypress/e2e/dashboard_list/list.test.ts        |  7 +++
 superset-frontend/package-lock.json                | 30 +--------
 superset-frontend/package.json                     |  3 -
 .../shared/components/createQueryStory.tsx         |  3 -
 .../superset-ui-connection/ConnectionStories.tsx   |  6 +-
 .../src/components/ListView/CardSortSelect.tsx     | 18 +++---
 .../src/components/ListView/ListView.tsx           |  9 ++-
 superset-frontend/src/components/ListView/types.ts |  4 +-
 superset-frontend/src/components/ListView/utils.ts |  4 +-
 .../filters/components/Range/RangeFilterPlugin.tsx | 14 +++++
 superset-frontend/src/types/dom-to-pdf.d.ts        |  6 +-
 superset/cli/importexport.py                       | 39 +++++++-----
 superset/sql_parse.py                              | 17 +++--
 tests/unit_tests/sql_parse_tests.py                | 10 +--
 20 files changed, 99 insertions(+), 173 deletions(-)
 delete mode 100644 .github/workflows/chromatic-master.yml


(superset) 08/08: fix: Inoperable dashboard filter slider when range is <= 1 (#27271)

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelsmolina pushed a commit to branch 3.1
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 38bc2d3b02aabdf2599d6b29fb56c728b7decaa8
Author: Michael S. Molina <70...@users.noreply.github.com>
AuthorDate: Tue Feb 27 11:38:18 2024 -0500

    fix: Inoperable dashboard filter slider when range is <= 1 (#27271)
    
    Co-authored-by: Justin Francos <jf...@manifold.ai>
    (cherry picked from commit ce9e4b4b776ba8071aab2ede538b51828250bb2b)
---
 .../src/filters/components/Range/RangeFilterPlugin.tsx     | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx b/superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx
index 5c8533dd1e..9b30cd4824 100644
--- a/superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx
+++ b/superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx
@@ -300,6 +300,16 @@ export default function RangeFilterPlugin(props: PluginFilterRangeProps) {
     }
   }, [enableSingleExactValue]);
 
+  const MIN_NUM_STEPS = 20;
+  const stepHeuristic = (min: number, max: number) => {
+    const maxStepSize = (max - min) / MIN_NUM_STEPS;
+    // normalizedStepSize: .06 -> .01, .003 -> .001
+    const normalizedStepSize = `1E${Math.floor(Math.log10(maxStepSize))}`;
+    return Math.min(1, parseFloat(normalizedStepSize));
+  };
+
+  const step = max - min <= 1 ? stepHeuristic(min, max) : 1;
+
   return (
     <FilterPluginStyle height={height} width={width}>
       {Number.isNaN(Number(min)) || Number.isNaN(Number(max)) ? (
@@ -323,6 +333,7 @@ export default function RangeFilterPlugin(props: PluginFilterRangeProps) {
               <AntdSlider
                 min={min}
                 max={max}
+                step={step}
                 value={minMax[maxIndex]}
                 tipFormatter={tipFormatter}
                 marks={marks}
@@ -335,6 +346,7 @@ export default function RangeFilterPlugin(props: PluginFilterRangeProps) {
                 validateStatus={filterState.validateStatus}
                 min={min}
                 max={max}
+                step={step}
                 value={minMax[minIndex]}
                 tipFormatter={tipFormatter}
                 marks={marks}
@@ -346,6 +358,7 @@ export default function RangeFilterPlugin(props: PluginFilterRangeProps) {
               <AntdSlider
                 min={min}
                 max={max}
+                step={step}
                 included={false}
                 value={minMax[minIndex]}
                 tipFormatter={tipFormatter}
@@ -359,6 +372,7 @@ export default function RangeFilterPlugin(props: PluginFilterRangeProps) {
                 range
                 min={min}
                 max={max}
+                step={step}
                 value={minMax}
                 onAfterChange={handleAfterChange}
                 onChange={handleChange}


(superset) 03/08: fix(sqlglot): Address regressions introduced in #26476 (#27217)

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelsmolina pushed a commit to branch 3.1
in repository https://gitbox.apache.org/repos/asf/superset.git

commit e687525524d406aa0a08a35af9a9fe6a02bf1167
Author: John Bodley <45...@users.noreply.github.com>
AuthorDate: Sat Feb 24 08:47:36 2024 +1300

    fix(sqlglot): Address regressions introduced in #26476 (#27217)
    
    (cherry picked from commit 2c564817f1978e34770e02034a7a4c02e1bfdc9f)
---
 superset/sql_parse.py               | 17 +++++++++++------
 tests/unit_tests/sql_parse_tests.py | 10 ++++++----
 2 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/superset/sql_parse.py b/superset/sql_parse.py
index 7b89ab8f0e..c85afc9460 100644
--- a/superset/sql_parse.py
+++ b/superset/sql_parse.py
@@ -28,7 +28,7 @@ import sqlparse
 from sqlalchemy import and_
 from sqlglot import exp, parse, parse_one
 from sqlglot.dialects import Dialects
-from sqlglot.errors import ParseError
+from sqlglot.errors import SqlglotError
 from sqlglot.optimizer.scope import Scope, ScopeType, traverse_scope
 from sqlparse import keywords
 from sqlparse.lexer import Lexer
@@ -287,7 +287,7 @@ class ParsedQuery:
         """
         try:
             statements = parse(self.stripped(), dialect=self._dialect)
-        except ParseError:
+        except SqlglotError:
             logger.warning("Unable to parse SQL (%s): %s", self._dialect, self.sql)
             return set()
 
@@ -319,12 +319,17 @@ class ParsedQuery:
         elif isinstance(statement, exp.Command):
             # Commands, like `SHOW COLUMNS FROM foo`, have to be converted into a
             # `SELECT` statetement in order to extract tables.
-            literal = statement.find(exp.Literal)
-            if not literal:
+            if not (literal := statement.find(exp.Literal)):
                 return set()
 
-            pseudo_query = parse_one(f"SELECT {literal.this}", dialect=self._dialect)
-            sources = pseudo_query.find_all(exp.Table)
+            try:
+                pseudo_query = parse_one(
+                    f"SELECT {literal.this}",
+                    dialect=self._dialect,
+                )
+                sources = pseudo_query.find_all(exp.Table)
+            except SqlglotError:
+                return set()
         else:
             sources = [
                 source
diff --git a/tests/unit_tests/sql_parse_tests.py b/tests/unit_tests/sql_parse_tests.py
index f650b77734..2d2448c2fa 100644
--- a/tests/unit_tests/sql_parse_tests.py
+++ b/tests/unit_tests/sql_parse_tests.py
@@ -271,6 +271,7 @@ def test_extract_tables_illdefined() -> None:
     assert extract_tables("SELECT * FROM catalogname..tbname") == {
         Table(table="tbname", schema=None, catalog="catalogname")
     }
+    assert extract_tables('SELECT * FROM "tbname') == set()
 
 
 def test_extract_tables_show_tables_from() -> None:
@@ -558,6 +559,10 @@ def test_extract_tables_multistatement() -> None:
         Table("t1"),
         Table("t2"),
     }
+    assert extract_tables(
+        "ADD JAR file:///hive.jar; SELECT * FROM t1;",
+        engine="hive",
+    ) == {Table("t1")}
 
 
 def test_extract_tables_complex() -> None:
@@ -1816,10 +1821,7 @@ def test_extract_table_references(mocker: MockerFixture) -> None:
     # test falling back to sqlparse
     logger = mocker.patch("superset.sql_parse.logger")
     sql = "SELECT * FROM table UNION ALL SELECT * FROM other_table"
-    assert extract_table_references(
-        sql,
-        "trino",
-    ) == {
+    assert extract_table_references(sql, "trino") == {
         Table(table="table", schema=None, catalog=None),
         Table(table="other_table", schema=None, catalog=None),
     }


(superset) 05/08: fix(trino): bumping trino to fix hudi schema fetching (#27213)

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelsmolina pushed a commit to branch 3.1
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 744e403b0cac72c0c52d2dbf88fe7c107c786fe3
Author: Evan Rusackas <ev...@preset.io>
AuthorDate: Fri Feb 23 13:25:21 2024 -0700

    fix(trino): bumping trino to fix hudi schema fetching (#27213)
---
 requirements/base.txt        |  4 +++-
 requirements/development.txt | 11 +----------
 requirements/testing.txt     |  2 +-
 setup.py                     |  2 +-
 4 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/requirements/base.txt b/requirements/base.txt
index 3b871a688d..09b81ec61a 100644
--- a/requirements/base.txt
+++ b/requirements/base.txt
@@ -141,7 +141,9 @@ geographiclib==1.52
 geopy==2.2.0
     # via apache-superset
 greenlet==2.0.2
-    # via shillelagh
+    # via
+    #   shillelagh
+    #   sqlalchemy
 gunicorn==21.2.0
     # via apache-superset
 hashids==1.3.1
diff --git a/requirements/development.txt b/requirements/development.txt
index ca80cd60ed..58dd97a753 100644
--- a/requirements/development.txt
+++ b/requirements/development.txt
@@ -82,10 +82,6 @@ ptyprocess==0.7.0
     # via pexpect
 pure-eval==0.2.2
     # via stack-data
-pure-sasl==0.6.2
-    # via
-    #   pyhive
-    #   thrift-sasl
 pyasn1==0.5.0
     # via
     #   pyasn1-modules
@@ -115,12 +111,7 @@ tableschema==1.20.2
 tabulator==1.53.5
     # via tableschema
 thrift==0.16.0
-    # via
-    #   apache-superset
-    #   pyhive
-    #   thrift-sasl
-thrift-sasl==0.4.3
-    # via pyhive
+    # via apache-superset
 tomli==2.0.1
     # via pylint
 tomlkit==0.11.8
diff --git a/requirements/testing.txt b/requirements/testing.txt
index e044f3ffab..382e3bee4b 100644
--- a/requirements/testing.txt
+++ b/requirements/testing.txt
@@ -145,7 +145,7 @@ tqdm==4.65.0
     # via
     #   cmdstanpy
     #   prophet
-trino==0.324.0
+trino==0.328.0
     # via apache-superset
 tzlocal==4.3
     # via trino
diff --git a/setup.py b/setup.py
index baf0e8d6c2..cb6be9ec12 100644
--- a/setup.py
+++ b/setup.py
@@ -191,7 +191,7 @@ setup(
         "playwright": ["playwright>=1.37.0, <2"],
         "postgres": ["psycopg2-binary==2.9.6"],
         "presto": ["pyhive[presto]>=0.6.5"],
-        "trino": ["trino>=0.324.0"],
+        "trino": ["trino>=0.328.0"],
         "prophet": ["prophet>=1.1.5, <2"],
         "redshift": ["sqlalchemy-redshift>=0.8.1, <0.9"],
         "rockset": ["rockset-sqlalchemy>=0.0.1, <1"],


(superset) 01/08: fix: bump FAB to 4.4.1 (perf issue) (#27233)

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelsmolina pushed a commit to branch 3.1
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 465bce1480578a2919a5c25b2b0fa885b6120ce5
Author: Daniel Vaz Gaspar <da...@gmail.com>
AuthorDate: Fri Feb 23 17:57:49 2024 +0000

    fix: bump FAB to 4.4.1 (perf issue) (#27233)
    
    (cherry picked from commit 62cf0365e9176e0ac0c68c64000ae2eca2104889)
---
 requirements/base.txt | 2 +-
 setup.py              | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/requirements/base.txt b/requirements/base.txt
index 4b607cf725..3b871a688d 100644
--- a/requirements/base.txt
+++ b/requirements/base.txt
@@ -104,7 +104,7 @@ flask==2.2.5
     #   flask-session
     #   flask-sqlalchemy
     #   flask-wtf
-flask-appbuilder==4.4.0
+flask-appbuilder==4.4.1
     # via apache-superset
 flask-babel==1.0.0
     # via flask-appbuilder
diff --git a/setup.py b/setup.py
index 99e7499e68..baf0e8d6c2 100644
--- a/setup.py
+++ b/setup.py
@@ -84,7 +84,7 @@ setup(
         "cryptography>=41.0.2, <43.0.0",
         "deprecation>=2.1.0, <2.2.0",
         "flask>=2.2.5, <3.0.0",
-        "flask-appbuilder>=4.4.0, <5.0.0",
+        "flask-appbuilder>=4.4.1, <5.0.0",
         "flask-caching>=2.1.0, <3",
         "flask-compress>=1.13, <2.0",
         "flask-talisman>=1.0.0, <2.0",


(superset) 02/08: chore: Removes Chromatic workflow and dependencies (#27232)

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelsmolina pushed a commit to branch 3.1
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 51f359113919220871e86a9d5ddd520964f6a9ce
Author: Michael S. Molina <70...@users.noreply.github.com>
AuthorDate: Fri Feb 23 13:31:58 2024 -0500

    chore: Removes Chromatic workflow and dependencies (#27232)
---
 .github/workflows/chromatic-master.yml             | 72 ----------------------
 superset-frontend/package-lock.json                | 30 +--------
 superset-frontend/package.json                     |  3 -
 .../shared/components/createQueryStory.tsx         |  3 -
 .../superset-ui-connection/ConnectionStories.tsx   |  6 +-
 5 files changed, 3 insertions(+), 111 deletions(-)

diff --git a/.github/workflows/chromatic-master.yml b/.github/workflows/chromatic-master.yml
deleted file mode 100644
index efdbfec2f6..0000000000
--- a/.github/workflows/chromatic-master.yml
+++ /dev/null
@@ -1,72 +0,0 @@
-# .github/workflows/chromatic.yml
-# see https://www.chromatic.com/docs/github-actions
-#
-# 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.
-#
-
-# Workflow name
-name: 'Chromatic Storybook Master'
-
-# Event for the workflow
-# Only run if changes were made in superset-frontend folder of repo on merge to Master
-on:
-  # This will trigger when a branch merges to master when the PR has changes in the frontend folder updating the chromatic baseline
-  push:
-    branches:
-      - master
-    paths:
-      - "superset-frontend/**"
-
-# List of jobs
-jobs:
-  config:
-    runs-on: "ubuntu-latest"
-    outputs:
-      has-secrets: ${{ steps.check.outputs.has-secrets }}
-    steps:
-      - name: "Check for secrets"
-        id: check
-        shell: bash
-        run: |
-          if [ -n "${{ (secrets.CHROMATIC_PROJECT_TOKEN != '') || '' }}" ]; then
-            echo "has-secrets=1" >> "$GITHUB_OUTPUT"
-          fi
-
-  chromatic-deployment:
-    needs: config
-    if: needs.config.outputs.has-secrets
-    # Operating System
-    runs-on: ubuntu-latest
-    # Job steps
-    steps:
-      - uses: actions/checkout@v3
-        with:
-          fetch-depth: 0 # 👈 Required to retrieve git history
-      - name: Install dependencies
-        run: npm ci
-        working-directory: superset-frontend
-      # 👇 Build and publish Storybook to Chromatic
-      - name: Build and publish Storybook to Chromatic
-        id: chromatic-master
-        uses: chromaui/action@v1
-        # Required options for the Chromatic GitHub Action
-        with:
-          # 👇 Location of package.json from root of mono-repo
-          workingDir: superset-frontend
-          # 👇 Chromatic projectToken, refer to the manage page to obtain it.
-          projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
-          exitZeroOnChanges: true # 👈 Option to prevent the workflow from failing
-          autoAcceptChanges: true # 👈 Option to accept all changes when merging to master
diff --git a/superset-frontend/package-lock.json b/superset-frontend/package-lock.json
index 8b371df962..0a4ed84d6c 100644
--- a/superset-frontend/package-lock.json
+++ b/superset-frontend/package-lock.json
@@ -1,12 +1,12 @@
 {
   "name": "superset",
-  "version": "3.1.0",
+  "version": "3.1.1",
   "lockfileVersion": 2,
   "requires": true,
   "packages": {
     "": {
       "name": "superset",
-      "version": "3.1.0",
+      "version": "3.1.1",
       "license": "Apache-2.0",
       "workspaces": [
         "packages/*",
@@ -221,7 +221,6 @@
         "babel-plugin-dynamic-import-node": "^2.3.3",
         "babel-plugin-jsx-remove-data-test-id": "^2.1.3",
         "babel-plugin-lodash": "^3.3.4",
-        "chromatic": "^6.7.4",
         "copy-webpack-plugin": "^9.1.0",
         "cross-env": "^5.2.1",
         "css-loader": "^6.8.1",
@@ -25322,21 +25321,6 @@
       "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz",
       "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg=="
     },
-    "node_modules/chromatic": {
-      "version": "6.7.4",
-      "resolved": "https://registry.npmjs.org/chromatic/-/chromatic-6.7.4.tgz",
-      "integrity": "sha512-QW4i8RQsON0JVnFnRf+8y70aIJptvC0Oi/26YJ669Dl03WmJRpobNO5qWFPTiv3KFKMc1Qf6/qFsRVZCtn+bfA==",
-      "dev": true,
-      "dependencies": {
-        "@discoveryjs/json-ext": "^0.5.7",
-        "@types/webpack-env": "^1.17.0"
-      },
-      "bin": {
-        "chroma": "bin/main.cjs",
-        "chromatic": "bin/main.cjs",
-        "chromatic-cli": "bin/main.cjs"
-      }
-    },
     "node_modules/chrome-trace-event": {
       "version": "1.0.2",
       "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.2.tgz",
@@ -84097,16 +84081,6 @@
       "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz",
       "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg=="
     },
-    "chromatic": {
-      "version": "6.7.4",
-      "resolved": "https://registry.npmjs.org/chromatic/-/chromatic-6.7.4.tgz",
-      "integrity": "sha512-QW4i8RQsON0JVnFnRf+8y70aIJptvC0Oi/26YJ669Dl03WmJRpobNO5qWFPTiv3KFKMc1Qf6/qFsRVZCtn+bfA==",
-      "dev": true,
-      "requires": {
-        "@discoveryjs/json-ext": "^0.5.7",
-        "@types/webpack-env": "^1.17.0"
-      }
-    },
     "chrome-trace-event": {
       "version": "1.0.2",
       "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.2.tgz",
diff --git a/superset-frontend/package.json b/superset-frontend/package.json
index a43f110abc..5d7c711bbe 100644
--- a/superset-frontend/package.json
+++ b/superset-frontend/package.json
@@ -44,7 +44,6 @@
     "build-instrumented": "cross-env NODE_ENV=production BABEL_ENV=instrumented webpack --mode=production --color",
     "build-storybook": "build-storybook",
     "check-translation": "prettier --check ../superset/translations/**/LC_MESSAGES/*.json",
-    "chromatic": "npx chromatic --skip 'dependabot/**'  --only-changed",
     "clean-translation": "prettier --write ../superset/translations/**/LC_MESSAGES/*.json",
     "core:cover": "cross-env NODE_ENV=test jest --coverage --coverageThreshold='{\"global\":{\"statements\":100,\"branches\":100,\"functions\":100,\"lines\":100}}' --collectCoverageFrom='[\"packages/**/src/**/*.{js,ts}\", \"!packages/superset-ui-demo/**/*\"]' packages",
     "cover": "cross-env NODE_ENV=test jest --coverage",
@@ -56,7 +55,6 @@
     "plugins:build": "node ./scripts/build.js",
     "plugins:build-assets": "node ./scripts/copyAssets.js",
     "plugins:build-storybook": "cd packages/superset-ui-demo && npm run build-storybook",
-    "plugins:chromatic": "cd packages/superset-ui-demo && npm run chromatic",
     "plugins:create-conventional-version": "npm run prune && lerna version --conventional-commits --create-release github --no-private --yes",
     "plugins:create-minor-version": "npm run prune && lerna version minor --no-private --yes",
     "plugins:create-patch-version": "npm run prune && lerna version patch --no-private --yes",
@@ -286,7 +284,6 @@
     "babel-plugin-dynamic-import-node": "^2.3.3",
     "babel-plugin-jsx-remove-data-test-id": "^2.1.3",
     "babel-plugin-lodash": "^3.3.4",
-    "chromatic": "^6.7.4",
     "copy-webpack-plugin": "^9.1.0",
     "cross-env": "^5.2.1",
     "css-loader": "^6.8.1",
diff --git a/superset-frontend/packages/superset-ui-demo/storybook/shared/components/createQueryStory.tsx b/superset-frontend/packages/superset-ui-demo/storybook/shared/components/createQueryStory.tsx
index eb1d39e41a..d6396d1320 100644
--- a/superset-frontend/packages/superset-ui-demo/storybook/shared/components/createQueryStory.tsx
+++ b/superset-frontend/packages/superset-ui-demo/storybook/shared/components/createQueryStory.tsx
@@ -96,8 +96,5 @@ export default function createQueryStory({
       </div>
     );
   };
-  story.parameters = {
-    chromatic: { disable: true },
-  };
   return story;
 }
diff --git a/superset-frontend/packages/superset-ui-demo/storybook/stories/superset-ui-connection/ConnectionStories.tsx b/superset-frontend/packages/superset-ui-demo/storybook/stories/superset-ui-connection/ConnectionStories.tsx
index 3f75837e91..4a31d8de35 100644
--- a/superset-frontend/packages/superset-ui-demo/storybook/stories/superset-ui-connection/ConnectionStories.tsx
+++ b/superset-frontend/packages/superset-ui-demo/storybook/stories/superset-ui-connection/ConnectionStories.tsx
@@ -41,7 +41,7 @@ export default {
   ],
 };
 
-export const configureCORS = () => {
+export const ConfigureCORS = () => {
   const host = text('Superset App host for CORS request', 'localhost:8088');
   const selectEndpoint = select('Endpoint', ENDPOINTS, '');
   const customEndpoint = text('Custom Endpoint (override above)', '');
@@ -80,7 +80,3 @@ export const configureCORS = () => {
     </div>
   );
 };
-
-configureCORS.parameters = {
-  chromatic: { disable: true },
-};


(superset) 07/08: fix(import-datasources): Use "admin" user as default for importing datasources (#27154)

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelsmolina pushed a commit to branch 3.1
in repository https://gitbox.apache.org/repos/asf/superset.git

commit dc493fe7afeab11464c435b09b6da8b6e1caaf32
Author: James O'Claire <ja...@gmail.com>
AuthorDate: Tue Feb 27 23:32:04 2024 +0800

    fix(import-datasources): Use "admin" user as default for importing datasources (#27154)
---
 superset/cli/importexport.py | 39 ++++++++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/superset/cli/importexport.py b/superset/cli/importexport.py
index 5b19cc9ffc..56abcc31fe 100755
--- a/superset/cli/importexport.py
+++ b/superset/cli/importexport.py
@@ -29,6 +29,7 @@ from flask.cli import with_appcontext
 from superset import security_manager
 from superset.cli.lib import feature_flags
 from superset.extensions import db
+from superset.utils.core import override_user
 
 logger = logging.getLogger(__name__)
 
@@ -174,26 +175,34 @@ if feature_flags.get("VERSIONED_EXPORT"):
         "-p",
         help="Path to a single ZIP file",
     )
-    def import_datasources(path: str) -> None:
+    @click.option(
+        "--username",
+        "-u",
+        required=False,
+        default="admin",
+        help="Specify the user name to assign datasources to",
+    )
+    def import_datasources(path: str, username: Optional[str] = "admin") -> None:
         """Import datasources from ZIP file"""
         # pylint: disable=import-outside-toplevel
         from superset.commands.dataset.importers.dispatcher import ImportDatasetsCommand
         from superset.commands.importers.v1.utils import get_contents_from_bundle
 
-        if is_zipfile(path):
-            with ZipFile(path) as bundle:
-                contents = get_contents_from_bundle(bundle)
-        else:
-            with open(path) as file:
-                contents = {path: file.read()}
-        try:
-            ImportDatasetsCommand(contents, overwrite=True).run()
-        except Exception:  # pylint: disable=broad-except
-            logger.exception(
-                "There was an error when importing the dataset(s), please check the "
-                "exception traceback in the log"
-            )
-            sys.exit(1)
+        with override_user(user=security_manager.find_user(username=username)):
+            if is_zipfile(path):
+                with ZipFile(path) as bundle:
+                    contents = get_contents_from_bundle(bundle)
+            else:
+                with open(path) as file:
+                    contents = {path: file.read()}
+            try:
+                ImportDatasetsCommand(contents, overwrite=True).run()
+            except Exception:  # pylint: disable=broad-except
+                logger.exception(
+                    "There was an error when importing the dataset(s), please check the "
+                    "exception traceback in the log"
+                )
+                sys.exit(1)
 
 else:
 


(superset) 06/08: fix: Sorting charts/dashboards makes the applied filters ineffective (#27258)

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelsmolina pushed a commit to branch 3.1
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 0d2cf7c93807950d8c705fc6120714de5337fddc
Author: Michael S. Molina <70...@users.noreply.github.com>
AuthorDate: Tue Feb 27 08:20:42 2024 -0500

    fix: Sorting charts/dashboards makes the applied filters ineffective (#27258)
    
    (cherry picked from commit 8b4dce71d6cbe3b48c8847c2f641bd7dd5de3e3c)
---
 .../cypress-base/cypress/e2e/chart_list/list.test.ts   |  7 +++++++
 .../cypress/e2e/dashboard_list/list.test.ts            |  7 +++++++
 .../src/components/ListView/CardSortSelect.tsx         | 18 +++++++++---------
 superset-frontend/src/components/ListView/ListView.tsx |  9 ++++-----
 superset-frontend/src/components/ListView/types.ts     |  4 +---
 superset-frontend/src/components/ListView/utils.ts     |  4 +++-
 6 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/superset-frontend/cypress-base/cypress/e2e/chart_list/list.test.ts b/superset-frontend/cypress-base/cypress/e2e/chart_list/list.test.ts
index 44f348edc5..3cd1f91b49 100644
--- a/superset-frontend/cypress-base/cypress/e2e/chart_list/list.test.ts
+++ b/superset-frontend/cypress-base/cypress/e2e/chart_list/list.test.ts
@@ -173,6 +173,13 @@ describe('Charts list', () => {
       orderAlphabetical();
       cy.getBySel('styled-card').first().contains('% Rural');
     });
+
+    it('should preserve other filters when sorting', () => {
+      cy.getBySel('styled-card').should('have.length', 25);
+      setFilter('Type', 'Big Number');
+      setFilter('Sort', 'Least recently modified');
+      cy.getBySel('styled-card').should('have.length', 3);
+    });
   });
 
   describe('common actions', () => {
diff --git a/superset-frontend/cypress-base/cypress/e2e/dashboard_list/list.test.ts b/superset-frontend/cypress-base/cypress/e2e/dashboard_list/list.test.ts
index 7dfb7cd673..917ca10455 100644
--- a/superset-frontend/cypress-base/cypress/e2e/dashboard_list/list.test.ts
+++ b/superset-frontend/cypress-base/cypress/e2e/dashboard_list/list.test.ts
@@ -117,6 +117,13 @@ describe('Dashboards list', () => {
       orderAlphabetical();
       cy.getBySel('styled-card').first().contains('Supported Charts Dashboard');
     });
+
+    it('should preserve other filters when sorting', () => {
+      cy.getBySel('styled-card').should('have.length', 5);
+      setFilter('Status', 'Published');
+      setFilter('Sort', 'Least recently modified');
+      cy.getBySel('styled-card').should('have.length', 3);
+    });
   });
 
   describe('common actions', () => {
diff --git a/superset-frontend/src/components/ListView/CardSortSelect.tsx b/superset-frontend/src/components/ListView/CardSortSelect.tsx
index 479355881f..2a77d51cfb 100644
--- a/superset-frontend/src/components/ListView/CardSortSelect.tsx
+++ b/superset-frontend/src/components/ListView/CardSortSelect.tsx
@@ -21,7 +21,7 @@ import { styled, t } from '@superset-ui/core';
 import { Select } from 'src/components';
 import { FormLabel } from 'src/components/Form';
 import { SELECT_WIDTH } from './utils';
-import { CardSortSelectOption, FetchDataConfig, SortColumn } from './types';
+import { CardSortSelectOption, SortColumn } from './types';
 
 const SortContainer = styled.div`
   display: inline-flex;
@@ -32,22 +32,22 @@ const SortContainer = styled.div`
 `;
 
 interface CardViewSelectSortProps {
-  onChange: (conf: FetchDataConfig) => any;
+  onChange: (value: SortColumn[]) => void;
   options: Array<CardSortSelectOption>;
   initialSort?: SortColumn[];
-  pageIndex: number;
-  pageSize: number;
 }
 
 export const CardSortSelect = ({
   initialSort,
   onChange,
   options,
-  pageIndex,
-  pageSize,
 }: CardViewSelectSortProps) => {
   const defaultSort =
-    (initialSort && options.find(({ id }) => id === initialSort[0].id)) ||
+    (initialSort &&
+      options.find(
+        ({ id, desc }) =>
+          id === initialSort[0].id && desc === initialSort[0].desc,
+      )) ||
     options[0];
 
   const [value, setValue] = useState({
@@ -72,7 +72,7 @@ export const CardSortSelect = ({
           desc: originalOption.desc,
         },
       ];
-      onChange({ pageIndex, pageSize, sortBy, filters: [] });
+      onChange(sortBy);
     }
   };
 
@@ -82,7 +82,7 @@ export const CardSortSelect = ({
         ariaLabel={t('Sort')}
         header={<FormLabel>{t('Sort')}</FormLabel>}
         labelInValue
-        onChange={(value: CardSortSelectOption) => handleOnChange(value)}
+        onChange={handleOnChange}
         options={formattedOptions}
         showSearch
         value={value}
diff --git a/superset-frontend/src/components/ListView/ListView.tsx b/superset-frontend/src/components/ListView/ListView.tsx
index 82cf6b1878..93847ca5d8 100644
--- a/superset-frontend/src/components/ListView/ListView.tsx
+++ b/superset-frontend/src/components/ListView/ListView.tsx
@@ -271,10 +271,11 @@ function ListView<T extends object = any>({
     pageCount = 1,
     gotoPage,
     applyFilterValue,
+    setSortBy,
     selectedFlatRows,
     toggleAllRowsSelected,
     setViewMode,
-    state: { pageIndex, pageSize, internalFilters, viewMode },
+    state: { pageIndex, pageSize, internalFilters, sortBy, viewMode },
     query,
   } = useListViewState({
     bulkSelectColumnConfig,
@@ -350,11 +351,9 @@ function ListView<T extends object = any>({
             )}
             {viewMode === 'card' && cardSortSelectOptions && (
               <CardSortSelect
-                initialSort={initialSort}
-                onChange={fetchData}
+                initialSort={sortBy}
+                onChange={(value: SortColumn[]) => setSortBy(value)}
                 options={cardSortSelectOptions}
-                pageIndex={pageIndex}
-                pageSize={pageSize}
               />
             )}
           </div>
diff --git a/superset-frontend/src/components/ListView/types.ts b/superset-frontend/src/components/ListView/types.ts
index 0c1314f263..a526d6870d 100644
--- a/superset-frontend/src/components/ListView/types.ts
+++ b/superset-frontend/src/components/ListView/types.ts
@@ -23,8 +23,6 @@ export interface SortColumn {
   desc?: boolean;
 }
 
-export type SortColumns = SortColumn[];
-
 export interface SelectOption {
   label: string;
   value: any;
@@ -84,7 +82,7 @@ export interface FilterValue {
 export interface FetchDataConfig {
   pageIndex: number;
   pageSize: number;
-  sortBy: SortColumns;
+  sortBy: SortColumn[];
   filters: FilterValue[];
 }
 
diff --git a/superset-frontend/src/components/ListView/utils.ts b/superset-frontend/src/components/ListView/utils.ts
index 8a8c57cb62..ec80e4cff5 100644
--- a/superset-frontend/src/components/ListView/utils.ts
+++ b/superset-frontend/src/components/ListView/utils.ts
@@ -221,7 +221,7 @@ export function useListViewState({
       query.sortColumn && query.sortOrder
         ? [{ id: query.sortColumn, desc: query.sortOrder === 'desc' }]
         : initialSort,
-    [query.sortColumn, query.sortOrder],
+    [initialSort, query.sortColumn, query.sortOrder],
   );
 
   const initialState = {
@@ -257,6 +257,7 @@ export function useListViewState({
     pageCount,
     gotoPage,
     setAllFilters,
+    setSortBy,
     selectedFlatRows,
     toggleAllRowsSelected,
     state: { pageIndex, pageSize, sortBy, filters },
@@ -374,6 +375,7 @@ export function useListViewState({
     rows,
     selectedFlatRows,
     setAllFilters,
+    setSortBy,
     state: { pageIndex, pageSize, sortBy, filters, internalFilters, viewMode },
     toggleAllRowsSelected,
     applyFilterValue,


(superset) 04/08: fix(reports): fixing unit test (#27236)

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelsmolina pushed a commit to branch 3.1
in repository https://gitbox.apache.org/repos/asf/superset.git

commit a1ebdd70b1dd573941f045509f96419804621529
Author: Jack <41...@users.noreply.github.com>
AuthorDate: Fri Feb 23 14:05:05 2024 -0600

    fix(reports): fixing unit test  (#27236)
    
    (cherry picked from commit 62783150727d5239eb7588728c941d9df8283120)
---
 superset-frontend/src/types/dom-to-pdf.d.ts | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/superset-frontend/src/types/dom-to-pdf.d.ts b/superset-frontend/src/types/dom-to-pdf.d.ts
index bc884fd43a..0d45ac5afd 100644
--- a/superset-frontend/src/types/dom-to-pdf.d.ts
+++ b/superset-frontend/src/types/dom-to-pdf.d.ts
@@ -12,9 +12,7 @@ declare module 'dom-to-pdf' {
     excludeClassNames?: string[];
   }
 
-  const domToPdf = (
-    elementToPrint: Element,
-    options?: Options,
-  ): Promise<any> => {};
+  function domToPdf(elementToPrint: Element, options?: Options): Promise<any>;
+
   export default domToPdf;
 }