Compare commits
201 Commits
chore/lint
...
fix/dropdo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf6e779200 | ||
|
|
ce6501c36c | ||
|
|
6ea6b01f4f | ||
|
|
c1376c05a9 | ||
|
|
0d681338aa | ||
|
|
6c88fcacfa | ||
|
|
e16656c6cf | ||
|
|
07c8e7f303 | ||
|
|
b2468d3752 | ||
|
|
7934665ac1 | ||
|
|
9366868f8f | ||
|
|
ae61000a12 | ||
|
|
7174695be7 | ||
|
|
4ee3a0fc07 | ||
|
|
f6c5219e89 | ||
|
|
72d39bea85 | ||
|
|
e9030b7fac | ||
|
|
f672b143db | ||
|
|
9f42ccecec | ||
|
|
5af17c7976 | ||
|
|
18d89f25ce | ||
|
|
73c4240ba4 | ||
|
|
1903b919d6 | ||
|
|
44177b4e35 | ||
|
|
e1ed5003a8 | ||
|
|
e6853894ab | ||
|
|
05fc5bb424 | ||
|
|
c373498543 | ||
|
|
fb3e129d62 | ||
|
|
003c232192 | ||
|
|
a51bbd46dc | ||
|
|
e77cfc93ed | ||
|
|
ef290b28e2 | ||
|
|
dd18b2eb54 | ||
|
|
d7a8c1934a | ||
|
|
af7a62ab3f | ||
|
|
69d2da9c61 | ||
|
|
67bc910eb5 | ||
|
|
a89f9bcb98 | ||
|
|
b302071723 | ||
|
|
e45330c2fd | ||
|
|
bd8d3ffb2d | ||
|
|
5e3a7ba106 | ||
|
|
c1a3de719a | ||
|
|
33deb028a6 | ||
|
|
919daabe54 | ||
|
|
0f2769ca3e | ||
|
|
a4a67296af | ||
|
|
b4000a025d | ||
|
|
a9761932bc | ||
|
|
29806780dc | ||
|
|
191337e08d | ||
|
|
a222dab781 | ||
|
|
230b25dd72 | ||
|
|
151d7d76da | ||
|
|
4f19bc4c5f | ||
|
|
11607dde04 | ||
|
|
e1bdb94efc | ||
|
|
6535fdd556 | ||
|
|
5fb89b865d | ||
|
|
6948e73ec7 | ||
|
|
c4cf03f899 | ||
|
|
d3de16c5f5 | ||
|
|
78fb09695b | ||
|
|
06818008c2 | ||
|
|
52ba4fd0cb | ||
|
|
4f2fa41f4e | ||
|
|
bf7ec853fa | ||
|
|
9fe3f634ec | ||
|
|
899e9294b2 | ||
|
|
dc9b459b27 | ||
|
|
7d3881f1da | ||
|
|
e5f9a6bf4b | ||
|
|
5cff657812 | ||
|
|
16387b0815 | ||
|
|
0857611a4e | ||
|
|
51ea2c297d | ||
|
|
fbd062165e | ||
|
|
55625c911f | ||
|
|
fca64de8e9 | ||
|
|
03725d1aaa | ||
|
|
a9487cbc84 | ||
|
|
ce5b2aa424 | ||
|
|
e535dce030 | ||
|
|
a7310b1fce | ||
|
|
cd6ce881a5 | ||
|
|
f0ef9f5e9c | ||
|
|
4ae16cb140 | ||
|
|
3d85e8e23b | ||
|
|
690a411cf3 | ||
|
|
be680408c9 | ||
|
|
4bdc8d4c68 | ||
|
|
db7a2bd682 | ||
|
|
2e0d482ccf | ||
|
|
e5b3a9c25d | ||
|
|
c289731212 | ||
|
|
f850c6b1b1 | ||
|
|
8ce234371b | ||
|
|
e5820b6b2b | ||
|
|
69f062b804 | ||
|
|
735dd5dbae | ||
|
|
cd7dddb5a1 | ||
|
|
7c76fd3d81 | ||
|
|
0b419a07f5 | ||
|
|
0b51e9cd5e | ||
|
|
e7b9fb277e | ||
|
|
838ee870d0 | ||
|
|
84af6c9f29 | ||
|
|
05227e8a80 | ||
|
|
76a209663d | ||
|
|
61c45e3dd8 | ||
|
|
e11a50bedf | ||
|
|
f4a6ea0fde | ||
|
|
e542e9f840 | ||
|
|
e0dcb2908d | ||
|
|
eaccb2e471 | ||
|
|
c1a1f2e7e7 | ||
|
|
45d5501aa7 | ||
|
|
388596e4fe | ||
|
|
b11d4f3ef0 | ||
|
|
998b9e387b | ||
|
|
b3e88db87e | ||
|
|
8471e82342 | ||
|
|
c3a0f2749b | ||
|
|
c2d96e0dce | ||
|
|
44e77fdf2b | ||
|
|
18d6feb499 | ||
|
|
0d91f5e982 | ||
|
|
5661fc9128 | ||
|
|
a6156676c8 | ||
|
|
b2bd2329bc | ||
|
|
724f1484b9 | ||
|
|
84f7b4a973 | ||
|
|
ddcb9be9a7 | ||
|
|
8d9b5bd479 | ||
|
|
4b88fc57b4 | ||
|
|
b76080e291 | ||
|
|
411f769896 | ||
|
|
ffcc6e8b63 | ||
|
|
86575e129b | ||
|
|
3e25f02da9 | ||
|
|
002d8ad1e4 | ||
|
|
6287a07912 | ||
|
|
fa97d0357f | ||
|
|
f836c3eccd | ||
|
|
499e27ea54 | ||
|
|
c2a35e2eea | ||
|
|
5138aa2c11 | ||
|
|
66a9e2e16e | ||
|
|
0f417f0040 | ||
|
|
1462ac9282 | ||
|
|
da371217ef | ||
|
|
c971ea3ec6 | ||
|
|
de98fdc37b | ||
|
|
fa1f12a0b5 | ||
|
|
de40b58e10 | ||
|
|
eea3557f61 | ||
|
|
7a243d329e | ||
|
|
98146251c4 | ||
|
|
0aa8cace1b | ||
|
|
450701ecec | ||
|
|
e9911fbac4 | ||
|
|
69c8eef78e | ||
|
|
2ff50667e7 | ||
|
|
f1cf274751 | ||
|
|
b65396ccd4 | ||
|
|
1ad76e847e | ||
|
|
4583ef93a4 | ||
|
|
f632d2474b | ||
|
|
b1d69f5b39 | ||
|
|
aba7e6dae4 | ||
|
|
8bcc90c766 | ||
|
|
e39dd1afce | ||
|
|
680cef0ee0 | ||
|
|
e17cf3c808 | ||
|
|
f49310b8ff | ||
|
|
c7955a38ef | ||
|
|
68067d7f44 | ||
|
|
5815665cc6 | ||
|
|
6649f35a0d | ||
|
|
5263abdc60 | ||
|
|
c49641538d | ||
|
|
d915e4f3ff | ||
|
|
bad5a35fce | ||
|
|
1bde6f3bfd | ||
|
|
4e0890ee1f | ||
|
|
d63308ca37 | ||
|
|
63cceb6a79 | ||
|
|
b8b2bdedf9 | ||
|
|
d5017e60c3 | ||
|
|
2e80f2a473 | ||
|
|
4c2dd63464 | ||
|
|
62302ad8c3 | ||
|
|
ed659958f3 | ||
|
|
36de05fe36 | ||
|
|
a64609f4f3 | ||
|
|
140f0001f2 | ||
|
|
587fe4af63 | ||
|
|
3a3a6536b7 | ||
|
|
4f695e1b4d | ||
|
|
6ba9096870 |
5
.github/CODEOWNERS
vendored
@@ -22,6 +22,11 @@
|
||||
|
||||
/.github/ @villebro @geido @eschutho @rusackas @betodealmeida @nytai @mistercrunch @craig-rueda @kgabryje @dpgaspar @sadpandajoe @hainenber
|
||||
|
||||
# Notify PMC members of changes to CI-executed scripts (supply-chain risk:
|
||||
# scripts/ files run directly in CI workflows and can execute arbitrary code)
|
||||
|
||||
/scripts/ @villebro @geido @eschutho @rusackas @betodealmeida @nytai @mistercrunch @craig-rueda @kgabryje @dpgaspar @sadpandajoe @hainenber
|
||||
|
||||
# Notify PMC members of changes to required GitHub Actions
|
||||
|
||||
/.asf.yaml @villebro @geido @eschutho @rusackas @betodealmeida @nytai @mistercrunch @craig-rueda @kgabryje @dpgaspar @Antonio-RiveroMartnez
|
||||
|
||||
4
.github/dependabot.yml
vendored
@@ -4,6 +4,10 @@ updates:
|
||||
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
ignore:
|
||||
# Ignore temporarily as release schedule is too mentally taxing for dep-handling maintainers
|
||||
# Additionally, very few PRs are reviewed by this action.
|
||||
- dependency-name: anthropics/claude-code-action
|
||||
schedule:
|
||||
interval: "daily"
|
||||
|
||||
|
||||
5
.github/labeler.yml
vendored
@@ -17,6 +17,11 @@
|
||||
- any-glob-to-any-file:
|
||||
- 'superset/migrations/**'
|
||||
|
||||
"risk:ci-script":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- 'scripts/**'
|
||||
|
||||
############################################
|
||||
# Dependencies
|
||||
############################################
|
||||
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
- name: Check and notify
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
github-token: ${{ github.token }}
|
||||
script: |
|
||||
|
||||
4
.github/workflows/claude.yml
vendored
@@ -44,7 +44,7 @@ jobs:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Comment access denied
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
script: |
|
||||
const message = `👋 Hi @${{ github.event.comment.user.login || github.event.review.user.login || github.event.issue.user.login }}!
|
||||
@@ -76,7 +76,7 @@ jobs:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Run Claude PR Action
|
||||
uses: anthropics/claude-code-action@6e2bd52842c65e914eba5c8badd17560bd26b5de # beta
|
||||
uses: anthropics/claude-code-action@5fb899572b81d2bb648d4d187173a2f423a9677c # beta
|
||||
with:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
timeout_minutes: "60"
|
||||
|
||||
2
.github/workflows/embedded-sdk-release.yml
vendored
@@ -31,7 +31,7 @@ jobs:
|
||||
working-directory: superset-embedded-sdk
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version-file: './superset-embedded-sdk/.nvmrc'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
2
.github/workflows/embedded-sdk-test.yml
vendored
@@ -19,7 +19,7 @@ jobs:
|
||||
working-directory: superset-embedded-sdk
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version-file: './superset-embedded-sdk/.nvmrc'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
4
.github/workflows/ephemeral-env-pr-close.yml
vendored
@@ -58,7 +58,7 @@ jobs:
|
||||
- name: Login to Amazon ECR
|
||||
if: steps.describe-services.outputs.active == 'true'
|
||||
id: login-ecr
|
||||
uses: aws-actions/amazon-ecr-login@f2e9fc6c2b355c1890b65e6f6f0e2ac3e6e22f78 # v2
|
||||
uses: aws-actions/amazon-ecr-login@376925c9d111252e87ae59691e5a442dd100ef6a # v2
|
||||
|
||||
- name: Delete ECR image tag
|
||||
if: steps.describe-services.outputs.active == 'true'
|
||||
@@ -71,7 +71,7 @@ jobs:
|
||||
|
||||
- name: Comment (success)
|
||||
if: steps.describe-services.outputs.active == 'true'
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
github-token: ${{github.token}}
|
||||
script: |
|
||||
|
||||
16
.github/workflows/ephemeral-env.yml
vendored
@@ -65,7 +65,7 @@ jobs:
|
||||
- name: Get event SHA
|
||||
id: get-sha
|
||||
if: steps.eval-label.outputs.result == 'up'
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
@@ -96,7 +96,7 @@ jobs:
|
||||
core.setOutput("sha", prSha);
|
||||
|
||||
- name: Looking for feature flags in PR description
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
id: eval-feature-flags
|
||||
if: steps.eval-label.outputs.result == 'up'
|
||||
with:
|
||||
@@ -118,7 +118,7 @@ jobs:
|
||||
return results;
|
||||
|
||||
- name: Reply with confirmation comment
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
if: steps.eval-label.outputs.result == 'up'
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -199,7 +199,7 @@ jobs:
|
||||
|
||||
- name: Login to Amazon ECR
|
||||
id: login-ecr
|
||||
uses: aws-actions/amazon-ecr-login@f2e9fc6c2b355c1890b65e6f6f0e2ac3e6e22f78 # v2
|
||||
uses: aws-actions/amazon-ecr-login@376925c9d111252e87ae59691e5a442dd100ef6a # v2
|
||||
|
||||
- name: Load, tag and push image to ECR
|
||||
id: push-image
|
||||
@@ -235,7 +235,7 @@ jobs:
|
||||
|
||||
- name: Login to Amazon ECR
|
||||
id: login-ecr
|
||||
uses: aws-actions/amazon-ecr-login@f2e9fc6c2b355c1890b65e6f6f0e2ac3e6e22f78 # v2
|
||||
uses: aws-actions/amazon-ecr-login@376925c9d111252e87ae59691e5a442dd100ef6a # v2
|
||||
|
||||
- name: Check target image exists in ECR
|
||||
id: check-image
|
||||
@@ -250,7 +250,7 @@ jobs:
|
||||
|
||||
- name: Fail on missing container image
|
||||
if: steps.check-image.outcome == 'failure'
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
github-token: ${{ github.token }}
|
||||
script: |
|
||||
@@ -324,7 +324,7 @@ jobs:
|
||||
echo "ip=$(aws ec2 describe-network-interfaces --network-interface-ids ${{ steps.get-eni.outputs.eni }} | jq -r '.NetworkInterfaces | first | .Association.PublicIp')" >> $GITHUB_OUTPUT
|
||||
- name: Comment (success)
|
||||
if: ${{ success() }}
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
github-token: ${{github.token}}
|
||||
script: |
|
||||
@@ -337,7 +337,7 @@ jobs:
|
||||
});
|
||||
- name: Comment (failure)
|
||||
if: ${{ failure() }}
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
github-token: ${{github.token}}
|
||||
script: |
|
||||
|
||||
@@ -17,7 +17,7 @@ jobs:
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
|
||||
2
.github/workflows/no-hold-label.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Check for 'hold' label
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||
script: |
|
||||
|
||||
4
.github/workflows/pre-commit.yml
vendored
@@ -42,7 +42,7 @@ jobs:
|
||||
echo "HOMEBREW_REPOSITORY=$HOMEBREW_REPOSITORY" >>"${GITHUB_ENV}"
|
||||
brew install norwoodj/tap/helm-docs
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
@@ -57,7 +57,7 @@ jobs:
|
||||
yarn install --immutable
|
||||
|
||||
- name: Cache pre-commit environments
|
||||
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
|
||||
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||
with:
|
||||
path: ~/.cache/pre-commit
|
||||
key: pre-commit-v2-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }}
|
||||
|
||||
6
.github/workflows/release.yml
vendored
@@ -44,13 +44,13 @@ jobs:
|
||||
|
||||
- name: Install Node.js
|
||||
if: env.HAS_TAGS
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version-file: './superset-frontend/.nvmrc'
|
||||
|
||||
- name: Cache npm
|
||||
if: env.HAS_TAGS
|
||||
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
|
||||
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||
with:
|
||||
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
|
||||
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
|
||||
@@ -64,7 +64,7 @@ jobs:
|
||||
run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
|
||||
- name: Cache npm
|
||||
if: env.HAS_TAGS
|
||||
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
|
||||
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||
id: npm-cache # use this to check for `cache-hit` (`steps.npm-cache.outputs.cache-hit != 'true'`)
|
||||
with:
|
||||
path: ${{ steps.npm-cache-dir-path.outputs.dir }}
|
||||
|
||||
2
.github/workflows/showtime-trigger.yml
vendored
@@ -37,7 +37,7 @@ jobs:
|
||||
steps:
|
||||
- name: Security Check - Authorize Maintainers Only
|
||||
id: auth
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
|
||||
2
.github/workflows/superset-docs-deploy.yml
vendored
@@ -46,7 +46,7 @@ jobs:
|
||||
persist-credentials: false
|
||||
submodules: recursive
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version-file: './docs/.nvmrc'
|
||||
- name: Setup Python
|
||||
|
||||
4
.github/workflows/superset-docs-verify.yml
vendored
@@ -72,7 +72,7 @@ jobs:
|
||||
persist-credentials: false
|
||||
submodules: recursive
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version-file: './docs/.nvmrc'
|
||||
- name: yarn install
|
||||
@@ -104,7 +104,7 @@ jobs:
|
||||
persist-credentials: false
|
||||
submodules: recursive
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version-file: './docs/.nvmrc'
|
||||
- name: yarn install
|
||||
|
||||
8
.github/workflows/superset-e2e.yml
vendored
@@ -109,7 +109,7 @@ jobs:
|
||||
run: testdata
|
||||
- name: Setup Node.js
|
||||
if: steps.check.outputs.python || steps.check.outputs.frontend
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version-file: './superset-frontend/.nvmrc'
|
||||
- name: Install npm dependencies
|
||||
@@ -146,7 +146,7 @@ jobs:
|
||||
SAFE_APP_ROOT=${APP_ROOT//\//_}
|
||||
echo "safe_app_root=$SAFE_APP_ROOT" >> $GITHUB_OUTPUT
|
||||
- name: Upload Artifacts
|
||||
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
|
||||
if: failure()
|
||||
with:
|
||||
path: ${{ github.workspace }}/superset-frontend/cypress-base/cypress/screenshots
|
||||
@@ -226,7 +226,7 @@ jobs:
|
||||
run: playwright_testdata
|
||||
- name: Setup Node.js
|
||||
if: steps.check.outputs.python || steps.check.outputs.frontend
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version-file: './superset-frontend/.nvmrc'
|
||||
- name: Install npm dependencies
|
||||
@@ -259,7 +259,7 @@ jobs:
|
||||
SAFE_APP_ROOT=${APP_ROOT//\//_}
|
||||
echo "safe_app_root=$SAFE_APP_ROOT" >> $GITHUB_OUTPUT
|
||||
- name: Upload Playwright Artifacts
|
||||
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
|
||||
if: failure()
|
||||
with:
|
||||
path: |
|
||||
|
||||
@@ -58,7 +58,7 @@ jobs:
|
||||
|
||||
- name: Upload HTML coverage report
|
||||
if: steps.check.outputs.superset-extensions-cli
|
||||
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
|
||||
with:
|
||||
name: superset-extensions-cli-coverage-html
|
||||
path: htmlcov/
|
||||
|
||||
4
.github/workflows/superset-frontend.yml
vendored
@@ -58,7 +58,7 @@ jobs:
|
||||
|
||||
- name: Upload Docker Image Artifact
|
||||
if: steps.check.outputs.frontend
|
||||
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
|
||||
with:
|
||||
name: docker-image
|
||||
path: docker-image.tar.zst
|
||||
@@ -91,7 +91,7 @@ jobs:
|
||||
"npm run test -- --coverage --shard=${{ matrix.shard }}/8 --coverageReporters=json"
|
||||
|
||||
- name: Upload Coverage Artifact
|
||||
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
|
||||
with:
|
||||
name: coverage-artifacts-${{ matrix.shard }}
|
||||
path: superset-frontend/coverage
|
||||
|
||||
2
.github/workflows/superset-helm-release.yml
vendored
@@ -101,7 +101,7 @@ jobs:
|
||||
CR_RELEASE_NAME_TEMPLATE: "superset-helm-chart-{{ .Version }}"
|
||||
|
||||
- name: Open Pull Request
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
script: |
|
||||
const branchName = '${{ env.branch_name }}';
|
||||
|
||||
4
.github/workflows/superset-playwright.yml
vendored
@@ -100,7 +100,7 @@ jobs:
|
||||
run: playwright_testdata
|
||||
- name: Setup Node.js
|
||||
if: steps.check.outputs.python || steps.check.outputs.frontend
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version-file: './superset-frontend/.nvmrc'
|
||||
- name: Install npm dependencies
|
||||
@@ -133,7 +133,7 @@ jobs:
|
||||
SAFE_APP_ROOT=${APP_ROOT//\//_}
|
||||
echo "safe_app_root=$SAFE_APP_ROOT" >> $GITHUB_OUTPUT
|
||||
- name: Upload Playwright Artifacts
|
||||
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
|
||||
if: failure()
|
||||
with:
|
||||
path: |
|
||||
|
||||
@@ -101,7 +101,7 @@ jobs:
|
||||
"
|
||||
- name: Upload database diagnostics artifact
|
||||
if: steps.check.outputs.python
|
||||
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
|
||||
with:
|
||||
name: database-diagnostics
|
||||
path: databases-diagnostics.json
|
||||
|
||||
2
.github/workflows/superset-translations.yml
vendored
@@ -31,7 +31,7 @@ jobs:
|
||||
|
||||
- name: Setup Node.js
|
||||
if: steps.check.outputs.frontend
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version-file: './superset-frontend/.nvmrc'
|
||||
- name: Install dependencies
|
||||
|
||||
2
.github/workflows/supersetbot.yml
vendored
@@ -26,7 +26,7 @@ jobs:
|
||||
steps:
|
||||
- name: Quickly add thumbs up!
|
||||
if: github.event_name == 'issue_comment' && contains(github.event.comment.body, '@supersetbot')
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
script: |
|
||||
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/')
|
||||
|
||||
4
.github/workflows/tag-release.yml
vendored
@@ -62,7 +62,7 @@ jobs:
|
||||
build: "true"
|
||||
|
||||
- name: Use Node.js 20
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
@@ -117,7 +117,7 @@ jobs:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Use Node.js 20
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
|
||||
2
.github/workflows/tech-debt.yml
vendored
@@ -35,7 +35,7 @@ jobs:
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||
with:
|
||||
node-version-file: './superset-frontend/.nvmrc'
|
||||
|
||||
|
||||
1
.gitignore
vendored
@@ -62,6 +62,7 @@ rat-results.txt
|
||||
superset/app/
|
||||
superset-websocket/config.json
|
||||
.direnv
|
||||
*.log
|
||||
|
||||
# Node.js, webpack artifacts, storybook
|
||||
*.entry.js
|
||||
|
||||
@@ -458,7 +458,7 @@ cd ../
|
||||
sed -i '' "s/version_string = .*/version_string = \"$SUPERSET_VERSION\"/" setup.py
|
||||
|
||||
# build the python distribution
|
||||
python setup.py sdist
|
||||
python -m build
|
||||
```
|
||||
|
||||
Publish to PyPI
|
||||
|
||||
@@ -287,6 +287,11 @@ categories:
|
||||
url: https://www.gfk.com/home
|
||||
contributors: ["@mherr"]
|
||||
|
||||
- name: Hifadih Business & Technology
|
||||
url: https://hifadih.net/en
|
||||
logo: hifadih.png
|
||||
contributors: ["@saintLaurent00"]
|
||||
|
||||
# Logo approved by @anmol-hpe on behalf of HPE
|
||||
- name: HPE
|
||||
url: https://www.hpe.com/in/en/home.html
|
||||
|
||||
14
UPDATING.md
@@ -24,6 +24,20 @@ assists people when migrating to a new version.
|
||||
|
||||
## Next
|
||||
|
||||
### Granular Export Controls
|
||||
|
||||
A new feature flag `GRANULAR_EXPORT_CONTROLS` introduces three fine-grained permissions that replace the legacy `can_csv` permission:
|
||||
|
||||
| Permission | Controls |
|
||||
|---|---|
|
||||
| `can_export_data` | CSV, Excel, JSON exports |
|
||||
| `can_export_image` | Screenshot/PDF exports |
|
||||
| `can_copy_clipboard` | Copy-to-clipboard operations |
|
||||
|
||||
When the feature flag is enabled, these permissions are enforced on both the frontend (disabled buttons with tooltips) and backend (403 responses from API endpoints). When disabled, legacy `can_csv` behavior is preserved.
|
||||
|
||||
**Migration behavior:** All three new permissions are granted to every role that currently has `can_csv`, preserving existing access. Admins can then selectively revoke individual export permissions from specific roles as needed.
|
||||
|
||||
### Deck.gl MapBox viewport and opacity controls are functional
|
||||
|
||||
The Deck.gl MapBox chart's **Opacity**, **Default longitude**, **Default latitude**, and **Zoom** controls were previously non-functional — changing them had no effect on the rendered map. These controls are now wired up correctly.
|
||||
|
||||
@@ -115,6 +115,10 @@ services:
|
||||
DATABASE_HOST: db-light
|
||||
DATABASE_DB: superset_light
|
||||
POSTGRES_DB: superset_light
|
||||
EXAMPLES_HOST: db-light
|
||||
EXAMPLES_DB: superset_light
|
||||
EXAMPLES_USER: superset
|
||||
EXAMPLES_PASSWORD: superset
|
||||
SUPERSET_CONFIG_PATH: /app/docker/pythonpath_dev/superset_config_docker_light.py
|
||||
GITHUB_HEAD_REF: ${GITHUB_HEAD_REF:-}
|
||||
GITHUB_SHA: ${GITHUB_SHA:-}
|
||||
@@ -137,6 +141,10 @@ services:
|
||||
DATABASE_HOST: db-light
|
||||
DATABASE_DB: superset_light
|
||||
POSTGRES_DB: superset_light
|
||||
EXAMPLES_HOST: db-light
|
||||
EXAMPLES_DB: superset_light
|
||||
EXAMPLES_USER: superset
|
||||
EXAMPLES_PASSWORD: superset
|
||||
SUPERSET_CONFIG_PATH: /app/docker/pythonpath_dev/superset_config_docker_light.py
|
||||
healthcheck:
|
||||
disable: true
|
||||
@@ -157,6 +165,7 @@ services:
|
||||
BUILD_SUPERSET_FRONTEND_IN_DOCKER: true
|
||||
NPM_RUN_PRUNE: false
|
||||
SCARF_ANALYTICS: "${SCARF_ANALYTICS:-}"
|
||||
DISABLE_TS_CHECKER: "${DISABLE_TS_CHECKER:-true}"
|
||||
# configuring the dev-server to use the host.docker.internal to connect to the backend
|
||||
superset: "http://superset-light:8088"
|
||||
# Webpack dev server must bind to 0.0.0.0 to be accessible from outside the container
|
||||
|
||||
@@ -80,7 +80,7 @@ case "${1}" in
|
||||
;;
|
||||
app)
|
||||
echo "Starting web app (using development server)..."
|
||||
flask run -p $PORT --reload --debugger --without-threads --host=0.0.0.0 --exclude-patterns "*/node_modules/*:*/.venv/*:*/build/*:*/__pycache__/*"
|
||||
flask run -p $PORT --reload --debugger --host=0.0.0.0 --exclude-patterns "*/node_modules/*:*/.venv/*:*/build/*:*/__pycache__/*:*/superset-frontend/*"
|
||||
;;
|
||||
app-gunicorn)
|
||||
echo "Starting web app..."
|
||||
|
||||
162
docs/admin_docs/configuration/aws-iam.mdx
Normal file
@@ -0,0 +1,162 @@
|
||||
{/*
|
||||
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.
|
||||
*/}
|
||||
|
||||
---
|
||||
title: AWS IAM Authentication
|
||||
sidebar_label: AWS IAM Authentication
|
||||
sidebar_position: 15
|
||||
---
|
||||
|
||||
# AWS IAM Authentication for AWS Databases
|
||||
|
||||
Superset supports IAM-based authentication for **Amazon Aurora** (PostgreSQL and MySQL) and **Amazon Redshift**. IAM auth eliminates the need for database passwords — Superset generates a short-lived auth token using temporary AWS credentials instead.
|
||||
|
||||
Cross-account IAM role assumption via STS `AssumeRole` is supported, allowing a Superset deployment in one AWS account to connect to databases in a different account.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Enable the `AWS_DATABASE_IAM_AUTH` feature flag in `superset_config.py`. IAM authentication is gated behind this flag; if it is disabled, connections using `aws_iam` fail with *"AWS IAM database authentication is not enabled."*
|
||||
```python
|
||||
FEATURE_FLAGS = {
|
||||
"AWS_DATABASE_IAM_AUTH": True,
|
||||
}
|
||||
```
|
||||
- `boto3` must be installed in your Superset environment:
|
||||
```bash
|
||||
pip install boto3
|
||||
```
|
||||
- The Superset server's IAM role (or static credentials) must have permission to call `sts:AssumeRole` (for cross-account) or the same-account permissions for the target service:
|
||||
- **Aurora (RDS)**: `rds-db:connect`
|
||||
- **Redshift provisioned**: `redshift:GetClusterCredentials`
|
||||
- **Redshift Serverless**: `redshift-serverless:GetCredentials` and `redshift-serverless:GetWorkgroup`
|
||||
- SSL must be enabled on the Aurora / Redshift endpoint (required for IAM token auth).
|
||||
|
||||
## Configuration
|
||||
|
||||
IAM authentication is configured via the **encrypted_extra** field of the database connection. Access this field in the **Advanced** → **Security** section of the database connection form, under **Secure Extra**.
|
||||
|
||||
### Aurora PostgreSQL or Aurora MySQL
|
||||
|
||||
```json
|
||||
{
|
||||
"aws_iam": {
|
||||
"enabled": true,
|
||||
"role_arn": "arn:aws:iam::222222222222:role/SupersetDatabaseAccess",
|
||||
"external_id": "superset-prod-12345",
|
||||
"region": "us-east-1",
|
||||
"db_username": "superset_iam_user",
|
||||
"session_duration": 3600
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Required | Description |
|
||||
|-------|----------|-------------|
|
||||
| `enabled` | Yes | Set to `true` to activate IAM auth |
|
||||
| `role_arn` | No | ARN of the cross-account IAM role to assume via STS. Omit for same-account auth |
|
||||
| `external_id` | No | External ID for the STS `AssumeRole` call, if required by the target role's trust policy |
|
||||
| `region` | Yes | AWS region of the database cluster |
|
||||
| `db_username` | Yes | The database username associated with the IAM identity |
|
||||
| `session_duration` | No | STS session duration in seconds (default: `3600`) |
|
||||
|
||||
### Redshift (Serverless)
|
||||
|
||||
```json
|
||||
{
|
||||
"aws_iam": {
|
||||
"enabled": true,
|
||||
"role_arn": "arn:aws:iam::222222222222:role/SupersetRedshiftAccess",
|
||||
"region": "us-east-1",
|
||||
"workgroup_name": "my-workgroup",
|
||||
"db_name": "dev"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Redshift (Provisioned Cluster)
|
||||
|
||||
```json
|
||||
{
|
||||
"aws_iam": {
|
||||
"enabled": true,
|
||||
"role_arn": "arn:aws:iam::222222222222:role/SupersetRedshiftAccess",
|
||||
"region": "us-east-1",
|
||||
"cluster_identifier": "my-cluster",
|
||||
"db_username": "superset_iam_user",
|
||||
"db_name": "dev"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Cross-Account IAM Setup
|
||||
|
||||
To connect to a database in Account B from a Superset deployment in Account A:
|
||||
|
||||
**1. In Account B — create a database-access role:**
|
||||
|
||||
```json
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": ["rds-db:connect"],
|
||||
"Resource": "arn:aws:rds-db:us-east-1:222222222222:dbuser/db-XXXXXXXXXXXX/superset_iam_user"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**Trust policy** (allows Account A's Superset role to assume it):
|
||||
|
||||
```json
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "arn:aws:iam::111111111111:role/SupersetInstanceRole"
|
||||
},
|
||||
"Action": "sts:AssumeRole",
|
||||
"Condition": {
|
||||
"StringEquals": {
|
||||
"sts:ExternalId": "superset-prod-12345"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**2. In Account A — grant Superset's role permission to assume the Account B role:**
|
||||
|
||||
```json
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": "sts:AssumeRole",
|
||||
"Resource": "arn:aws:iam::222222222222:role/SupersetDatabaseAccess"
|
||||
}
|
||||
```
|
||||
|
||||
**3. Configure the database connection in Superset** using the `role_arn` and `external_id` from the trust policy (as shown in the configuration example above).
|
||||
|
||||
## Credential Caching
|
||||
|
||||
STS credentials are cached in memory keyed by `(role_arn, region, external_id)` with a 10-minute TTL. This reduces the number of STS API calls when multiple queries are executed with the same connection. Tokens are refreshed automatically before expiry.
|
||||
@@ -109,6 +109,14 @@ SECRET_KEY = 'YOUR_OWN_RANDOM_GENERATED_SECRET_KEY'
|
||||
|
||||
You can generate a strong secure key with `openssl rand -base64 42`.
|
||||
|
||||
Alternatively, you can set the secret key using `SUPERSET_SECRET_KEY` environment variable:
|
||||
|
||||
On a Unix-based system, such as Linux or macOS, you can do so by running the following command in your terminal:
|
||||
|
||||
```bash
|
||||
export SUPERSET_SECRET_KEY=$(openssl rand -base64 42)
|
||||
```
|
||||
|
||||
:::caution Use a strong secret key
|
||||
This key will be used for securely signing session cookies and encrypting sensitive information stored in Superset's application metadata database.
|
||||
Your deployment must use a complex, unique key.
|
||||
|
||||
@@ -10,6 +10,10 @@ version: 1
|
||||
The superset cli allows you to import and export datasources from and to YAML. Datasources include
|
||||
databases. The data is expected to be organized in the following hierarchy:
|
||||
|
||||
:::info
|
||||
Superset's ZIP-based import/export also covers **dashboards**, **charts**, and **saved queries**, exercised through the UI and REST API. The [Dashboard Import Overwrite Behavior](#dashboard-import-overwrite-behavior) and [UUIDs in API Responses](#uuids-in-api-responses) sections below document the behavior shared across all asset types.
|
||||
:::
|
||||
|
||||
```text
|
||||
├──databases
|
||||
| ├──database_1
|
||||
@@ -75,6 +79,29 @@ The optional username flag **-u** sets the user used for the datasource import.
|
||||
superset import_datasources -p <path / filename> -u 'admin'
|
||||
```
|
||||
|
||||
## Dashboard Import Overwrite Behavior
|
||||
|
||||
When importing a dashboard ZIP with the **overwrite** option enabled, any existing charts that are part of the dashboard are **replaced** rather than duplicated. This applies to:
|
||||
|
||||
- Charts whose UUID matches a chart already present in the target instance
|
||||
- The full chart configuration (query, visualization type, columns, metrics) is replaced by the imported version
|
||||
|
||||
If you import without the overwrite flag, existing charts with conflicting UUIDs are left unchanged and the import skips those objects. Use overwrite when you want to push a fully updated dashboard (including chart definitions) from a development or staging environment to production.
|
||||
|
||||
## UUIDs in API Responses
|
||||
|
||||
The REST API POST endpoints for **datasets**, **charts**, and **dashboards** include the auto-generated `uuid` field in the response body:
|
||||
|
||||
```json
|
||||
{
|
||||
"id": 42,
|
||||
"uuid": "b8a8d5c3-1234-4abc-8def-0123456789ab",
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
UUIDs remain stable across import/export cycles and can be used for cross-environment workflows — for example, recording a UUID when creating a chart in development and using it to identify the matching chart after importing into production.
|
||||
|
||||
## Legacy Importing Datasources
|
||||
|
||||
### From older versions of Superset to current version
|
||||
|
||||
@@ -501,6 +501,7 @@ All MCP settings go in `superset_config.py`. Defaults are defined in `superset/m
|
||||
| `MCP_SERVICE_URL` | `None` | Public base URL for MCP-generated links (set this when behind a reverse proxy) |
|
||||
| `MCP_DEBUG` | `False` | Enable debug logging |
|
||||
| `MCP_DEV_USERNAME` | -- | Superset username for development mode (no auth) |
|
||||
| `MCP_PARSE_REQUEST_ENABLED` | `True` | Pre-parse MCP tool inputs from JSON strings into objects. Set to `False` for clients (Claude Desktop, LangChain) that do not double-serialize arguments — this produces cleaner tool schemas for those clients |
|
||||
|
||||
### Authentication
|
||||
|
||||
@@ -664,6 +665,32 @@ MCP_CSRF_CONFIG = {
|
||||
|
||||
---
|
||||
|
||||
## Audit Events
|
||||
|
||||
All MCP tool calls are logged to Superset's event logger, the same system used by the web UI (viewable at **Settings → Action Log**). Each event captures:
|
||||
|
||||
- **Action**: `mcp.<tool_name>.<phase>` (e.g., `mcp.list_databases.query`)
|
||||
- **User**: the resolved Superset username from the JWT or dev config
|
||||
- **Timestamp**: when the operation ran
|
||||
|
||||
This means MCP activity is auditable alongside normal user activity. No additional configuration is required — logging is on by default whenever the event logger is enabled in your Superset deployment.
|
||||
|
||||
## Tool Pagination
|
||||
|
||||
MCP list tools (`list_datasets`, `list_charts`, `list_dashboards`, `list_databases`) use **offset pagination** via `page` (1-based) and `page_size` parameters. Responses include `page`, `page_size`, `total_count`, `total_pages`, `has_previous`, and `has_next`. To iterate through all results:
|
||||
|
||||
```python
|
||||
# Example: fetch all charts across pages
|
||||
all_charts = []
|
||||
page = 1
|
||||
while True:
|
||||
result = mcp.list_charts(page=page, page_size=50)
|
||||
all_charts.extend(result["charts"])
|
||||
if not result.get("has_next"):
|
||||
break
|
||||
page += 1
|
||||
```
|
||||
|
||||
## Security Best Practices
|
||||
|
||||
- **Use TLS** for all production MCP endpoints -- place the server behind a reverse proxy with HTTPS
|
||||
|
||||
@@ -412,7 +412,7 @@ curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
|
||||
|--------|----------|-------------|
|
||||
| `GET` | [Get security roles](/developer-docs/api/get-security-roles) | `/api/v1/security/roles/` |
|
||||
| `POST` | [Create security roles](/developer-docs/api/create-security-roles) | `/api/v1/security/roles/` |
|
||||
| `GET` | [Get security roles info](/developer-docs/api/get-security-roles-info) | `/api/v1/security/roles/_info` |
|
||||
| `GET` | [Get security roles info](/developer-docs/api/get-security-roles-info) | `/api/v1/security/roles/_info` |
|
||||
| `DELETE` | [Delete security roles by pk](/developer-docs/api/delete-security-roles-by-pk) | `/api/v1/security/roles/{pk}` |
|
||||
| `GET` | [Get security roles by pk](/developer-docs/api/get-security-roles-by-pk) | `/api/v1/security/roles/{pk}` |
|
||||
| `PUT` | [Update security roles by pk](/developer-docs/api/update-security-roles-by-pk) | `/api/v1/security/roles/{pk}` |
|
||||
@@ -430,7 +430,7 @@ curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
|
||||
|--------|----------|-------------|
|
||||
| `GET` | [Get security users](/developer-docs/api/get-security-users) | `/api/v1/security/users/` |
|
||||
| `POST` | [Create security users](/developer-docs/api/create-security-users) | `/api/v1/security/users/` |
|
||||
| `GET` | [Get security users info](/developer-docs/api/get-security-users-info) | `/api/v1/security/users/_info` |
|
||||
| `GET` | [Get security users info](/developer-docs/api/get-security-users-info) | `/api/v1/security/users/_info` |
|
||||
| `DELETE` | [Delete security users by pk](/developer-docs/api/delete-security-users-by-pk) | `/api/v1/security/users/{pk}` |
|
||||
| `GET` | [Get security users by pk](/developer-docs/api/get-security-users-by-pk) | `/api/v1/security/users/{pk}` |
|
||||
| `PUT` | [Update security users by pk](/developer-docs/api/update-security-users-by-pk) | `/api/v1/security/users/{pk}` |
|
||||
@@ -443,7 +443,7 @@ curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
|
||||
| Method | Endpoint | Description |
|
||||
|--------|----------|-------------|
|
||||
| `GET` | [Get security permissions](/developer-docs/api/get-security-permissions) | `/api/v1/security/permissions/` |
|
||||
| `GET` | [Get security permissions info](/developer-docs/api/get-security-permissions-info) | `/api/v1/security/permissions/_info` |
|
||||
| `GET` | [Get security permissions info](/developer-docs/api/get-security-permissions-info) | `/api/v1/security/permissions/_info` |
|
||||
| `GET` | [Get security permissions by pk](/developer-docs/api/get-security-permissions-by-pk) | `/api/v1/security/permissions/{pk}` |
|
||||
|
||||
</details>
|
||||
@@ -455,7 +455,7 @@ curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
|
||||
|--------|----------|-------------|
|
||||
| `GET` | [Get security resources](/developer-docs/api/get-security-resources) | `/api/v1/security/resources/` |
|
||||
| `POST` | [Create security resources](/developer-docs/api/create-security-resources) | `/api/v1/security/resources/` |
|
||||
| `GET` | [Get security resources info](/developer-docs/api/get-security-resources-info) | `/api/v1/security/resources/_info` |
|
||||
| `GET` | [Get security resources info](/developer-docs/api/get-security-resources-info) | `/api/v1/security/resources/_info` |
|
||||
| `DELETE` | [Delete security resources by pk](/developer-docs/api/delete-security-resources-by-pk) | `/api/v1/security/resources/{pk}` |
|
||||
| `GET` | [Get security resources by pk](/developer-docs/api/get-security-resources-by-pk) | `/api/v1/security/resources/{pk}` |
|
||||
| `PUT` | [Update security resources by pk](/developer-docs/api/update-security-resources-by-pk) | `/api/v1/security/resources/{pk}` |
|
||||
@@ -469,7 +469,7 @@ curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
|
||||
|--------|----------|-------------|
|
||||
| `GET` | [Get security permissions resources](/developer-docs/api/get-security-permissions-resources) | `/api/v1/security/permissions-resources/` |
|
||||
| `POST` | [Create security permissions resources](/developer-docs/api/create-security-permissions-resources) | `/api/v1/security/permissions-resources/` |
|
||||
| `GET` | [Get security permissions resources info](/developer-docs/api/get-security-permissions-resources-info) | `/api/v1/security/permissions-resources/_info` |
|
||||
| `GET` | [Get security permissions resources info](/developer-docs/api/get-security-permissions-resources-info) | `/api/v1/security/permissions-resources/_info` |
|
||||
| `DELETE` | [Delete security permissions resources by pk](/developer-docs/api/delete-security-permissions-resources-by-pk) | `/api/v1/security/permissions-resources/{pk}` |
|
||||
| `GET` | [Get security permissions resources by pk](/developer-docs/api/get-security-permissions-resources-by-pk) | `/api/v1/security/permissions-resources/{pk}` |
|
||||
| `PUT` | [Update security permissions resources by pk](/developer-docs/api/update-security-permissions-resources-by-pk) | `/api/v1/security/permissions-resources/{pk}` |
|
||||
@@ -578,7 +578,29 @@ curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
|
||||
|
||||
| Method | Endpoint | Description |
|
||||
|--------|----------|-------------|
|
||||
| `GET` | [Get api by version openapi](/developer-docs/api/get-api-by-version-openapi) | `/api/{version}/_openapi` |
|
||||
| `GET` | [Get api by version openapi](/developer-docs/api/get-api-by-version-openapi) | `/api/{version}/_openapi` |
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><strong>Themes</strong> (14 endpoints) — Manage UI themes for customizing Superset's appearance.</summary>
|
||||
|
||||
| Method | Endpoint | Description |
|
||||
|--------|----------|-------------|
|
||||
| `DELETE` | [Bulk delete themes](/developer-docs/api/bulk-delete-themes) | `/api/v1/theme/` |
|
||||
| `GET` | [Get a list of themes](/developer-docs/api/get-a-list-of-themes) | `/api/v1/theme/` |
|
||||
| `POST` | [Create a theme](/developer-docs/api/create-a-theme) | `/api/v1/theme/` |
|
||||
| `GET` | [Get metadata information about this API resource (theme-info)](/developer-docs/api/get-metadata-information-about-this-api-resource-theme-info) | `/api/v1/theme/_info` |
|
||||
| `DELETE` | [Delete a theme](/developer-docs/api/delete-a-theme) | `/api/v1/theme/{pk}` |
|
||||
| `GET` | [Get a theme](/developer-docs/api/get-a-theme) | `/api/v1/theme/{pk}` |
|
||||
| `PUT` | [Update a theme](/developer-docs/api/update-a-theme) | `/api/v1/theme/{pk}` |
|
||||
| `PUT` | [Set a theme as the system dark theme](/developer-docs/api/set-a-theme-as-the-system-dark-theme) | `/api/v1/theme/{pk}/set_system_dark` |
|
||||
| `PUT` | [Set a theme as the system default theme](/developer-docs/api/set-a-theme-as-the-system-default-theme) | `/api/v1/theme/{pk}/set_system_default` |
|
||||
| `GET` | [Download multiple themes as YAML files](/developer-docs/api/download-multiple-themes-as-yaml-files) | `/api/v1/theme/export/` |
|
||||
| `POST` | [Import themes from a ZIP file](/developer-docs/api/import-themes-from-a-zip-file) | `/api/v1/theme/import/` |
|
||||
| `GET` | [Get related fields data (theme-related-column-name)](/developer-docs/api/get-related-fields-data-theme-related-column-name) | `/api/v1/theme/related/{column_name}` |
|
||||
| `DELETE` | [Clear the system dark theme](/developer-docs/api/clear-the-system-dark-theme) | `/api/v1/theme/unset_system_dark` |
|
||||
| `DELETE` | [Clear the system default theme](/developer-docs/api/clear-the-system-default-theme) | `/api/v1/theme/unset_system_default` |
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ or a view.
|
||||
When working with tables, the solution would be to create a table that contains all the fields
|
||||
needed for your analysis, most likely through some scheduled batch process.
|
||||
|
||||
A view is a simple logical layer that abstracts an arbitrary SQL queries as a virtual table. This can
|
||||
A view is a simple logical layer that abstracts an arbitrary SQL query as a virtual table. This can
|
||||
allow you to join and union multiple tables and to apply some transformation using arbitrary SQL
|
||||
expressions. The limitation there is your database performance, as Superset effectively will run a
|
||||
query on top of your query (view). A good practice may be to limit yourself to joining your main
|
||||
|
||||
78
docs/docs/security/granular-export-controls.mdx
Normal file
@@ -0,0 +1,78 @@
|
||||
---
|
||||
title: Granular Export Controls
|
||||
sidebar_position: 4
|
||||
---
|
||||
|
||||
# Granular Export Controls
|
||||
|
||||
Superset provides granular, permission-based controls for data export, image export, and clipboard operations. These replace the legacy `can_csv` permission with three fine-grained permissions that can be assigned independently to roles.
|
||||
|
||||
## Feature Flag
|
||||
|
||||
Granular export controls are gated behind the `GRANULAR_EXPORT_CONTROLS` feature flag. When the flag is disabled, the legacy `can_csv` permission behavior is preserved.
|
||||
|
||||
```python
|
||||
FEATURE_FLAGS = {
|
||||
"GRANULAR_EXPORT_CONTROLS": True,
|
||||
}
|
||||
```
|
||||
|
||||
## Permissions
|
||||
|
||||
| Permission | Resource | Controls |
|
||||
| -------------------- | ---------- | ---------------------------------------------------------------------- |
|
||||
| `can_export_data` | `Superset` | CSV, Excel, and JSON data exports from charts, dashboards, and SQL Lab |
|
||||
| `can_export_image` | `Superset` | Screenshot (JPEG/PNG) and PDF exports from charts and dashboards |
|
||||
| `can_copy_clipboard` | `Superset` | Copy-to-clipboard operations in SQL Lab and the Explore data pane |
|
||||
|
||||
## Default Role Assignments
|
||||
|
||||
The migration grants all three new permissions (`can_export_data`, `can_export_image`, `can_copy_clipboard`) to every role that currently has `can_csv`. This preserves existing behavior — no role loses access during the upgrade.
|
||||
|
||||
After the migration, admins can selectively revoke individual export permissions from any role to restrict access. For example, to prevent Gamma users from exporting data or images while still allowing clipboard operations, revoke `can_export_data` and `can_export_image` from the Gamma role.
|
||||
|
||||
## Configuration Steps
|
||||
|
||||
1. **Enable the feature flag** in `superset_config.py`:
|
||||
|
||||
```python
|
||||
FEATURE_FLAGS = {
|
||||
"GRANULAR_EXPORT_CONTROLS": True,
|
||||
}
|
||||
```
|
||||
|
||||
2. **Run the database migration** to register the new permissions:
|
||||
|
||||
```bash
|
||||
superset db upgrade
|
||||
```
|
||||
|
||||
3. **Initialize permissions** so roles are populated:
|
||||
|
||||
```bash
|
||||
superset init
|
||||
```
|
||||
|
||||
4. **Verify role assignments** in **Settings > List Roles**. Confirm that each role has the expected permissions from the table above.
|
||||
|
||||
5. **Customize as needed**: Grant or revoke individual export permissions on any role through the role editor.
|
||||
|
||||
## User Experience
|
||||
|
||||
When a user lacks a required export permission:
|
||||
|
||||
- **Menu items** (CSV, Excel, JSON, screenshot) appear **disabled** with an info tooltip icon explaining the restriction
|
||||
- **Buttons** (SQL Lab download, clipboard copy) appear **disabled** with a tooltip on hover
|
||||
- **API endpoints** return **403 Forbidden** when the corresponding permission is missing
|
||||
|
||||
## API Enforcement
|
||||
|
||||
The following API endpoints enforce granular export permissions when the feature flag is enabled:
|
||||
|
||||
| Endpoint | Required Permission |
|
||||
| --------------------------------------------------------- | ------------------- |
|
||||
| `GET /api/v1/chart/{id}/data/` (CSV/Excel format) | `can_export_data` |
|
||||
| `GET /api/v1/chart/{id}/cache_screenshot/` | `can_export_image` |
|
||||
| `POST /api/v1/dashboard/{id}/cache_dashboard_screenshot/` | `can_export_image` |
|
||||
| `GET /api/v1/sqllab/export/{client_id}/` | `can_export_data` |
|
||||
| `POST /api/v1/sqllab/export_streaming/` | `can_export_data` |
|
||||
@@ -63,6 +63,12 @@ by clicking the **Connect** button in the bottom right corner of the modal windo
|
||||
|
||||
Congratulations, you've just added a new data source in Superset!
|
||||
|
||||
### Sharing a Database Connection
|
||||
|
||||
When adding a new database, you can share the connection with other Superset users. Shared connections appear in other users' database lists, making it easier to collaborate on the same data without requiring each user to configure the same connection separately.
|
||||
|
||||
To share a connection, enable the **Share connection with other users** option in the **Advanced** tab of the database connection modal before saving. You can change sharing settings later by editing the database connection.
|
||||
|
||||
### Registering a new table
|
||||
|
||||
Now that you’ve configured a data source, you can select specific tables (called **Datasets** in Superset)
|
||||
@@ -80,6 +86,22 @@ we register the **cleaned_sales_data** table from the **examples** database.
|
||||
|
||||
To finish, click the **Add** button in the bottom right corner. You should now see your dataset in the list of datasets.
|
||||
|
||||
### Organizing Datasets into Folders
|
||||
|
||||
The Datasets list view supports **folders** for organizing datasets into groups. To create and manage folders:
|
||||
|
||||
1. In the **Datasets** list, click the **Folders** panel on the left sidebar.
|
||||
2. Click **+ New Folder** to create a top-level folder, or drag an existing folder to nest it.
|
||||
3. Drag dataset rows onto a folder to move them in, or right-click a dataset and select **Move to folder**.
|
||||
|
||||
Folders are per-user organizational aids — they do not affect dataset access permissions or how other users see the datasets.
|
||||
|
||||
### Uploading Files via the OS File Manager (PWA)
|
||||
|
||||
When Superset is installed as a **Progressive Web App (PWA)** from your browser, your operating system will offer Superset as an option when opening CSV, Excel (`.xls`/`.xlsx`), and Parquet files. Double-clicking or right-clicking a supported file and selecting "Open with Superset" navigates directly to the upload workflow for that file.
|
||||
|
||||
To install Superset as a PWA, look for the install icon in your browser's address bar (Chrome, Edge) when visiting your Superset instance over HTTPS. PWA installation requires HTTPS and a valid manifest — your admin needs to confirm the app manifest is served correctly.
|
||||
|
||||
### Customizing column properties
|
||||
|
||||
Now that you've registered your dataset, you can configure column properties
|
||||
@@ -234,6 +256,64 @@ For example, when running the local development build, the following will disabl
|
||||
Top Nav and remove the Filter Bar:
|
||||
`http://localhost:8088/superset/dashboard/my-dashboard/?standalone=1&show_filters=0`
|
||||
|
||||
### AG Grid Interactive Table
|
||||
|
||||
The **AG Grid Interactive Table** chart type is Superset's fully-featured data grid, suitable for large paginated datasets where the standard Table chart is not enough.
|
||||
|
||||
#### Server-Side Column Filters
|
||||
|
||||
AG Grid supports server-side column filters that query the full dataset — not just the loaded page. Filters are applied before data is sent to the browser, so results are correct even across millions of rows.
|
||||
|
||||
**Available filter types:**
|
||||
|
||||
| Column type | Filter options |
|
||||
|---|---|
|
||||
| Text | Contains, equals, starts with, ends with |
|
||||
| Number | Equals, not equal, less than, greater than, between |
|
||||
| Date | Before, after, between, blank |
|
||||
| Set | Select from a list of distinct values |
|
||||
|
||||
**AND / OR logic:** Each column supports combining multiple conditions with AND or OR. Filters from different columns are always combined with AND.
|
||||
|
||||
**Interaction with pagination:** Server-side filters run as WHERE clauses in the underlying SQL query, so pagination always operates over the already-filtered result set.
|
||||
|
||||
#### Time Shift (Time Comparison)
|
||||
|
||||
AG Grid Interactive Table supports **Time Shift** (time comparison), matching the behavior of the standard Table chart. In the **Advanced Analytics** → **Time Comparison** section of the chart configuration, enter a shift expression (e.g., `1 year ago`, `minus 7 days`) to add comparison columns showing values from the offset period. Dashboard-level time range overrides apply to both the base and comparison periods.
|
||||
|
||||
### Dynamic Currency Formatting
|
||||
|
||||
Chart metric values can display currencies dynamically rather than using a fixed currency code. To enable:
|
||||
|
||||
1. Open the dataset editor for your dataset (**Datasets → Edit**).
|
||||
2. In the **Advanced** tab, set **Currency Code Column** to the name of a column in your dataset that contains ISO 4217 currency codes (e.g., `USD`, `EUR`, `GBP`).
|
||||
3. In the Explore chart configuration, open the metric's **Number format** section and select **Auto-detect** for currency.
|
||||
|
||||
When Auto-detect is active, each row uses the currency code from the designated column, so a single chart can display values in multiple currencies — each formatted correctly for its currency.
|
||||
|
||||
### ECharts Option Editor
|
||||
|
||||
For ECharts-based chart types (line, bar, area, scatter, pie, and others), Explore includes an advanced **ECharts Option Editor** that accepts raw JSON overrides for the underlying ECharts configuration.
|
||||
|
||||
Access it via the **Customize** tab → **ECharts Options** section at the bottom of the panel. The JSON you enter is deep-merged on top of Superset's generated ECharts config, so you can override specific options without rewriting the entire config.
|
||||
|
||||
**Example:** override the legend position and add a custom title:
|
||||
|
||||
```json
|
||||
{
|
||||
"legend": { "orient": "vertical", "right": "5%", "top": "middle" },
|
||||
"title": { "text": "My Custom Title", "left": "center" }
|
||||
}
|
||||
```
|
||||
|
||||
:::caution
|
||||
ECharts option overrides bypass Superset's validation layer. Invalid option keys are silently ignored by ECharts. Overrides that conflict with Superset-generated options (e.g., `series`) may produce unexpected results.
|
||||
:::
|
||||
|
||||
### Table Chart: Exporting Filtered Data
|
||||
|
||||
When the **Search Box** is visible in a Table chart, the **Download** action exports only the rows currently visible after the search filter is applied — not the full underlying dataset. This matches the visual output and is intentional. To export the full dataset regardless of search state, use the **Download as CSV** option from the chart's three-dot menu in the dashboard or from the Explore chart toolbar before applying a search filter.
|
||||
|
||||
:::resources
|
||||
- [Dashboard Customization](https://docs.preset.io/docs/dashboard-customization) - Advanced dashboard styling and layout options
|
||||
- [Blog: BI Dashboard Best Practices](https://preset.io/blog/bi-dashboard-best-practices/)
|
||||
|
||||
130
docs/docs/using-superset/embedding.mdx
Normal file
@@ -0,0 +1,130 @@
|
||||
{/*
|
||||
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.
|
||||
*/}
|
||||
|
||||
---
|
||||
title: Embedding Superset
|
||||
sidebar_position: 6
|
||||
---
|
||||
|
||||
# Embedding Superset
|
||||
|
||||
Superset dashboards can be embedded directly in host applications using the `@superset-ui/embedded-sdk` package.
|
||||
|
||||
:::info Prerequisites
|
||||
- The `EMBEDDED_SUPERSET` feature flag must be enabled.
|
||||
- The embedding domain and allowed origins must be configured by an admin.
|
||||
:::
|
||||
|
||||
## Quick Start
|
||||
|
||||
Install the SDK:
|
||||
|
||||
```bash
|
||||
npm install @superset-ui/embedded-sdk
|
||||
```
|
||||
|
||||
Embed a dashboard:
|
||||
|
||||
```javascript
|
||||
import { embedDashboard } from '@superset-ui/embedded-sdk';
|
||||
|
||||
embedDashboard({
|
||||
id: 'dashboard-uuid-here', // from Dashboard → Embed
|
||||
supersetDomain: 'https://superset.example.com',
|
||||
mountPoint: document.getElementById('superset-container'),
|
||||
fetchGuestToken: () => fetchTokenFromYourBackend(),
|
||||
dashboardUiConfig: {
|
||||
hideTitle: true,
|
||||
filters: { expanded: false },
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
`fetchGuestToken` must return a **guest token** obtained from your server by calling Superset's `/api/v1/security/guest_token/` endpoint with a service account. Do not call this endpoint from client-side code.
|
||||
|
||||
---
|
||||
|
||||
## Callbacks
|
||||
|
||||
### `resolvePermalinkUrl`
|
||||
|
||||
When a user copies a permalink from an embedded dashboard, Superset generates a URL on its own domain. In an embedded context this URL is usually not meaningful to the host application's users — the dashboard is rendered inside the host app, not at the Superset URL.
|
||||
|
||||
The `resolvePermalinkUrl` callback lets the host app intercept permalink generation and return a URL on the host domain instead:
|
||||
|
||||
```javascript
|
||||
embedDashboard({
|
||||
id: 'my-dashboard-uuid',
|
||||
supersetDomain: 'https://superset.example.com',
|
||||
mountPoint: document.getElementById('superset-container'),
|
||||
fetchGuestToken: () => fetchGuestToken(),
|
||||
/**
|
||||
* Called when Superset generates a permalink.
|
||||
* @param {Object} args - { key: string } — the permalink key
|
||||
* @returns {string | null} - your host URL, or null to use Superset's default
|
||||
*/
|
||||
resolvePermalinkUrl: ({ key }) => {
|
||||
return `https://myapp.example.com/dashboard?permalink=${key}`;
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
If the callback returns `null` or is not provided, Superset uses its own permalink URL as a fallback.
|
||||
|
||||
---
|
||||
|
||||
## Feature Flags for Embedded Mode
|
||||
|
||||
### `DISABLE_EMBEDDED_SUPERSET_LOGOUT`
|
||||
|
||||
Hides the logout button when Superset is embedded in a host application. This is useful when the host application manages the session lifecycle and you do not want users to accidentally log out of the embedded Superset session:
|
||||
|
||||
```python
|
||||
# superset_config.py
|
||||
FEATURE_FLAGS = {
|
||||
"EMBEDDED_SUPERSET": True,
|
||||
"DISABLE_EMBEDDED_SUPERSET_LOGOUT": True,
|
||||
}
|
||||
```
|
||||
|
||||
When enabled, the **Logout** menu item is removed from the user avatar dropdown in the embedded view. The session can still be invalidated server-side by revoking the guest token.
|
||||
|
||||
### `EMBEDDED_SUPERSET`
|
||||
|
||||
Must be `True` to enable the embedded SDK and the guest token endpoint. Without this flag, `embedDashboard` will fail to load.
|
||||
|
||||
---
|
||||
|
||||
## URL Parameters
|
||||
|
||||
The following URL parameters can be passed through the `urlParams` option in `dashboardUiConfig` or appended to the embedded iframe URL:
|
||||
|
||||
| Parameter | Values | Effect |
|
||||
|-----------|--------|--------|
|
||||
| `standalone` | `0`, `1`, `2`, `3` | `0`: normal; `1`: hide nav; `2`: hide nav + title; `3`: hide nav + title + tabs |
|
||||
| `show_filters` | `0`, `1` | Show or hide the native filter bar |
|
||||
| `expand_filters` | `0`, `1` | Start with filter bar expanded or collapsed |
|
||||
|
||||
---
|
||||
|
||||
## Security Notes
|
||||
|
||||
- **Guest tokens expire** — their lifetime is controlled by the `GUEST_TOKEN_JWT_EXP_SECONDS` config (default: 5 minutes). Refresh tokens before they expire using a token refresh mechanism in your host app.
|
||||
- **Row-level security** — pass `rls` rules in the guest token request to restrict which rows are visible to the embedded user.
|
||||
- **Allowed domains** — restrict which host origins can embed a dashboard by setting **Allowed Domains** per-dashboard in the *Embed* settings modal. Superset checks the request's `Referer` header against this list before serving the embedded view; an empty list allows any origin, so configure this explicitly for production.
|
||||
@@ -329,6 +329,27 @@ various options in this section, refer to the
|
||||
Lastly, save your chart as Tutorial Resample and add it to the Tutorial Dashboard. Go to the
|
||||
tutorial dashboard to see the four charts side by side and compare the different outputs.
|
||||
|
||||
### SQL Lab Tips
|
||||
|
||||
**Schema and table browser**: The left-side table browser uses a collapsible treeview — click a schema to expand its tables, and click a table to see its columns and sample data inline. This makes navigating large schemas much faster than the previous flat list.
|
||||
|
||||
**Find in editor**: Press **Ctrl+F** (or **Cmd+F** on Mac) to open the Monaco find/replace widget inside the SQL editor without leaving the editor.
|
||||
|
||||
**Resizable panels**: The dividers between the SQL editor, schema browser, and results pane are draggable. Adjust them to match your workflow and screen size.
|
||||
|
||||
**Dialect-aware Format SQL**: The **Format SQL** button applies the SQL dialect of the currently selected database — Trino, Presto, MySQL, PostgreSQL, etc. — rather than a generic formatter. Switch to a different database in the toolbar and re-format to get dialect-specific output. Jinja template syntax (`{{ }}`, `{% %}`) is preserved during formatting and will not cause format errors.
|
||||
|
||||
### Time Range Natural Language Expressions
|
||||
|
||||
The **Custom** time range picker accepts natural language expressions alongside specific dates:
|
||||
|
||||
- **Relative**: `Last 7 days`, `Last month`, `Last quarter`, `Last year`
|
||||
- **Anchored**: `previous calendar week`, `previous calendar month`
|
||||
- **"First of" expressions**: `first day of this week`, `first day of this month`, `first day of this quarter`, `first day of this year`, `first week of this year`
|
||||
- **Offsets**: `30 days ago`, `1 year ago`, `next week`
|
||||
|
||||
These expressions are evaluated at query time, so saved charts always display data relative to the current date.
|
||||
|
||||
:::resources
|
||||
- [Chart Walkthroughs](https://docs.preset.io/docs/chart-walkthroughs) - Detailed guides for most chart types
|
||||
- [Blog: Why Apache ECharts is the Future of Apache Superset](https://preset.io/blog/2021-4-1-why-echarts/)
|
||||
|
||||
@@ -56,8 +56,8 @@ Ask your AI assistant to browse what's available in your Superset instance:
|
||||
Describe the visualization you want and AI creates it for you:
|
||||
|
||||
- **Create charts from natural language** -- describe what you want to see and AI picks the right chart type, metrics, and dimensions
|
||||
- **Preview before saving** -- AI generates a preview so you can review before committing
|
||||
- **Modify existing charts** -- update filters, change chart types, add metrics
|
||||
- **Preview before saving** -- `generate_chart` defaults to `save_chart=False`, showing the chart in Explore before it's committed. Ask AI to save once you're satisfied.
|
||||
- **Modify existing charts** -- `update_chart` also supports preview mode so you can review changes before saving
|
||||
- **Get Explore links** -- open any chart in Superset's Explore view for further refinement
|
||||
|
||||
**Example prompts:**
|
||||
@@ -195,27 +195,59 @@ Ask your admin for the MCP server URL and any authentication tokens you need.
|
||||
|
||||
## Available Tools Reference
|
||||
|
||||
### Exploration & Discovery
|
||||
|
||||
| Tool | Description |
|
||||
|------|-------------|
|
||||
| `health_check` | Verify the MCP server is running and connected |
|
||||
| `get_instance_info` | Get instance statistics (dataset, chart, dashboard counts) |
|
||||
| `get_schema` | Discover available charts, datasets, and dashboards with schema info |
|
||||
|
||||
### Datasets
|
||||
|
||||
| Tool | Description |
|
||||
|------|-------------|
|
||||
| `list_datasets` | List datasets with filtering and search |
|
||||
| `get_dataset_info` | Get dataset metadata (columns, metrics, filters) |
|
||||
| `create_virtual_dataset` | Create a virtual dataset from a SQL query |
|
||||
|
||||
### Charts
|
||||
|
||||
| Tool | Description |
|
||||
|------|-------------|
|
||||
| `list_charts` | List charts with filtering and search |
|
||||
| `get_chart_info` | Get chart metadata and configuration |
|
||||
| `get_chart_data` | Retrieve chart data (JSON, CSV, or Excel) |
|
||||
| `get_chart_preview` | Generate a chart preview (URL, ASCII, table, or Vega-Lite) |
|
||||
| `generate_chart` | Create a new chart from a specification |
|
||||
| `update_chart` | Modify an existing chart's configuration |
|
||||
| `get_chart_type_schema` | Get the configuration schema for a chart type |
|
||||
| `generate_chart` | Create a new chart from a specification (defaults to preview mode — review before saving) |
|
||||
| `update_chart` | Modify an existing chart's configuration (pass `generate_preview=False` to persist immediately instead of returning a preview URL) |
|
||||
| `update_chart_preview` | Update a cached chart preview without saving |
|
||||
| `generate_explore_link` | Generate an Explore URL for interactive visualization |
|
||||
|
||||
### Dashboards
|
||||
|
||||
| Tool | Description |
|
||||
|------|-------------|
|
||||
| `list_dashboards` | List dashboards with filtering and search |
|
||||
| `get_dashboard_info` | Get dashboard metadata and layout |
|
||||
| `generate_dashboard` | Create a new dashboard with specified charts |
|
||||
| `add_chart_to_existing_dashboard` | Add a chart to an existing dashboard |
|
||||
|
||||
### SQL
|
||||
|
||||
| Tool | Description |
|
||||
|------|-------------|
|
||||
| `execute_sql` | Run a SQL query with RBAC enforcement |
|
||||
| `save_sql_query` | Persist a SQL query to SQL Lab's saved queries |
|
||||
| `open_sql_lab_with_context` | Open SQL Lab with a pre-populated query |
|
||||
| `generate_explore_link` | Generate an Explore URL for interactive visualization |
|
||||
|
||||
### Databases
|
||||
|
||||
| Tool | Description |
|
||||
|------|-------------|
|
||||
| `list_databases` | List configured database connections |
|
||||
| `get_database_info` | Get details about a specific database connection |
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -41,12 +41,12 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@ant-design/icons": "^6.1.1",
|
||||
"@docusaurus/core": "3.9.2",
|
||||
"@docusaurus/faster": "^3.9.2",
|
||||
"@docusaurus/plugin-client-redirects": "3.9.2",
|
||||
"@docusaurus/preset-classic": "3.9.2",
|
||||
"@docusaurus/theme-live-codeblock": "^3.9.2",
|
||||
"@docusaurus/theme-mermaid": "^3.9.2",
|
||||
"@docusaurus/core": "^3.10.0",
|
||||
"@docusaurus/faster": "^3.10.0",
|
||||
"@docusaurus/plugin-client-redirects": "^3.10.0",
|
||||
"@docusaurus/preset-classic": "3.10.0",
|
||||
"@docusaurus/theme-live-codeblock": "^3.10.0",
|
||||
"@docusaurus/theme-mermaid": "^3.10.0",
|
||||
"@emotion/core": "^11.0.0",
|
||||
"@emotion/react": "^11.13.3",
|
||||
"@emotion/styled": "^11.14.1",
|
||||
@@ -67,12 +67,12 @@
|
||||
"@storybook/preview-api": "^8.6.18",
|
||||
"@storybook/theming": "^8.6.15",
|
||||
"@superset-ui/core": "^0.20.4",
|
||||
"@swc/core": "^1.15.21",
|
||||
"antd": "^6.3.5",
|
||||
"baseline-browser-mapping": "^2.10.13",
|
||||
"caniuse-lite": "^1.0.30001786",
|
||||
"docusaurus-plugin-openapi-docs": "^4.6.0",
|
||||
"docusaurus-theme-openapi-docs": "^4.6.0",
|
||||
"@swc/core": "^1.15.30",
|
||||
"antd": "^6.3.6",
|
||||
"baseline-browser-mapping": "^2.10.20",
|
||||
"caniuse-lite": "^1.0.30001790",
|
||||
"docusaurus-plugin-openapi-docs": "^5.0.1",
|
||||
"docusaurus-theme-openapi-docs": "^5.0.1",
|
||||
"js-yaml": "^4.1.1",
|
||||
"js-yaml-loader": "^1.2.2",
|
||||
"json-bigint": "^1.0.0",
|
||||
@@ -86,28 +86,28 @@
|
||||
"remark-import-partial": "^0.0.2",
|
||||
"reselect": "^5.1.1",
|
||||
"storybook": "^8.6.18",
|
||||
"swagger-ui-react": "^5.32.1",
|
||||
"swagger-ui-react": "^5.32.4",
|
||||
"swc-loader": "^0.2.7",
|
||||
"tinycolor2": "^1.4.2",
|
||||
"unist-util-visit": "^5.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@docusaurus/module-type-aliases": "^3.9.1",
|
||||
"@docusaurus/tsconfig": "^3.9.2",
|
||||
"@docusaurus/module-type-aliases": "^3.10.0",
|
||||
"@docusaurus/tsconfig": "^3.10.0",
|
||||
"@eslint/js": "^9.39.2",
|
||||
"@types/js-yaml": "^4.0.9",
|
||||
"@types/react": "^19.1.8",
|
||||
"@typescript-eslint/eslint-plugin": "^8.52.0",
|
||||
"@typescript-eslint/parser": "^8.56.1",
|
||||
"@typescript-eslint/parser": "^8.59.0",
|
||||
"eslint": "^9.39.2",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-prettier": "^5.5.5",
|
||||
"eslint-plugin-react": "^7.37.5",
|
||||
"globals": "^17.4.0",
|
||||
"prettier": "^3.8.1",
|
||||
"typescript": "~5.9.3",
|
||||
"typescript-eslint": "^8.58.0",
|
||||
"webpack": "^5.105.4"
|
||||
"globals": "^17.5.0",
|
||||
"prettier": "^3.8.3",
|
||||
"typescript": "~6.0.3",
|
||||
"typescript-eslint": "^8.59.0",
|
||||
"webpack": "^5.106.2"
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
@@ -124,7 +124,8 @@
|
||||
"resolutions": {
|
||||
"react-redux": "^9.2.0",
|
||||
"@reduxjs/toolkit": "^2.5.0",
|
||||
"baseline-browser-mapping": "^2.9.19"
|
||||
"baseline-browser-mapping": "^2.9.19",
|
||||
"webpackbar": "^7.0.0"
|
||||
},
|
||||
"packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
|
||||
}
|
||||
|
||||
@@ -129,6 +129,30 @@ def add_missing_schemas(spec: dict[str, Any]) -> tuple[dict[str, Any], list[str]
|
||||
}
|
||||
fixed.append("DashboardColorsConfigUpdateSchema")
|
||||
|
||||
# DashboardChartCustomizationsConfigUpdateSchema (dashboards/schemas.py)
|
||||
if "DashboardChartCustomizationsConfigUpdateSchema" not in schemas:
|
||||
schemas["DashboardChartCustomizationsConfigUpdateSchema"] = {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"deleted": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"},
|
||||
"description": "List of deleted chart customization IDs.",
|
||||
},
|
||||
"modified": {
|
||||
"type": "array",
|
||||
"items": {"type": "object"},
|
||||
"description": "List of modified chart customizations.",
|
||||
},
|
||||
"reordered": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"},
|
||||
"description": "List of chart customization IDs in new order.",
|
||||
},
|
||||
},
|
||||
}
|
||||
fixed.append("DashboardChartCustomizationsConfigUpdateSchema")
|
||||
|
||||
# FormatQueryPayloadSchema - based on superset/sqllab/schemas.py
|
||||
if "FormatQueryPayloadSchema" not in schemas:
|
||||
schemas["FormatQueryPayloadSchema"] = {
|
||||
@@ -295,6 +319,7 @@ TAG_DESCRIPTIONS = {
|
||||
"Security Roles": "Manage security roles and their permissions.",
|
||||
"Security Users": "Manage user accounts.",
|
||||
"Tags": "Organize assets with tags.",
|
||||
"Themes": "Manage UI themes for customizing Superset's appearance.",
|
||||
"User": "User profile and preferences.",
|
||||
}
|
||||
|
||||
|
||||
BIN
docs/static/img/logos/hifadih.png
vendored
Normal file
|
After Width: | Height: | Size: 18 KiB |
5791
docs/static/resources/openapi.json
vendored
@@ -3,6 +3,7 @@
|
||||
"extends": "@docusaurus/tsconfig",
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"ignoreDeprecations": "6.0",
|
||||
"skipLibCheck": true,
|
||||
"noImplicitAny": false,
|
||||
"strict": false,
|
||||
|
||||
@@ -109,6 +109,14 @@ SECRET_KEY = 'YOUR_OWN_RANDOM_GENERATED_SECRET_KEY'
|
||||
|
||||
You can generate a strong secure key with `openssl rand -base64 42`.
|
||||
|
||||
Alternatively, you can set the secret key using `SUPERSET_SECRET_KEY` environment variable:
|
||||
|
||||
On a Unix-based system, such as Linux or macOS, you can do so by running the following command in your terminal:
|
||||
|
||||
```bash
|
||||
export SUPERSET_SECRET_KEY=$(openssl rand -base64 42)
|
||||
```
|
||||
|
||||
:::caution Use a strong secret key
|
||||
This key will be used for securely signing session cookies and encrypting sensitive information stored in Superset's application metadata database.
|
||||
Your deployment must use a complex, unique key.
|
||||
|
||||
@@ -35,7 +35,7 @@ or a view.
|
||||
When working with tables, the solution would be to create a table that contains all the fields
|
||||
needed for your analysis, most likely through some scheduled batch process.
|
||||
|
||||
A view is a simple logical layer that abstracts an arbitrary SQL queries as a virtual table. This can
|
||||
A view is a simple logical layer that abstracts an arbitrary SQL query as a virtual table. This can
|
||||
allow you to join and union multiple tables and to apply some transformation using arbitrary SQL
|
||||
expressions. The limitation there is your database performance, as Superset effectively will run a
|
||||
query on top of your query (view). A good practice may be to limit yourself to joining your main
|
||||
|
||||
2016
docs/yarn.lock
@@ -48,7 +48,7 @@ dependencies = [
|
||||
"cryptography>=42.0.4, <47.0.0",
|
||||
"deprecation>=2.1.0, <2.2.0",
|
||||
"flask>=2.2.5, <4.0.0",
|
||||
"flask-appbuilder>=5.0.2,<6",
|
||||
"flask-appbuilder>=5.2.1, <6.0.0",
|
||||
"flask-caching>=2.1.0, <3",
|
||||
"flask-compress>=1.13, <2.0",
|
||||
"flask-talisman>=1.0.0, <2.0",
|
||||
@@ -89,7 +89,7 @@ dependencies = [
|
||||
"python-dateutil",
|
||||
"python-dotenv", # optional dependencies for Flask but required for Superset, see https://flask.palletsprojects.com/en/stable/installation/#optional-dependencies
|
||||
"pygeohash",
|
||||
"pyarrow>=16.1.0, <19", # before upgrading pyarrow, check that all db dependencies support this, see e.g. https://github.com/apache/superset/pull/34693
|
||||
"pyarrow>=16.1.0, <21", # before upgrading pyarrow, check that all db dependencies support this, see e.g. https://github.com/apache/superset/pull/34693
|
||||
"pyyaml>=6.0.0, <7.0.0",
|
||||
"PyJWT>=2.4.0, <3.0",
|
||||
"redis>=5.0.0, <6.0",
|
||||
@@ -183,6 +183,7 @@ risingwave = ["sqlalchemy-risingwave"]
|
||||
shillelagh = ["shillelagh[all]>=1.4.3, <2"]
|
||||
singlestore = ["sqlalchemy-singlestoredb>=1.1.1, <2"]
|
||||
snowflake = ["snowflake-sqlalchemy>=1.2.4, <2"]
|
||||
sqlite = ["syntaqlite>=0.1.0"]
|
||||
spark = [
|
||||
"pyhive[hive]>=0.6.5;python_version<'3.11'",
|
||||
"pyhive[hive_pure_sasl]>=0.7",
|
||||
@@ -226,6 +227,7 @@ development = [
|
||||
"ruff",
|
||||
"sqloxide",
|
||||
"statsd",
|
||||
"syntaqlite>=0.1.0",
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
@@ -238,7 +240,7 @@ combine_as_imports = true
|
||||
include_trailing_comma = true
|
||||
line_length = 88
|
||||
known_first_party = "superset, apache-superset-core, apache-superset-extensions-cli"
|
||||
known_third_party = "alembic, apispec, backoff, celery, click, colorama, cron_descriptor, croniter, cryptography, dateutil, deprecation, flask, flask_appbuilder, flask_babel, flask_caching, flask_compress, flask_jwt_extended, flask_login, flask_migrate, flask_sqlalchemy, flask_talisman, flask_testing, flask_wtf, freezegun, geohash, geopy, holidays, humanize, isodate, jinja2, jwt, markdown, markupsafe, marshmallow, marshmallow-union, msgpack, nh3, numpy, pandas, parameterized, parsedatetime, pgsanity, polyline, prison, progress, pyarrow, sqlalchemy_bigquery, pyhive, pyparsing, pytest, pytest_mock, pytz, redis, requests, selenium, setuptools, shillelagh, simplejson, slack, sqlalchemy, sqlalchemy_utils, typing_extensions, urllib3, werkzeug, wtforms, wtforms_json, yaml"
|
||||
known_third_party = "alembic, apispec, backoff, celery, click, colorama, cron_descriptor, croniter, cryptography, dateutil, deprecation, flask, flask_appbuilder, flask_babel, flask_caching, flask_compress, flask_jwt_extended, flask_login, flask_migrate, flask_sqlalchemy, flask_talisman, flask_testing, flask_wtf, freezegun, geohash, geopy, holidays, humanize, isodate, jinja2, jwt, markdown, markupsafe, marshmallow, marshmallow-union, msgpack, nh3, numpy, pandas, parameterized, parsedatetime, pgsanity, polyline, prison, progress, pyarrow, sqlalchemy_bigquery, pyhive, pyparsing, pytest, pytest_mock, pytz, redis, requests, selenium, setuptools, shillelagh, simplejson, slack, sqlalchemy, sqlalchemy_utils, syntaqlite, typing_extensions, urllib3, werkzeug, wtforms, wtforms_json, yaml"
|
||||
multi_line_output = 3
|
||||
order_by_type = false
|
||||
|
||||
@@ -372,6 +374,7 @@ unfixable = []
|
||||
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
|
||||
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
"superset/mcp_service/app.py" = ["S608", "E501"] # LLM instruction text: SQL examples (S608) and long lines in multiline string (E501)
|
||||
"scripts/*" = ["TID251"]
|
||||
"setup.py" = ["TID251"]
|
||||
"superset/config.py" = ["TID251"]
|
||||
|
||||
@@ -25,6 +25,16 @@ filelock>=3.20.3,<4.0.0
|
||||
# Security: decompression bomb fix (required by aiohttp 3.13.3)
|
||||
brotli>=1.2.0,<2.0.0
|
||||
numexpr>=2.9.0
|
||||
# Security: CVE-2026-34073 (MEDIUM) - Improper Certificate Validation
|
||||
cryptography>=46.0.7,<47.0.0
|
||||
# Security: Snyk - XSS vulnerability in Mako templates
|
||||
mako>=1.3.11,<2.0.0
|
||||
# Security: CVE-2024-52338 (CRITICAL) - Deserialization of untrusted data in IPC/Parquet readers
|
||||
pyarrow>=20.0.0,<21.0.0
|
||||
# Security: CVE-2026-27459 - pyopenssl certificate validation
|
||||
pyopenssl>=26.0.0,<27.0.0
|
||||
# Security: CVE-2026-25645 (MEDIUM) - Insecure Temporary File
|
||||
requests>=2.33.0,<3.0.0
|
||||
|
||||
# 5.0.0 has a sensitive deprecation used in other libs
|
||||
# -> https://github.com/aio-libs/async-timeout/blob/master/CHANGES.rst#500-2024-10-31
|
||||
|
||||
@@ -86,8 +86,9 @@ cron-descriptor==1.4.5
|
||||
# via apache-superset (pyproject.toml)
|
||||
croniter==6.0.0
|
||||
# via apache-superset (pyproject.toml)
|
||||
cryptography==46.0.6
|
||||
cryptography==46.0.7
|
||||
# via
|
||||
# -r requirements/base.in
|
||||
# apache-superset (pyproject.toml)
|
||||
# paramiko
|
||||
# pyopenssl
|
||||
@@ -120,7 +121,7 @@ flask==2.3.3
|
||||
# flask-session
|
||||
# flask-sqlalchemy
|
||||
# flask-wtf
|
||||
flask-appbuilder==5.2.0
|
||||
flask-appbuilder==5.2.1
|
||||
# via
|
||||
# apache-superset (pyproject.toml)
|
||||
# apache-superset-core
|
||||
@@ -205,8 +206,9 @@ kombu==5.5.3
|
||||
# via celery
|
||||
limits==5.1.0
|
||||
# via flask-limiter
|
||||
mako==1.3.10
|
||||
mako==1.3.11
|
||||
# via
|
||||
# -r requirements/base.in
|
||||
# apache-superset (pyproject.toml)
|
||||
# alembic
|
||||
markdown==3.8.1
|
||||
@@ -291,8 +293,10 @@ prison==0.2.1
|
||||
# via flask-appbuilder
|
||||
prompt-toolkit==3.0.51
|
||||
# via click-repl
|
||||
pyarrow==16.1.0
|
||||
# via apache-superset (pyproject.toml)
|
||||
pyarrow==20.0.0
|
||||
# via
|
||||
# -r requirements/base.in
|
||||
# apache-superset (pyproject.toml)
|
||||
pyasn1==0.6.3
|
||||
# via
|
||||
# pyasn1-modules
|
||||
@@ -319,8 +323,10 @@ pyjwt==2.12.0
|
||||
# redis
|
||||
pynacl==1.6.2
|
||||
# via paramiko
|
||||
pyopenssl==25.3.0
|
||||
# via shillelagh
|
||||
pyopenssl==26.0.0
|
||||
# via
|
||||
# -r requirements/base.in
|
||||
# shillelagh
|
||||
pyparsing==3.2.3
|
||||
# via apache-superset (pyproject.toml)
|
||||
pysocks==1.7.1
|
||||
@@ -353,8 +359,9 @@ referencing==0.36.2
|
||||
# via
|
||||
# jsonschema
|
||||
# jsonschema-specifications
|
||||
requests==2.32.4
|
||||
requests==2.33.0
|
||||
# via
|
||||
# -r requirements/base.in
|
||||
# requests-cache
|
||||
# shillelagh
|
||||
requests-cache==1.2.1
|
||||
|
||||
@@ -178,7 +178,7 @@ croniter==6.0.0
|
||||
# via
|
||||
# -c requirements/base-constraint.txt
|
||||
# apache-superset
|
||||
cryptography==46.0.6
|
||||
cryptography==46.0.7
|
||||
# via
|
||||
# -c requirements/base-constraint.txt
|
||||
# apache-superset
|
||||
@@ -259,7 +259,7 @@ flask==2.3.3
|
||||
# flask-sqlalchemy
|
||||
# flask-testing
|
||||
# flask-wtf
|
||||
flask-appbuilder==5.2.0
|
||||
flask-appbuilder==5.2.1
|
||||
# via
|
||||
# -c requirements/base-constraint.txt
|
||||
# apache-superset
|
||||
@@ -503,7 +503,7 @@ limits==5.1.0
|
||||
# via
|
||||
# -c requirements/base-constraint.txt
|
||||
# flask-limiter
|
||||
mako==1.3.10
|
||||
mako==1.3.11
|
||||
# via
|
||||
# -c requirements/base-constraint.txt
|
||||
# alembic
|
||||
@@ -710,7 +710,7 @@ psycopg2-binary==2.9.9
|
||||
# via apache-superset
|
||||
py-key-value-aio==0.4.4
|
||||
# via fastmcp
|
||||
pyarrow==16.1.0
|
||||
pyarrow==20.0.0
|
||||
# via
|
||||
# -c requirements/base-constraint.txt
|
||||
# apache-superset
|
||||
@@ -778,7 +778,7 @@ pynacl==1.6.2
|
||||
# via
|
||||
# -c requirements/base-constraint.txt
|
||||
# paramiko
|
||||
pyopenssl==25.3.0
|
||||
pyopenssl==26.0.0
|
||||
# via
|
||||
# -c requirements/base-constraint.txt
|
||||
# shillelagh
|
||||
@@ -865,7 +865,7 @@ referencing==0.36.2
|
||||
# jsonschema
|
||||
# jsonschema-path
|
||||
# jsonschema-specifications
|
||||
requests==2.32.4
|
||||
requests==2.33.0
|
||||
# via
|
||||
# -c requirements/base-constraint.txt
|
||||
# docker
|
||||
@@ -992,6 +992,8 @@ starlette==0.49.1
|
||||
# via mcp
|
||||
statsd==4.0.1
|
||||
# via apache-superset
|
||||
syntaqlite==0.1.0
|
||||
# via apache-superset
|
||||
tabulate==0.9.0
|
||||
# via
|
||||
# -c requirements/base-constraint.txt
|
||||
|
||||
@@ -18,20 +18,20 @@
|
||||
|
||||
[project]
|
||||
name = "apache-superset-core"
|
||||
version = "0.1.0rc1"
|
||||
version = "0.1.0rc2"
|
||||
description = "Core Python package for building Apache Superset backend extensions and integrations"
|
||||
readme = "README.md"
|
||||
authors = [
|
||||
{ name = "Apache Software Foundation", email = "dev@superset.apache.org" },
|
||||
]
|
||||
license = { file="LICENSE.txt" }
|
||||
license = "Apache-2.0"
|
||||
license-files = ["LICENSE.txt"]
|
||||
requires-python = ">=3.10"
|
||||
keywords = ["superset", "apache", "analytics", "business-intelligence", "extensions", "visualization"]
|
||||
classifiers = [
|
||||
"Development Status :: 3 - Alpha",
|
||||
"Environment :: Web Environment",
|
||||
"Intended Audience :: Developers",
|
||||
"License :: OSI Approved :: Apache Software License",
|
||||
"Operating System :: OS Independent",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
|
||||
@@ -23,14 +23,14 @@ readme = "README.md"
|
||||
authors = [
|
||||
{ name = "Apache Software Foundation", email = "dev@superset.apache.org" },
|
||||
]
|
||||
license = { file="LICENSE.txt" }
|
||||
license = "Apache-2.0"
|
||||
license-files = ["LICENSE.txt"]
|
||||
requires-python = ">=3.10"
|
||||
keywords = ["superset", "apache", "cli", "extensions", "analytics", "business-intelligence", "development-tools"]
|
||||
classifiers = [
|
||||
"Development Status :: 3 - Alpha",
|
||||
"Environment :: Console",
|
||||
"Intended Audience :: Developers",
|
||||
"License :: OSI Approved :: Apache Software License",
|
||||
"Operating System :: OS Independent",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
|
||||
@@ -1,73 +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.
|
||||
*/
|
||||
import { selectResultsTab } from './sqllab.helper';
|
||||
|
||||
describe.skip('SqlLab datasource panel', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit('/sqllab');
|
||||
});
|
||||
|
||||
// TODO the test below is flaky, and has been disabled for the time being
|
||||
// (notice the `it.skip`)
|
||||
it('creates a table preview when a database, schema, and table are selected', () => {
|
||||
cy.intercept('**/superset/table/**').as('tableMetadata');
|
||||
|
||||
// it should have dropdowns to select database, schema, and table
|
||||
cy.get('.sql-toolbar .Select').should('have.length', 3);
|
||||
|
||||
cy.get('.sql-toolbar .table-schema').should('not.exist');
|
||||
cy.get('[data-test="filterable-table-container"]').should('not.exist');
|
||||
|
||||
cy.get('.sql-toolbar .Select')
|
||||
.eq(0) // database select
|
||||
.within(() => {
|
||||
// note: we have to set force: true because the input is invisible / cypress throws
|
||||
cy.get('input').type('main{enter}', { force: true });
|
||||
});
|
||||
|
||||
cy.get('.sql-toolbar .Select')
|
||||
.eq(1) // schema select
|
||||
.within(() => {
|
||||
cy.get('input').type('main{enter}', { force: true });
|
||||
});
|
||||
|
||||
cy.get('.sql-toolbar .Select')
|
||||
.eq(2) // table select
|
||||
.within(() => {
|
||||
cy.get('input').type('birth_names{enter}', { force: true });
|
||||
});
|
||||
|
||||
cy.wait('@tableMetadata');
|
||||
|
||||
cy.get('.sql-toolbar .table-schema').should('have.length', 1);
|
||||
selectResultsTab().should('have.length', 1);
|
||||
|
||||
// add another table and check for added schema + preview
|
||||
cy.get('.sql-toolbar .Select')
|
||||
.eq(2)
|
||||
.within(() => {
|
||||
cy.get('input').type('logs{enter}', { force: true });
|
||||
});
|
||||
|
||||
cy.wait('@tableMetadata');
|
||||
|
||||
cy.get('.sql-toolbar .table-schema').should('have.length', 2);
|
||||
selectResultsTab().should('have.length', 2);
|
||||
});
|
||||
});
|
||||
@@ -1,192 +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.
|
||||
*/
|
||||
import { nanoid } from 'nanoid';
|
||||
import { selectResultsTab, assertSQLLabResultsAreEqual } from './sqllab.helper';
|
||||
|
||||
function parseClockStr(node: JQuery) {
|
||||
return Number.parseFloat(node.text().replace(/:/g, ''));
|
||||
}
|
||||
|
||||
describe('SqlLab query panel', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit('/sqllab');
|
||||
});
|
||||
|
||||
it.skip('supports entering and running a query', () => {
|
||||
// row limit has to be < ~10 for us to be able to determine how many rows
|
||||
// are fetched below (because React _Virtualized_ does not render all rows)
|
||||
let clockTime = 0;
|
||||
|
||||
cy.intercept({
|
||||
method: 'POST',
|
||||
url: '**/api/v1/sqllab/execute/',
|
||||
}).as('mockSQLResponse');
|
||||
|
||||
cy.get('.TableSelector .Select:eq(0)').click();
|
||||
cy.get('.TableSelector .Select:eq(0) input[type=text]').focus();
|
||||
cy.focused().type('{enter}');
|
||||
|
||||
cy.get('#brace-editor textarea').focus();
|
||||
cy.focused().clear();
|
||||
cy.focused().type(`{selectall}{backspace}SELECT 1`);
|
||||
|
||||
cy.get('#js-sql-toolbar button:eq(0)').eq(0).click();
|
||||
|
||||
// wait for 300 milliseconds
|
||||
cy.wait(300);
|
||||
|
||||
// started timer
|
||||
cy.get('.sql-toolbar .label-success').then(node => {
|
||||
clockTime = parseClockStr(node);
|
||||
// should be longer than 0.2s
|
||||
expect(clockTime).greaterThan(0.2);
|
||||
});
|
||||
|
||||
cy.wait('@mockSQLResponse');
|
||||
|
||||
// timer is increasing
|
||||
cy.get('.sql-toolbar .label-success').then(node => {
|
||||
const newClockTime = parseClockStr(node);
|
||||
expect(newClockTime).greaterThan(0.9);
|
||||
clockTime = newClockTime;
|
||||
});
|
||||
|
||||
// rerun the query
|
||||
cy.get('#js-sql-toolbar button:eq(0)').eq(0).click();
|
||||
|
||||
// should restart the timer
|
||||
cy.get('.sql-toolbar .label-success').contains('00:00:00');
|
||||
cy.wait('@mockSQLResponse');
|
||||
cy.get('.sql-toolbar .label-success').then(node => {
|
||||
expect(parseClockStr(node)).greaterThan(0.9);
|
||||
});
|
||||
});
|
||||
|
||||
it.skip('successfully saves a query', () => {
|
||||
cy.intercept('**/api/v1/database/**/tables/**').as('getTables');
|
||||
|
||||
const query =
|
||||
'SELECT ds, gender, name, num FROM main.birth_names ORDER BY name LIMIT 3';
|
||||
const savedQueryTitle = `CYPRESS TEST QUERY ${nanoid()}`;
|
||||
|
||||
// we will assert that the results of the query we save, and the saved query are the same
|
||||
let initialResultsTable: HTMLElement | null = null;
|
||||
let savedQueryResultsTable = null;
|
||||
|
||||
cy.get('#brace-editor textarea').clear({ force: true });
|
||||
cy.get('#brace-editor textarea').type(`{selectall}{backspace}${query}`, {
|
||||
force: true,
|
||||
});
|
||||
cy.get('#brace-editor textarea').focus(); // focus => blur is required for updating the query that is to be saved
|
||||
cy.focused().blur();
|
||||
|
||||
// ctrl + r also runs query
|
||||
cy.get('#brace-editor textarea').type('{ctrl}r', { force: true });
|
||||
|
||||
cy.wait('@sqlLabQuery');
|
||||
|
||||
// Save results to check against below
|
||||
selectResultsTab().then(resultsA => {
|
||||
initialResultsTable = resultsA[0];
|
||||
});
|
||||
|
||||
cy.get('#js-sql-toolbar button')
|
||||
.eq(1) // save query
|
||||
.click();
|
||||
|
||||
// Enter name + save into modal
|
||||
cy.get('.modal-sm input').clear({ force: true });
|
||||
cy.get('.modal-sm input').type(`{selectall}{backspace}${savedQueryTitle}`, {
|
||||
force: true,
|
||||
});
|
||||
|
||||
cy.get('.modal-sm .modal-body button')
|
||||
.eq(0) // save
|
||||
.click();
|
||||
|
||||
// first row contains most recent link, follow back to SqlLab
|
||||
cy.get('table tr:first-child a[href*="savedQueryId"').click();
|
||||
|
||||
// will timeout without explicitly waiting here
|
||||
cy.wait(['@getSavedQuery', '@getTables']);
|
||||
|
||||
// run the saved query
|
||||
cy.get('#js-sql-toolbar button')
|
||||
.eq(0) // run query
|
||||
.click();
|
||||
|
||||
cy.wait('@sqlLabQuery');
|
||||
|
||||
// assert the results of the saved query match the initial results
|
||||
selectResultsTab().then(resultsB => {
|
||||
savedQueryResultsTable = resultsB[0];
|
||||
|
||||
assertSQLLabResultsAreEqual(initialResultsTable, savedQueryResultsTable);
|
||||
});
|
||||
});
|
||||
|
||||
it.skip('Create a chart from a query', () => {
|
||||
cy.intercept('**/api/v1/sqllab/execute/').as('queryFinished');
|
||||
cy.intercept('**/api/v1/explore/**').as('explore');
|
||||
cy.intercept('**/api/v1/chart/**').as('chart');
|
||||
cy.intercept('**/tabstateview/**').as('tabstateview');
|
||||
|
||||
// cypress doesn't handle opening a new tab, override window.open to open in the same tab
|
||||
cy.window().then(win => {
|
||||
cy.stub(win, 'open', url => {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
win.location.href = url;
|
||||
});
|
||||
});
|
||||
cy.wait('@tabstateview');
|
||||
|
||||
const query = 'SELECT gender, name FROM birth_names';
|
||||
|
||||
cy.get('.ace_text-input').focus();
|
||||
cy.focused().clear({ force: true });
|
||||
cy.focused().type(`{selectall}{backspace}${query}`, { force: true });
|
||||
cy.get('.sql-toolbar button').contains('Run').click();
|
||||
cy.wait('@queryFinished');
|
||||
|
||||
cy.get(
|
||||
'.SouthPane .ant-tabs-content > .ant-tabs-tabpane-active > div button:first',
|
||||
{ timeout: 10000 },
|
||||
).click();
|
||||
|
||||
cy.wait('@explore');
|
||||
cy.get('[data-test="datasource-control"] .title-select').contains(query);
|
||||
cy.get('.column-option-label').first().contains('gender');
|
||||
cy.get('.column-option-label').last().contains('name');
|
||||
|
||||
cy.get(
|
||||
'[data-test="all_columns"] [data-test="dnd-labels-container"] > div:first-child',
|
||||
).contains('gender');
|
||||
cy.get(
|
||||
'[data-test="all_columns"] [data-test="dnd-labels-container"] > div:nth-child(2)',
|
||||
).contains('name');
|
||||
|
||||
cy.wait('@chart');
|
||||
cy.get('[data-test="slice-container"] table > thead th')
|
||||
.first()
|
||||
.contains('gender');
|
||||
cy.get('[data-test="slice-container"] table > thead th')
|
||||
.last()
|
||||
.contains('name');
|
||||
});
|
||||
});
|
||||
@@ -1,41 +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.
|
||||
*/
|
||||
export const selectResultsTab = () =>
|
||||
cy.get('.SouthPane .ReactVirtualized__Table', { timeout: 10000 });
|
||||
|
||||
// this function asserts that the result set for two SQL lab table results are equal
|
||||
export const assertSQLLabResultsAreEqual = (resultsA, resultsB) => {
|
||||
const [headerA, bodyWrapperA] = resultsA.childNodes;
|
||||
const bodyA = bodyWrapperA.childNodes[0];
|
||||
|
||||
const [headerB, bodyWrapperB] = resultsB.childNodes;
|
||||
const bodyB = bodyWrapperB.childNodes[0];
|
||||
|
||||
expect(headerA.childNodes.length).to.equal(headerB.childNodes.length);
|
||||
expect(bodyA.childNodes.length).to.equal(bodyB.childNodes.length);
|
||||
|
||||
bodyA.childNodes.forEach((rowA, rowIndex) => {
|
||||
const rowB = bodyB.childNodes[rowIndex];
|
||||
|
||||
rowA.childNodes.forEach((cellA, columnIndex) => {
|
||||
const cellB = rowB.childNodes[columnIndex];
|
||||
expect(cellA.innerText).to.equal(cellB.innerText);
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -1,113 +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.visit('/sqllab');
|
||||
});
|
||||
|
||||
const tablistSelector = '[data-test="sql-editor-tabs"] > [role="tablist"]';
|
||||
const tabSelector = `${tablistSelector} [role="tab"]:not([type="button"])`;
|
||||
|
||||
it('allows you to create and close a 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]) ||
|
||||
0,
|
||||
)
|
||||
.toArray(),
|
||||
);
|
||||
|
||||
// add two new tabs
|
||||
cy.get('[data-test="add-tab-icon"]:visible:last').click({ force: true });
|
||||
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({ force: true });
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
||||
it('opens a new tab by a button and a shortcut', () => {
|
||||
const editorContent = '.ace_editor .ace_content';
|
||||
const editorInput = '.ace_editor textarea';
|
||||
const queryLimitSelector = '#js-sql-toolbar .limitDropdown';
|
||||
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]) ||
|
||||
0,
|
||||
)
|
||||
.toArray(),
|
||||
);
|
||||
|
||||
// configure some editor settings
|
||||
cy.get(editorInput).type('some random query string', { force: true });
|
||||
cy.get(queryLimitSelector).parent().click({ force: true });
|
||||
cy.get('.ant-dropdown-menu')
|
||||
.last()
|
||||
.find('.ant-dropdown-menu-item')
|
||||
.first()
|
||||
.click({ force: true });
|
||||
|
||||
// open a new tab by a button
|
||||
cy.get('[data-test="add-tab-icon"]:visible:last').click({ force: true });
|
||||
cy.contains('[role="tab"]', `Untitled Query ${initialUntitledCount + 1}`);
|
||||
cy.get(tabSelector).should('have.length', initialTabCount + 1);
|
||||
cy.get(editorContent).contains('SELECT ...');
|
||||
cy.get(queryLimitSelector).contains('10');
|
||||
|
||||
// close the tab
|
||||
cy.get(`${tabSelector}:last [data-test="dropdown-trigger"]`).click({
|
||||
force: true,
|
||||
});
|
||||
cy.get(`${tablistSelector} [aria-label="remove"]:last`).click({
|
||||
force: true,
|
||||
});
|
||||
cy.get(tabSelector).should('have.length', initialTabCount);
|
||||
|
||||
// open a new tab by a shortcut
|
||||
cy.get('body').type('{ctrl}t');
|
||||
cy.get(tabSelector).should('have.length', initialTabCount + 1);
|
||||
cy.contains('[role="tab"]', `Untitled Query ${initialUntitledCount + 1}`);
|
||||
cy.get(editorContent).contains('SELECT ...');
|
||||
cy.get(queryLimitSelector).contains('10');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -33,6 +33,33 @@
|
||||
// - No FontAwesome icons (use Icons component)
|
||||
// - No template variables in i18n (use parameterized messages)
|
||||
|
||||
// === Rules carried over from ESLint that oxlint does NOT implement ===
|
||||
// oxlint 1.58+ errors on unknown builtin rules, so these can no longer
|
||||
// be listed in this config. They were silently dropped in earlier
|
||||
// oxlint versions (not actually enforced). Documented here for future
|
||||
// maintainers — if/when oxlint adds them, re-enable in the relevant
|
||||
// plugin section above.
|
||||
// import: newline-after-import, no-extraneous-dependencies,
|
||||
// no-import-module-exports, no-relative-packages,
|
||||
// no-unresolved, no-useless-path-segments
|
||||
// react: default-props-match-prop-types, destructuring-assignment,
|
||||
// forbid-component-props, forbid-foreign-prop-types,
|
||||
// forbid-prop-types, function-component-definition,
|
||||
// jsx-no-bind, jsx-uses-vars, no-access-state-in-setstate,
|
||||
// no-deprecated, no-did-update-set-state, no-typos,
|
||||
// no-unstable-nested-components,
|
||||
// no-unused-class-component-methods, no-unused-prop-types,
|
||||
// no-unused-state, prefer-stateless-function, prop-types,
|
||||
// require-default-props, sort-comp, static-property-placement
|
||||
// (prefer-stateless-function / function-component-definition
|
||||
// are represented by react/prefer-function-component below)
|
||||
// jsx-a11y: interactive-supports-focus,
|
||||
// no-interactive-element-to-noninteractive-role,
|
||||
// no-noninteractive-element-interactions,
|
||||
// no-noninteractive-element-to-interactive-role
|
||||
// typescript: naming-convention
|
||||
// unicorn: prevent-abbreviations
|
||||
|
||||
// === Core ESLint rules ===
|
||||
// Error prevention
|
||||
"no-console": "warn",
|
||||
@@ -89,7 +116,6 @@
|
||||
"no-object-constructor": "error",
|
||||
|
||||
// === Import plugin rules ===
|
||||
"import/no-unresolved": "error",
|
||||
// TODO: Fix incorrect named imports in Storybook and other files
|
||||
"import/named": "warn",
|
||||
// TODO: Fix duplicate exports in shared-controls and other modules
|
||||
@@ -105,56 +131,24 @@
|
||||
"import/first": "error",
|
||||
// TODO: Consolidate duplicate imports in DatasetList and other files
|
||||
"import/no-duplicates": "warn",
|
||||
"import/newline-after-import": "error",
|
||||
"import/no-absolute-path": "error",
|
||||
"import/no-dynamic-require": "error",
|
||||
"import/no-webpack-loader-syntax": "error",
|
||||
"import/no-self-import": "error",
|
||||
"import/no-cycle": "off",
|
||||
"import/no-useless-path-segments": ["error", { "commonjs": true }],
|
||||
"import/prefer-default-export": "off",
|
||||
"import/no-relative-packages": "off",
|
||||
"import/no-import-module-exports": "off",
|
||||
"import/no-extraneous-dependencies": [
|
||||
"error",
|
||||
{
|
||||
"devDependencies": [
|
||||
"test/**",
|
||||
"tests/**",
|
||||
"spec/**",
|
||||
"**/__tests__/**",
|
||||
"**/__mocks__/**",
|
||||
"*.test.{js,jsx,ts,tsx}",
|
||||
"*.spec.{js,jsx,ts,tsx}",
|
||||
"**/*.test.{js,jsx,ts,tsx}",
|
||||
"**/*.spec.{js,jsx,ts,tsx}",
|
||||
"**/jest.config.js",
|
||||
"**/jest.setup.js",
|
||||
"**/webpack.config.js",
|
||||
"**/webpack.config.*.js",
|
||||
"**/.eslintrc.js"
|
||||
],
|
||||
"optionalDependencies": false
|
||||
}
|
||||
],
|
||||
|
||||
// === React plugin rules ===
|
||||
"react/prop-types": "off",
|
||||
"react/require-default-props": "off",
|
||||
"react/forbid-prop-types": "off",
|
||||
"react/forbid-component-props": "warn",
|
||||
"react/jsx-filename-extension": [
|
||||
"warn",
|
||||
{ "extensions": [".jsx", ".tsx"] }
|
||||
],
|
||||
"react/jsx-fragments": "error",
|
||||
"react/jsx-no-bind": "off",
|
||||
"react/jsx-props-no-spreading": "off",
|
||||
"react/jsx-boolean-value": ["error", "never", { "always": [] }],
|
||||
"react/jsx-no-duplicate-props": "error",
|
||||
"react/jsx-no-undef": "error",
|
||||
"react/jsx-pascal-case": ["error", { "allowAllCaps": true, "ignore": [] }],
|
||||
"react/jsx-uses-vars": "error",
|
||||
"react/jsx-no-target-blank": ["error", { "enforceDynamicLinks": "always" }],
|
||||
"react/jsx-no-comment-textnodes": "error",
|
||||
"react/jsx-no-useless-fragment": "off",
|
||||
@@ -165,40 +159,27 @@
|
||||
"react/no-array-index-key": "off",
|
||||
"react/no-children-prop": "error",
|
||||
"react/no-danger": "error",
|
||||
"react/forbid-foreign-prop-types": "error",
|
||||
"react/no-danger-with-children": "error",
|
||||
"react/no-deprecated": "error",
|
||||
"react/no-did-update-set-state": "error",
|
||||
"react/no-find-dom-node": "error",
|
||||
"react/no-is-mounted": "error",
|
||||
"react/no-render-return-value": "error",
|
||||
"react/no-string-refs": "off",
|
||||
"react/no-unescaped-entities": "off",
|
||||
"react/no-unknown-property": "off",
|
||||
"react/no-unused-prop-types": "off",
|
||||
"react/no-unused-state": "error",
|
||||
"react/no-will-update-set-state": "error",
|
||||
"react/prefer-es6-class": ["error", "always"],
|
||||
"react/prefer-stateless-function": [
|
||||
"error",
|
||||
{ "ignorePureComponents": true }
|
||||
],
|
||||
"react/require-render-return": "error",
|
||||
"react/self-closing-comp": "error",
|
||||
"react/void-dom-elements-no-children": "error",
|
||||
"react/no-access-state-in-setstate": "error",
|
||||
"react/no-redundant-should-component-update": "error",
|
||||
"react/no-this-in-sfc": "error",
|
||||
"react/no-typos": "error",
|
||||
"react/no-unstable-nested-components": "off",
|
||||
"react/no-unused-class-component-methods": "off",
|
||||
"react/destructuring-assignment": "off",
|
||||
"react/sort-comp": "off",
|
||||
"react/state-in-constructor": "off",
|
||||
"react/static-property-placement": "off",
|
||||
"react/react-in-jsx-scope": "off",
|
||||
"react/function-component-definition": "off",
|
||||
"react/default-props-match-prop-types": "off",
|
||||
// Successor to the ESLint-era `react/prefer-stateless-function` and
|
||||
// `react/function-component-definition` rules. Disabled because the
|
||||
// codebase still contains legacy class components; flip to "error"
|
||||
// once the class-to-function migration completes.
|
||||
"react/prefer-function-component": "off",
|
||||
"react/button-has-type": [
|
||||
"error",
|
||||
{ "button": true, "submit": true, "reset": false }
|
||||
@@ -223,7 +204,6 @@
|
||||
"jsx-a11y/html-has-lang": "error",
|
||||
"jsx-a11y/iframe-has-title": "error",
|
||||
"jsx-a11y/img-redundant-alt": "error",
|
||||
"jsx-a11y/interactive-supports-focus": "error",
|
||||
"jsx-a11y/label-has-associated-control": "error",
|
||||
"jsx-a11y/lang": "error",
|
||||
"jsx-a11y/media-has-caption": "error",
|
||||
@@ -231,9 +211,6 @@
|
||||
"jsx-a11y/no-access-key": "error",
|
||||
"jsx-a11y/no-autofocus": ["error", { "ignoreNonDOM": true }],
|
||||
"jsx-a11y/no-distracting-elements": "error",
|
||||
"jsx-a11y/no-interactive-element-to-noninteractive-role": "error",
|
||||
"jsx-a11y/no-noninteractive-element-interactions": "error",
|
||||
"jsx-a11y/no-noninteractive-element-to-interactive-role": "error",
|
||||
"jsx-a11y/no-noninteractive-tabindex": "error",
|
||||
"jsx-a11y/no-redundant-roles": "error",
|
||||
"jsx-a11y/no-static-element-interactions": "off",
|
||||
@@ -253,17 +230,6 @@
|
||||
"@typescript-eslint/explicit-module-boundary-types": "off",
|
||||
"@typescript-eslint/no-unused-vars": "warn",
|
||||
"@typescript-eslint/prefer-optional-chain": "error",
|
||||
"@typescript-eslint/naming-convention": [
|
||||
"error",
|
||||
{
|
||||
"selector": "enum",
|
||||
"format": ["PascalCase"]
|
||||
},
|
||||
{
|
||||
"selector": "enumMember",
|
||||
"format": ["PascalCase"]
|
||||
}
|
||||
],
|
||||
|
||||
// === Unicorn rules (bonus coverage) ===
|
||||
"unicorn/no-new-array": "error",
|
||||
@@ -279,7 +245,6 @@
|
||||
"unicorn/prefer-negative-index": "error",
|
||||
"unicorn/prefer-math-trunc": "error",
|
||||
"unicorn/filename-case": "off",
|
||||
"unicorn/prevent-abbreviations": "off",
|
||||
"unicorn/no-null": "off",
|
||||
"unicorn/no-array-reduce": "off",
|
||||
"unicorn/no-array-for-each": "off",
|
||||
|
||||
2226
superset-frontend/package-lock.json
generated
@@ -128,17 +128,17 @@
|
||||
"@superset-ui/legacy-plugin-chart-chord": "file:./plugins/legacy-plugin-chart-chord",
|
||||
"@superset-ui/legacy-plugin-chart-country-map": "file:./plugins/legacy-plugin-chart-country-map",
|
||||
"@superset-ui/legacy-plugin-chart-horizon": "file:./plugins/legacy-plugin-chart-horizon",
|
||||
"@superset-ui/legacy-plugin-chart-map-box": "file:./plugins/legacy-plugin-chart-map-box",
|
||||
"@superset-ui/legacy-plugin-chart-paired-t-test": "file:./plugins/legacy-plugin-chart-paired-t-test",
|
||||
"@superset-ui/legacy-plugin-chart-parallel-coordinates": "file:./plugins/legacy-plugin-chart-parallel-coordinates",
|
||||
"@superset-ui/legacy-plugin-chart-partition": "file:./plugins/legacy-plugin-chart-partition",
|
||||
"@superset-ui/legacy-plugin-chart-rose": "file:./plugins/legacy-plugin-chart-rose",
|
||||
"@superset-ui/legacy-plugin-chart-world-map": "file:./plugins/legacy-plugin-chart-world-map",
|
||||
"@superset-ui/legacy-preset-chart-deckgl": "file:./plugins/legacy-preset-chart-deckgl",
|
||||
"@superset-ui/preset-chart-deckgl": "file:./plugins/preset-chart-deckgl",
|
||||
"@superset-ui/legacy-preset-chart-nvd3": "file:./plugins/legacy-preset-chart-nvd3",
|
||||
"@superset-ui/plugin-chart-ag-grid-table": "file:./plugins/plugin-chart-ag-grid-table",
|
||||
"@superset-ui/plugin-chart-cartodiagram": "file:./plugins/plugin-chart-cartodiagram",
|
||||
"@superset-ui/plugin-chart-echarts": "file:./plugins/plugin-chart-echarts",
|
||||
"@superset-ui/plugin-chart-point-cluster-map": "file:./plugins/plugin-chart-point-cluster-map",
|
||||
"@superset-ui/plugin-chart-handlebars": "file:./plugins/plugin-chart-handlebars",
|
||||
"@superset-ui/plugin-chart-pivot-table": "file:./plugins/plugin-chart-pivot-table",
|
||||
"@superset-ui/plugin-chart-table": "file:./plugins/plugin-chart-table",
|
||||
@@ -154,8 +154,8 @@
|
||||
"@visx/scale": "^3.5.0",
|
||||
"@visx/tooltip": "^3.0.0",
|
||||
"@visx/xychart": "^3.5.1",
|
||||
"ag-grid-community": "35.0.1",
|
||||
"ag-grid-react": "35.0.1",
|
||||
"ag-grid-community": "35.2.1",
|
||||
"ag-grid-react": "35.2.1",
|
||||
"antd": "^5.26.0",
|
||||
"chrono-node": "^2.9.0",
|
||||
"classnames": "^2.2.5",
|
||||
@@ -168,11 +168,11 @@
|
||||
"echarts": "^5.6.0",
|
||||
"fast-glob": "^3.3.2",
|
||||
"fs-extra": "^11.3.4",
|
||||
"fuse.js": "^7.1.0",
|
||||
"fuse.js": "^7.3.0",
|
||||
"geolib": "^3.3.14",
|
||||
"geostyler": "^18.3.1",
|
||||
"geostyler": "^18.5.0",
|
||||
"geostyler-data": "^1.1.0",
|
||||
"geostyler-openlayers-parser": "^5.4.1",
|
||||
"geostyler-openlayers-parser": "^5.7.0",
|
||||
"geostyler-style": "11.0.2",
|
||||
"geostyler-wfs-parser": "^3.0.1",
|
||||
"google-auth-library": "^10.6.2",
|
||||
@@ -183,20 +183,20 @@
|
||||
"json-bigint": "^1.0.0",
|
||||
"json-stringify-pretty-compact": "^2.0.0",
|
||||
"lodash": "^4.18.1",
|
||||
"mapbox-gl": "^3.20.0",
|
||||
"markdown-to-jsx": "^9.7.13",
|
||||
"mapbox-gl": "^3.22.0",
|
||||
"markdown-to-jsx": "^9.7.16",
|
||||
"match-sorter": "^8.2.0",
|
||||
"memoize-one": "^5.2.1",
|
||||
"mousetrap": "^1.6.5",
|
||||
"mustache": "^4.2.0",
|
||||
"nanoid": "^5.1.7",
|
||||
"nanoid": "^5.1.9",
|
||||
"ol": "^10.8.0",
|
||||
"pretty-ms": "^9.3.0",
|
||||
"query-string": "9.3.1",
|
||||
"re-resizable": "^6.11.2",
|
||||
"react": "^17.0.2",
|
||||
"react-arborist": "^3.4.3",
|
||||
"react-checkbox-tree": "^1.8.0",
|
||||
"react-arborist": "^3.5.0",
|
||||
"react-checkbox-tree": "^2.0.1",
|
||||
"react-diff-viewer-continued": "^4.2.0",
|
||||
"react-dnd": "^11.1.3",
|
||||
"react-dnd-html5-backend": "^11.1.3",
|
||||
@@ -230,7 +230,7 @@
|
||||
"use-event-callback": "^0.1.0",
|
||||
"use-immer": "^0.11.0",
|
||||
"use-query-params": "^2.2.2",
|
||||
"uuid": "^13.0.0",
|
||||
"uuid": "^14.0.0",
|
||||
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
|
||||
"yargs": "^17.7.2"
|
||||
},
|
||||
@@ -258,19 +258,19 @@
|
||||
"@mihkeleidast/storybook-addon-source": "^1.0.1",
|
||||
"@playwright/test": "^1.59.1",
|
||||
"@pmmmwh/react-refresh-webpack-plugin": "^0.6.2",
|
||||
"@storybook/addon-actions": "^8.6.17",
|
||||
"@storybook/addon-controls": "^8.6.17",
|
||||
"@storybook/addon-essentials": "^8.6.17",
|
||||
"@storybook/addon-links": "^8.6.17",
|
||||
"@storybook/addon-mdx-gfm": "^8.6.17",
|
||||
"@storybook/components": "^8.6.17",
|
||||
"@storybook/preview-api": "^8.6.17",
|
||||
"@storybook/react": "^8.6.17",
|
||||
"@storybook/react-webpack5": "^8.6.17",
|
||||
"@storybook/test": "^8.6.15",
|
||||
"@storybook/addon-actions": "^8.6.18",
|
||||
"@storybook/addon-controls": "^8.6.18",
|
||||
"@storybook/addon-essentials": "^8.6.18",
|
||||
"@storybook/addon-links": "^8.6.18",
|
||||
"@storybook/addon-mdx-gfm": "^8.6.18",
|
||||
"@storybook/components": "^8.6.18",
|
||||
"@storybook/preview-api": "^8.6.18",
|
||||
"@storybook/react": "^8.6.18",
|
||||
"@storybook/react-webpack5": "^8.6.18",
|
||||
"@storybook/test": "^8.6.18",
|
||||
"@storybook/test-runner": "^0.17.0",
|
||||
"@svgr/webpack": "^8.1.0",
|
||||
"@swc/core": "^1.15.24",
|
||||
"@swc/core": "^1.15.30",
|
||||
"@swc/plugin-emotion": "^14.8.0",
|
||||
"@swc/plugin-transform-imports": "^12.5.0",
|
||||
"@testing-library/dom": "^8.20.1",
|
||||
@@ -281,10 +281,11 @@
|
||||
"@types/content-disposition": "^0.5.9",
|
||||
"@types/dom-to-image": "^2.6.7",
|
||||
"@types/jest": "^30.0.0",
|
||||
"@types/jquery": "^4.0.0",
|
||||
"@types/js-levenshtein": "^1.1.3",
|
||||
"@types/json-bigint": "^1.0.4",
|
||||
"@types/mousetrap": "^1.6.15",
|
||||
"@types/node": "^25.5.0",
|
||||
"@types/node": "^25.6.0",
|
||||
"@types/react": "^17.0.83",
|
||||
"@types/react-dom": "^17.0.26",
|
||||
"@types/react-loadable": "^5.5.11",
|
||||
@@ -305,7 +306,7 @@
|
||||
"babel-plugin-dynamic-import-node": "^2.3.3",
|
||||
"babel-plugin-jsx-remove-data-test-id": "^3.0.0",
|
||||
"babel-plugin-lodash": "^3.3.4",
|
||||
"baseline-browser-mapping": "^2.10.13",
|
||||
"baseline-browser-mapping": "^2.10.21",
|
||||
"cheerio": "1.2.0",
|
||||
"concurrently": "^9.2.1",
|
||||
"copy-webpack-plugin": "^14.0.0",
|
||||
@@ -325,7 +326,7 @@
|
||||
"eslint-plugin-no-only-tests": "^3.3.0",
|
||||
"eslint-plugin-prettier": "^5.5.5",
|
||||
"eslint-plugin-react-prefer-function-component": "^5.0.0",
|
||||
"eslint-plugin-react-you-might-not-need-an-effect": "^0.9.2",
|
||||
"eslint-plugin-react-you-might-not-need-an-effect": "^0.9.3",
|
||||
"eslint-plugin-storybook": "^0.8.0",
|
||||
"eslint-plugin-testing-library": "^7.16.2",
|
||||
"eslint-plugin-theme-colors": "file:eslint-rules/eslint-plugin-theme-colors",
|
||||
@@ -345,9 +346,9 @@
|
||||
"lightningcss": "^1.32.0",
|
||||
"mini-css-extract-plugin": "^2.10.2",
|
||||
"open-cli": "^9.0.0",
|
||||
"oxlint": "^1.56.0",
|
||||
"oxlint": "^1.61.0",
|
||||
"po2json": "^0.4.5",
|
||||
"prettier": "3.8.1",
|
||||
"prettier": "3.8.3",
|
||||
"prettier-plugin-packagejson": "^3.0.2",
|
||||
"process": "^0.11.10",
|
||||
"react-refresh": "^0.18.0",
|
||||
@@ -356,7 +357,7 @@
|
||||
"source-map": "^0.7.6",
|
||||
"source-map-support": "^0.5.21",
|
||||
"speed-measure-webpack-plugin": "^1.6.0",
|
||||
"storybook": "8.6.17",
|
||||
"storybook": "8.6.18",
|
||||
"style-loader": "^4.0.0",
|
||||
"swc-loader": "^0.2.7",
|
||||
"terser-webpack-plugin": "^5.4.0",
|
||||
@@ -367,8 +368,8 @@
|
||||
"typescript": "5.4.5",
|
||||
"unzipper": "^0.12.3",
|
||||
"vm-browserify": "^1.1.2",
|
||||
"wait-on": "^9.0.4",
|
||||
"webpack": "^5.105.4",
|
||||
"wait-on": "^9.0.5",
|
||||
"webpack": "^5.106.2",
|
||||
"webpack-bundle-analyzer": "^5.3.0",
|
||||
"webpack-cli": "^6.0.1",
|
||||
"webpack-dev-server": "^5.2.3",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@apache-superset/core",
|
||||
"version": "0.1.0-rc1",
|
||||
"version": "0.1.0-rc2",
|
||||
"description": "This package contains UI elements, APIs, and utility functions used by Superset.",
|
||||
"sideEffects": false,
|
||||
"main": "lib/index.js",
|
||||
@@ -70,8 +70,8 @@
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"author": "Apache Software Foundation",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.28.6",
|
||||
"@babel/core": "^7.29.0",
|
||||
|
||||
@@ -21,7 +21,11 @@ import { styled, css } from '@apache-superset/core/theme';
|
||||
export const ControlSubSectionHeader = styled.div`
|
||||
${({ theme }) => css`
|
||||
font-weight: ${theme.fontWeightStrong};
|
||||
margin-top: ${theme.sizeUnit * 3}px;
|
||||
margin-bottom: ${theme.sizeUnit}px;
|
||||
font-size: ${theme.fontSizeSM}px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
color: ${theme.colorTextSecondary};
|
||||
`}
|
||||
`;
|
||||
|
||||
@@ -23,7 +23,7 @@ import { ControlPanelSectionConfig } from '../types';
|
||||
import { formatSelectOptions } from '../utils';
|
||||
|
||||
export const TITLE_MARGIN_OPTIONS: number[] = [
|
||||
0, 15, 30, 50, 75, 100, 125, 150, 200,
|
||||
0, 15, 30, 40, 50, 75, 100, 125, 150, 200,
|
||||
];
|
||||
export const TITLE_POSITION_OPTIONS: [string, string][] = [
|
||||
['Left', t('Left')],
|
||||
@@ -56,7 +56,7 @@ export const titleControls: ControlPanelSectionConfig = {
|
||||
clearable: true,
|
||||
label: t('X Axis Title Margin'),
|
||||
renderTrigger: true,
|
||||
default: TITLE_MARGIN_OPTIONS[0],
|
||||
default: TITLE_MARGIN_OPTIONS[3],
|
||||
choices: formatSelectOptions(TITLE_MARGIN_OPTIONS),
|
||||
},
|
||||
},
|
||||
@@ -82,7 +82,7 @@ export const titleControls: ControlPanelSectionConfig = {
|
||||
clearable: true,
|
||||
label: t('Y Axis Title Margin'),
|
||||
renderTrigger: true,
|
||||
default: TITLE_MARGIN_OPTIONS[0],
|
||||
default: TITLE_MARGIN_OPTIONS[4],
|
||||
choices: formatSelectOptions(TITLE_MARGIN_OPTIONS),
|
||||
},
|
||||
},
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
"@types/json-bigint": "^1.0.4",
|
||||
"@visx/responsive": "^3.12.0",
|
||||
"ace-builds": "^1.43.6",
|
||||
"ag-grid-community": "35.0.1",
|
||||
"ag-grid-react": "35.0.1",
|
||||
"ag-grid-community": "35.2.1",
|
||||
"ag-grid-react": "35.2.1",
|
||||
"brace": "^0.11.1",
|
||||
"classnames": "^2.5.1",
|
||||
"core-js": "^3.49.0",
|
||||
@@ -42,7 +42,7 @@
|
||||
"d3-time": "^3.1.0",
|
||||
"d3-time-format": "^4.1.0",
|
||||
"dayjs": "^1.11.20",
|
||||
"dompurify": "^3.3.3",
|
||||
"dompurify": "^3.4.0",
|
||||
"fetch-retry": "^6.0.0",
|
||||
"handlebars": "^4.7.9",
|
||||
"jed": "^1.1.1",
|
||||
@@ -56,7 +56,7 @@
|
||||
"react-js-cron": "^5.2.0",
|
||||
"react-markdown": "^8.0.7",
|
||||
"react-resize-detector": "^7.1.2",
|
||||
"react-syntax-highlighter": "^16.1.0",
|
||||
"react-syntax-highlighter": "^16.1.1",
|
||||
"react-ultimate-pagination": "^1.3.2",
|
||||
"regenerator-runtime": "^0.14.1",
|
||||
"rehype-raw": "^7.0.0",
|
||||
@@ -74,9 +74,9 @@
|
||||
"@types/d3-scale": "^2.1.1",
|
||||
"@types/d3-time": "^3.0.4",
|
||||
"@types/d3-time-format": "^4.0.3",
|
||||
"@types/jquery": "^3.5.33",
|
||||
"@types/jquery": "^4.0.0",
|
||||
"@types/lodash": "^4.17.24",
|
||||
"@types/node": "^25.5.0",
|
||||
"@types/node": "^25.6.0",
|
||||
"@types/prop-types": "^15.7.15",
|
||||
"@types/react-syntax-highlighter": "^15.5.13",
|
||||
"@types/react-table": "^7.7.20",
|
||||
@@ -85,7 +85,7 @@
|
||||
"fetch-mock": "^12.6.0",
|
||||
"jest-mock-console": "^2.0.0",
|
||||
"resize-observer-polyfill": "1.5.1",
|
||||
"timezone-mock": "1.4.0"
|
||||
"timezone-mock": "^1.4.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@emotion/cache": "^11.4.0",
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { PureComponent, ReactNode } from 'react';
|
||||
import { memo, ReactNode } from 'react';
|
||||
|
||||
import { isDefined } from '../utils';
|
||||
|
||||
@@ -29,7 +29,7 @@ type Props = {
|
||||
contentWidth?: number;
|
||||
contentHeight?: number;
|
||||
height: number;
|
||||
renderContent: ({
|
||||
renderContent?: ({
|
||||
height,
|
||||
width,
|
||||
}: {
|
||||
@@ -39,36 +39,35 @@ type Props = {
|
||||
width: number;
|
||||
};
|
||||
|
||||
export default class ChartFrame extends PureComponent<Props, {}> {
|
||||
static defaultProps = {
|
||||
renderContent() {},
|
||||
};
|
||||
function ChartFrame({
|
||||
contentWidth,
|
||||
contentHeight,
|
||||
width,
|
||||
height,
|
||||
renderContent = () => null,
|
||||
}: Props) {
|
||||
const overflowX = checkNumber(contentWidth) && contentWidth > width;
|
||||
const overflowY = checkNumber(contentHeight) && contentHeight > height;
|
||||
|
||||
render() {
|
||||
const { contentWidth, contentHeight, width, height, renderContent } =
|
||||
this.props;
|
||||
|
||||
const overflowX = checkNumber(contentWidth) && contentWidth > width;
|
||||
const overflowY = checkNumber(contentHeight) && contentHeight > height;
|
||||
|
||||
if (overflowX || overflowY) {
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
height,
|
||||
overflowX: overflowX ? 'auto' : 'hidden',
|
||||
overflowY: overflowY ? 'auto' : 'hidden',
|
||||
width,
|
||||
}}
|
||||
>
|
||||
{renderContent({
|
||||
height: Math.max(contentHeight ?? 0, height),
|
||||
width: Math.max(contentWidth ?? 0, width),
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return renderContent({ height, width });
|
||||
if (overflowX || overflowY) {
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
height,
|
||||
overflowX: overflowX ? 'auto' : 'hidden',
|
||||
overflowY: overflowY ? 'auto' : 'hidden',
|
||||
width,
|
||||
}}
|
||||
>
|
||||
{renderContent({
|
||||
height: Math.max(contentHeight ?? 0, height),
|
||||
width: Math.max(contentWidth ?? 0, width),
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return <>{renderContent({ height, width })}</>;
|
||||
}
|
||||
|
||||
export default memo(ChartFrame);
|
||||
|
||||
@@ -17,26 +17,19 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { CSSProperties, ReactNode, PureComponent } from 'react';
|
||||
import { CSSProperties, ReactNode, memo, useMemo } from 'react';
|
||||
import { ParentSize } from '@visx/responsive';
|
||||
|
||||
const defaultProps = {
|
||||
className: '',
|
||||
height: 'auto' as number | string,
|
||||
position: 'top',
|
||||
width: 'auto' as number | string,
|
||||
};
|
||||
|
||||
type Props = {
|
||||
className: string;
|
||||
className?: string;
|
||||
debounceTime?: number;
|
||||
width: number | string;
|
||||
height: number | string;
|
||||
width?: number | string;
|
||||
height?: number | string;
|
||||
legendJustifyContent?: 'center' | 'flex-start' | 'flex-end';
|
||||
position: 'top' | 'left' | 'bottom' | 'right';
|
||||
position?: 'top' | 'left' | 'bottom' | 'right';
|
||||
renderChart: (dim: { width: number; height: number }) => ReactNode;
|
||||
renderLegend?: (params: { direction: string }) => ReactNode;
|
||||
} & Readonly<typeof defaultProps>;
|
||||
};
|
||||
|
||||
const LEGEND_STYLE_BASE: CSSProperties = {
|
||||
display: 'flex',
|
||||
@@ -52,95 +45,101 @@ const CHART_STYLE_BASE: CSSProperties = {
|
||||
position: 'relative',
|
||||
};
|
||||
|
||||
class WithLegend extends PureComponent<Props, {}> {
|
||||
static defaultProps = defaultProps;
|
||||
|
||||
getContainerDirection(): CSSProperties['flexDirection'] {
|
||||
const { position } = this.props;
|
||||
|
||||
if (position === 'left') {
|
||||
return 'row';
|
||||
}
|
||||
if (position === 'right') {
|
||||
return 'row-reverse';
|
||||
}
|
||||
if (position === 'bottom') {
|
||||
return 'column-reverse';
|
||||
}
|
||||
|
||||
return 'column';
|
||||
function getContainerDirection(
|
||||
position: Props['position'],
|
||||
): CSSProperties['flexDirection'] {
|
||||
if (position === 'left') {
|
||||
return 'row';
|
||||
}
|
||||
if (position === 'right') {
|
||||
return 'row-reverse';
|
||||
}
|
||||
if (position === 'bottom') {
|
||||
return 'column-reverse';
|
||||
}
|
||||
|
||||
getLegendJustifyContent() {
|
||||
const { legendJustifyContent, position } = this.props;
|
||||
if (legendJustifyContent) {
|
||||
return legendJustifyContent;
|
||||
}
|
||||
|
||||
if (position === 'left' || position === 'right') {
|
||||
return 'flex-start';
|
||||
}
|
||||
|
||||
return 'flex-end';
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
className,
|
||||
debounceTime,
|
||||
width,
|
||||
height,
|
||||
position,
|
||||
renderChart,
|
||||
renderLegend,
|
||||
} = this.props;
|
||||
|
||||
const isHorizontal = position === 'left' || position === 'right';
|
||||
|
||||
const style: CSSProperties = {
|
||||
display: 'flex',
|
||||
flexDirection: this.getContainerDirection(),
|
||||
height,
|
||||
width,
|
||||
};
|
||||
|
||||
const chartStyle: CSSProperties = { ...CHART_STYLE_BASE };
|
||||
if (isHorizontal) {
|
||||
chartStyle.width = 0;
|
||||
} else {
|
||||
chartStyle.height = 0;
|
||||
}
|
||||
|
||||
const legendDirection = isHorizontal ? 'column' : 'row';
|
||||
const legendStyle: CSSProperties = {
|
||||
...LEGEND_STYLE_BASE,
|
||||
flexDirection: legendDirection,
|
||||
justifyContent: this.getLegendJustifyContent(),
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={`with-legend ${className}`} style={style}>
|
||||
{renderLegend && (
|
||||
<div className="legend-container" style={legendStyle}>
|
||||
{renderLegend({
|
||||
// Pass flexDirection for @vx/legend to arrange legend items
|
||||
direction: legendDirection,
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
<div className="main-container" style={chartStyle}>
|
||||
<ParentSize debounceTime={debounceTime}>
|
||||
{(parent: { width: number; height: number }) =>
|
||||
parent.width > 0 && parent.height > 0
|
||||
? // Only render when necessary
|
||||
renderChart(parent)
|
||||
: null
|
||||
}
|
||||
</ParentSize>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return 'column';
|
||||
}
|
||||
|
||||
export default WithLegend;
|
||||
function getLegendJustifyContent(
|
||||
legendJustifyContent: Props['legendJustifyContent'],
|
||||
position: Props['position'],
|
||||
) {
|
||||
if (legendJustifyContent) {
|
||||
return legendJustifyContent;
|
||||
}
|
||||
|
||||
if (position === 'left' || position === 'right') {
|
||||
return 'flex-start';
|
||||
}
|
||||
|
||||
return 'flex-end';
|
||||
}
|
||||
|
||||
function WithLegend({
|
||||
className = '',
|
||||
debounceTime,
|
||||
width = 'auto',
|
||||
height = 'auto',
|
||||
legendJustifyContent,
|
||||
position = 'top',
|
||||
renderChart,
|
||||
renderLegend,
|
||||
}: Props) {
|
||||
const isHorizontal = position === 'left' || position === 'right';
|
||||
|
||||
const style: CSSProperties = useMemo(
|
||||
() => ({
|
||||
display: 'flex',
|
||||
flexDirection: getContainerDirection(position),
|
||||
height,
|
||||
width,
|
||||
}),
|
||||
[position, height, width],
|
||||
);
|
||||
|
||||
const chartStyle: CSSProperties = useMemo(() => {
|
||||
const baseStyle = { ...CHART_STYLE_BASE };
|
||||
if (isHorizontal) {
|
||||
baseStyle.width = 0;
|
||||
} else {
|
||||
baseStyle.height = 0;
|
||||
}
|
||||
return baseStyle;
|
||||
}, [isHorizontal]);
|
||||
|
||||
const legendDirection = isHorizontal ? 'column' : 'row';
|
||||
const legendStyle: CSSProperties = useMemo(
|
||||
() => ({
|
||||
...LEGEND_STYLE_BASE,
|
||||
flexDirection: legendDirection,
|
||||
justifyContent: getLegendJustifyContent(legendJustifyContent, position),
|
||||
}),
|
||||
[legendDirection, legendJustifyContent, position],
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={`with-legend ${className}`} style={style}>
|
||||
{renderLegend && (
|
||||
<div className="legend-container" style={legendStyle}>
|
||||
{renderLegend({
|
||||
// Pass flexDirection for @vx/legend to arrange legend items
|
||||
direction: legendDirection,
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
<div className="main-container" style={chartStyle}>
|
||||
<ParentSize debounceTime={debounceTime}>
|
||||
{(parent: { width: number; height: number }) =>
|
||||
parent.width > 0 && parent.height > 0
|
||||
? // Only render when necessary
|
||||
renderChart(parent)
|
||||
: null
|
||||
}
|
||||
</ParentSize>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default memo(WithLegend);
|
||||
|
||||
@@ -17,31 +17,21 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { PureComponent, ReactNode } from 'react';
|
||||
|
||||
const defaultProps = {
|
||||
className: '',
|
||||
};
|
||||
import { memo, ReactNode } from 'react';
|
||||
|
||||
type Props = {
|
||||
className?: string;
|
||||
children: ReactNode;
|
||||
} & Readonly<typeof defaultProps>;
|
||||
};
|
||||
|
||||
const CONTAINER_STYLE = { padding: 8 };
|
||||
|
||||
class TooltipFrame extends PureComponent<Props, {}> {
|
||||
static defaultProps = defaultProps;
|
||||
|
||||
render() {
|
||||
const { className, children } = this.props;
|
||||
|
||||
return (
|
||||
<div className={className} style={CONTAINER_STYLE}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
function TooltipFrame({ className = '', children }: Props) {
|
||||
return (
|
||||
<div className={className} style={CONTAINER_STYLE}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default TooltipFrame;
|
||||
export default memo(TooltipFrame);
|
||||
|
||||
@@ -41,6 +41,7 @@ export enum VizType {
|
||||
LegacyBubble = 'bubble',
|
||||
Line = 'echarts_timeseries_line',
|
||||
MapBox = 'mapbox',
|
||||
PointClusterMap = 'point_cluster_map',
|
||||
MixedTimeseries = 'mixed_timeseries',
|
||||
PairedTTest = 'paired_ttest',
|
||||
ParallelCoordinates = 'para',
|
||||
|
||||
@@ -319,6 +319,11 @@ export function AsyncAceEditor(
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
/* Style bracket matching to blend with theme */
|
||||
.ace_editor .ace_bracket {
|
||||
border-color: ${token.colorPrimaryBorderHover} !important;
|
||||
}
|
||||
|
||||
/* Adjust cursor color */
|
||||
.ace_editor .ace_cursor {
|
||||
color: ${token.colorPrimaryText} !important;
|
||||
|
||||
@@ -33,20 +33,22 @@ import type { PlaceholderProps } from './types';
|
||||
function DefaultPlaceholder({
|
||||
width,
|
||||
height,
|
||||
showLoadingForImport = false,
|
||||
showLoadingForImport = true,
|
||||
placeholderStyle: style,
|
||||
}: PlaceholderProps) {
|
||||
return (
|
||||
// since `width` defaults to 100%, we can display the placeholder once
|
||||
// height is specified.
|
||||
(height && (
|
||||
if (showLoadingForImport) {
|
||||
return (
|
||||
<div key="async-asm-placeholder" style={{ width, height, ...style }}>
|
||||
{showLoadingForImport && <Loading position="floating" />}
|
||||
<Loading position="floating" size="s" />
|
||||
</div>
|
||||
)) ||
|
||||
// `|| null` is for in case of height=0.
|
||||
null
|
||||
);
|
||||
);
|
||||
}
|
||||
if (height) {
|
||||
return (
|
||||
<div key="async-asm-placeholder" style={{ width, height, ...style }} />
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { render, screen } from '../../spec';
|
||||
import { render, screen, fireEvent } from '../../spec';
|
||||
import CodeSyntaxHighlighter from './index';
|
||||
|
||||
// Simple mock that just returns the content
|
||||
@@ -153,4 +153,44 @@ describe('CodeSyntaxHighlighter', () => {
|
||||
|
||||
expect(screen.getByText('SELECT * FROM users;')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('shows copy button by default', () => {
|
||||
render(
|
||||
<CodeSyntaxHighlighter language="sql">SELECT 1;</CodeSyntaxHighlighter>,
|
||||
);
|
||||
|
||||
expect(screen.getByTitle('Copy to clipboard')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('hides copy button when showCopyButton is false', () => {
|
||||
render(
|
||||
<CodeSyntaxHighlighter language="sql" showCopyButton={false}>
|
||||
SELECT 1;
|
||||
</CodeSyntaxHighlighter>,
|
||||
);
|
||||
|
||||
expect(screen.queryByTitle('Copy to clipboard')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('copy button does not throw when clipboard API is unavailable', () => {
|
||||
const originalClipboard = navigator.clipboard;
|
||||
Object.defineProperty(navigator, 'clipboard', {
|
||||
value: undefined,
|
||||
configurable: true,
|
||||
});
|
||||
document.execCommand = jest.fn().mockReturnValue(true);
|
||||
|
||||
render(
|
||||
<CodeSyntaxHighlighter language="sql">SELECT 1;</CodeSyntaxHighlighter>,
|
||||
);
|
||||
|
||||
expect(() =>
|
||||
fireEvent.click(screen.getByTitle('Copy to clipboard')),
|
||||
).not.toThrow();
|
||||
|
||||
Object.defineProperty(navigator, 'clipboard', {
|
||||
value: originalClipboard,
|
||||
configurable: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -16,11 +16,14 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import SyntaxHighlighterBase from 'react-syntax-highlighter/dist/cjs/light';
|
||||
import github from 'react-syntax-highlighter/dist/cjs/styles/hljs/github';
|
||||
import tomorrow from 'react-syntax-highlighter/dist/cjs/styles/hljs/tomorrow-night';
|
||||
import { isThemeDark, useTheme } from '@apache-superset/core/theme';
|
||||
import { css, isThemeDark, useTheme } from '@apache-superset/core/theme';
|
||||
import { t } from '@apache-superset/core/translation';
|
||||
import copyTextToClipboard from '../../utils/copy';
|
||||
import { Icons } from '../Icons';
|
||||
|
||||
export type SupportedLanguage = 'sql' | 'htmlbars' | 'markdown' | 'json';
|
||||
|
||||
@@ -31,6 +34,7 @@ export interface CodeSyntaxHighlighterProps {
|
||||
showLineNumbers?: boolean;
|
||||
wrapLines?: boolean;
|
||||
style?: any; // Override theme style if needed
|
||||
showCopyButton?: boolean;
|
||||
}
|
||||
|
||||
// Track which languages have been registered to avoid duplicate registrations
|
||||
@@ -76,11 +80,14 @@ export const CodeSyntaxHighlighter: React.FC<CodeSyntaxHighlighterProps> = ({
|
||||
showLineNumbers = false,
|
||||
wrapLines = true,
|
||||
style: overrideStyle,
|
||||
showCopyButton = true,
|
||||
}) => {
|
||||
const theme = useTheme();
|
||||
const [isLanguageReady, setIsLanguageReady] = useState(
|
||||
registeredLanguages.has(language),
|
||||
);
|
||||
const [copied, setCopied] = useState(false);
|
||||
const copyTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const loadLanguage = async () => {
|
||||
@@ -93,6 +100,21 @@ export const CodeSyntaxHighlighter: React.FC<CodeSyntaxHighlighterProps> = ({
|
||||
loadLanguage();
|
||||
}, [language]);
|
||||
|
||||
useEffect(
|
||||
() => () => {
|
||||
if (copyTimeoutRef.current) clearTimeout(copyTimeoutRef.current);
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
const handleCopy = useCallback(() => {
|
||||
copyTextToClipboard(() => Promise.resolve(children)).then(() => {
|
||||
if (copyTimeoutRef.current) clearTimeout(copyTimeoutRef.current);
|
||||
setCopied(true);
|
||||
copyTimeoutRef.current = setTimeout(() => setCopied(false), 1500);
|
||||
});
|
||||
}, [children]);
|
||||
|
||||
const isDark = isThemeDark(theme);
|
||||
const themeStyle = overrideStyle || (isDark ? tomorrow : github);
|
||||
|
||||
@@ -104,32 +126,79 @@ export const CodeSyntaxHighlighter: React.FC<CodeSyntaxHighlighterProps> = ({
|
||||
...customStyle,
|
||||
};
|
||||
|
||||
const copyButton = showCopyButton && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={(e: React.MouseEvent) => {
|
||||
e.stopPropagation();
|
||||
handleCopy();
|
||||
}}
|
||||
title={copied ? t('Copied!') : t('Copy to clipboard')}
|
||||
css={css`
|
||||
position: absolute;
|
||||
top: ${theme.sizeUnit}px;
|
||||
right: ${theme.sizeUnit}px;
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
padding: ${theme.sizeUnit}px;
|
||||
color: ${copied ? theme.colorSuccess : theme.colorTextSecondary};
|
||||
line-height: 1;
|
||||
border-radius: ${theme.borderRadius}px;
|
||||
&:hover {
|
||||
color: ${copied ? theme.colorSuccess : theme.colorText};
|
||||
background: ${theme.colorBgTextHover};
|
||||
}
|
||||
`}
|
||||
>
|
||||
{copied ? (
|
||||
<Icons.CheckOutlined style={{ fontSize: theme.fontSizeSM }} />
|
||||
) : (
|
||||
<Icons.CopyOutlined style={{ fontSize: theme.fontSizeSM }} />
|
||||
)}
|
||||
</button>
|
||||
);
|
||||
|
||||
// Show a simple pre-formatted text while language is loading
|
||||
if (!isLanguageReady) {
|
||||
return (
|
||||
<pre
|
||||
style={{
|
||||
...defaultCustomStyle,
|
||||
fontFamily: 'monospace',
|
||||
whiteSpace: 'pre-wrap',
|
||||
margin: 0,
|
||||
}}
|
||||
<div
|
||||
css={css`
|
||||
position: relative;
|
||||
`}
|
||||
>
|
||||
{children}
|
||||
</pre>
|
||||
{copyButton}
|
||||
<pre
|
||||
style={{
|
||||
...defaultCustomStyle,
|
||||
fontFamily: 'monospace',
|
||||
whiteSpace: 'pre-wrap',
|
||||
margin: 0,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</pre>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<SyntaxHighlighterBase
|
||||
language={language}
|
||||
style={themeStyle}
|
||||
customStyle={defaultCustomStyle}
|
||||
showLineNumbers={showLineNumbers}
|
||||
wrapLines={wrapLines}
|
||||
<div
|
||||
css={css`
|
||||
position: relative;
|
||||
`}
|
||||
>
|
||||
{children}
|
||||
</SyntaxHighlighterBase>
|
||||
{copyButton}
|
||||
<SyntaxHighlighterBase
|
||||
language={language}
|
||||
style={themeStyle}
|
||||
customStyle={defaultCustomStyle}
|
||||
showLineNumbers={showLineNumbers}
|
||||
wrapLines={wrapLines}
|
||||
>
|
||||
{children}
|
||||
</SyntaxHighlighterBase>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -51,8 +51,16 @@ test('renders children with custom horizontal spacing', () => {
|
||||
expect(screen.getByTestId('container')).toHaveStyle('gap: 20px');
|
||||
});
|
||||
|
||||
test('does not render a dropdown button when not overflowing', () => {
|
||||
test('renders dropdown button when items exist even when not overflowing', () => {
|
||||
render(<DropdownContainer items={generateItems(3)} />);
|
||||
// Button should always be visible when items exist to prevent layout shifts
|
||||
expect(screen.getByText('More')).toBeInTheDocument();
|
||||
// Badge should show 0 when nothing is overflowing
|
||||
expect(screen.getByText('0')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('does not render a dropdown button when no items', () => {
|
||||
render(<DropdownContainer items={[]} />);
|
||||
expect(screen.queryByText('More')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ import { t } from '@apache-superset/core/translation';
|
||||
import { usePrevious } from '@superset-ui/core';
|
||||
import { css, useTheme } from '@apache-superset/core/theme';
|
||||
import { useResizeDetector } from 'react-resize-detector';
|
||||
import { Badge, Icons, Button, Tooltip, Popover } from '..';
|
||||
import { Badge, Icons, Button, Popover } from '..';
|
||||
import { DropdownContainerProps, DropdownItem, DropdownRef } from './types';
|
||||
|
||||
const MAX_HEIGHT = 500;
|
||||
@@ -234,6 +234,10 @@ export const DropdownContainer = forwardRef(
|
||||
const overflowingCount =
|
||||
overflowingIndex !== -1 ? items.length - overflowingIndex : 0;
|
||||
|
||||
// Always show button when items exist to prevent layout shifts
|
||||
// and ensure consistent UI even when no items are overflowing
|
||||
const shouldShowButton = items.length > 0 || !!dropdownContent;
|
||||
|
||||
const popoverContent = useMemo(
|
||||
() =>
|
||||
dropdownContent || overflowingCount ? (
|
||||
@@ -293,6 +297,44 @@ export const DropdownContainer = forwardRef(
|
||||
};
|
||||
}, [popoverVisible]);
|
||||
|
||||
const triggerButton = (
|
||||
<Button
|
||||
buttonStyle="secondary"
|
||||
data-test="dropdown-container-btn"
|
||||
icon={dropdownTriggerIcon}
|
||||
disabled={!popoverContent}
|
||||
tooltip={dropdownTriggerTooltip}
|
||||
css={css`
|
||||
padding-left: ${theme.paddingXS}px;
|
||||
padding-right: ${theme.paddingXXS}px;
|
||||
gap: ${theme.sizeXXS}px;
|
||||
`}
|
||||
>
|
||||
{dropdownTriggerText}
|
||||
<Badge
|
||||
count={dropdownTriggerCount ?? overflowingCount}
|
||||
color={
|
||||
(dropdownTriggerCount ?? overflowingCount) > 0
|
||||
? theme.colorPrimary
|
||||
: theme.colorTextSecondary
|
||||
}
|
||||
showZero
|
||||
css={css`
|
||||
margin-left: ${theme.sizeUnit * 2}px;
|
||||
`}
|
||||
/>
|
||||
<Icons.DownOutlined
|
||||
iconSize="m"
|
||||
iconColor={theme.colorIcon}
|
||||
css={css`
|
||||
.anticon {
|
||||
display: flex;
|
||||
}
|
||||
`}
|
||||
/>
|
||||
</Button>
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={ref}
|
||||
@@ -314,7 +356,7 @@ export const DropdownContainer = forwardRef(
|
||||
>
|
||||
{notOverflowedItems.map(item => item.element)}
|
||||
</div>
|
||||
{popoverContent && (
|
||||
{shouldShowButton && (
|
||||
<>
|
||||
<Global
|
||||
styles={css`
|
||||
@@ -339,57 +381,27 @@ export const DropdownContainer = forwardRef(
|
||||
`}
|
||||
/>
|
||||
|
||||
<Popover
|
||||
styles={{
|
||||
body: {
|
||||
maxHeight: `${MAX_HEIGHT}px`,
|
||||
overflow: showOverflow ? 'auto' : 'visible',
|
||||
},
|
||||
}}
|
||||
content={popoverContent}
|
||||
trigger="click"
|
||||
open={popoverVisible}
|
||||
onOpenChange={visible => setPopoverVisible(visible)}
|
||||
placement="bottom"
|
||||
forceRender={forceRender}
|
||||
fresh // This prop prevents caching and stale data for filter scoping.
|
||||
>
|
||||
<Tooltip title={dropdownTriggerTooltip}>
|
||||
<Button
|
||||
buttonStyle="secondary"
|
||||
data-test="dropdown-container-btn"
|
||||
icon={dropdownTriggerIcon}
|
||||
css={css`
|
||||
padding-left: ${theme.paddingXS}px;
|
||||
padding-right: ${theme.paddingXXS}px;
|
||||
gap: ${theme.sizeXXS}px;
|
||||
`}
|
||||
>
|
||||
{dropdownTriggerText}
|
||||
<Badge
|
||||
count={dropdownTriggerCount ?? overflowingCount}
|
||||
color={
|
||||
(dropdownTriggerCount ?? overflowingCount) > 0
|
||||
? theme.colorPrimary
|
||||
: theme.colorTextSecondary
|
||||
}
|
||||
showZero
|
||||
css={css`
|
||||
margin-left: ${theme.sizeUnit * 2}px;
|
||||
`}
|
||||
/>
|
||||
<Icons.DownOutlined
|
||||
iconSize="m"
|
||||
iconColor={theme.colorIcon}
|
||||
css={css`
|
||||
.anticon {
|
||||
display: flex;
|
||||
}
|
||||
`}
|
||||
/>
|
||||
</Button>
|
||||
</Tooltip>
|
||||
</Popover>
|
||||
{popoverContent ? (
|
||||
<Popover
|
||||
styles={{
|
||||
body: {
|
||||
maxHeight: `${MAX_HEIGHT}px`,
|
||||
overflow: showOverflow ? 'auto' : 'visible',
|
||||
},
|
||||
}}
|
||||
content={popoverContent}
|
||||
trigger="click"
|
||||
open={popoverVisible}
|
||||
onOpenChange={visible => setPopoverVisible(visible)}
|
||||
placement="bottom"
|
||||
forceRender={forceRender}
|
||||
fresh // This prop prevents caching and stale data for filter scoping.
|
||||
>
|
||||
{triggerButton}
|
||||
</Popover>
|
||||
) : (
|
||||
triggerButton
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -17,10 +17,10 @@ specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
<svg viewBox="0 0 119 78" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect x="17" y="1" width="86" height="62" rx="3" stroke="currentColor" stroke-width="2"/>
|
||||
<rect x="21" y="5" width="78" height="14" rx="3" stroke="currentColor" stroke-width="2"/>
|
||||
<rect x="21" y="23" width="38" height="36" rx="3" stroke="currentColor" stroke-width="2"/>
|
||||
<rect x="63" y="37" width="36" height="22" rx="3" stroke="currentColor" stroke-width="2"/>
|
||||
<rect x="63" y="23" width="36" height="10" rx="3" stroke="currentColor" stroke-width="2"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M16 55.2892C6.07439 57.7013 0 60.9397 0 64.5C0 71.9559 26.6391 78 59.5 78C92.3609 78 119 71.9559 119 64.5C119 61.0609 113.332 57.9221 104 55.5383V60C104 62.2092 102.209 64 100 64H20C17.7909 64 16 62.2092 16 60V55.2892Z" fill="currentColor" fill-opacity="0.25" stroke="currentColor"/>
|
||||
<path d="M99.3193 1H20.6639C19.0349 1 17.7143 2.32057 17.7143 3.94958V59.0084C17.7143 60.6374 19.0349 61.958 20.6639 61.958H99.3193C100.948 61.958 102.269 60.6374 102.269 59.0084V3.94958C102.269 2.32057 100.948 1 99.3193 1Z" stroke="currentColor" stroke-width="2"/>
|
||||
<path d="M95.3866 4.93277H24.5966C22.9676 4.93277 21.647 6.25335 21.647 7.88235V15.7479C21.647 17.3769 22.9676 18.6975 24.5966 18.6975H95.3866C97.0156 18.6975 98.3361 17.3769 98.3361 15.7479V7.88235C98.3361 6.25335 97.0156 4.93277 95.3866 4.93277Z" stroke="currentColor" stroke-width="2"/>
|
||||
<path d="M56.0588 22.6303H24.5966C22.9676 22.6303 21.647 23.9508 21.647 25.5798V55.0756C21.647 56.7046 22.9676 58.0252 24.5966 58.0252H56.0588C57.6878 58.0252 59.0084 56.7046 59.0084 55.0756V25.5798C59.0084 23.9508 57.6878 22.6303 56.0588 22.6303Z" stroke="currentColor" stroke-width="2"/>
|
||||
<path d="M95.3865 36.395H65.8907C64.2617 36.395 62.9412 37.7155 62.9412 39.3445V55.0756C62.9412 56.7046 64.2617 58.0252 65.8907 58.0252H95.3865C97.0155 58.0252 98.3361 56.7046 98.3361 55.0756V39.3445C98.3361 37.7155 97.0155 36.395 95.3865 36.395Z" stroke="currentColor" stroke-width="2"/>
|
||||
<path d="M95.3865 22.6303H65.8907C64.2617 22.6303 62.9412 23.9508 62.9412 25.5798V29.5126C62.9412 31.1416 64.2617 32.4622 65.8907 32.4622H95.3865C97.0155 32.4622 98.3361 31.1416 98.3361 29.5126V25.5798C98.3361 23.9508 97.0155 22.6303 95.3865 22.6303Z" stroke="currentColor" stroke-width="2"/>
|
||||
<path d="M17.2227 59.0086C17.2228 60.9091 18.7637 62.45 20.6641 62.45H99.3193C101.22 62.45 102.761 60.9091 102.761 59.0086V53.9891L103.374 54.1453C107.981 55.3221 111.718 56.6931 114.315 58.2137C116.877 59.7134 118.491 61.4572 118.491 63.4324C118.491 64.5056 118.01 65.513 117.177 66.4373C116.346 67.3587 115.143 68.2232 113.635 69.032C110.618 70.6501 106.286 72.0925 100.975 73.2977C90.343 75.7099 75.6797 77.1971 59.5 77.1971C43.3203 77.1971 28.657 75.7099 18.0254 73.2977C12.7137 72.0925 8.38162 70.6501 5.36523 69.032C3.85742 68.2232 2.65424 67.3587 1.82324 66.4373C0.989641 65.513 0.508789 64.5056 0.508789 63.4324C0.508977 61.389 2.23587 59.5926 4.96484 58.0535C7.73449 56.4916 11.717 55.0896 16.6152 53.8992L17.2227 53.7518V59.0086Z" fill="currentColor" fill-opacity="0.25" stroke="currentColor"/>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 3.0 KiB |
@@ -17,6 +17,6 @@ specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
<svg viewBox="0 0 119 76" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M83.1952 1.36598L103 24V62C103 64.2091 101.209 66 99 66H20C17.7909 66 16 64.2091 16 62V24L35.8048 1.36598C36.5643 0.497921 37.6616 0 38.8151 0H80.1849C81.3384 0 82.4357 0.497922 83.1952 1.36598ZM101 26V62C101 63.1046 100.105 64 99 64H20C18.8954 64 18 63.1046 18 62V26H35.25C37.8734 26 40 28.1266 40 30.75C40 34.4779 43.0221 37.5 46.75 37.5H72.25C75.9779 37.5 79 34.4779 79 30.75C79 28.1266 81.1266 26 83.75 26H101ZM100.342 24L81.6901 2.68299C81.3103 2.24896 80.7617 2 80.1849 2H38.8151C38.2383 2 37.6897 2.24896 37.3099 2.68299L18.6575 24H35.25C38.9779 24 42 27.0221 42 30.75C42 33.3734 44.1266 35.5 46.75 35.5H72.25C74.8734 35.5 77 33.3734 77 30.75C77 27.0221 80.0221 24 83.75 24H100.342Z" fill="currentColor"/>
|
||||
<path d="M16 53.2891C6.07439 55.7012 0 58.9396 0 62.4999C0 69.9557 26.6391 75.9999 59.5 75.9999C92.3609 75.9999 119 69.9557 119 62.4999C119 58.9396 112.926 55.7012 103 53.2891V61.9999C103 64.209 101.209 65.9999 99 65.9999H20C17.7909 65.9999 16 64.209 16 61.9999V53.2891Z" fill="currentColor" stroke="currentColor" fill-opacity="0.25" />
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M82.7969 1.34302L102.269 23.5966V60.958C102.269 63.13 100.508 64.8908 98.3361 64.8908H20.6639C18.4919 64.8908 16.7311 63.13 16.7311 60.958V23.5966L36.203 1.34302C36.9498 0.489553 38.0286 0 39.1627 0H79.8372C80.9713 0 82.0502 0.489554 82.7969 1.34302ZM100.303 25.563V60.958C100.303 62.044 99.4225 62.9244 98.3361 62.9244H20.6639C19.5778 62.9244 18.6975 62.044 18.6975 60.958V25.563H35.6575C38.2369 25.563 40.3277 27.6539 40.3277 30.2332C40.3277 33.8984 43.299 36.8698 46.9643 36.8698H72.0357C75.7009 36.8698 78.6723 33.8984 78.6723 30.2332C78.6723 27.6539 80.7631 25.563 83.3424 25.563H100.303ZM99.6556 23.5966L81.3171 2.6379C80.9437 2.21116 80.4043 1.96639 79.8372 1.96639H39.1627C38.5956 1.96639 38.0562 2.21116 37.6828 2.6379L19.3439 23.5966H35.6575C39.3228 23.5966 42.2941 26.568 42.2941 30.2332C42.2941 32.8125 44.385 34.9034 46.9643 34.9034H72.0357C74.615 34.9034 76.7059 32.8125 76.7059 30.2332C76.7059 26.568 79.6772 23.5966 83.3424 23.5966H99.6556Z" fill="currentColor"/>
|
||||
<path d="M102.385 51.9159C107.283 53.1063 111.266 54.5083 114.035 56.0702C116.764 57.6093 118.491 59.4058 118.491 61.4492C118.491 62.5223 118.01 63.5298 117.177 64.454C116.346 65.3754 115.143 66.2399 113.635 67.0488C110.618 68.6668 106.286 70.1092 100.975 71.3144C90.343 73.7266 75.6797 75.2138 59.5 75.2138C43.3203 75.2138 28.657 73.7266 18.0254 71.3144C12.7137 70.1092 8.38162 68.6668 5.36523 67.0488C3.85743 66.2399 2.65424 65.3754 1.82324 64.454C0.989642 63.5298 0.508789 62.5223 0.508789 61.4492C0.508976 59.4057 2.23587 57.6093 4.96484 56.0702C7.73449 54.5083 11.717 53.1063 16.6152 51.9159L17.2227 51.7685V60.9579C17.2227 62.8584 18.7636 64.3993 20.6641 64.3993H98.3359C100.236 64.3993 101.777 62.8584 101.777 60.9579V51.7685L102.385 51.9159Z" fill="currentColor" stroke="currentColor" fill-opacity="0.25" />
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 2.6 KiB |
@@ -17,6 +17,6 @@ specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
<svg viewBox="0 0 119 78" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M59.2123 1.55857C59.4575 0.81382 60.5425 0.813801 60.7878 1.55857L67.5616 22.1322C67.9434 23.292 69.0328 24.0653 70.249 24.0653L92.1695 24.0653C92.9982 24.0653 93.2777 25.0719 92.6607 25.5143L74.9266 38.2295C73.9348 38.9406 73.5131 40.2085 73.8958 41.3707L80.6696 61.9444C80.8987 62.6402 80.076 63.3262 79.3906 62.8348L61.6566 50.1196C60.6679 49.4107 59.3321 49.4107 58.3434 50.1196L40.6094 62.8348C39.924 63.3262 39.1013 62.6402 39.3304 61.9444L46.1042 41.3707C46.4869 40.2085 46.0652 38.9406 45.0734 38.2295L27.3393 25.5143C26.7223 25.0719 27.0018 24.0653 27.8305 24.0653L49.751 24.0653C50.9672 24.0653 52.0566 23.292 52.4384 22.1322L59.2123 1.55857Z" stroke="currentColor" stroke-width="2"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M41.6782 51.616C17.5239 53.3343 0 58.4528 0 64.5C0 71.9558 26.6391 78 59.5 78C92.3609 78 119 71.9558 119 64.5C119 58.5387 101.97 53.4798 78.3466 51.6913L81.6194 61.6317C82.1664 63.2928 80.2398 64.6741 78.808 63.6475L61.1757 51.0053C60.619 51.0018 60.0604 51 59.5 51C59.2765 51 59.0534 51.0003 58.8305 51.0008L41.192 63.6475C39.7602 64.6741 37.8337 63.2928 38.3806 61.6317L41.6782 51.616Z" fill="currentColor" fill-opacity="0.25" stroke="currentColor"/>
|
||||
<path d="M59.2172 1.54918C59.4582 0.816949 60.525 0.81693 60.7662 1.54918L67.4261 21.777C67.8015 22.9173 68.8726 23.6776 70.0684 23.6776H91.6205C92.4352 23.6776 92.71 24.6673 92.1034 25.1023L74.6673 37.6038C73.6922 38.3029 73.2776 39.5495 73.6539 40.6922L80.3138 60.9201C80.5391 61.6042 79.7302 62.2787 79.0563 61.7956L61.6204 49.2941C60.6483 48.5971 59.3349 48.5971 58.3629 49.2941L40.9269 61.7956C40.253 62.2787 39.4441 61.6042 39.6694 60.9201L46.3294 40.6922C46.7056 39.5495 46.291 38.3029 45.3159 37.6038L27.8798 25.1023C27.2732 24.6673 27.548 23.6776 28.3628 23.6776H49.9149C51.1106 23.6776 52.1817 22.9173 52.5571 21.777L59.2172 1.54918Z" stroke="currentColor" stroke-width="2"/>
|
||||
<path d="M59.5 49.6685C60.052 49.6685 60.6021 49.6699 61.1504 49.6733L61.3066 49.6743L61.4336 49.7651L78.7695 62.1948C79.8103 62.9411 81.1618 61.9247 80.7803 60.7661L77.5625 50.9927L77.333 50.2935L78.0674 50.3491C89.7005 51.2299 99.7327 52.9176 106.87 55.1284C110.435 56.2328 113.307 57.4759 115.298 58.8335C117.27 60.1787 118.491 61.7173 118.491 63.4331C118.491 64.5061 118.01 65.5129 117.177 66.437C116.346 67.3584 115.143 68.2239 113.635 69.0327C110.618 70.6507 106.286 72.0922 100.975 73.2974C90.343 75.7096 75.6797 77.1978 59.5 77.1978C43.3203 77.1978 28.657 75.7096 18.0254 73.2974C12.7139 72.0922 8.3816 70.6507 5.36523 69.0327C3.85739 68.2239 2.65424 67.3584 1.82324 66.437C0.989783 65.5129 0.508887 64.5061 0.508789 63.4331C0.508789 61.6928 1.7644 60.135 3.78906 58.7749C5.83338 57.4017 8.78191 56.1452 12.4404 55.0327C19.7642 52.8057 30.0482 51.1211 41.9424 50.2749L42.6738 50.2231L42.4443 50.9194L39.2021 60.7661C38.8207 61.9247 40.1722 62.9409 41.2129 62.1948L58.5557 49.7612L58.6836 49.6694L58.8408 49.6685C59.0602 49.668 59.2799 49.6685 59.5 49.6685Z" fill="currentColor" fill-opacity="0.25" stroke="currentColor"/>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.6 KiB |
@@ -90,6 +90,7 @@ import {
|
||||
InfoCircleFilled,
|
||||
InsertRowAboveOutlined,
|
||||
InsertRowBelowOutlined,
|
||||
LeftOutlined,
|
||||
LineChartOutlined,
|
||||
LineOutlined,
|
||||
LinkOutlined,
|
||||
@@ -115,6 +116,7 @@ import {
|
||||
PlusSquareOutlined,
|
||||
PlusOutlined,
|
||||
ProfileOutlined,
|
||||
PushpinFilled,
|
||||
PushpinOutlined,
|
||||
QuestionCircleOutlined,
|
||||
ReloadOutlined,
|
||||
@@ -245,6 +247,7 @@ const AntdIcons = {
|
||||
InfoCircleFilled,
|
||||
InsertRowAboveOutlined,
|
||||
InsertRowBelowOutlined,
|
||||
LeftOutlined,
|
||||
LineChartOutlined,
|
||||
LineOutlined,
|
||||
LinkOutlined,
|
||||
@@ -270,6 +273,7 @@ const AntdIcons = {
|
||||
PlusSquareOutlined,
|
||||
PlusOutlined,
|
||||
ProfileOutlined,
|
||||
PushpinFilled,
|
||||
PushpinOutlined,
|
||||
ReloadOutlined,
|
||||
QuestionCircleOutlined,
|
||||
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
waitFor,
|
||||
within,
|
||||
} from '@superset-ui/core/spec';
|
||||
import { formatNumber } from '@superset-ui/core';
|
||||
import { Select } from '.';
|
||||
|
||||
type Option = {
|
||||
@@ -85,8 +86,10 @@ const getElementsByClassName = (className: string) =>
|
||||
const getSelect = () =>
|
||||
screen.getByRole('combobox', { name: new RegExp(ARIA_LABEL, 'i') });
|
||||
|
||||
const selectAllButtonText = (length: number) => `Select all (${length})`;
|
||||
const deselectAllButtonText = (length: number) => `Clear (${length})`;
|
||||
const selectAllButtonText = (length: number) =>
|
||||
`Select all (${formatNumber('SMART_NUMBER', length)})`;
|
||||
const deselectAllButtonText = (length: number) =>
|
||||
`Clear (${formatNumber('SMART_NUMBER', length)})`;
|
||||
|
||||
const findSelectOption = (text: string) =>
|
||||
waitFor(() =>
|
||||
@@ -811,6 +814,62 @@ test('Maintains stable maxTagCount to prevent click target disappearing in oneLi
|
||||
expect(withinSelector.getByText('+ 2 ...')).toBeVisible();
|
||||
});
|
||||
|
||||
test('dropdown width matches input width after tags collapse in oneLine mode', async () => {
|
||||
render(
|
||||
<div style={{ width: '300px' }}>
|
||||
<Select
|
||||
{...defaultProps}
|
||||
value={[OPTIONS[0], OPTIONS[1], OPTIONS[2]]}
|
||||
mode="multiple"
|
||||
oneLine
|
||||
/>
|
||||
</div>,
|
||||
);
|
||||
|
||||
await open();
|
||||
|
||||
// Wait for RAF to complete and tags to collapse
|
||||
await waitFor(() => {
|
||||
const withinSelector = within(
|
||||
getElementByClassName('.ant-select-selector'),
|
||||
);
|
||||
expect(
|
||||
withinSelector.queryByText(OPTIONS[0].label),
|
||||
).not.toBeInTheDocument();
|
||||
expect(withinSelector.getByText('+ 3 ...')).toBeVisible();
|
||||
});
|
||||
|
||||
const selectElement = document.querySelector('.ant-select') as HTMLElement;
|
||||
expect(selectElement).toBeInTheDocument();
|
||||
|
||||
// Mock the select element's width since JSDOM doesn't perform real layout
|
||||
jest.spyOn(selectElement, 'getBoundingClientRect').mockReturnValue({
|
||||
width: 300,
|
||||
height: 32,
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 300,
|
||||
bottom: 32,
|
||||
x: 0,
|
||||
y: 0,
|
||||
toJSON: () => ({}),
|
||||
} as DOMRect);
|
||||
|
||||
// Close and reopen to trigger width measurement with mocked value
|
||||
await type('{esc}');
|
||||
await open();
|
||||
|
||||
const dropdown = document.querySelector(
|
||||
'.ant-select-dropdown',
|
||||
) as HTMLElement;
|
||||
expect(dropdown).toBeInTheDocument();
|
||||
|
||||
// Verify the dropdown has inline width matching the mocked select width
|
||||
await waitFor(() => {
|
||||
expect(parseInt(dropdown.style.width, 10)).toBe(300);
|
||||
});
|
||||
});
|
||||
|
||||
test('does not render "Select all" when there are 0 or 1 options', async () => {
|
||||
const { rerender } = render(
|
||||
<Select {...defaultProps} options={[]} mode="multiple" allowNewOptions />,
|
||||
@@ -915,6 +974,17 @@ test('"Select all" does not affect disabled options', async () => {
|
||||
expect(await findSelectValue()).not.toHaveTextContent(options[1].label);
|
||||
});
|
||||
|
||||
test('abbreviates large numbers in bulk action buttons', async () => {
|
||||
const manyOptions = Array.from({ length: 1500 }, (_, i) => ({
|
||||
label: `Option ${i}`,
|
||||
value: i,
|
||||
}));
|
||||
render(<Select {...defaultProps} mode="multiple" options={manyOptions} />);
|
||||
await open();
|
||||
// SMART_NUMBER format uses lowercase 'k' for thousands (d3-format)
|
||||
expect(await screen.findByText('Select all (1.5k)')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('dropdown takes full width of the select input for multi select', async () => {
|
||||
render(
|
||||
<div style={{ width: '400px' }}>
|
||||
|
||||
@@ -31,7 +31,7 @@ import {
|
||||
} from 'react';
|
||||
|
||||
import { t } from '@apache-superset/core/translation';
|
||||
import { ensureIsArray, usePrevious } from '@superset-ui/core';
|
||||
import { ensureIsArray, formatNumber, usePrevious } from '@superset-ui/core';
|
||||
import { Constants } from '@superset-ui/core/components';
|
||||
import {
|
||||
LabeledValue as AntdLabeledValue,
|
||||
@@ -149,6 +149,8 @@ const Select = forwardRef(
|
||||
// Prevent maxTagCount change during click events to avoid click target disappearing
|
||||
const [stableMaxTagCount, setStableMaxTagCount] = useState(maxTagCount);
|
||||
const isOpeningRef = useRef(false);
|
||||
const selectContainerRef = useRef<HTMLDivElement>(null);
|
||||
const [dropdownWidth, setDropdownWidth] = useState<number | true>(true);
|
||||
|
||||
useEffect(() => {
|
||||
if (oneLine) {
|
||||
@@ -159,12 +161,23 @@ const Select = forwardRef(
|
||||
requestAnimationFrame(() => {
|
||||
setStableMaxTagCount(0);
|
||||
isOpeningRef.current = false;
|
||||
|
||||
// Measure collapsed width and update dropdown width
|
||||
const selectElement =
|
||||
selectContainerRef.current?.querySelector('.ant-select');
|
||||
if (selectElement) {
|
||||
const { width } = selectElement.getBoundingClientRect();
|
||||
if (width > 0) {
|
||||
setDropdownWidth(width);
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!isDropdownVisible) {
|
||||
// When closing, immediately show the first tag
|
||||
setStableMaxTagCount(1);
|
||||
setDropdownWidth(true); // Reset to default when closing
|
||||
isOpeningRef.current = false;
|
||||
}
|
||||
return;
|
||||
@@ -494,7 +507,7 @@ const Select = forwardRef(
|
||||
|
||||
const bulkSelectComponent = useMemo(
|
||||
() => (
|
||||
<StyledBulkActionsContainer justify="center">
|
||||
<StyledBulkActionsContainer justify="space-between">
|
||||
<Button
|
||||
type="link"
|
||||
buttonStyle="link"
|
||||
@@ -506,7 +519,7 @@ const Select = forwardRef(
|
||||
handleSelectAll();
|
||||
}}
|
||||
>
|
||||
{`${t('Select all')} (${bulkSelectCounts.selectable})`}
|
||||
{`${t('Select all')} (${formatNumber('SMART_NUMBER', bulkSelectCounts.selectable)})`}
|
||||
</Button>
|
||||
<Button
|
||||
type="link"
|
||||
@@ -523,7 +536,7 @@ const Select = forwardRef(
|
||||
handleDeselectAll();
|
||||
}}
|
||||
>
|
||||
{`${t('Clear')} (${bulkSelectCounts.deselectable})`}
|
||||
{`${t('Clear')} (${formatNumber('SMART_NUMBER', bulkSelectCounts.deselectable)})`}
|
||||
</Button>
|
||||
</StyledBulkActionsContainer>
|
||||
),
|
||||
@@ -717,7 +730,11 @@ const Select = forwardRef(
|
||||
};
|
||||
|
||||
return (
|
||||
<StyledContainer className={className} headerPosition={headerPosition}>
|
||||
<StyledContainer
|
||||
ref={selectContainerRef}
|
||||
className={className}
|
||||
headerPosition={headerPosition}
|
||||
>
|
||||
{header && (
|
||||
<StyledHeader headerPosition={headerPosition}>{header}</StyledHeader>
|
||||
)}
|
||||
@@ -777,7 +794,7 @@ const Select = forwardRef(
|
||||
options={visibleOptions}
|
||||
optionRender={option => <Space>{option.label || option.value}</Space>}
|
||||
oneLine={oneLine}
|
||||
popupMatchSelectWidth
|
||||
popupMatchSelectWidth={oneLine ? dropdownWidth : true}
|
||||
css={props.css}
|
||||
dropdownAlign={DROPDOWN_ALIGN_BOTTOM}
|
||||
{...props}
|
||||
|
||||
@@ -140,11 +140,17 @@ export const StyledErrorMessage = styled.div`
|
||||
|
||||
export const StyledBulkActionsContainer = styled(Flex)`
|
||||
${({ theme }) => `
|
||||
padding: ${theme.sizeUnit}px;
|
||||
padding: ${theme.sizeUnit}px 0;
|
||||
border-top: 1px solid ${theme.colorSplit};
|
||||
gap: ${theme.sizeUnit * 2}px;
|
||||
& .superset-button {
|
||||
font-family: inherit;
|
||||
margin-left: 0 !important;
|
||||
}
|
||||
& .superset-button:first-of-type {
|
||||
padding-right: 0 !important;
|
||||
}
|
||||
& .superset-button:last-of-type {
|
||||
padding-left: 0 !important;
|
||||
}
|
||||
`}
|
||||
`;
|
||||
|
||||
@@ -158,11 +158,13 @@ test('passes all props through to AgGridReact', () => {
|
||||
/>,
|
||||
);
|
||||
|
||||
// onGridReady and onFirstDataRendered are intercepted by the component to expose
|
||||
// the grid API on the container element; the wrapped function is passed instead.
|
||||
expect(AgGridReact).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
rowData: mockRowData,
|
||||
columnDefs: mockColumnDefs,
|
||||
onGridReady,
|
||||
onGridReady: expect.any(Function),
|
||||
onCellClicked,
|
||||
pagination: true,
|
||||
paginationPageSize: 10,
|
||||
@@ -171,6 +173,47 @@ test('passes all props through to AgGridReact', () => {
|
||||
);
|
||||
});
|
||||
|
||||
test('onGridReady wrapper calls user callback and exposes api on container', () => {
|
||||
const onGridReady = jest.fn();
|
||||
|
||||
render(
|
||||
<ThemedAgGridReact
|
||||
rowData={mockRowData}
|
||||
columnDefs={mockColumnDefs}
|
||||
onGridReady={onGridReady}
|
||||
/>,
|
||||
);
|
||||
|
||||
// Retrieve the wrapped handler that was passed to AgGridReact
|
||||
const lastCall = (AgGridReact as jest.Mock).mock.calls.at(-1)[0];
|
||||
const wrappedOnGridReady = lastCall.onGridReady as Function;
|
||||
|
||||
const mockApi = { setGridOption: jest.fn() };
|
||||
wrappedOnGridReady({ api: mockApi });
|
||||
|
||||
// The user-provided callback must be forwarded
|
||||
expect(onGridReady).toHaveBeenCalledWith({ api: mockApi });
|
||||
});
|
||||
|
||||
test('onFirstDataRendered wrapper calls user callback', () => {
|
||||
const onFirstDataRendered = jest.fn();
|
||||
|
||||
render(
|
||||
<ThemedAgGridReact
|
||||
rowData={mockRowData}
|
||||
columnDefs={mockColumnDefs}
|
||||
onFirstDataRendered={onFirstDataRendered}
|
||||
/>,
|
||||
);
|
||||
|
||||
const lastCall = (AgGridReact as jest.Mock).mock.calls.at(-1)[0];
|
||||
const wrappedOnFirstDataRendered = lastCall.onFirstDataRendered as Function;
|
||||
|
||||
wrappedOnFirstDataRendered({ firstRow: 0 });
|
||||
|
||||
expect(onFirstDataRendered).toHaveBeenCalledWith({ firstRow: 0 });
|
||||
});
|
||||
|
||||
test('applies custom theme colors from Superset theme', () => {
|
||||
const customTheme = {
|
||||
...supersetTheme,
|
||||
|
||||
@@ -16,19 +16,28 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { useMemo, forwardRef } from 'react';
|
||||
import { useMemo, useRef, useCallback, forwardRef } from 'react';
|
||||
import { css } from '@emotion/react';
|
||||
import { AgGridReact, type AgGridReactProps } from 'ag-grid-react';
|
||||
import {
|
||||
themeQuartz,
|
||||
colorSchemeDark,
|
||||
colorSchemeLight,
|
||||
type GridApi,
|
||||
type GridReadyEvent,
|
||||
type FirstDataRenderedEvent,
|
||||
} from 'ag-grid-community';
|
||||
import { useTheme, useThemeMode } from '@apache-superset/core/theme';
|
||||
|
||||
// Note: With ag-grid v34's new theming API, CSS files are injected automatically
|
||||
// Do NOT import 'ag-grid-community/styles/ag-grid.css' or theme CSS files
|
||||
|
||||
// Extends HTMLDivElement with ag-grid state attached to the container for downloadAsImage.
|
||||
export interface AgGridContainerElement extends HTMLDivElement {
|
||||
_agGridApi?: GridApi;
|
||||
_agGridFirstDataRendered?: boolean;
|
||||
}
|
||||
|
||||
export interface ThemedAgGridReactProps extends AgGridReactProps {
|
||||
/**
|
||||
* Optional theme parameter overrides to customize specific ag-grid theme values.
|
||||
@@ -71,9 +80,13 @@ export interface ThemedAgGridReactProps extends AgGridReactProps {
|
||||
export const ThemedAgGridReact = forwardRef<
|
||||
AgGridReact,
|
||||
ThemedAgGridReactProps
|
||||
>(function ThemedAgGridReact({ themeOverrides, ...props }, ref) {
|
||||
>(function ThemedAgGridReact(
|
||||
{ themeOverrides, onGridReady, onFirstDataRendered, ...props },
|
||||
ref,
|
||||
) {
|
||||
const theme = useTheme();
|
||||
const isDarkMode = useThemeMode();
|
||||
const containerRef = useRef<AgGridContainerElement>(null);
|
||||
|
||||
// Get the appropriate ag-grid theme based on dark/light mode
|
||||
const agGridTheme = useMemo(() => {
|
||||
@@ -140,8 +153,32 @@ export const ThemedAgGridReact = forwardRef<
|
||||
return baseTheme.withParams(finalParams);
|
||||
}, [theme, isDarkMode, themeOverrides]);
|
||||
|
||||
// Expose gridApi and first-data-rendered flag on the container for downloadAsImage.
|
||||
const handleGridReady = useCallback(
|
||||
(event: GridReadyEvent) => {
|
||||
if (containerRef.current) {
|
||||
containerRef.current._agGridFirstDataRendered = false;
|
||||
containerRef.current._agGridApi = event.api;
|
||||
}
|
||||
onGridReady?.(event);
|
||||
},
|
||||
[onGridReady],
|
||||
);
|
||||
|
||||
// Mark the container once rows are painted so downloadAsImage can gate on readiness.
|
||||
const handleFirstDataRendered = useCallback(
|
||||
(event: FirstDataRenderedEvent) => {
|
||||
if (containerRef.current) {
|
||||
containerRef.current._agGridFirstDataRendered = true;
|
||||
}
|
||||
onFirstDataRendered?.(event);
|
||||
},
|
||||
[onFirstDataRendered],
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={containerRef}
|
||||
css={css`
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
@@ -151,7 +188,13 @@ export const ThemedAgGridReact = forwardRef<
|
||||
`}
|
||||
data-themed-ag-grid="true"
|
||||
>
|
||||
<AgGridReact ref={ref} theme={agGridTheme} {...props} />
|
||||
<AgGridReact
|
||||
ref={ref}
|
||||
theme={agGridTheme}
|
||||
onGridReady={handleGridReady}
|
||||
onFirstDataRendered={handleFirstDataRendered}
|
||||
{...props}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
@@ -171,6 +214,7 @@ export type {
|
||||
CellClassParams,
|
||||
IMenuActionParams,
|
||||
IHeaderParams,
|
||||
SelectionChangedEvent,
|
||||
SortModelItem,
|
||||
ValueFormatterParams,
|
||||
ValueGetterParams,
|
||||
|
||||
@@ -201,6 +201,7 @@ export * from './Result';
|
||||
export {
|
||||
ThemedAgGridReact,
|
||||
type ThemedAgGridReactProps,
|
||||
type AgGridContainerElement,
|
||||
setupAGGridModules,
|
||||
defaultModules,
|
||||
} from './ThemedAgGridReact';
|
||||
|
||||
@@ -81,6 +81,7 @@ export type Filter = {
|
||||
granularity?: string;
|
||||
time_grain_sqla?: string;
|
||||
time_range?: string;
|
||||
time_grains?: string[];
|
||||
requiredFirst?: boolean;
|
||||
tabsInScope?: string[];
|
||||
chartsInScope?: number[];
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
const isSafari = (): boolean => {
|
||||
const { userAgent } = navigator;
|
||||
return Boolean(userAgent && /^((?!chrome|android).)*safari/i.test(userAgent));
|
||||
};
|
||||
|
||||
// Use the new Clipboard API if the browser supports it
|
||||
const copyTextWithClipboardApi = async (getText: () => Promise<string>) => {
|
||||
// Safari (WebKit) does not support delayed generation of clipboard.
|
||||
// This means that writing to the clipboard, from the moment the user
|
||||
// interacts with the app, must be instantaneous.
|
||||
// However, neither writeText nor write accepts a Promise, so
|
||||
// we need to create a ClipboardItem that accepts said Promise to
|
||||
// delay the text generation, as needed.
|
||||
// Source: https://bugs.webkit.org/show_bug.cgi?id=222262P
|
||||
if (isSafari()) {
|
||||
try {
|
||||
const clipboardItem = new ClipboardItem({
|
||||
'text/plain': getText(),
|
||||
});
|
||||
await navigator.clipboard.write([clipboardItem]);
|
||||
} catch {
|
||||
// Fallback to default clipboard API implementation
|
||||
const text = await getText();
|
||||
await navigator.clipboard.writeText(text);
|
||||
}
|
||||
} else {
|
||||
// For Blink, the above method won't work, but we can use the
|
||||
// default (intended) API, since the delayed generation of the
|
||||
// clipboard is now supported.
|
||||
// Source: https://bugs.chromium.org/p/chromium/issues/detail?id=1014310
|
||||
const text = await getText();
|
||||
await navigator.clipboard.writeText(text);
|
||||
}
|
||||
};
|
||||
|
||||
const copyTextToClipboard = (getText: () => Promise<string>) =>
|
||||
copyTextWithClipboardApi(getText)
|
||||
// If the Clipboard API is not supported, fallback to the older method.
|
||||
.catch(() =>
|
||||
getText().then(
|
||||
text =>
|
||||
new Promise<void>((resolve, reject) => {
|
||||
const selection: Selection | null = document.getSelection();
|
||||
if (selection) {
|
||||
selection.removeAllRanges();
|
||||
const range = document.createRange();
|
||||
const span = document.createElement('span');
|
||||
span.textContent = text;
|
||||
span.style.position = 'fixed';
|
||||
span.style.top = '0';
|
||||
span.style.clip = 'rect(0, 0, 0, 0)';
|
||||
span.style.whiteSpace = 'pre';
|
||||
|
||||
document.body.appendChild(span);
|
||||
range.selectNode(span);
|
||||
selection.addRange(range);
|
||||
|
||||
try {
|
||||
if (!document.execCommand('copy')) {
|
||||
reject();
|
||||
}
|
||||
} catch (err) {
|
||||
reject();
|
||||
}
|
||||
|
||||
document.body.removeChild(span);
|
||||
if (selection.removeRange) {
|
||||
selection.removeRange(range);
|
||||
} else {
|
||||
selection.removeAllRanges();
|
||||
}
|
||||
}
|
||||
|
||||
resolve();
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
export default copyTextToClipboard;
|
||||
@@ -17,6 +17,7 @@
|
||||
* under the License.
|
||||
*/
|
||||
export { default as convertKeysToCamelCase } from './convertKeysToCamelCase';
|
||||
export { default as copyTextToClipboard } from './copy';
|
||||
export { default as ensureIsArray } from './ensureIsArray';
|
||||
export { default as ensureIsInt } from './ensureIsInt';
|
||||
export { default as isDefined } from './isDefined';
|
||||
|
||||
@@ -109,10 +109,10 @@ test('should handle custom range with relative dates (now)', () => {
|
||||
timeRangeFilter,
|
||||
shifts,
|
||||
startDate,
|
||||
['5 days ago'],
|
||||
['4 days ago'],
|
||||
);
|
||||
runTimezoneTest(NOW_IN_UTC, 'UTC', timeRangeFilter, shifts, startDate, [
|
||||
'5 days ago',
|
||||
'4 days ago',
|
||||
]);
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_PACIFIC,
|
||||
@@ -218,10 +218,10 @@ test('should handle null timeRangeFilter', () => {
|
||||
timeRangeFilter,
|
||||
shifts,
|
||||
startDate,
|
||||
['3 days ago'],
|
||||
['2 days ago'],
|
||||
);
|
||||
runTimezoneTest(NOW_IN_UTC, 'UTC', timeRangeFilter, shifts, startDate, [
|
||||
'3 days ago',
|
||||
'2 days ago',
|
||||
]);
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_PACIFIC,
|
||||
@@ -304,10 +304,10 @@ test('should handle custom range with DATEADD function and relative start date',
|
||||
timeRangeFilter,
|
||||
shifts,
|
||||
startDate,
|
||||
['3 days ago'],
|
||||
['2 days ago'],
|
||||
);
|
||||
runTimezoneTest(NOW_IN_UTC, 'UTC', timeRangeFilter, shifts, startDate, [
|
||||
'3 days ago',
|
||||
'2 days ago',
|
||||
]);
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_PACIFIC,
|
||||
@@ -362,10 +362,10 @@ test('should handle custom range with specific date and relative end date', () =
|
||||
timeRangeFilter,
|
||||
shifts,
|
||||
startDate,
|
||||
['8 days ago'],
|
||||
['9 days ago'],
|
||||
);
|
||||
runTimezoneTest(NOW_IN_UTC, 'UTC', timeRangeFilter, shifts, startDate, [
|
||||
'8 days ago',
|
||||
'9 days ago',
|
||||
]);
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_PACIFIC,
|
||||
@@ -390,10 +390,10 @@ test('should handle custom range with specific date and specific end date', () =
|
||||
timeRangeFilter,
|
||||
shifts,
|
||||
startDate,
|
||||
['1 days ago'],
|
||||
['2 days ago'],
|
||||
);
|
||||
runTimezoneTest(NOW_IN_UTC, 'UTC', timeRangeFilter, shifts, startDate, [
|
||||
'1 days ago',
|
||||
'2 days ago',
|
||||
]);
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_PACIFIC,
|
||||
@@ -474,7 +474,7 @@ test('should handle custom range with previous calendar week', () => {
|
||||
timeRangeFilter,
|
||||
shifts,
|
||||
startDate,
|
||||
['3 days ago'],
|
||||
['1 days ago'],
|
||||
);
|
||||
runTimezoneTest(
|
||||
'2024-06-05T00:06:00Z',
|
||||
@@ -482,7 +482,7 @@ test('should handle custom range with previous calendar week', () => {
|
||||
timeRangeFilter,
|
||||
shifts,
|
||||
startDate,
|
||||
['3 days ago'],
|
||||
['1 days ago'],
|
||||
);
|
||||
runTimezoneTest(
|
||||
'2024-06-04T16:06:00-08:00',
|
||||
@@ -507,7 +507,7 @@ test('should handle custom range with previous calendar month', () => {
|
||||
timeRangeFilter,
|
||||
shifts,
|
||||
startDate,
|
||||
['7 days ago'],
|
||||
['5 days ago'],
|
||||
);
|
||||
runTimezoneTest(
|
||||
'2024-06-05T00:06:00Z',
|
||||
@@ -515,7 +515,7 @@ test('should handle custom range with previous calendar month', () => {
|
||||
timeRangeFilter,
|
||||
shifts,
|
||||
startDate,
|
||||
['7 days ago'],
|
||||
['5 days ago'],
|
||||
);
|
||||
runTimezoneTest(
|
||||
'2024-06-04T16:06:00-08:00',
|
||||
@@ -541,7 +541,7 @@ test('should handle custom range with previous calendar year', () => {
|
||||
timeRangeFilter,
|
||||
shifts,
|
||||
startDate,
|
||||
['8 days ago'],
|
||||
['6 days ago'],
|
||||
);
|
||||
runTimezoneTest(
|
||||
'2024-06-05T00:06:00Z',
|
||||
@@ -549,7 +549,7 @@ test('should handle custom range with previous calendar year', () => {
|
||||
timeRangeFilter,
|
||||
shifts,
|
||||
startDate,
|
||||
['8 days ago'],
|
||||
['6 days ago'],
|
||||
);
|
||||
runTimezoneTest(
|
||||
'2024-06-04T16:06:00-08:00',
|
||||
@@ -760,10 +760,10 @@ test('should handle future custom shift with different format', () => {
|
||||
timeRangeFilter,
|
||||
shifts,
|
||||
startDate,
|
||||
['3 days after'],
|
||||
['4 days after'],
|
||||
);
|
||||
runTimezoneTest(NOW_IN_UTC, 'UTC', timeRangeFilter, shifts, startDate, [
|
||||
'3 days after',
|
||||
'4 days after',
|
||||
]);
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_PACIFIC,
|
||||
@@ -771,7 +771,7 @@ test('should handle future custom shift with different format', () => {
|
||||
timeRangeFilter,
|
||||
shifts,
|
||||
startDate,
|
||||
['4 days after'],
|
||||
['5 days after'],
|
||||
);
|
||||
});
|
||||
|
||||
@@ -850,10 +850,10 @@ test('should handle custom range with relative dates (hour)', () => {
|
||||
timeRangeFilter,
|
||||
shifts,
|
||||
startDate,
|
||||
['2 days ago'],
|
||||
['4 days ago'],
|
||||
);
|
||||
runTimezoneTest(NOW_IN_UTC, 'UTC', timeRangeFilter, shifts, startDate, [
|
||||
'2 days ago',
|
||||
'4 days ago',
|
||||
]);
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_PACIFIC,
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
import { parseDttmToDate } from '@superset-ui/core';
|
||||
import timezoneMock from 'timezone-mock';
|
||||
|
||||
// NOW will be set at midnight 2024-06-03 and transforme dfrom local timezone to UTC
|
||||
// NOW will be set at midnight 2024-06-03 and transformed from local timezone to UTC
|
||||
const NOW_IN_UTC = '2024-06-03T00:00:00Z';
|
||||
const NOW_UTC_IN_EUROPE = '2024-06-02T22:00:00Z'; // Same as 2024-06-03T00:00:00+02:00
|
||||
const NOW_UTC_IN_PACIFIC = '2024-06-03T08:00:00Z'; // Same as 2024-06-03T00:00:00-08:00
|
||||
@@ -69,9 +69,9 @@ test('should return the current date for "today"', () => {
|
||||
'today',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-06-01T22:00:00Z'),
|
||||
new Date('2024-06-02T22:00:00Z'),
|
||||
);
|
||||
runTimezoneTest('today', NOW_IN_UTC, 'UTC', new Date('2024-06-02T00:00:00Z'));
|
||||
runTimezoneTest('today', NOW_IN_UTC, 'UTC', new Date('2024-06-03T00:00:00Z'));
|
||||
runTimezoneTest(
|
||||
'today',
|
||||
NOW_UTC_IN_PACIFIC,
|
||||
@@ -125,13 +125,13 @@ test('should return yesterday date for "Last day"', () => {
|
||||
'Last day',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-05-31T22:00:00Z'),
|
||||
new Date('2024-06-01T22:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'Last day',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-06-01T00:00:00Z'),
|
||||
new Date('2024-06-02T00:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'Last day',
|
||||
@@ -147,13 +147,13 @@ test('should return the date one week ago for "Last week"', () => {
|
||||
'Last week',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-05-25T22:00:00Z'),
|
||||
new Date('2024-05-26T22:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'Last week',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-05-26T00:00:00Z'),
|
||||
new Date('2024-05-27T00:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'Last week',
|
||||
@@ -169,13 +169,13 @@ test('should return the date one month ago for "Last month"', () => {
|
||||
'Last month',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-05-01T22:00:00Z'),
|
||||
new Date('2024-05-02T22:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'Last month',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-05-02T00:00:00Z'),
|
||||
new Date('2024-05-03T00:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'Last month',
|
||||
@@ -191,13 +191,13 @@ test('should return the date three months ago for "Last quarter"', () => {
|
||||
'Last quarter',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-03-01T22:00:00Z'),
|
||||
new Date('2024-03-02T22:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'Last quarter',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-03-02T00:00:00Z'),
|
||||
new Date('2024-03-03T00:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'Last quarter',
|
||||
@@ -213,13 +213,13 @@ test('should return the date one year ago for "Last year"', () => {
|
||||
'Last year',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2023-06-01T22:00:00Z'),
|
||||
new Date('2023-06-02T22:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'Last year',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2023-06-02T00:00:00Z'),
|
||||
new Date('2023-06-03T00:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'Last year',
|
||||
@@ -235,19 +235,19 @@ test('should return the date for "previous calendar week"', () => {
|
||||
'previous calendar week',
|
||||
'2024-06-04T22:00:00Z',
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-05-27T16:00:00Z'),
|
||||
new Date('2024-05-26T22:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'previous calendar week',
|
||||
'2024-06-05T00:00:00Z',
|
||||
'UTC',
|
||||
new Date('2024-05-27T20:00:00Z'),
|
||||
new Date('2024-05-27T00:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'previous calendar week',
|
||||
'2024-06-05T08:00:00Z',
|
||||
'Etc/GMT+8',
|
||||
new Date('2024-05-27T12:00:00Z'),
|
||||
new Date('2024-05-27T08:00:00Z'),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -257,19 +257,19 @@ test('should return the date for "previous calendar month"', () => {
|
||||
'previous calendar month',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-05-01T10:00:00Z'),
|
||||
new Date('2024-04-30T22:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'previous calendar month',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-05-01T16:00:00Z'),
|
||||
new Date('2024-05-01T00:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'previous calendar month',
|
||||
NOW_UTC_IN_PACIFIC,
|
||||
'Etc/GMT+8',
|
||||
new Date('2024-05-01T16:00:00Z'),
|
||||
new Date('2024-05-01T08:00:00Z'),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -279,19 +279,19 @@ test('should return the date for "previous calendar year"', () => {
|
||||
'previous calendar year',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2023-01-01T16:00:00Z'),
|
||||
new Date('2022-12-31T22:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'previous calendar year',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2023-01-01T20:00:00Z'),
|
||||
new Date('2023-01-01T00:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'previous calendar year',
|
||||
NOW_UTC_IN_PACIFIC,
|
||||
'Etc/GMT+8',
|
||||
new Date('2023-01-01T12:00:00Z'),
|
||||
new Date('2023-01-01T08:00:00Z'),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -301,13 +301,13 @@ test('should return the date for "1 day ago"', () => {
|
||||
'1 day ago',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-05-31T22:00:00Z'),
|
||||
new Date('2024-06-01T22:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'1 day ago',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-06-01T00:00:00Z'),
|
||||
new Date('2024-06-02T00:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'1 day ago',
|
||||
@@ -323,13 +323,13 @@ test('should return the date for "1 week ago"', () => {
|
||||
'1 week ago',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-05-25T22:00:00Z'),
|
||||
new Date('2024-05-26T22:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'1 week ago',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-05-26T00:00:00Z'),
|
||||
new Date('2024-05-27T00:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'1 week ago',
|
||||
@@ -345,13 +345,13 @@ test('should return the date for "1 month ago"', () => {
|
||||
'1 month ago',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-05-01T22:00:00Z'),
|
||||
new Date('2024-05-02T22:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'1 month ago',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-05-02T00:00:00Z'),
|
||||
new Date('2024-05-03T00:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'1 month ago',
|
||||
@@ -367,13 +367,13 @@ test('should return the date for "1 year ago"', () => {
|
||||
'1 year ago',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2023-06-01T22:00:00Z'),
|
||||
new Date('2023-06-02T22:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'1 year ago',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2023-06-02T00:00:00Z'),
|
||||
new Date('2023-06-03T00:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'1 year ago',
|
||||
@@ -389,13 +389,13 @@ test('should return the date for "2024-03-09"', () => {
|
||||
'2024-03-09',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-03-07T22:00:00.000Z'),
|
||||
new Date('2024-03-08T22:00:00.000Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'2024-03-09',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-03-08T00:00:00.000Z'),
|
||||
new Date('2024-03-09T00:00:00.000Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'2024-03-09',
|
||||
@@ -411,14 +411,14 @@ test('should return the current date for "Last day" with isEndDate true', () =>
|
||||
'Last day',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-06-01T22:00:00Z'),
|
||||
new Date('2024-06-02T22:00:00Z'),
|
||||
true,
|
||||
);
|
||||
runTimezoneTest(
|
||||
'Last day',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-06-02T00:00:00Z'),
|
||||
new Date('2024-06-03T00:00:00Z'),
|
||||
true,
|
||||
);
|
||||
runTimezoneTest(
|
||||
@@ -436,14 +436,14 @@ test('should return the current date for "Last week" with isEndDate true', () =>
|
||||
'Last week',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-06-01T22:00:00Z'),
|
||||
new Date('2024-06-02T22:00:00Z'),
|
||||
true,
|
||||
);
|
||||
runTimezoneTest(
|
||||
'Last week',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-06-02T00:00:00Z'),
|
||||
new Date('2024-06-03T00:00:00Z'),
|
||||
true,
|
||||
);
|
||||
runTimezoneTest(
|
||||
@@ -461,14 +461,14 @@ test('should return the current date for "Last quarter" with isEndDate true', ()
|
||||
'Last quarter',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-06-01T22:00:00Z'),
|
||||
new Date('2024-06-02T22:00:00Z'),
|
||||
true,
|
||||
);
|
||||
runTimezoneTest(
|
||||
'Last quarter',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-06-02T00:00:00Z'),
|
||||
new Date('2024-06-03T00:00:00Z'),
|
||||
true,
|
||||
);
|
||||
runTimezoneTest(
|
||||
@@ -486,14 +486,14 @@ test('should return the current date for "Last year" with isEndDate true', () =>
|
||||
'Last year',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-06-01T22:00:00Z'),
|
||||
new Date('2024-06-02T22:00:00Z'),
|
||||
true,
|
||||
);
|
||||
runTimezoneTest(
|
||||
'Last year',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-06-02T00:00:00Z'),
|
||||
new Date('2024-06-03T00:00:00Z'),
|
||||
true,
|
||||
);
|
||||
runTimezoneTest(
|
||||
@@ -511,21 +511,21 @@ test('should return the date for "previous calendar week" with isEndDate true',
|
||||
'previous calendar week',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-06-03T16:00:00Z'),
|
||||
new Date('2024-06-02T22:00:00Z'),
|
||||
true,
|
||||
);
|
||||
runTimezoneTest(
|
||||
'previous calendar week',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-06-03T20:00:00Z'),
|
||||
new Date('2024-06-03T00:00:00Z'),
|
||||
true,
|
||||
);
|
||||
runTimezoneTest(
|
||||
'previous calendar week',
|
||||
NOW_UTC_IN_PACIFIC,
|
||||
'Etc/GMT+8',
|
||||
new Date('2024-06-03T12:00:00Z'),
|
||||
new Date('2024-06-03T08:00:00Z'),
|
||||
true,
|
||||
);
|
||||
});
|
||||
@@ -536,21 +536,21 @@ test('should return the date for "previous calendar month" with isEndDate true',
|
||||
'previous calendar month',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-06-01T16:00:00Z'),
|
||||
new Date('2024-05-31T22:00:00Z'),
|
||||
true,
|
||||
);
|
||||
runTimezoneTest(
|
||||
'previous calendar month',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-06-01T20:00:00Z'),
|
||||
new Date('2024-06-01T00:00:00Z'),
|
||||
true,
|
||||
);
|
||||
runTimezoneTest(
|
||||
'previous calendar month',
|
||||
NOW_UTC_IN_PACIFIC,
|
||||
'Etc/GMT+8',
|
||||
new Date('2024-06-01T12:00:00Z'),
|
||||
new Date('2024-06-01T08:00:00Z'),
|
||||
true,
|
||||
);
|
||||
});
|
||||
@@ -561,21 +561,21 @@ test('should return the date for "previous calendar year" with isEndDate true',
|
||||
'previous calendar year',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-01-01T16:00:00Z'),
|
||||
new Date('2023-12-31T22:00:00Z'),
|
||||
true,
|
||||
);
|
||||
runTimezoneTest(
|
||||
'previous calendar year',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-01-01T20:00:00Z'),
|
||||
new Date('2024-01-01T00:00:00Z'),
|
||||
true,
|
||||
);
|
||||
runTimezoneTest(
|
||||
'previous calendar year',
|
||||
NOW_UTC_IN_PACIFIC,
|
||||
'Etc/GMT+8',
|
||||
new Date('2024-01-01T12:00:00Z'),
|
||||
new Date('2024-01-01T08:00:00Z'),
|
||||
true,
|
||||
);
|
||||
});
|
||||
@@ -586,9 +586,9 @@ test('should return the date for "2024" with parts.length === 1', () => {
|
||||
'2024',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2023-12-30T22:00:00.000Z'),
|
||||
new Date('2023-12-31T22:00:00.000Z'),
|
||||
);
|
||||
runTimezoneTest('2024', NOW_IN_UTC, 'UTC', new Date('2023-12-31T00:00:00Z'));
|
||||
runTimezoneTest('2024', NOW_IN_UTC, 'UTC', new Date('2024-01-01T00:00:00Z'));
|
||||
runTimezoneTest(
|
||||
'2024',
|
||||
NOW_UTC_IN_PACIFIC,
|
||||
@@ -603,13 +603,13 @@ test('should return the date for "2024-03" with parts.length === 2', () => {
|
||||
'2024-03',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-02-28T22:00:00.000Z'),
|
||||
new Date('2024-02-29T22:00:00.000Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'2024-03',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-02-29T00:00:00Z'),
|
||||
new Date('2024-03-01T00:00:00Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'2024-03',
|
||||
@@ -625,13 +625,13 @@ test('should return the date for "2024-03-06" with parts.length === 3', () => {
|
||||
'2024-03-06',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
new Date('2024-03-04T22:00:00.000Z'),
|
||||
new Date('2024-03-05T22:00:00.000Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'2024-03-06',
|
||||
NOW_IN_UTC,
|
||||
'UTC',
|
||||
new Date('2024-03-05T00:00:00.000Z'),
|
||||
new Date('2024-03-06T00:00:00.000Z'),
|
||||
);
|
||||
runTimezoneTest(
|
||||
'2024-03-06',
|
||||
@@ -643,7 +643,7 @@ test('should return the date for "2024-03-06" with parts.length === 3', () => {
|
||||
|
||||
test('should return the date for "2024-03-06" with computingShifts true', () => {
|
||||
jest.useFakeTimers();
|
||||
const expectedDate = new Date('2024-03-05T22:00:00Z');
|
||||
const expectedDate = new Date('2024-03-06T22:00:00Z');
|
||||
expectedDate.setHours(-expectedDate.getTimezoneOffset() / 60, 0, 0, 0);
|
||||
runTimezoneTest(
|
||||
'2024-03-06',
|
||||
@@ -657,7 +657,7 @@ test('should return the date for "2024-03-06" with computingShifts true', () =>
|
||||
|
||||
test('should return the date for "2024-03-06" with computingShifts true and isEndDate true', () => {
|
||||
jest.useFakeTimers();
|
||||
const expectedDate = new Date('2024-03-05T22:00:00Z');
|
||||
const expectedDate = new Date('2024-03-06T22:00:00Z');
|
||||
expectedDate.setHours(-expectedDate.getTimezoneOffset() / 60, 0, 0, 0);
|
||||
runTimezoneTest(
|
||||
'2024-03-06',
|
||||
|
||||
@@ -0,0 +1,216 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
import { copyTextToClipboard } from '@superset-ui/core';
|
||||
|
||||
const SAFARI_UA =
|
||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15';
|
||||
const CHROME_UA =
|
||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36';
|
||||
|
||||
const makeGetText = (text: string) => () => Promise.resolve(text);
|
||||
|
||||
const globalWithClipboardItem = global as unknown as {
|
||||
ClipboardItem?: unknown;
|
||||
};
|
||||
|
||||
afterEach(() => {
|
||||
jest.restoreAllMocks();
|
||||
delete globalWithClipboardItem.ClipboardItem;
|
||||
});
|
||||
|
||||
test('uses Clipboard API writeText on non-Safari browsers', async () => {
|
||||
Object.defineProperty(navigator, 'userAgent', {
|
||||
value: CHROME_UA,
|
||||
configurable: true,
|
||||
});
|
||||
const writeText = jest.fn().mockResolvedValue(undefined);
|
||||
Object.defineProperty(navigator, 'clipboard', {
|
||||
value: { writeText },
|
||||
configurable: true,
|
||||
});
|
||||
|
||||
await copyTextToClipboard(makeGetText('hello'));
|
||||
|
||||
expect(writeText).toHaveBeenCalledWith('hello');
|
||||
});
|
||||
|
||||
test('uses ClipboardItem API on Safari browsers', async () => {
|
||||
Object.defineProperty(navigator, 'userAgent', {
|
||||
value: SAFARI_UA,
|
||||
configurable: true,
|
||||
});
|
||||
const write = jest.fn().mockResolvedValue(undefined);
|
||||
Object.defineProperty(navigator, 'clipboard', {
|
||||
value: { write },
|
||||
configurable: true,
|
||||
});
|
||||
const MockClipboardItem = jest.fn().mockImplementation(data => ({ data }));
|
||||
globalWithClipboardItem.ClipboardItem = MockClipboardItem;
|
||||
|
||||
await copyTextToClipboard(makeGetText('safari text'));
|
||||
|
||||
expect(MockClipboardItem).toHaveBeenCalled();
|
||||
expect(write).toHaveBeenCalledWith([expect.anything()]);
|
||||
});
|
||||
|
||||
test('falls back to writeText on Safari when ClipboardItem write fails', async () => {
|
||||
Object.defineProperty(navigator, 'userAgent', {
|
||||
value: SAFARI_UA,
|
||||
configurable: true,
|
||||
});
|
||||
const writeText = jest.fn().mockResolvedValue(undefined);
|
||||
const write = jest.fn().mockRejectedValue(new Error('not supported'));
|
||||
Object.defineProperty(navigator, 'clipboard', {
|
||||
value: { write, writeText },
|
||||
configurable: true,
|
||||
});
|
||||
const MockClipboardItem = jest.fn().mockImplementation(data => ({ data }));
|
||||
globalWithClipboardItem.ClipboardItem = MockClipboardItem;
|
||||
|
||||
await copyTextToClipboard(makeGetText('fallback text'));
|
||||
|
||||
expect(writeText).toHaveBeenCalledWith('fallback text');
|
||||
});
|
||||
|
||||
function mockExecCommand(impl: (cmd: string) => boolean) {
|
||||
Object.defineProperty(document, 'execCommand', {
|
||||
value: jest.fn().mockImplementation(impl),
|
||||
configurable: true,
|
||||
writable: true,
|
||||
});
|
||||
}
|
||||
|
||||
function setupFallbackMocks(options: { selection: Partial<Selection> | null }) {
|
||||
Object.defineProperty(navigator, 'userAgent', {
|
||||
value: CHROME_UA,
|
||||
configurable: true,
|
||||
});
|
||||
Object.defineProperty(navigator, 'clipboard', {
|
||||
value: {
|
||||
writeText: jest.fn().mockRejectedValue(new Error('not allowed')),
|
||||
},
|
||||
configurable: true,
|
||||
});
|
||||
|
||||
const mockRange = { selectNode: jest.fn() };
|
||||
const mockSpan = {
|
||||
style: {} as CSSStyleDeclaration,
|
||||
textContent: '',
|
||||
} as unknown as HTMLSpanElement;
|
||||
|
||||
jest
|
||||
.spyOn(document, 'getSelection')
|
||||
.mockReturnValue(options.selection as Selection | null);
|
||||
jest
|
||||
.spyOn(document, 'createRange')
|
||||
.mockReturnValue(mockRange as unknown as Range);
|
||||
jest.spyOn(document, 'createElement').mockReturnValue(mockSpan);
|
||||
jest.spyOn(document.body, 'appendChild').mockImplementation(() => mockSpan);
|
||||
jest.spyOn(document.body, 'removeChild').mockImplementation(() => mockSpan);
|
||||
|
||||
return { mockRange, mockSpan };
|
||||
}
|
||||
|
||||
test('falls back to execCommand copy when Clipboard API is unavailable', async () => {
|
||||
const removeRange = jest.fn();
|
||||
const { mockRange } = setupFallbackMocks({
|
||||
selection: {
|
||||
removeAllRanges: jest.fn(),
|
||||
addRange: jest.fn(),
|
||||
removeRange,
|
||||
},
|
||||
});
|
||||
mockExecCommand(cmd => cmd === 'copy');
|
||||
|
||||
await copyTextToClipboard(makeGetText('exec text'));
|
||||
|
||||
expect(document.execCommand).toHaveBeenCalledWith('copy');
|
||||
expect(removeRange).toHaveBeenCalledWith(mockRange);
|
||||
});
|
||||
|
||||
test('falls back to removeAllRanges when removeRange is not available', async () => {
|
||||
const removeAllRanges = jest.fn();
|
||||
setupFallbackMocks({
|
||||
selection: {
|
||||
removeAllRanges,
|
||||
addRange: jest.fn(),
|
||||
removeRange: undefined,
|
||||
},
|
||||
});
|
||||
mockExecCommand(cmd => cmd === 'copy');
|
||||
|
||||
await copyTextToClipboard(makeGetText('no removeRange'));
|
||||
|
||||
expect(removeAllRanges).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('rejects when execCommand returns false', async () => {
|
||||
setupFallbackMocks({
|
||||
selection: {
|
||||
removeAllRanges: jest.fn(),
|
||||
addRange: jest.fn(),
|
||||
removeRange: jest.fn(),
|
||||
},
|
||||
});
|
||||
mockExecCommand(() => false);
|
||||
|
||||
await expect(
|
||||
copyTextToClipboard(makeGetText('fail')),
|
||||
).rejects.toBeUndefined();
|
||||
});
|
||||
|
||||
test('rejects when execCommand throws', async () => {
|
||||
setupFallbackMocks({
|
||||
selection: {
|
||||
removeAllRanges: jest.fn(),
|
||||
addRange: jest.fn(),
|
||||
removeRange: jest.fn(),
|
||||
},
|
||||
});
|
||||
Object.defineProperty(document, 'execCommand', {
|
||||
value: jest.fn().mockImplementation(() => {
|
||||
throw new Error('execCommand error');
|
||||
}),
|
||||
configurable: true,
|
||||
writable: true,
|
||||
});
|
||||
|
||||
await expect(
|
||||
copyTextToClipboard(makeGetText('throw')),
|
||||
).rejects.toBeUndefined();
|
||||
});
|
||||
|
||||
test('resolves without copying when getSelection returns null', async () => {
|
||||
Object.defineProperty(navigator, 'userAgent', {
|
||||
value: CHROME_UA,
|
||||
configurable: true,
|
||||
});
|
||||
Object.defineProperty(navigator, 'clipboard', {
|
||||
value: {
|
||||
writeText: jest.fn().mockRejectedValue(new Error('not allowed')),
|
||||
},
|
||||
configurable: true,
|
||||
});
|
||||
|
||||
jest.spyOn(document, 'getSelection').mockReturnValue(null);
|
||||
|
||||
await expect(
|
||||
copyTextToClipboard(makeGetText('no selection')),
|
||||
).resolves.toBeUndefined();
|
||||
});
|
||||
@@ -94,6 +94,7 @@ export default defineConfig({
|
||||
name: 'chromium',
|
||||
testIgnore: [
|
||||
'**/tests/auth/**/*.spec.ts',
|
||||
'**/tests/sqllab/**/*.spec.ts',
|
||||
...(process.env.INCLUDE_EXPERIMENTAL ? [] : ['**/experimental/**']),
|
||||
],
|
||||
use: {
|
||||
@@ -103,6 +104,22 @@ export default defineConfig({
|
||||
storageState: 'playwright/.auth/user.json',
|
||||
},
|
||||
},
|
||||
{
|
||||
// SQL Lab needs its own project because tab state is stored server-side
|
||||
// per user (/tabstateview/*). All workers share the same auth user, so
|
||||
// parallel workers mutating tabs would cause nondeterministic tab counts
|
||||
// and cross-worker tab deletions. Other test suites (dataset, dashboard,
|
||||
// chart) don't need this because they create/delete isolated resources
|
||||
// via API with unique names — no shared mutable state between tests.
|
||||
name: 'chromium-sqllab',
|
||||
testMatch: '**/tests/sqllab/**/*.spec.ts',
|
||||
fullyParallel: false,
|
||||
use: {
|
||||
browserName: 'chromium',
|
||||
testIdAttribute: 'data-test',
|
||||
storageState: 'playwright/.auth/user.json',
|
||||
},
|
||||
},
|
||||
{
|
||||
// Separate project for unauthenticated tests (login, signup, etc.)
|
||||
// These tests use beforeEach for per-test navigation - no global auth
|
||||
|
||||
85
superset-frontend/playwright/components/core/AgGrid.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import { Locator, Page } from '@playwright/test';
|
||||
|
||||
const AG_GRID_SELECTORS = {
|
||||
ROOT: '[role="grid"]',
|
||||
HEADER_ROW: '.ag-header-row',
|
||||
HEADER_CELL: '.ag-header-cell',
|
||||
BODY_ROW: '.ag-row',
|
||||
CELL: '.ag-cell',
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* AG Grid component wrapper for Playwright.
|
||||
* Used by FilterableTable/GridTable in SQL Lab results and elsewhere.
|
||||
*/
|
||||
export class AgGrid {
|
||||
readonly page: Page;
|
||||
private readonly locator: Locator;
|
||||
|
||||
constructor(page: Page, locator: Locator) {
|
||||
this.page = page;
|
||||
this.locator = locator;
|
||||
}
|
||||
|
||||
get element(): Locator {
|
||||
return this.locator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for the grid to render with data rows
|
||||
*/
|
||||
async waitForRows(options?: { timeout?: number }): Promise<void> {
|
||||
await this.locator
|
||||
.locator(AG_GRID_SELECTORS.BODY_ROW)
|
||||
.first()
|
||||
.waitFor({ state: 'visible', ...options });
|
||||
}
|
||||
|
||||
/**
|
||||
* Get header cell texts
|
||||
*/
|
||||
async getHeaderTexts(): Promise<string[]> {
|
||||
return this.locator
|
||||
.locator(AG_GRID_SELECTORS.HEADER_CELL)
|
||||
.allTextContents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of visible data rows
|
||||
*/
|
||||
async getRowCount(): Promise<number> {
|
||||
return this.locator.locator(AG_GRID_SELECTORS.BODY_ROW).count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell text at a specific row and column index (0-based)
|
||||
*/
|
||||
async getCellText(row: number, col: number): Promise<string> {
|
||||
const text = await this.locator
|
||||
.locator(AG_GRID_SELECTORS.BODY_ROW)
|
||||
.nth(row)
|
||||
.locator(AG_GRID_SELECTORS.CELL)
|
||||
.nth(col)
|
||||
.textContent();
|
||||
return text?.trim() ?? '';
|
||||
}
|
||||
}
|
||||
46
superset-frontend/playwright/components/core/EditableTabs.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import { Tabs } from './Tabs';
|
||||
|
||||
/**
|
||||
* EditableTabs component for Ant Design editable-card tabs.
|
||||
*
|
||||
* Mirrors the Superset EditableTabs component (type="editable-card")
|
||||
* which adds add/remove tab functionality to the base Tabs component.
|
||||
*
|
||||
* The add button (.ant-tabs-nav-add) is only rendered when
|
||||
* type="editable-card". If the host component switches to type="card"
|
||||
* (e.g., SQL Lab empty state), use the host page object for that case.
|
||||
*/
|
||||
export class EditableTabs extends Tabs {
|
||||
/**
|
||||
* Clicks the add-tab button rendered by antd in editable-card mode.
|
||||
*/
|
||||
async addTab(): Promise<void> {
|
||||
await this.element.getByRole('button', { name: 'Add tab' }).click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clicks the remove button on the last tab.
|
||||
*/
|
||||
async removeLastTab(): Promise<void> {
|
||||
await this.nav.locator('.ant-tabs-tab-remove').last().click();
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ export class Modal {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a footer button by text content (private helper)
|
||||
* Gets a footer button by text content
|
||||
* @param buttonText - The text content of the button
|
||||
*/
|
||||
private getFooterButton(buttonText: string): Locator {
|
||||
@@ -80,7 +80,7 @@ export class Modal {
|
||||
* @param buttonText - The text content of the button to click
|
||||
* @param options - Optional click options
|
||||
*/
|
||||
protected async clickFooterButton(
|
||||
async clickFooterButton(
|
||||
buttonText: string,
|
||||
options?: { timeout?: number; force?: boolean; delay?: number },
|
||||
): Promise<void> {
|
||||
|
||||
53
superset-frontend/playwright/components/core/Popover.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import { Locator, Page } from '@playwright/test';
|
||||
import { Button } from './Button';
|
||||
|
||||
/**
|
||||
* Ant Design Popover component.
|
||||
*/
|
||||
export class Popover {
|
||||
readonly page: Page;
|
||||
private readonly locator: Locator;
|
||||
|
||||
constructor(page: Page, locator?: Locator) {
|
||||
this.page = page;
|
||||
this.locator = locator ?? page.locator('.ant-popover-content');
|
||||
}
|
||||
|
||||
get element(): Locator {
|
||||
return this.locator;
|
||||
}
|
||||
|
||||
async waitForVisible(options?: { timeout?: number }): Promise<void> {
|
||||
await this.locator.waitFor({ state: 'visible', ...options });
|
||||
}
|
||||
|
||||
async waitForHidden(options?: { timeout?: number }): Promise<void> {
|
||||
await this.locator.waitFor({ state: 'hidden', ...options });
|
||||
}
|
||||
|
||||
getButton(name: string): Button {
|
||||
return new Button(
|
||||
this.page,
|
||||
this.locator.getByRole('button', { name, exact: true }),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
import { Locator, Page } from '@playwright/test';
|
||||
import { TIMEOUT } from '../../utils/constants';
|
||||
|
||||
/**
|
||||
* Ant Design Select component selectors
|
||||
@@ -87,7 +88,7 @@ export class Select {
|
||||
await this.page
|
||||
.locator(`${SELECT_SELECTORS.DROPDOWN}:not(.ant-select-dropdown-hidden)`)
|
||||
.last()
|
||||
.waitFor({ state: 'hidden', timeout: 5000 })
|
||||
.waitFor({ state: 'hidden', timeout: TIMEOUT.UI_TRANSITION })
|
||||
.catch(error => {
|
||||
// Only ignore TimeoutError (dropdown may already be closed); re-throw others
|
||||
if (!(error instanceof Error) || error.name !== 'TimeoutError') {
|
||||
|
||||