mirror of
https://github.com/apache/superset.git
synced 2026-09-09 16:54:29 +00:00
Compare commits
@@ -49,7 +49,7 @@ jobs:
|
||||
# allowlist (only v8.1.0+ are, at apache/infrastructure-actions'
|
||||
# actions.yml). Needs an INFRA request before this can de-vendor too.
|
||||
- name: Set up chart-testing
|
||||
uses: ./.github/actions/chart-testing-action
|
||||
uses: $/.github/actions/chart-testing-action
|
||||
|
||||
- name: Run chart-testing (list-changed)
|
||||
id: list-changed
|
||||
|
||||
@@ -42,7 +42,7 @@ jobs:
|
||||
persist-credentials: false
|
||||
- name: Check for file changes
|
||||
id: check
|
||||
uses: ./.github/actions/change-detector/
|
||||
uses: $/.github/actions/change-detector/
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
@@ -109,13 +109,25 @@ jobs:
|
||||
submodules: recursive
|
||||
# -------------------------------------------------------
|
||||
- name: Setup Python
|
||||
uses: ./.github/actions/setup-backend/
|
||||
uses: $/.github/actions/setup-backend/
|
||||
- name: Setup postgres
|
||||
uses: ./.github/actions/cached-dependencies
|
||||
# cached-dependencies is a submodule (not a plain directory), and
|
||||
# the $/ self-repository syntax resolves action files directly from
|
||||
# the repository without performing a real (submodule-aware)
|
||||
# checkout, so it can't see into a submodule's link. Keep this one
|
||||
# on the workspace-relative ./ form, consistent with every other
|
||||
# workflow in the repo that references this action.
|
||||
uses: ./.github/actions/cached-dependencies # zizmor: ignore[self-repository] - $/ cannot resolve an action that lives in a submodule; ./ is required here
|
||||
with:
|
||||
run: setup-postgres
|
||||
- name: Import test data
|
||||
uses: ./.github/actions/cached-dependencies
|
||||
# cached-dependencies is a submodule (not a plain directory), and
|
||||
# the $/ self-repository syntax resolves action files directly from
|
||||
# the repository without performing a real (submodule-aware)
|
||||
# checkout, so it can't see into a submodule's link. Keep this one
|
||||
# on the workspace-relative ./ form, consistent with every other
|
||||
# workflow in the repo that references this action.
|
||||
uses: ./.github/actions/cached-dependencies # zizmor: ignore[self-repository] - $/ cannot resolve an action that lives in a submodule; ./ is required here
|
||||
with:
|
||||
run: playwright_testdata
|
||||
- name: Setup Node.js
|
||||
@@ -125,19 +137,42 @@ jobs:
|
||||
cache: "npm"
|
||||
cache-dependency-path: "superset-frontend/package-lock.json"
|
||||
- name: Install npm dependencies
|
||||
uses: ./.github/actions/cached-dependencies
|
||||
# cached-dependencies is a submodule (not a plain directory), and
|
||||
# the $/ self-repository syntax resolves action files directly from
|
||||
# the repository without performing a real (submodule-aware)
|
||||
# checkout, so it can't see into a submodule's link. Keep this one
|
||||
# on the workspace-relative ./ form, consistent with every other
|
||||
# workflow in the repo that references this action.
|
||||
uses: ./.github/actions/cached-dependencies # zizmor: ignore[self-repository] - $/ cannot resolve an action that lives in a submodule; ./ is required here
|
||||
with:
|
||||
run: npm-install
|
||||
- name: Build javascript packages
|
||||
uses: ./.github/actions/cached-dependencies
|
||||
# cached-dependencies is a submodule (not a plain directory), and
|
||||
# the $/ self-repository syntax resolves action files directly from
|
||||
# the repository without performing a real (submodule-aware)
|
||||
# checkout, so it can't see into a submodule's link. Keep this one
|
||||
# on the workspace-relative ./ form, consistent with every other
|
||||
# workflow in the repo that references this action.
|
||||
uses: ./.github/actions/cached-dependencies # zizmor: ignore[self-repository] - $/ cannot resolve an action that lives in a submodule; ./ is required here
|
||||
with:
|
||||
run: build-instrumented-assets
|
||||
- name: Install Playwright
|
||||
uses: ./.github/actions/cached-dependencies
|
||||
# the $/ self-repository syntax resolves action files directly from
|
||||
# the repository without performing a real (submodule-aware)
|
||||
# checkout, so it can't see into a submodule's gitlink. Keep this one
|
||||
# on the workspace-relative ./ form, consistent with every other
|
||||
# workflow in the repo that references this action.
|
||||
uses: ./.github/actions/cached-dependencies # zizmor: ignore[self-repository] - $/ cannot resolve an action that lives in a submodule; ./ is required here
|
||||
with:
|
||||
run: playwright-install
|
||||
- name: Run Playwright (Experimental Tests)
|
||||
uses: ./.github/actions/cached-dependencies
|
||||
# cached-dependencies is a submodule (not a plain directory), and
|
||||
# the $/ self-repository syntax resolves action files directly from
|
||||
# the repository without performing a real (submodule-aware)
|
||||
# checkout, so it can't see into a submodule's link. Keep this one
|
||||
# on the workspace-relative ./ form, consistent with every other
|
||||
# workflow in the repo that references this action.
|
||||
uses: ./.github/actions/cached-dependencies # zizmor: ignore[self-repository] - $/ cannot resolve an action that lives in a submodule; ./ is required here
|
||||
env:
|
||||
NODE_OPTIONS: "--max-old-space-size=4096"
|
||||
with:
|
||||
|
||||
@@ -34,7 +34,7 @@ jobs:
|
||||
persist-credentials: false
|
||||
- name: Check for file changes
|
||||
id: check
|
||||
uses: ./.github/actions/change-detector/
|
||||
uses: $/.github/actions/change-detector/
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
@@ -75,9 +75,15 @@ jobs:
|
||||
persist-credentials: false
|
||||
submodules: recursive
|
||||
- name: Setup Python
|
||||
uses: ./.github/actions/setup-backend/
|
||||
uses: $/.github/actions/setup-backend/
|
||||
- name: Setup MySQL
|
||||
uses: ./.github/actions/cached-dependencies
|
||||
# cached-dependencies is a git submodule (not a plain directory), and
|
||||
# the $/ self-repository syntax resolves action files directly from
|
||||
# the repository without performing a real (submodule-aware)
|
||||
# checkout, so it can't see into a submodule's gitlink. Keep this one
|
||||
# on the workspace-relative ./ form, consistent with every other
|
||||
# workflow in the repo that references this action.
|
||||
uses: ./.github/actions/cached-dependencies # zizmor: ignore[self-repository] - $/ cannot resolve an action that lives in a submodule; ./ is required here
|
||||
with:
|
||||
run: setup-mysql
|
||||
- name: Start Celery worker
|
||||
|
||||
+56
-25
@@ -231,20 +231,6 @@ RUN /app/docker/apt-install.sh \
|
||||
# The database file will be created at runtime when examples are loaded from Parquet files
|
||||
RUN mkdir -p /app/data && chown -R superset:superset /app/data
|
||||
|
||||
# Copy compiled things from previous stages
|
||||
COPY --from=superset-node /app/superset/static/assets superset/static/assets
|
||||
# Copy service.worker.js optionall as it doesn't exist when DEV_MODE=true
|
||||
COPY --from=superset-node /app/superset/static/service-worker.j[s] superset/static/service-worker.js
|
||||
|
||||
# TODO, when the next version comes out, use --exclude superset/translations
|
||||
COPY superset superset
|
||||
# TODO in the meantime, remove the .po files
|
||||
RUN rm superset/translations/*/*/*.po
|
||||
|
||||
# Merging translations from backend and frontend stages
|
||||
COPY --from=superset-node /app/superset/translations superset/translations
|
||||
COPY --from=python-translation-compiler /app/translations_mo superset/translations
|
||||
|
||||
# --- Realtime WebSocket server (part of the official image) ---------------
|
||||
# The realtime transport (superset-websocket) is a Node service, bundled by
|
||||
# esbuild into a single self-contained file. Copy the Node runtime plus that
|
||||
@@ -267,7 +253,10 @@ EXPOSE ${SUPERSET_PORT}
|
||||
######################################################################
|
||||
FROM python-common AS lean
|
||||
|
||||
# Install Python dependencies using docker/pip-install.sh
|
||||
# Install Python dependencies using docker/pip-install.sh.
|
||||
# Requirements are installed *before* the application source is copied
|
||||
# below so that source-only changes don't bust this (slow, network-bound)
|
||||
# cache layer or defeat --cache-from.
|
||||
COPY requirements/base.txt requirements/
|
||||
|
||||
# Copy superset-core package needed for editable install in base.txt
|
||||
@@ -275,9 +264,27 @@ COPY superset-core superset-core
|
||||
|
||||
RUN --mount=type=cache,target=${SUPERSET_HOME}/.cache/uv \
|
||||
/app/docker/pip-install.sh --requires-build-essential -r requirements/base.txt
|
||||
# Install the superset package
|
||||
|
||||
# Copy compiled frontend assets and application source now that
|
||||
# dependencies have been resolved and cached above.
|
||||
COPY --from=superset-node /app/superset/static/assets superset/static/assets
|
||||
# Copy service.worker.js optionally as it doesn't exist when DEV_MODE=true
|
||||
COPY --from=superset-node /app/superset/static/service-worker.j[s] superset/static/service-worker.js
|
||||
|
||||
# TODO, when the next version comes out, use --exclude superset/translations
|
||||
COPY superset superset
|
||||
# TODO in the meantime, remove the .po files
|
||||
RUN rm superset/translations/*/*/*.po
|
||||
|
||||
# Merging translations from backend and frontend stages
|
||||
COPY --from=superset-node /app/superset/translations superset/translations
|
||||
COPY --from=python-translation-compiler /app/translations_mo superset/translations
|
||||
|
||||
# Install the superset package itself. --no-deps because its dependencies
|
||||
# were already installed from requirements/base.txt above, so this layer
|
||||
# stays fast even though the source copy above changes on every edit.
|
||||
RUN --mount=type=cache,target=${SUPERSET_HOME}/.cache/uv \
|
||||
uv pip install -e .
|
||||
uv pip install -e . --no-deps
|
||||
RUN python -m compileall /app/superset
|
||||
|
||||
USER superset
|
||||
@@ -293,22 +300,46 @@ RUN /app/docker/apt-install.sh \
|
||||
pkg-config \
|
||||
default-libmysqlclient-dev
|
||||
|
||||
# Copy development requirements and install them
|
||||
# Copy development requirements and install them *before* the application
|
||||
# source is copied below, so source-only edits don't bust this cache layer.
|
||||
COPY requirements/*.txt requirements/
|
||||
|
||||
# Copy local packages needed for editable installs in development.txt
|
||||
COPY superset-core superset-core
|
||||
COPY superset-extensions-cli superset-extensions-cli
|
||||
|
||||
# Install Python dependencies using docker/pip-install.sh
|
||||
# requirements/development.txt is generated by `uv pip compile` and embeds
|
||||
# `-e .` (an editable install of this same package) as its first line. That
|
||||
# self-reference needs the full superset/ source tree, which hasn't been
|
||||
# copied in yet at this point, so it's stripped here; the real editable
|
||||
# install of `.` runs below, once the source is present.
|
||||
RUN --mount=type=cache,target=${SUPERSET_HOME}/.cache/uv \
|
||||
/app/docker/pip-install.sh --requires-build-essential -r requirements/development.txt
|
||||
# Install the superset package
|
||||
RUN --mount=type=cache,target=${SUPERSET_HOME}/.cache/uv \
|
||||
uv pip install -e .
|
||||
grep -vxF -- "-e ." requirements/development.txt > requirements/development-deps.txt && \
|
||||
/app/docker/pip-install.sh --requires-build-essential -r requirements/development-deps.txt
|
||||
|
||||
RUN uv pip install .[postgres]
|
||||
RUN python -m compileall /app/superset
|
||||
# Copy compiled frontend assets and application source now that
|
||||
# dependencies have been resolved and cached above.
|
||||
COPY --from=superset-node /app/superset/static/assets superset/static/assets
|
||||
# Copy service.worker.js optionally as it doesn't exist when DEV_MODE=true
|
||||
COPY --from=superset-node /app/superset/static/service-worker.j[s] superset/static/service-worker.js
|
||||
|
||||
# TODO, when the next version comes out, use --exclude superset/translations
|
||||
COPY superset superset
|
||||
# TODO in the meantime, remove the .po files
|
||||
RUN rm superset/translations/*/*/*.po
|
||||
|
||||
# Merging translations from backend and frontend stages
|
||||
COPY --from=superset-node /app/superset/translations superset/translations
|
||||
COPY --from=python-translation-compiler /app/translations_mo superset/translations
|
||||
|
||||
# Install the superset package together with its postgres extra, using the
|
||||
# same uv cache mount as the requirements install above. --no-deps because
|
||||
# all dependencies (including the postgres extra's psycopg2-binary) are
|
||||
# already installed from requirements/development.txt above.
|
||||
# NOTE: source is bind-mounted over /app/superset in DEV_MODE, so a
|
||||
# compileall pass here would be wasted work; unlike `lean`, `dev` skips it.
|
||||
RUN --mount=type=cache,target=${SUPERSET_HOME}/.cache/uv \
|
||||
uv pip install -e .[postgres] --no-deps
|
||||
|
||||
USER superset
|
||||
|
||||
|
||||
@@ -1233,6 +1233,8 @@ Custom time ranges that use the "Now" or "Today" anchor (for the Start, End, or
|
||||
|
||||
Charts and dashboards using these anchors will compute a different (correct) timestamp after upgrading; if a chart's filters or drill-downs were tuned to compensate for the old offset, review them after upgrading.
|
||||
|
||||
- [43916](https://github.com/apache/superset/pull/43916): The `docker-compose` dev loop now skips re-running `superset load_examples` on every `docker compose up` once the example data and dashboards are present in the databases (set `SUPERSET_FORCE_LOAD_EXAMPLES=yes` to reload them anyway), and the `superset-node` service now defaults `DISABLE_TS_CHECKER=true` like `docker-compose-light.yml` already did, skipping webpack's TypeScript type-checking pass in dev by default.
|
||||
|
||||
## 6.1.0
|
||||
|
||||
### ClickHouse minimum driver version bump
|
||||
|
||||
@@ -138,6 +138,7 @@ services:
|
||||
condition: service_started
|
||||
volumes: *superset-volumes
|
||||
environment:
|
||||
SUPERSET_FORCE_LOAD_EXAMPLES: "${SUPERSET_FORCE_LOAD_EXAMPLES:-}"
|
||||
DATABASE_HOST: db-light
|
||||
DATABASE_DB: superset_light
|
||||
POSTGRES_DB: superset_light
|
||||
|
||||
@@ -183,6 +183,8 @@ services:
|
||||
condition: service_started
|
||||
user: *superset-user
|
||||
volumes: *superset-volumes
|
||||
environment:
|
||||
SUPERSET_FORCE_LOAD_EXAMPLES: "${SUPERSET_FORCE_LOAD_EXAMPLES:-}"
|
||||
healthcheck:
|
||||
disable: true
|
||||
|
||||
@@ -202,6 +204,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:8088"
|
||||
# Webpack dev server must bind to 0.0.0.0 to be accessible from outside the container
|
||||
|
||||
@@ -73,6 +73,12 @@ SUPERSET_ENV=development
|
||||
# Swagger UI is opt-in (off by default); enable it for local development.
|
||||
SUPERSET_ENABLE_SWAGGER_UI=true
|
||||
SUPERSET_LOAD_EXAMPLES=yes
|
||||
# Once the example data and dashboards are present in the databases,
|
||||
# `docker-init.sh` skips `superset load_examples` on later runs. Set to "yes"
|
||||
# (or run `SUPERSET_FORCE_LOAD_EXAMPLES=yes docker compose up`) to reload the
|
||||
# examples anyway, e.g. after changing the example datasets or after a partial
|
||||
# load.
|
||||
#SUPERSET_FORCE_LOAD_EXAMPLES=no
|
||||
CYPRESS_CONFIG=false
|
||||
SUPERSET_PORT=8088
|
||||
MAPBOX_API_KEY=''
|
||||
|
||||
+33
-3
@@ -66,14 +66,44 @@ echo_step "3" "Starting" "Setting up roles and perms"
|
||||
superset init
|
||||
echo_step "3" "Complete" "Setting up roles and perms"
|
||||
|
||||
# Loading examples parses and inserts every example dataset, chart and
|
||||
# dashboard and is one of the slowest steps of `docker compose up`. Rather
|
||||
# than trusting a marker file (which goes stale as soon as the database volume
|
||||
# is recreated), ask the databases themselves: when both the example data and
|
||||
# the dashboards imported from it are present, the previous load completed and
|
||||
# there is nothing left to redo. Any failure here (missing tables, unreachable
|
||||
# database, import error) simply reports "not loaded" so the full load runs.
|
||||
examples_already_loaded() {
|
||||
python - <<'PY' 2>/dev/null
|
||||
import sys
|
||||
|
||||
from superset.app import create_app
|
||||
from superset.sql.parse import Table
|
||||
|
||||
app = create_app()
|
||||
with app.app_context():
|
||||
from superset import db
|
||||
from superset.models.dashboard import Dashboard
|
||||
from superset.utils.database import get_example_database
|
||||
|
||||
has_dashboard = (
|
||||
db.session.query(Dashboard).filter_by(slug="world_health").first() is not None
|
||||
)
|
||||
has_data = get_example_database().has_table(Table("wb_health_population"))
|
||||
sys.exit(0 if has_dashboard and has_data else 1)
|
||||
PY
|
||||
}
|
||||
|
||||
if [ "$SUPERSET_LOAD_EXAMPLES" = "yes" ]; then
|
||||
# Load some data to play with
|
||||
echo_step "4" "Starting" "Loading examples"
|
||||
|
||||
|
||||
# If Cypress run which consumes superset_test_config – load required data for tests
|
||||
# Cypress runs always load, since they need a distinct set of test data
|
||||
# (`--load-test-data`) in a separate database. Set
|
||||
# SUPERSET_FORCE_LOAD_EXAMPLES=yes to reload the examples regardless.
|
||||
if [ "$CYPRESS_CONFIG" == "true" ]; then
|
||||
superset load_examples --load-test-data
|
||||
elif [ "$SUPERSET_FORCE_LOAD_EXAMPLES" != "yes" ] && examples_already_loaded; then
|
||||
echo "Examples already loaded, skipping (set SUPERSET_FORCE_LOAD_EXAMPLES=yes to reload them)"
|
||||
else
|
||||
superset load_examples
|
||||
fi
|
||||
|
||||
@@ -196,7 +196,9 @@ One important variable is `SUPERSET_LOAD_EXAMPLES` which determines whether the
|
||||
container will populate example data and visualizations into the metadata database. These examples
|
||||
are helpful for learning and testing out Superset but unnecessary for experienced users and
|
||||
production deployments. The loading process can sometimes take a few minutes and a good amount of
|
||||
CPU, so you may want to disable it on a resource-constrained device.
|
||||
CPU, so you may want to disable it on a resource-constrained device. Once the example data and
|
||||
dashboards are present in the databases, later `superset_init` runs skip loading them; run
|
||||
`SUPERSET_FORCE_LOAD_EXAMPLES=yes docker compose up` to reload the examples anyway.
|
||||
|
||||
For more advanced or dynamic configurations that are typically managed in a `superset_config.py` file
|
||||
located in your `PYTHONPATH`, note that it can be done by providing a
|
||||
|
||||
@@ -99,11 +99,16 @@ Affecting the Docker build process:
|
||||
- **INCLUDE_CHROMIUM (default=false):** whether to include the Chromium headless browser in the build
|
||||
- **BUILD_TRANSLATIONS(default=false):** whether to compile the translations from the .po files available
|
||||
- **SUPERSET_LOAD_EXAMPLES (default=yes):** whether to load the examples into the database upon startup,
|
||||
save some precious time on startup by `SUPERSET_LOAD_EXAMPLES=no docker compose up`
|
||||
save some precious time on startup by `SUPERSET_LOAD_EXAMPLES=no docker compose up`. Once the example
|
||||
data and dashboards are present in the databases, later `docker compose up` runs skip loading
|
||||
them; run `SUPERSET_FORCE_LOAD_EXAMPLES=yes docker compose up` to reload the examples anyway.
|
||||
- **SUPERSET_LOG_LEVEL (default=info)**: Can be set to debug, info, warning, error, critical
|
||||
for more verbose logging
|
||||
- **SUPERSET_DEBUG_ENABLED (default=false)**: Enable Werkzeug debugger with interactive console.
|
||||
Set to `true` for debugging: `SUPERSET_DEBUG_ENABLED=true docker compose up`
|
||||
- **DISABLE_TS_CHECKER (default=true)**: whether the `superset-node` webpack dev server skips
|
||||
TypeScript type-checking, which speeds up rebuilds and saves several GB of memory. Set to
|
||||
`false` to have webpack surface type errors during development.
|
||||
|
||||
For more env vars that affect your configuration, see this
|
||||
[superset_config.py](https://github.com/apache/superset/blob/master/docker/pythonpath_dev/superset_config.py)
|
||||
|
||||
@@ -93,7 +93,7 @@ Look through the GitHub issues. Issues tagged with
|
||||
|
||||
Superset could always use better documentation,
|
||||
whether as part of the official Superset docs,
|
||||
in docstrings, `docs/*.rst` or even on the web as blog posts or
|
||||
in docstrings, Markdown files in `docs/`, or even on the web as blog posts or
|
||||
articles. See [Documentation](./howtos.md#contributing-to-documentation) for more details.
|
||||
|
||||
### Add Translations
|
||||
|
||||
+1
-1
@@ -88,7 +88,7 @@
|
||||
"@types/js-yaml": "^4.0.9",
|
||||
"@types/react": "^19.1.8",
|
||||
"oxfmt": "^0.66.0",
|
||||
"oxlint": "^1.80.0",
|
||||
"oxlint": "^1.81.0",
|
||||
"oxlint-tsgolint": "^7.0.2001",
|
||||
"typescript": "7.0.2",
|
||||
"webpack": "^5.110.3"
|
||||
|
||||
+99
-99
@@ -3203,100 +3203,100 @@
|
||||
resolved "https://registry.yarnpkg.com/@oxlint-tsgolint/win32-x64/-/win32-x64-7.0.2001.tgz#814bcdd2707fa8ab1ae0f0b51a7243b034d2833a"
|
||||
integrity sha512-FkDRm8hx9OwzGQqyWG1tO5QrTLRApff9DzSgpz9QZau37BR8d1VYKOxMLGf6shPZntJFoTwIIJYT68VndYDCog==
|
||||
|
||||
"@oxlint/binding-android-arm-eabi@1.80.0":
|
||||
version "1.80.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-android-arm-eabi/-/binding-android-arm-eabi-1.80.0.tgz#924b041cbcea4e934fd9ef66a2d2b7d7463c0180"
|
||||
integrity sha512-RM3Plj+biQpxa5d1GOOX6ciDlcUROmm4OZ/pLTpitkQt2mJv4jhtY4cbgaetOm5UKWZe05/TGQ6o1Vl8EOHkrA==
|
||||
"@oxlint/binding-android-arm-eabi@1.81.0":
|
||||
version "1.81.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-android-arm-eabi/-/binding-android-arm-eabi-1.81.0.tgz#86a0305480e680431429c8259c5701ac5592e4a7"
|
||||
integrity sha512-IcCRsXiedJoJopY6mpZUBEeVFsUrutmrG7dZ87zMuKJlhg70Ora9bBl1WcCxZQtyI10YpnVdEso5oCg7YcfSHw==
|
||||
|
||||
"@oxlint/binding-android-arm64@1.80.0":
|
||||
version "1.80.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-android-arm64/-/binding-android-arm64-1.80.0.tgz#d1716d2be903de06b4fdb2fdaa121a2943695c35"
|
||||
integrity sha512-YlO5JEf0Yr2bUUlu8O8daVcUxtcGGbcSmyV7E7nSbJbfAdxTE0PFPwgnIlw7wXJaTYjb+qs5hI5q3jxUkI7cAw==
|
||||
"@oxlint/binding-android-arm64@1.81.0":
|
||||
version "1.81.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-android-arm64/-/binding-android-arm64-1.81.0.tgz#dba51cb2a1258f37eaca15a4e74d5d6ee19f238c"
|
||||
integrity sha512-GRrIPyTGVhx3L3h+0T5xT2A0jFAcdPv4+IfuXpGDLIdl6XeYhgg/zw72A5ILZoUgRqZuM8F1y+V/gfDriXSxzQ==
|
||||
|
||||
"@oxlint/binding-darwin-arm64@1.80.0":
|
||||
version "1.80.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-darwin-arm64/-/binding-darwin-arm64-1.80.0.tgz#475eb4061db4d4fe9349e92f15962c0203e8ebec"
|
||||
integrity sha512-BULDOyO3AhsmdWfQeIUCykDt3dd7XZBGLhp1eIh56skRv01O+cNjNPwXMIbeW1x4+pxcln5if72wcRgViVo7PA==
|
||||
"@oxlint/binding-darwin-arm64@1.81.0":
|
||||
version "1.81.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-darwin-arm64/-/binding-darwin-arm64-1.81.0.tgz#f384ae1eddd399429281f88a0073729e287ec0b1"
|
||||
integrity sha512-qNQ9tXRgLuKbqSV1S2h9h4KPHjbovO7RRR2/enUOtHzTkFZ7B9X5zqqHJua8dRyc7dBy7Aoyq5pqTSLFVcAzGQ==
|
||||
|
||||
"@oxlint/binding-darwin-x64@1.80.0":
|
||||
version "1.80.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-darwin-x64/-/binding-darwin-x64-1.80.0.tgz#602fa5681dd746c0fb5ca7a0e4a81d0dd07b7f90"
|
||||
integrity sha512-YJ4JzLw7N5TDSQFlA0hAQGHvnDZgyypm1yunObVWcWiF9KM7eGCJKYKLgTC2Fi/57OdnBhbj4OkzPGdFQJ6HyA==
|
||||
"@oxlint/binding-darwin-x64@1.81.0":
|
||||
version "1.81.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-darwin-x64/-/binding-darwin-x64-1.81.0.tgz#7167e3b4c18852fcd1ddade536d232d73d55d30c"
|
||||
integrity sha512-q0QTm32jWga2Gv4j7IaVZN0jYMi9UV73sWVgFtDA4iIfqwMCLLZ3ve+9KwfYtsaKZSgQhmPaogeZWqDZpcY1Pw==
|
||||
|
||||
"@oxlint/binding-freebsd-x64@1.80.0":
|
||||
version "1.80.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-freebsd-x64/-/binding-freebsd-x64-1.80.0.tgz#4e0490c344726fd0b1a027afc129fb9c78f069ec"
|
||||
integrity sha512-AYUIk5QnL0s8oWAYsREZwkRYy1SupJTXALo93J1TgzHywxQtdM99FecRMQ87MXEdPQ0j1TmEpeeq3fGNkpvMqg==
|
||||
"@oxlint/binding-freebsd-x64@1.81.0":
|
||||
version "1.81.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-freebsd-x64/-/binding-freebsd-x64-1.81.0.tgz#64f230765343bfe7e2280b071bb191bb666303ac"
|
||||
integrity sha512-/+8wVWDXEC7wHVAhOc59Fw/SkMc1arLkFD8iQCaSsmzenK1X4doFqquL9H1wrtGUzaiycVqkf/sSpcILK6W1UA==
|
||||
|
||||
"@oxlint/binding-linux-arm-gnueabihf@1.80.0":
|
||||
version "1.80.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.80.0.tgz#82d215fc05e046a0ec085821c1da8ab99d35fbdc"
|
||||
integrity sha512-9hBZVANupQ89W9dXyE0n8doCyaW5pDyGn3y6XlIMPZ+rIKuyqkr3SNUXmVJIhuvUq0NBU3RBiSXXE69l4XI6KA==
|
||||
"@oxlint/binding-linux-arm-gnueabihf@1.81.0":
|
||||
version "1.81.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.81.0.tgz#5095f021a28009146f7536a7ccd518cdfcbfc3bf"
|
||||
integrity sha512-4xt422FEgioRq9hAL4Tq7fujGUWnc8z1BJ+Oi8RN8vB8axaP+sdK6a2xdlcQCCYnJg9QMuMFS0AucuIFx/EacA==
|
||||
|
||||
"@oxlint/binding-linux-arm-musleabihf@1.80.0":
|
||||
version "1.80.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-linux-arm-musleabihf/-/binding-linux-arm-musleabihf-1.80.0.tgz#92068e3b51cd50fc5a83a3ebfba7925313d6cd11"
|
||||
integrity sha512-SvS2uKqzY+pbfuvAHzH4338R6Zwo805GAwrIMVvK1KxoOWCIjZUdfzTCvilD7z6JK91v011+zYMryabhDo2AsQ==
|
||||
"@oxlint/binding-linux-arm-musleabihf@1.81.0":
|
||||
version "1.81.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-linux-arm-musleabihf/-/binding-linux-arm-musleabihf-1.81.0.tgz#d894dcfb6fb1b8b224b79e6ce07b17403f413749"
|
||||
integrity sha512-u3vna8KdGplH4DRCW9K54D68fcMo7IxVrkCJWwXnIhwtBdnDnYrmzOUA/XjmBlPpcLsgw9Z5BNdY4za9+Dj+MQ==
|
||||
|
||||
"@oxlint/binding-linux-arm64-gnu@1.80.0":
|
||||
version "1.80.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.80.0.tgz#6c81ddc85dd5b79070f87401d61813172068666d"
|
||||
integrity sha512-tCLadyqRVL3pQTRPNg7cjXKvcvS4fbyXeQHhKk5BTJ1oftQln5/yIIWbu/Xom/DX41zv2P9QGt6+D/TtQVtY3A==
|
||||
"@oxlint/binding-linux-arm64-gnu@1.81.0":
|
||||
version "1.81.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.81.0.tgz#bf8e362c87e7828ba28c2ec36bae73ad82989ef1"
|
||||
integrity sha512-3j9k+gsYsE7nv71GWotXsqsa2l9/aJenD7dVHNt/CBvsb0SgRjSMnHFeP59IXUAl1wvVFhqGl2wJNMwWU3UBlA==
|
||||
|
||||
"@oxlint/binding-linux-arm64-musl@1.80.0":
|
||||
version "1.80.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.80.0.tgz#11216704b606d67e946a868850243dc2739ec92e"
|
||||
integrity sha512-XfpCNRlOPcLlJl4Bn/FUhjqlR6BVavEykERBf/MV7YA9VZDa5g5znVqYhyviMafcxS9Pe/i/kPvHNO0U6svEHQ==
|
||||
"@oxlint/binding-linux-arm64-musl@1.81.0":
|
||||
version "1.81.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.81.0.tgz#2aa5214eb5b032e8f77d94a27c9bd3f6dbc446f3"
|
||||
integrity sha512-k5iAp3dNxW0/uDCBY+WSm8jKB2szu7SkEQZdgRRpDXvuDd69vvDcqhB3A/pWCfCwXyenjNjFn9Td1fVoyAc+Yg==
|
||||
|
||||
"@oxlint/binding-linux-ppc64-gnu@1.80.0":
|
||||
version "1.80.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.80.0.tgz#125302a0e6732e32e4a7d53f0212d58f1b13af01"
|
||||
integrity sha512-3I4yMwcFG9NeO8ioY6JBBuKsIm5GL/x7MATt1S4tVWaxPu5HcJ+XnLUbcVBTxG8q2Wu56HSj+NmXQiVYb1lp6A==
|
||||
"@oxlint/binding-linux-ppc64-gnu@1.81.0":
|
||||
version "1.81.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.81.0.tgz#a0af1af6fd309214555f33b4fa0432f3ec45f242"
|
||||
integrity sha512-TFqLja3uYmVSte6nof9GWrex9Z8WgdZrNiLC6Te5rXGDqXB2y4j/26iFhwosXiAFqDhE9JJVuuCkDKLwptTn1g==
|
||||
|
||||
"@oxlint/binding-linux-riscv64-gnu@1.80.0":
|
||||
version "1.80.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-linux-riscv64-gnu/-/binding-linux-riscv64-gnu-1.80.0.tgz#03846614f184ed3dcbab4bffad7417fd54cd0967"
|
||||
integrity sha512-E1wAKymkpe1/E8helzBKdm81OBOF+ezxRyXRMEuik3ZpWDER5CPOKZwF66RsdwW98uwZv8UTFremUQtC1CzdJA==
|
||||
"@oxlint/binding-linux-riscv64-gnu@1.81.0":
|
||||
version "1.81.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-linux-riscv64-gnu/-/binding-linux-riscv64-gnu-1.81.0.tgz#60413a335a63e0911a625d047690e41c03f2a833"
|
||||
integrity sha512-UEcySvGS0NOVo7h7n7CYyJL9+6gFAh7Zc/ToDXVScFvzHSTIxtzkMVU30rmQ6+nQ1LF+UdiRDdJajpDu+OylLg==
|
||||
|
||||
"@oxlint/binding-linux-riscv64-musl@1.80.0":
|
||||
version "1.80.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-linux-riscv64-musl/-/binding-linux-riscv64-musl-1.80.0.tgz#49e0fb90e1c8358429b9989a407f4020c56d8ea9"
|
||||
integrity sha512-+gLRGD4sIo3+VA++iham5UxD9tKSoJ/VOrROCEXIcknrYtQg6iIQgvjN0cpiRF7N6UYC7pJbvHJlDnMge5LRpQ==
|
||||
"@oxlint/binding-linux-riscv64-musl@1.81.0":
|
||||
version "1.81.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-linux-riscv64-musl/-/binding-linux-riscv64-musl-1.81.0.tgz#5f1dd7bc2bdbe92fa5454df081ee91fa2c499948"
|
||||
integrity sha512-H+diDbhD00+wI1IRP8Kz88x/lat+DgtoBJzoTthS16xkTJGNaEkfb8gzmd1rzc/2uDQQMl7GNl+JFUacVeWxIA==
|
||||
|
||||
"@oxlint/binding-linux-s390x-gnu@1.80.0":
|
||||
version "1.80.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.80.0.tgz#7aee2ae2426f7bdcae77969073a015a6b3f8373e"
|
||||
integrity sha512-aR0PrzHj9leW3NmzBAAP4EzdoBNoJcs9sjnIQPIwyRnBGYrRbXUIpEB5Q39AqK3PLY5JK5uEhDQDiUa1QSAstw==
|
||||
"@oxlint/binding-linux-s390x-gnu@1.81.0":
|
||||
version "1.81.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.81.0.tgz#830c5bdd145ad39c9b5371e3214d0a9f9c1f46b1"
|
||||
integrity sha512-8znJ/5TekjOKg1j1Acho4PJMdiAHLtlcXuWEiipOhAMV6rQcXdmDdXCbheyDczN6TjBwiNfjcP81k4AthrKRzw==
|
||||
|
||||
"@oxlint/binding-linux-x64-gnu@1.80.0":
|
||||
version "1.80.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.80.0.tgz#0c850b00faed2f884cf8665fe9c391f9f653d6ca"
|
||||
integrity sha512-vSVh5cSo3Xxs6ghBCcFJlpbkbENzDog1qXtoXLa/HC3aCrR4XO76GZbXmQoCPHnu99nQpdCeC3H9tdNICfDh7A==
|
||||
"@oxlint/binding-linux-x64-gnu@1.81.0":
|
||||
version "1.81.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.81.0.tgz#7f72ea3c9ae70a76c1a92e56a5755869f335e756"
|
||||
integrity sha512-Q2Wj70yFsvn5QjlmifFzbj4H+kJy53bwqc41o1fzoM7MpLV1NIbhg/LpWXRfC6KOkSAdUx1Wd8VJsdPmhp/HRA==
|
||||
|
||||
"@oxlint/binding-linux-x64-musl@1.80.0":
|
||||
version "1.80.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-linux-x64-musl/-/binding-linux-x64-musl-1.80.0.tgz#91f54f1b0cc93a7e75ce4118aa85f9fd112f25c0"
|
||||
integrity sha512-FfzBXpNQ8u7/ZI/p8bl73MeZ508Ax3hxWp3SiJpEFiC+BB9XcXy5FAZHTLKDPSzrUpxQZSZJAVdDmuJp/+HDBQ==
|
||||
"@oxlint/binding-linux-x64-musl@1.81.0":
|
||||
version "1.81.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-linux-x64-musl/-/binding-linux-x64-musl-1.81.0.tgz#758fd6ea69123c6f4c1ba160bfc28f6b84548c11"
|
||||
integrity sha512-cPInHp/ddEe5qkyK2IiyQ8Q3Mp2oLLEhhsGgTK2oZx4L6+llGam1H1yBvJZ7qHfOXj8N3hxBS8sj4tO+gtFlIg==
|
||||
|
||||
"@oxlint/binding-openharmony-arm64@1.80.0":
|
||||
version "1.80.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-openharmony-arm64/-/binding-openharmony-arm64-1.80.0.tgz#7ab37c21e547812177bffdbd97c8a34493eedd7b"
|
||||
integrity sha512-zMzbkumtmprCgRwoYNzcB3iC39fXdJIMLMU33KdCjEGLlJGOEt1+LwQ4LF8ndLzAEKVz4BR0y3V6Xrkk3Nm3yA==
|
||||
"@oxlint/binding-openharmony-arm64@1.81.0":
|
||||
version "1.81.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-openharmony-arm64/-/binding-openharmony-arm64-1.81.0.tgz#e492b7a1875b70ea55ffe13f685d4302e6b1900e"
|
||||
integrity sha512-0CQxSX4ajqm07AHBf5U33qQzXKdd7wtq/oTL/7vpY6RNNuxrRi8W4bqUV1Jyu/vj+9KmxQyDhxfeVX1nQL6kfg==
|
||||
|
||||
"@oxlint/binding-win32-arm64-msvc@1.80.0":
|
||||
version "1.80.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.80.0.tgz#5a470fa82339044ad9cceef2bb8c62d88695e394"
|
||||
integrity sha512-ib6iRcrXsk4t1fm3iKcwksyWh1ZkZXC/2mEzakl0ai2+6HZunf1WWMZ/xP9EJAvw9g9K4UVTC3NF/+G2qLrbTQ==
|
||||
"@oxlint/binding-win32-arm64-msvc@1.81.0":
|
||||
version "1.81.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.81.0.tgz#9247fdc1b4c86ecc718747c5f8c68902969677d1"
|
||||
integrity sha512-l0hbeISm9673hVrrQU8j/p2M7YH9Ouoj7p7E/QM55NTrKVLP+P3PF8hLu+OY+x0VtGRW+ggiQKZqmdYps9H+TA==
|
||||
|
||||
"@oxlint/binding-win32-ia32-msvc@1.80.0":
|
||||
version "1.80.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-1.80.0.tgz#06f6559998f1a53a8f5ace78d91f217a54f6a963"
|
||||
integrity sha512-xhRWBMpLxZvgKAH6+DJZmpP+W8Y8UdQOSU1JfxSWNXsaBaRGW77j+1hCuNHlzj7OH4SPN8fYd1q0o2qrDtoVyw==
|
||||
"@oxlint/binding-win32-ia32-msvc@1.81.0":
|
||||
version "1.81.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-1.81.0.tgz#dfa4eed78612c5f4df788eb056fd5d1b05a75bb1"
|
||||
integrity sha512-ksqPP5jbFXcYreEQ7zdJh06rJQBymCTyGRCdaXjfcf2aG4f8KxUWY5wcgYHmaTK+FJ4bPG5sUAdOX+6trnH1JA==
|
||||
|
||||
"@oxlint/binding-win32-x64-msvc@1.80.0":
|
||||
version "1.80.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.80.0.tgz#d3abbf1a7a09b9039ca5ca570c9689908850efc4"
|
||||
integrity sha512-yAnO7lwBYQnz2pcfBPIGQQZWIX5zd5R/1aAKIF3oE+TVj7IhoHcROjOkz3sRDngzqhfPKfFaXqug5j5rE5dn6Q==
|
||||
"@oxlint/binding-win32-x64-msvc@1.81.0":
|
||||
version "1.81.0"
|
||||
resolved "https://registry.yarnpkg.com/@oxlint/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.81.0.tgz#27a474cc288e47a0e5c2d9c922bee64de0cfd614"
|
||||
integrity sha512-IZuUCwGw9emG5JtCp+fYGB+Z4OWEoeEcM8R5BA1pYw63/ieYFVdcU2ylxTpHbVHSenZnsYE+ZZ20uHAJszQ4cA==
|
||||
|
||||
"@parcel/watcher-android-arm64@2.5.6":
|
||||
version "2.5.6"
|
||||
@@ -11580,30 +11580,30 @@ oxlint-tsgolint@^7.0.2001:
|
||||
"@oxlint-tsgolint/win32-arm64" "7.0.2001"
|
||||
"@oxlint-tsgolint/win32-x64" "7.0.2001"
|
||||
|
||||
oxlint@^1.80.0:
|
||||
version "1.80.0"
|
||||
resolved "https://registry.yarnpkg.com/oxlint/-/oxlint-1.80.0.tgz#228271087d3f04e391e383ccdc0e840458d8b653"
|
||||
integrity sha512-5nTiSps4qdbCWLbxzuO00alHkEO2exR9YMN/ig6QXWrLsYSG0KaObOAM+l6oU2LcKPWoSAGYbkZIGEu1ViiWKA==
|
||||
oxlint@^1.81.0:
|
||||
version "1.81.0"
|
||||
resolved "https://registry.yarnpkg.com/oxlint/-/oxlint-1.81.0.tgz#7b20ada29a171883de4517d041ea5b057fb48ab5"
|
||||
integrity sha512-HyrJYqeoOCL0iqaLEzGewGT48ZX99P3hxYh8udAF9RGGIghSamkXE4ClUyBpEDNqasamThgmlPbuMOe7SAZmHg==
|
||||
optionalDependencies:
|
||||
"@oxlint/binding-android-arm-eabi" "1.80.0"
|
||||
"@oxlint/binding-android-arm64" "1.80.0"
|
||||
"@oxlint/binding-darwin-arm64" "1.80.0"
|
||||
"@oxlint/binding-darwin-x64" "1.80.0"
|
||||
"@oxlint/binding-freebsd-x64" "1.80.0"
|
||||
"@oxlint/binding-linux-arm-gnueabihf" "1.80.0"
|
||||
"@oxlint/binding-linux-arm-musleabihf" "1.80.0"
|
||||
"@oxlint/binding-linux-arm64-gnu" "1.80.0"
|
||||
"@oxlint/binding-linux-arm64-musl" "1.80.0"
|
||||
"@oxlint/binding-linux-ppc64-gnu" "1.80.0"
|
||||
"@oxlint/binding-linux-riscv64-gnu" "1.80.0"
|
||||
"@oxlint/binding-linux-riscv64-musl" "1.80.0"
|
||||
"@oxlint/binding-linux-s390x-gnu" "1.80.0"
|
||||
"@oxlint/binding-linux-x64-gnu" "1.80.0"
|
||||
"@oxlint/binding-linux-x64-musl" "1.80.0"
|
||||
"@oxlint/binding-openharmony-arm64" "1.80.0"
|
||||
"@oxlint/binding-win32-arm64-msvc" "1.80.0"
|
||||
"@oxlint/binding-win32-ia32-msvc" "1.80.0"
|
||||
"@oxlint/binding-win32-x64-msvc" "1.80.0"
|
||||
"@oxlint/binding-android-arm-eabi" "1.81.0"
|
||||
"@oxlint/binding-android-arm64" "1.81.0"
|
||||
"@oxlint/binding-darwin-arm64" "1.81.0"
|
||||
"@oxlint/binding-darwin-x64" "1.81.0"
|
||||
"@oxlint/binding-freebsd-x64" "1.81.0"
|
||||
"@oxlint/binding-linux-arm-gnueabihf" "1.81.0"
|
||||
"@oxlint/binding-linux-arm-musleabihf" "1.81.0"
|
||||
"@oxlint/binding-linux-arm64-gnu" "1.81.0"
|
||||
"@oxlint/binding-linux-arm64-musl" "1.81.0"
|
||||
"@oxlint/binding-linux-ppc64-gnu" "1.81.0"
|
||||
"@oxlint/binding-linux-riscv64-gnu" "1.81.0"
|
||||
"@oxlint/binding-linux-riscv64-musl" "1.81.0"
|
||||
"@oxlint/binding-linux-s390x-gnu" "1.81.0"
|
||||
"@oxlint/binding-linux-x64-gnu" "1.81.0"
|
||||
"@oxlint/binding-linux-x64-musl" "1.81.0"
|
||||
"@oxlint/binding-openharmony-arm64" "1.81.0"
|
||||
"@oxlint/binding-win32-arm64-msvc" "1.81.0"
|
||||
"@oxlint/binding-win32-ia32-msvc" "1.81.0"
|
||||
"@oxlint/binding-win32-x64-msvc" "1.81.0"
|
||||
|
||||
p-cancelable@^3.0.0:
|
||||
version "3.0.0"
|
||||
|
||||
Generated
+58
-213
@@ -244,7 +244,7 @@
|
||||
"html-webpack-plugin": "^5.6.8",
|
||||
"imports-loader": "^5.0.0",
|
||||
"jest": "^30.5.1",
|
||||
"jest-environment-jsdom": "^30.5.0",
|
||||
"jest-environment-jsdom": "^30.5.1",
|
||||
"jest-html-reporter": "^4.4.0",
|
||||
"jest-websocket-mock": "^2.5.0",
|
||||
"js-yaml-loader": "^1.2.2",
|
||||
@@ -5933,18 +5933,18 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@jest/environment-jsdom-abstract": {
|
||||
"version": "30.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@jest/environment-jsdom-abstract/-/environment-jsdom-abstract-30.5.0.tgz",
|
||||
"integrity": "sha512-825vac4Dmysbn2kU7VUQPoKuj/HNUpSTgv98KCByMOSPvHuj1/HpVZeLRsP/itDB2HFiDcoTUrsg8fSu3PxKBw==",
|
||||
"version": "30.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@jest/environment-jsdom-abstract/-/environment-jsdom-abstract-30.5.1.tgz",
|
||||
"integrity": "sha512-J395vmP3Fb2Te0JmF7pe4si4jpfbXef1YsY4UpHYL6OOxS2molu9Dsie1VmIiUalXdtmz1P5QRgc+5hBD+ssBg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jest/environment": "30.5.0",
|
||||
"@jest/fake-timers": "30.5.0",
|
||||
"@jest/types": "30.5.0",
|
||||
"@jest/environment": "30.5.1",
|
||||
"@jest/fake-timers": "30.5.1",
|
||||
"@jest/types": "30.5.1",
|
||||
"@types/node": "*",
|
||||
"jest-mock": "30.5.0",
|
||||
"jest-util": "30.5.0"
|
||||
"jest-mock": "30.5.1",
|
||||
"jest-util": "30.5.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0"
|
||||
@@ -5961,34 +5961,34 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@jest/environment-jsdom-abstract/node_modules/@jest/environment": {
|
||||
"version": "30.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@jest/environment/-/environment-30.5.0.tgz",
|
||||
"integrity": "sha512-HUaqexIauIh69IQ4NTuPDEUCB8g8T4TOPSIzQOS18mwI/KEHKQk1j013K2o6ra031szZE2t5jGmVx3xbzdjgKA==",
|
||||
"version": "30.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@jest/environment/-/environment-30.5.1.tgz",
|
||||
"integrity": "sha512-eYJAkOsrpwDXPcoLNEG6lN9Zo3Cy35pxnVQD74vyIfsi/Q8wB/lZFsEjU4wrecOgT4ZviQDZaX/cFIJyMdMxTw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jest/fake-timers": "30.5.0",
|
||||
"@jest/types": "30.5.0",
|
||||
"@jest/fake-timers": "30.5.1",
|
||||
"@jest/types": "30.5.1",
|
||||
"@types/node": "*",
|
||||
"jest-mock": "30.5.0"
|
||||
"jest-mock": "30.5.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@jest/environment-jsdom-abstract/node_modules/@jest/fake-timers": {
|
||||
"version": "30.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-30.5.0.tgz",
|
||||
"integrity": "sha512-sg8xIbYwe5GdB/vT3/0qrDIpO7Ov9mazHi++M95uynmDKEZ70G1r169AWct73H07VrTZhrz1SJEfLtjYv8tE3A==",
|
||||
"version": "30.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-30.5.1.tgz",
|
||||
"integrity": "sha512-rEkV6YzpBXo/L9cnj2ibyuYZuyGiNWaPUsyCu3HYJbqCV4jnEiKmf7hId20z8eKjZ0JQ9jtIYKxRSmYB/OYSsA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jest/types": "30.5.0",
|
||||
"@jest/types": "30.5.1",
|
||||
"@sinonjs/fake-timers": "^15.4.0",
|
||||
"@types/node": "*",
|
||||
"jest-message-util": "30.5.0",
|
||||
"jest-mock": "30.5.0",
|
||||
"jest-util": "30.5.0"
|
||||
"jest-message-util": "30.5.1",
|
||||
"jest-mock": "30.5.1",
|
||||
"jest-util": "30.5.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0"
|
||||
@@ -6028,20 +6028,20 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@jest/environment-jsdom-abstract/node_modules/jest-message-util": {
|
||||
"version": "30.5.0",
|
||||
"resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-30.5.0.tgz",
|
||||
"integrity": "sha512-dBYMhplGfspKaCnVk9TUy1cZnknWubpuPNEputjz0YJk1G/92R45rn45BvbPMPMtC5LVcIdxJGPOaOSQTiuzJw==",
|
||||
"version": "30.5.1",
|
||||
"resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-30.5.1.tgz",
|
||||
"integrity": "sha512-UdQlLdd9wL/Ys7xRErckqwD6wPlSZYueosSWuHc1r2ztGLwlgPvtSJq2+BPEgaEY13WLvfFbmhTj8pba0Sd1jg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "^7.27.1",
|
||||
"@jest/types": "30.5.0",
|
||||
"@jest/types": "30.5.1",
|
||||
"@types/stack-utils": "^2.0.3",
|
||||
"chalk": "^4.1.2",
|
||||
"graceful-fs": "^4.2.11",
|
||||
"jest-util": "30.5.0",
|
||||
"jest-util": "30.5.1",
|
||||
"picomatch": "^4.0.3",
|
||||
"pretty-format": "30.5.0",
|
||||
"pretty-format": "30.5.1",
|
||||
"slash": "^3.0.0",
|
||||
"stack-utils": "^2.0.6"
|
||||
},
|
||||
@@ -6063,9 +6063,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@jest/environment-jsdom-abstract/node_modules/pretty-format": {
|
||||
"version": "30.5.0",
|
||||
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-30.5.0.tgz",
|
||||
"integrity": "sha512-mzNzBErpHwM0zpmWS7ExOv62yhQhvd546nUuFqVR0dmnJB59tfrw9sjDF0DJknwsr59OXP0buwJ7PaKguczHSg==",
|
||||
"version": "30.5.1",
|
||||
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-30.5.1.tgz",
|
||||
"integrity": "sha512-byhRAPguVKMQIj4kjJwJ5lAskVhfuiSdiYl/aLTWpgkGEmic2jYhJh1yE9ih8Ox44Xg9ccCT11/S6QrzSJuNrg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -27311,32 +27311,6 @@
|
||||
"node": "^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-config/node_modules/@jest/transform": {
|
||||
"version": "30.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@jest/transform/-/transform-30.5.0.tgz",
|
||||
"integrity": "sha512-n1cYhoByyULEIXi64wbT4Lq91qeT1E6bwpM//sprFXhw955qaiHTdAmy1c1rNFGB6fCf1J+nxDUSf3RGwgZP5A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.27.4",
|
||||
"@jest/types": "30.5.0",
|
||||
"@jridgewell/trace-mapping": "^0.3.31",
|
||||
"babel-plugin-istanbul": "^8.0.0",
|
||||
"chalk": "^4.1.2",
|
||||
"convert-source-map": "^2.0.0",
|
||||
"fast-json-stable-stringify": "^2.1.0",
|
||||
"graceful-fs": "^4.2.11",
|
||||
"jest-haste-map": "30.5.0",
|
||||
"jest-regex-util": "30.5.0",
|
||||
"jest-util": "30.5.0",
|
||||
"pirates": "^4.0.7",
|
||||
"slash": "^3.0.0",
|
||||
"write-file-atomic": "^5.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-config/node_modules/@napi-rs/wasm-runtime": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.2.3.tgz",
|
||||
@@ -27685,48 +27659,6 @@
|
||||
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-config/node_modules/babel-jest": {
|
||||
"version": "30.5.0",
|
||||
"resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-30.5.0.tgz",
|
||||
"integrity": "sha512-PrhPHlKC+MsLnuNzgIH/y1dkz1f6cSfKWaQeaG8WxLMuG44dYWQ8E9uRrsBbAGCU/3+BEFYPN4d6G3Zc5Y+waA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jest/transform": "30.5.0",
|
||||
"@types/babel__core": "^7.20.5",
|
||||
"babel-plugin-istanbul": "^8.0.0",
|
||||
"babel-preset-jest": "30.5.0",
|
||||
"chalk": "^4.1.2",
|
||||
"graceful-fs": "^4.2.11",
|
||||
"slash": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.11.0 || ^8.0.0-0"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-config/node_modules/babel-plugin-istanbul": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-8.0.0.tgz",
|
||||
"integrity": "sha512-18wCskrN3DgbuBmp1gr7LBGT8xdz5xhQQqFvFhVxbkl8VBCrMKQ2YtqBWtUal1Zrc1HTuX0011+Brjw78TCFkg==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause",
|
||||
"workspaces": [
|
||||
"test/babel-8"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/helper-plugin-utils": "^7.0.0",
|
||||
"@istanbuljs/load-nyc-config": "^1.0.0",
|
||||
"@istanbuljs/schema": "^0.1.3",
|
||||
"istanbul-lib-instrument": "^6.0.2",
|
||||
"test-exclude": "^7.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-config/node_modules/fdir": {
|
||||
"version": "6.5.0",
|
||||
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
|
||||
@@ -27964,93 +27896,6 @@
|
||||
"url": "https://github.com/chalk/supports-color?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-config/node_modules/test-exclude": {
|
||||
"version": "7.0.2",
|
||||
"resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-7.0.2.tgz",
|
||||
"integrity": "sha512-u9E6A+ZDYdp7a4WnarkXPZOx8Ilz46+kby6p1yZ8zsGTz9gYa6FIS7lj2oezzNKmtdyyJNNmmXDppga5GB7kSw==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@istanbuljs/schema": "^0.1.2",
|
||||
"glob": "^10.4.1",
|
||||
"minimatch": "^10.2.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-config/node_modules/test-exclude/node_modules/brace-expansion": {
|
||||
"version": "2.1.4",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.4.tgz",
|
||||
"integrity": "sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"balanced-match": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-config/node_modules/test-exclude/node_modules/glob": {
|
||||
"version": "10.5.0",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-10.5.0.tgz",
|
||||
"integrity": "sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==",
|
||||
"deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"foreground-child": "^3.1.0",
|
||||
"jackspeak": "^3.1.2",
|
||||
"minimatch": "^9.0.4",
|
||||
"minipass": "^7.1.2",
|
||||
"package-json-from-dist": "^1.0.0",
|
||||
"path-scurry": "^1.11.1"
|
||||
},
|
||||
"bin": {
|
||||
"glob": "dist/esm/bin.mjs"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-config/node_modules/test-exclude/node_modules/glob/node_modules/minimatch": {
|
||||
"version": "9.0.9",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.9.tgz",
|
||||
"integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"brace-expansion": "^2.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16 || 14 >=14.17"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-config/node_modules/test-exclude/node_modules/lru-cache": {
|
||||
"version": "10.4.3",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz",
|
||||
"integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==",
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/jest-config/node_modules/test-exclude/node_modules/path-scurry": {
|
||||
"version": "1.11.1",
|
||||
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz",
|
||||
"integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==",
|
||||
"dev": true,
|
||||
"license": "BlueOak-1.0.0",
|
||||
"dependencies": {
|
||||
"lru-cache": "^10.2.0",
|
||||
"minipass": "^5.0.0 || ^6.0.2 || ^7.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16 || 14 >=14.18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-config/node_modules/unrs-resolver": {
|
||||
"version": "1.12.2",
|
||||
"resolved": "https://registry.npmjs.org/unrs-resolver/-/unrs-resolver-1.12.2.tgz",
|
||||
@@ -28213,14 +28058,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/jest-environment-jsdom": {
|
||||
"version": "30.5.0",
|
||||
"resolved": "https://registry.npmjs.org/jest-environment-jsdom/-/jest-environment-jsdom-30.5.0.tgz",
|
||||
"integrity": "sha512-VVHN/G3zrxsQR398jvMalM76ALX6YBAftsYLCGtTeKRmz4f42YJAP05AGpk0VF5SLtoHdkfKunYGfnKPnmcEOA==",
|
||||
"version": "30.5.1",
|
||||
"resolved": "https://registry.npmjs.org/jest-environment-jsdom/-/jest-environment-jsdom-30.5.1.tgz",
|
||||
"integrity": "sha512-8lzKbC/SRbQE24wr1OOJV+aYtDAuVNKBryN6YcFiCcaZZ3I7grcZY7w91BwNvGET0ubKDmomEHZFHMaF+6pAlA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jest/environment": "30.5.0",
|
||||
"@jest/environment-jsdom-abstract": "30.5.0",
|
||||
"@jest/environment": "30.5.1",
|
||||
"@jest/environment-jsdom-abstract": "30.5.1",
|
||||
"@types/jsdom": "^21.1.7",
|
||||
"jsdom": "^26.1.0"
|
||||
},
|
||||
@@ -28237,34 +28082,34 @@
|
||||
}
|
||||
},
|
||||
"node_modules/jest-environment-jsdom/node_modules/@jest/environment": {
|
||||
"version": "30.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@jest/environment/-/environment-30.5.0.tgz",
|
||||
"integrity": "sha512-HUaqexIauIh69IQ4NTuPDEUCB8g8T4TOPSIzQOS18mwI/KEHKQk1j013K2o6ra031szZE2t5jGmVx3xbzdjgKA==",
|
||||
"version": "30.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@jest/environment/-/environment-30.5.1.tgz",
|
||||
"integrity": "sha512-eYJAkOsrpwDXPcoLNEG6lN9Zo3Cy35pxnVQD74vyIfsi/Q8wB/lZFsEjU4wrecOgT4ZviQDZaX/cFIJyMdMxTw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jest/fake-timers": "30.5.0",
|
||||
"@jest/types": "30.5.0",
|
||||
"@jest/fake-timers": "30.5.1",
|
||||
"@jest/types": "30.5.1",
|
||||
"@types/node": "*",
|
||||
"jest-mock": "30.5.0"
|
||||
"jest-mock": "30.5.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-environment-jsdom/node_modules/@jest/fake-timers": {
|
||||
"version": "30.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-30.5.0.tgz",
|
||||
"integrity": "sha512-sg8xIbYwe5GdB/vT3/0qrDIpO7Ov9mazHi++M95uynmDKEZ70G1r169AWct73H07VrTZhrz1SJEfLtjYv8tE3A==",
|
||||
"version": "30.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-30.5.1.tgz",
|
||||
"integrity": "sha512-rEkV6YzpBXo/L9cnj2ibyuYZuyGiNWaPUsyCu3HYJbqCV4jnEiKmf7hId20z8eKjZ0JQ9jtIYKxRSmYB/OYSsA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jest/types": "30.5.0",
|
||||
"@jest/types": "30.5.1",
|
||||
"@sinonjs/fake-timers": "^15.4.0",
|
||||
"@types/node": "*",
|
||||
"jest-message-util": "30.5.0",
|
||||
"jest-mock": "30.5.0",
|
||||
"jest-util": "30.5.0"
|
||||
"jest-message-util": "30.5.1",
|
||||
"jest-mock": "30.5.1",
|
||||
"jest-util": "30.5.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0"
|
||||
@@ -28331,20 +28176,20 @@
|
||||
}
|
||||
},
|
||||
"node_modules/jest-environment-jsdom/node_modules/jest-message-util": {
|
||||
"version": "30.5.0",
|
||||
"resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-30.5.0.tgz",
|
||||
"integrity": "sha512-dBYMhplGfspKaCnVk9TUy1cZnknWubpuPNEputjz0YJk1G/92R45rn45BvbPMPMtC5LVcIdxJGPOaOSQTiuzJw==",
|
||||
"version": "30.5.1",
|
||||
"resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-30.5.1.tgz",
|
||||
"integrity": "sha512-UdQlLdd9wL/Ys7xRErckqwD6wPlSZYueosSWuHc1r2ztGLwlgPvtSJq2+BPEgaEY13WLvfFbmhTj8pba0Sd1jg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "^7.27.1",
|
||||
"@jest/types": "30.5.0",
|
||||
"@jest/types": "30.5.1",
|
||||
"@types/stack-utils": "^2.0.3",
|
||||
"chalk": "^4.1.2",
|
||||
"graceful-fs": "^4.2.11",
|
||||
"jest-util": "30.5.0",
|
||||
"jest-util": "30.5.1",
|
||||
"picomatch": "^4.0.3",
|
||||
"pretty-format": "30.5.0",
|
||||
"pretty-format": "30.5.1",
|
||||
"slash": "^3.0.0",
|
||||
"stack-utils": "^2.0.6"
|
||||
},
|
||||
@@ -28406,9 +28251,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/jest-environment-jsdom/node_modules/pretty-format": {
|
||||
"version": "30.5.0",
|
||||
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-30.5.0.tgz",
|
||||
"integrity": "sha512-mzNzBErpHwM0zpmWS7ExOv62yhQhvd546nUuFqVR0dmnJB59tfrw9sjDF0DJknwsr59OXP0buwJ7PaKguczHSg==",
|
||||
"version": "30.5.1",
|
||||
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-30.5.1.tgz",
|
||||
"integrity": "sha512-byhRAPguVKMQIj4kjJwJ5lAskVhfuiSdiYl/aLTWpgkGEmic2jYhJh1yE9ih8Ox44Xg9ccCT11/S6QrzSJuNrg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
||||
@@ -321,7 +321,7 @@
|
||||
"html-webpack-plugin": "^5.6.8",
|
||||
"imports-loader": "^5.0.0",
|
||||
"jest": "^30.5.1",
|
||||
"jest-environment-jsdom": "^30.5.0",
|
||||
"jest-environment-jsdom": "^30.5.1",
|
||||
"jest-html-reporter": "^4.4.0",
|
||||
"jest-websocket-mock": "^2.5.0",
|
||||
"js-yaml-loader": "^1.2.2",
|
||||
|
||||
@@ -113,8 +113,19 @@ export interface BackendOwnState {
|
||||
* Each chart plugin can implement this to convert its internal state representation
|
||||
* to the standardized backend format.
|
||||
*/
|
||||
export interface ChartStateConverterOptions {
|
||||
// Set when converting for a download/export query rather than the chart's
|
||||
// live (re-)query. Some chart-specific state (e.g. AG Grid's client-side
|
||||
// sort/filter) is normally excluded from the live query's ownState to
|
||||
// avoid triggering an unnecessary requery, but a downloaded file has no
|
||||
// client-side pass to apply that state, so it still needs to be converted
|
||||
// for exports to reproduce the displayed view.
|
||||
forExport?: boolean;
|
||||
}
|
||||
|
||||
export type ChartStateConverter<TChartState = JsonObject> = (
|
||||
chartState: TChartState,
|
||||
options?: ChartStateConverterOptions,
|
||||
) => Partial<BackendOwnState>;
|
||||
|
||||
export interface PlainObject {
|
||||
|
||||
@@ -222,6 +222,7 @@ export type {
|
||||
GridState,
|
||||
GridReadyEvent,
|
||||
CellClickedEvent,
|
||||
CellContextMenuEvent,
|
||||
CellKeyDownEvent,
|
||||
CellClassParams,
|
||||
IMenuActionParams,
|
||||
|
||||
@@ -20,6 +20,15 @@ import type { DataRecordValue } from '../query/types/QueryResponse';
|
||||
import type { TimeFormatFunction } from './types';
|
||||
import normalizeTimestamp from './utils/normalizeTimestamp';
|
||||
|
||||
/**
|
||||
* A missing date can arrive as either `null`/`undefined` or an empty string
|
||||
* (e.g. a blank cell in an otherwise-numeric epoch column, which also has the
|
||||
* side effect of degrading the whole column's formatter to `String` - see
|
||||
* `isNumeric` in transformProps.ts). Both should be treated as "no value".
|
||||
*/
|
||||
export const isEmptyDateInput = (input: DataRecordValue): boolean =>
|
||||
input === null || input === undefined || input === '';
|
||||
|
||||
/**
|
||||
* Extended Date object with a custom formatter, and retains the original input
|
||||
* when the formatter is simple `String(..)`.
|
||||
|
||||
@@ -19,7 +19,10 @@
|
||||
|
||||
export { default as TimeFormats, LOCAL_PREFIX } from './TimeFormats';
|
||||
export { default as TimeFormatter, PREVIEW_TIME } from './TimeFormatter';
|
||||
export { default as DateWithFormatter } from './DateWithFormatter';
|
||||
export {
|
||||
default as DateWithFormatter,
|
||||
isEmptyDateInput,
|
||||
} from './DateWithFormatter';
|
||||
export { DEFAULT_D3_TIME_FORMAT } from './D3FormatConfig';
|
||||
|
||||
export {
|
||||
|
||||
@@ -79,4 +79,5 @@ export interface AgGridChartState {
|
||||
columnOrder?: string[];
|
||||
pageSize?: number;
|
||||
currentPage?: number;
|
||||
serverPagination?: boolean;
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ import {
|
||||
GridReadyEvent,
|
||||
GridState,
|
||||
CellClickedEvent,
|
||||
CellContextMenuEvent,
|
||||
CellKeyDownEvent,
|
||||
SelectionChangedEvent,
|
||||
} from '@superset-ui/core/components/ThemedAgGridReact';
|
||||
@@ -59,9 +60,13 @@ import getInitialSortState, { shouldSort } from '../utils/getInitialSortState';
|
||||
import getInitialFilterModel from '../utils/getInitialFilterModel';
|
||||
import reconcileColumnState from '../utils/reconcileColumnState';
|
||||
import getColumnStateSignature from '../utils/getColumnStateSignature';
|
||||
import { PAGE_SIZE_OPTIONS } from '../consts';
|
||||
import { getCompleteFilterState } from '../utils/filterStateManager';
|
||||
import { PAGE_SIZE_OPTIONS, ROW_NUMBER_COL_ID } from '../consts';
|
||||
import {
|
||||
getCompleteFilterState,
|
||||
type FilterState,
|
||||
} from '../utils/filterStateManager';
|
||||
import { copyCellValueOnKeyDown } from '../utils/copyCellValue';
|
||||
import type { ClientViewSnapshot } from '../utils/externalAPIs';
|
||||
|
||||
export interface AgGridState extends Partial<GridState> {
|
||||
timestamp?: number;
|
||||
@@ -77,7 +82,6 @@ export type AgGridChartStateWithMetadata = Partial<AgGridChartState> & {
|
||||
export interface AgGridTableProps {
|
||||
gridTheme?: string;
|
||||
isDarkMode?: boolean;
|
||||
gridHeight?: number;
|
||||
updateInterval?: number;
|
||||
data?: any[];
|
||||
onGridReady?: (params: GridReadyEvent) => void;
|
||||
@@ -100,17 +104,20 @@ export interface AgGridTableProps {
|
||||
serverPageLength: number;
|
||||
hasServerPageLengthChanged: boolean;
|
||||
handleCellClicked: (event: CellClickedEvent) => void;
|
||||
handleCellContextMenu?: (event: CellContextMenuEvent) => void;
|
||||
handleSelectionChanged: (event: SelectionChangedEvent) => void;
|
||||
filters?: Record<string, DataRecordValue[]> | null;
|
||||
isActiveFilterValue?: (key: string, val: DataRecordValue) => boolean;
|
||||
renderTimeComparisonDropdown: () => JSX.Element | null;
|
||||
cleanedTotals: DataRecord;
|
||||
showTotals: boolean;
|
||||
width: number;
|
||||
onColumnStateChange?: (state: AgGridChartStateWithMetadata) => void;
|
||||
onFilterChanged?: (filterModel: Record<string, any>) => void;
|
||||
onFilterChanged?: (completeFilterState: FilterState) => void;
|
||||
metricColumns?: string[];
|
||||
gridRef?: RefObject<AgGridReact>;
|
||||
chartState?: AgGridChartState;
|
||||
onClientViewChange?: (snapshot: ClientViewSnapshot) => void;
|
||||
}
|
||||
|
||||
ModuleRegistry.registerModules([AllCommunityModule, ClientSideRowModelModule]);
|
||||
@@ -119,7 +126,6 @@ const isSearchFocused = new Map<string, boolean>();
|
||||
|
||||
const AgGridDataTable: FunctionComponent<AgGridTableProps> = memo(
|
||||
({
|
||||
gridHeight,
|
||||
data = [],
|
||||
colDefsFromProps,
|
||||
includeSearch,
|
||||
@@ -140,8 +146,10 @@ const AgGridDataTable: FunctionComponent<AgGridTableProps> = memo(
|
||||
serverPageLength,
|
||||
hasServerPageLengthChanged,
|
||||
handleCellClicked,
|
||||
handleCellContextMenu,
|
||||
handleSelectionChanged,
|
||||
filters,
|
||||
isActiveFilterValue,
|
||||
renderTimeComparisonDropdown,
|
||||
cleanedTotals,
|
||||
showTotals,
|
||||
@@ -150,12 +158,14 @@ const AgGridDataTable: FunctionComponent<AgGridTableProps> = memo(
|
||||
onFilterChanged,
|
||||
metricColumns = [],
|
||||
chartState,
|
||||
onClientViewChange,
|
||||
}) => {
|
||||
const gridRef = useRef<AgGridReact>(null);
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const rowData = useMemo(() => data, [data]);
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const lastCapturedStateRef = useRef<string | null>(null);
|
||||
const hasCapturedInitialGridStateRef = useRef(false);
|
||||
const filterOperationVersionRef = useRef(0);
|
||||
|
||||
const searchId = `search-${id}`;
|
||||
@@ -189,13 +199,26 @@ const AgGridDataTable: FunctionComponent<AgGridTableProps> = memo(
|
||||
[],
|
||||
);
|
||||
|
||||
// Memoize container style
|
||||
// Fills the full height allotted by the chart container (StyledChartContainer);
|
||||
// the search/time-comparison controls and pagination bar take their natural
|
||||
// height and the grid flexes into whatever space remains (see gridFlexStyles),
|
||||
// instead of a hardcoded pixel height that drifts from the actual chrome height.
|
||||
const containerStyles = useMemo(
|
||||
() => ({
|
||||
height: gridHeight,
|
||||
height: '100%',
|
||||
width,
|
||||
display: 'flex',
|
||||
flexDirection: 'column' as const,
|
||||
}),
|
||||
[gridHeight, width],
|
||||
[width],
|
||||
);
|
||||
|
||||
const gridFlexStyles = useMemo(
|
||||
() => ({
|
||||
flex: '1 1 auto',
|
||||
minHeight: 0,
|
||||
}),
|
||||
[],
|
||||
);
|
||||
|
||||
const [quickFilterText, setQuickFilterText] = useState<string>();
|
||||
@@ -293,6 +316,7 @@ const AgGridDataTable: FunctionComponent<AgGridTableProps> = memo(
|
||||
sortModel,
|
||||
filterModel,
|
||||
timestamp: Date.now(),
|
||||
serverPagination: true,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -321,49 +345,85 @@ const AgGridDataTable: FunctionComponent<AgGridTableProps> = memo(
|
||||
[serverPagination, gridInitialState, percentMetrics, onSortChange],
|
||||
);
|
||||
|
||||
const handleGridStateChange = useCallback(
|
||||
const captureGridState = useCallback(() => {
|
||||
const { api } = gridRef.current ?? {};
|
||||
if (!api) return null;
|
||||
|
||||
const columnState = api.getColumnState ? api.getColumnState() : [];
|
||||
const filterModel = api.getFilterModel ? api.getFilterModel() : {};
|
||||
const sortModel = columnState
|
||||
.filter(col => col.sort)
|
||||
.map(col => ({
|
||||
colId: col.colId,
|
||||
sort: col.sort as 'asc' | 'desc',
|
||||
sortIndex: col.sortIndex || 0,
|
||||
}))
|
||||
.sort((a, b) => (a.sortIndex || 0) - (b.sortIndex || 0));
|
||||
|
||||
return {
|
||||
stateToSave: {
|
||||
columnState,
|
||||
sortModel,
|
||||
filterModel,
|
||||
timestamp: Date.now(),
|
||||
serverPagination: !!serverPagination,
|
||||
},
|
||||
stateHash: getColumnStateSignature(columnState, sortModel, filterModel),
|
||||
};
|
||||
}, [serverPagination]);
|
||||
|
||||
const persistGridStateChange = useCallback(
|
||||
debounce(() => {
|
||||
if (onColumnStateChange && gridRef.current?.api) {
|
||||
try {
|
||||
const { api } = gridRef.current;
|
||||
if (!onColumnStateChange) return;
|
||||
try {
|
||||
const captured = captureGridState();
|
||||
if (!captured) return;
|
||||
const { stateToSave, stateHash } = captured;
|
||||
|
||||
const columnState = api.getColumnState ? api.getColumnState() : [];
|
||||
if (stateHash !== lastCapturedStateRef.current) {
|
||||
lastCapturedStateRef.current = stateHash;
|
||||
|
||||
const filterModel = api.getFilterModel ? api.getFilterModel() : {};
|
||||
|
||||
const sortModel = columnState
|
||||
.filter(col => col.sort)
|
||||
.map(col => ({
|
||||
colId: col.colId,
|
||||
sort: col.sort as 'asc' | 'desc',
|
||||
sortIndex: col.sortIndex || 0,
|
||||
}))
|
||||
.sort((a, b) => (a.sortIndex || 0) - (b.sortIndex || 0));
|
||||
|
||||
const stateToSave = {
|
||||
columnState,
|
||||
sortModel,
|
||||
filterModel,
|
||||
timestamp: Date.now(),
|
||||
};
|
||||
|
||||
const stateHash = getColumnStateSignature(
|
||||
columnState,
|
||||
sortModel,
|
||||
filterModel,
|
||||
);
|
||||
|
||||
if (stateHash !== lastCapturedStateRef.current) {
|
||||
lastCapturedStateRef.current = stateHash;
|
||||
|
||||
onColumnStateChange(stateToSave);
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('Error capturing AG Grid state:', error);
|
||||
onColumnStateChange(stateToSave);
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('Error capturing AG Grid state:', error);
|
||||
}
|
||||
}, Constants.SLOW_DEBOUNCE),
|
||||
[onColumnStateChange],
|
||||
[onColumnStateChange, captureGridState],
|
||||
);
|
||||
|
||||
const handleGridStateChange = useCallback(() => {
|
||||
// AG Grid fires onStateUpdated once as it applies the initial
|
||||
// column/sort/filter state on mount, before any user interaction.
|
||||
// That first event just reflects the state the grid was initialized
|
||||
// with (chartState/gridInitialState) - not a user-driven change - so
|
||||
// it's captured synchronously as the baseline rather than persisted.
|
||||
// This check runs on every raw call, before debouncing, so a real
|
||||
// user action that lands inside the same debounce window as this
|
||||
// first call is never coalesced into it and dropped.
|
||||
if (!hasCapturedInitialGridStateRef.current) {
|
||||
hasCapturedInitialGridStateRef.current = true;
|
||||
try {
|
||||
const captured = captureGridState();
|
||||
if (captured) {
|
||||
lastCapturedStateRef.current = captured.stateHash;
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('Error capturing AG Grid state:', error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
persistGridStateChange();
|
||||
}, [captureGridState, persistGridStateChange]);
|
||||
|
||||
useEffect(
|
||||
() =>
|
||||
// Cleanup debounced grid-state capture
|
||||
() => {
|
||||
persistGridStateChange.cancel();
|
||||
},
|
||||
[persistGridStateChange],
|
||||
);
|
||||
|
||||
const handleFilterChanged = useCallback(async () => {
|
||||
@@ -416,6 +476,81 @@ const AgGridDataTable: FunctionComponent<AgGridTableProps> = memo(
|
||||
serverPaginationData?.agGridFilterModel,
|
||||
]);
|
||||
|
||||
// Captures the "current view" (post-filter/sort, all rows across all
|
||||
// pages) for the "Export Current View" menu, mirroring Table V1's
|
||||
// clientView snapshot. Client-side mode only: in server pagination mode
|
||||
// the grid only ever holds a single page's rows, so a client-derived
|
||||
// snapshot can't represent the full filtered/sorted result and export
|
||||
// falls back to a fresh backend query instead (see useExploreAdditionalActionsMenu).
|
||||
const lastClientViewSignatureRef = useRef<string | null>(null);
|
||||
// Unlike handleGridStateChange's columnState/sortModel/filterModel,
|
||||
// clientView is excluded from ownState re-query comparisons on both the
|
||||
// Explore (ExploreViewContainer) and dashboard (activeAllDashboardFilters)
|
||||
// paths, so publishing it - including the very first snapshot right
|
||||
// after mount - can't trigger a requery/remount loop. It's therefore
|
||||
// always persisted below rather than having its initial value skipped;
|
||||
// skipping it would leave "Export Current View" without a snapshot to
|
||||
// export until some later grid event changes the signature.
|
||||
// Debounced (like handleGridStateChange below) because the full
|
||||
// filtered+sorted traversal is O(n) and onModelUpdated can fire rapidly
|
||||
// in succession (e.g. while typing into a quick filter); only the
|
||||
// trailing update needs to recompute the snapshot.
|
||||
const handleModelUpdated = useCallback(
|
||||
debounce(() => {
|
||||
if (serverPagination || !onClientViewChange || !gridRef.current?.api) {
|
||||
return;
|
||||
}
|
||||
const { api } = gridRef.current;
|
||||
const displayedColumns = api
|
||||
.getAllDisplayedColumns()
|
||||
.filter(column => column.getColId() !== ROW_NUMBER_COL_ID);
|
||||
const columns = displayedColumns.map(column => {
|
||||
const colDef = column.getColDef();
|
||||
// For comparison columns, colId has "Main " stripped for display,
|
||||
// but row data is still keyed by the unstripped original field
|
||||
// (colDef.context.dataKey, set in useColDefs) -- use that to read
|
||||
// row values so exported rows aren't blank for the main metric.
|
||||
const dataKey = colDef.context?.dataKey ?? column.getColId();
|
||||
return {
|
||||
key: dataKey,
|
||||
label: colDef.headerName || column.getColId(),
|
||||
};
|
||||
});
|
||||
|
||||
const rows: Record<string, unknown>[] = [];
|
||||
api.forEachNodeAfterFilterAndSort(node => {
|
||||
if (node.data) {
|
||||
rows.push(node.data);
|
||||
}
|
||||
});
|
||||
|
||||
// Without a getRowId callback, AG Grid's node ids are purely
|
||||
// positional and reset to 0..n-1 on every setRowData call, so they
|
||||
// don't identify a row's content across a data refresh — hashing
|
||||
// the actual filtered+sorted row content (which this function
|
||||
// already has to visit to build `rows`) is what actually detects
|
||||
// both value changes (e.g. a refresh with the same row count) and
|
||||
// order changes (e.g. a pure sort), not just count/column changes.
|
||||
const signature = `${JSON.stringify(rows)}|${columns.map(c => c.key).join(',')}`;
|
||||
|
||||
if (signature === lastClientViewSignatureRef.current) {
|
||||
return;
|
||||
}
|
||||
lastClientViewSignatureRef.current = signature;
|
||||
onClientViewChange({ rows, columns, count: rows.length });
|
||||
}, Constants.SLOW_DEBOUNCE),
|
||||
[serverPagination, onClientViewChange],
|
||||
);
|
||||
|
||||
useEffect(
|
||||
() =>
|
||||
// Cleanup debounced client-view snapshot capture
|
||||
() => {
|
||||
handleModelUpdated.cancel();
|
||||
},
|
||||
[handleModelUpdated],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
hasServerPageLengthChanged &&
|
||||
@@ -436,14 +571,32 @@ const AgGridDataTable: FunctionComponent<AgGridTableProps> = memo(
|
||||
}
|
||||
}, [width]);
|
||||
|
||||
// Row highlighting must reflect the active cross filter regardless of how
|
||||
// it was applied (cell click, context menu, or an external dashboard
|
||||
// filter), so it survives re-renders and server-side re-queries rather
|
||||
// than only reflecting whichever handler last called setSelected.
|
||||
useEffect(() => {
|
||||
if (
|
||||
(!filters || Object.keys(filters).length === 0) &&
|
||||
gridRef.current?.api?.getSelectedRows().length
|
||||
) {
|
||||
gridRef.current.api.deselectAll();
|
||||
const api = gridRef.current?.api;
|
||||
if (!api) return;
|
||||
|
||||
if (!filters || Object.keys(filters).length === 0) {
|
||||
if (api.getSelectedRows().length) {
|
||||
api.deselectAll();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}, [filters]);
|
||||
|
||||
if (!isActiveFilterValue) return;
|
||||
|
||||
api.forEachNode(node => {
|
||||
const matches = Object.keys(filters).some(key =>
|
||||
isActiveFilterValue(key, node.data?.[key] as DataRecordValue),
|
||||
);
|
||||
if (node.isSelected() !== matches) {
|
||||
node.setSelected(matches, false, 'api');
|
||||
}
|
||||
});
|
||||
}, [filters, isActiveFilterValue, rowData]);
|
||||
|
||||
const onGridReady = (params: GridReadyEvent) => {
|
||||
// This will make columns fill the grid width
|
||||
@@ -511,126 +664,130 @@ const AgGridDataTable: FunctionComponent<AgGridTableProps> = memo(
|
||||
)}
|
||||
</div>
|
||||
|
||||
<ThemedAgGridReact
|
||||
ref={gridRef}
|
||||
onGridReady={onGridReady}
|
||||
className="ag-container"
|
||||
rowData={rowData}
|
||||
headerHeight={36}
|
||||
rowHeight={30}
|
||||
columnDefs={colDefsFromProps}
|
||||
defaultColDef={defaultColDef}
|
||||
onColumnGroupOpened={params => params.api.sizeColumnsToFit()}
|
||||
rowSelection="multiple"
|
||||
animateRows
|
||||
onCellClicked={handleCellClicked}
|
||||
onCellKeyDown={handleCellKeyDown}
|
||||
onSelectionChanged={handleSelectionChanged}
|
||||
onFilterChanged={handleFilterChanged}
|
||||
onStateUpdated={handleGridStateChange}
|
||||
initialState={gridInitialState}
|
||||
maintainColumnOrder
|
||||
suppressAggFuncInHeader
|
||||
// Clicking a cell should select (focus) the cell rather than select
|
||||
// its text content (#106389). enableCellTextSelection forces browser
|
||||
// text selection on click, which suppresses the cell-focus behavior.
|
||||
// Because the Enterprise clipboard module isn't registered, native
|
||||
// text selection was the only way to copy a value, so onCellKeyDown
|
||||
// (above) restores Ctrl/Cmd+C copy for the focused cell. Full
|
||||
// multi-cell range selection still requires AG Grid Enterprise, which
|
||||
// is not available in the Community build used here.
|
||||
enableCellTextSelection={false}
|
||||
quickFilterText={serverPagination ? '' : quickFilterText}
|
||||
suppressMovableColumns={!allowRearrangeColumns}
|
||||
pagination={pagination}
|
||||
paginationPageSize={pageSize}
|
||||
paginationPageSizeSelector={PAGE_SIZE_OPTIONS}
|
||||
suppressDragLeaveHidesColumns
|
||||
pinnedBottomRowData={showTotals ? [cleanedTotals] : undefined}
|
||||
tooltipShowDelay={500}
|
||||
localeText={{
|
||||
// Pagination controls
|
||||
next: t('Next'),
|
||||
previous: t('Previous'),
|
||||
page: t('Page'),
|
||||
more: t('More'),
|
||||
to: t('to'),
|
||||
of: t('of'),
|
||||
first: t('First'),
|
||||
last: t('Last'),
|
||||
loadingOoo: t('Loading...'),
|
||||
// Set Filter
|
||||
selectAll: t('Select All'),
|
||||
searchOoo: t('Search...'),
|
||||
blanks: t('Blanks'),
|
||||
// Filter operations
|
||||
filterOoo: t('Filter'),
|
||||
applyFilter: t('Apply Filter'),
|
||||
equals: t('Equals'),
|
||||
notEqual: t('Not Equal'),
|
||||
lessThan: t('Less Than'),
|
||||
greaterThan: t('Greater Than'),
|
||||
lessThanOrEqual: t('Less Than or Equal'),
|
||||
greaterThanOrEqual: t('Greater Than or Equal'),
|
||||
inRange: t('In Range'),
|
||||
contains: t('Contains'),
|
||||
notContains: t('Not Contains'),
|
||||
startsWith: t('Starts With'),
|
||||
endsWith: t('Ends With'),
|
||||
// Logical conditions
|
||||
andCondition: t('AND'),
|
||||
orCondition: t('OR'),
|
||||
// Panel and group labels
|
||||
group: t('Group'),
|
||||
columns: t('Columns'),
|
||||
filters: t('Filters'),
|
||||
valueColumns: t('Value Columns'),
|
||||
pivotMode: t('Pivot Mode'),
|
||||
groups: t('Groups'),
|
||||
values: t('Values'),
|
||||
pivots: t('Pivots'),
|
||||
toolPanelButton: t('Tool Panel'),
|
||||
// Enterprise menu items
|
||||
pinColumn: t('Pin Column'),
|
||||
valueAggregation: t('Value Aggregation'),
|
||||
autosizeThiscolumn: t('Autosize This Column'),
|
||||
autosizeAllColumns: t('Autosize All Columns'),
|
||||
groupBy: t('Group By'),
|
||||
ungroupBy: t('Ungroup By'),
|
||||
resetColumns: t('Reset Columns'),
|
||||
expandAll: t('Expand All'),
|
||||
collapseAll: t('Collapse All'),
|
||||
toolPanel: t('Tool Panel'),
|
||||
export: t('Export'),
|
||||
csvExport: t('CSV Export'),
|
||||
excelExport: t('Excel Export'),
|
||||
excelXmlExport: t('Excel XML Export'),
|
||||
// Aggregation functions
|
||||
sum: t('Sum'),
|
||||
min: t('Min'),
|
||||
max: t('Max'),
|
||||
none: t('None'),
|
||||
count: t('Count'),
|
||||
average: t('Average'),
|
||||
// Standard menu items
|
||||
copy: t('Copy'),
|
||||
copyWithHeaders: t('Copy with Headers'),
|
||||
paste: t('Paste'),
|
||||
// Column menu and sorting
|
||||
sortAscending: t('Sort Ascending'),
|
||||
sortDescending: t('Sort Descending'),
|
||||
sortUnSort: t('Clear Sort'),
|
||||
}}
|
||||
context={{
|
||||
onColumnHeaderClicked: handleColumnHeaderClick,
|
||||
initialSortState: getInitialSortState(
|
||||
serverPaginationData?.sortBy || [],
|
||||
),
|
||||
lastFilteredColumn: serverPaginationData?.lastFilteredColumn,
|
||||
lastFilteredInputPosition:
|
||||
serverPaginationData?.lastFilteredInputPosition,
|
||||
}}
|
||||
/>
|
||||
<div style={gridFlexStyles}>
|
||||
<ThemedAgGridReact
|
||||
ref={gridRef}
|
||||
onGridReady={onGridReady}
|
||||
className="ag-container"
|
||||
rowData={rowData}
|
||||
headerHeight={36}
|
||||
rowHeight={30}
|
||||
columnDefs={colDefsFromProps}
|
||||
defaultColDef={defaultColDef}
|
||||
onColumnGroupOpened={params => params.api.sizeColumnsToFit()}
|
||||
rowSelection="multiple"
|
||||
animateRows
|
||||
onCellClicked={handleCellClicked}
|
||||
onCellContextMenu={handleCellContextMenu}
|
||||
onCellKeyDown={handleCellKeyDown}
|
||||
onSelectionChanged={handleSelectionChanged}
|
||||
onFilterChanged={handleFilterChanged}
|
||||
onModelUpdated={handleModelUpdated}
|
||||
onStateUpdated={handleGridStateChange}
|
||||
initialState={gridInitialState}
|
||||
maintainColumnOrder
|
||||
suppressAggFuncInHeader
|
||||
// Clicking a cell should select (focus) the cell rather than select
|
||||
// its text content (#106389). enableCellTextSelection forces browser
|
||||
// text selection on click, which suppresses the cell-focus behavior.
|
||||
// Because the Enterprise clipboard module isn't registered, native
|
||||
// text selection was the only way to copy a value, so onCellKeyDown
|
||||
// (above) restores Ctrl/Cmd+C copy for the focused cell. Full
|
||||
// multi-cell range selection still requires AG Grid Enterprise, which
|
||||
// is not available in the Community build used here.
|
||||
enableCellTextSelection={false}
|
||||
quickFilterText={serverPagination ? '' : quickFilterText}
|
||||
suppressMovableColumns={!allowRearrangeColumns}
|
||||
pagination={pagination}
|
||||
paginationPageSize={pageSize}
|
||||
paginationPageSizeSelector={PAGE_SIZE_OPTIONS}
|
||||
suppressDragLeaveHidesColumns
|
||||
pinnedBottomRowData={showTotals ? [cleanedTotals] : undefined}
|
||||
tooltipShowDelay={500}
|
||||
localeText={{
|
||||
// Pagination controls
|
||||
next: t('Next'),
|
||||
previous: t('Previous'),
|
||||
page: t('Page'),
|
||||
more: t('More'),
|
||||
to: t('to'),
|
||||
of: t('of'),
|
||||
first: t('First'),
|
||||
last: t('Last'),
|
||||
loadingOoo: t('Loading...'),
|
||||
// Set Filter
|
||||
selectAll: t('Select All'),
|
||||
searchOoo: t('Search...'),
|
||||
blanks: t('Blanks'),
|
||||
// Filter operations
|
||||
filterOoo: t('Filter'),
|
||||
applyFilter: t('Apply Filter'),
|
||||
equals: t('Equals'),
|
||||
notEqual: t('Not Equal'),
|
||||
lessThan: t('Less Than'),
|
||||
greaterThan: t('Greater Than'),
|
||||
lessThanOrEqual: t('Less Than or Equal'),
|
||||
greaterThanOrEqual: t('Greater Than or Equal'),
|
||||
inRange: t('In Range'),
|
||||
contains: t('Contains'),
|
||||
notContains: t('Not Contains'),
|
||||
startsWith: t('Starts With'),
|
||||
endsWith: t('Ends With'),
|
||||
// Logical conditions
|
||||
andCondition: t('AND'),
|
||||
orCondition: t('OR'),
|
||||
// Panel and group labels
|
||||
group: t('Group'),
|
||||
columns: t('Columns'),
|
||||
filters: t('Filters'),
|
||||
valueColumns: t('Value Columns'),
|
||||
pivotMode: t('Pivot Mode'),
|
||||
groups: t('Groups'),
|
||||
values: t('Values'),
|
||||
pivots: t('Pivots'),
|
||||
toolPanelButton: t('Tool Panel'),
|
||||
// Enterprise menu items
|
||||
pinColumn: t('Pin Column'),
|
||||
valueAggregation: t('Value Aggregation'),
|
||||
autosizeThiscolumn: t('Autosize This Column'),
|
||||
autosizeAllColumns: t('Autosize All Columns'),
|
||||
groupBy: t('Group By'),
|
||||
ungroupBy: t('Ungroup By'),
|
||||
resetColumns: t('Reset Columns'),
|
||||
expandAll: t('Expand All'),
|
||||
collapseAll: t('Collapse All'),
|
||||
toolPanel: t('Tool Panel'),
|
||||
export: t('Export'),
|
||||
csvExport: t('CSV Export'),
|
||||
excelExport: t('Excel Export'),
|
||||
excelXmlExport: t('Excel XML Export'),
|
||||
// Aggregation functions
|
||||
sum: t('Sum'),
|
||||
min: t('Min'),
|
||||
max: t('Max'),
|
||||
none: t('None'),
|
||||
count: t('Count'),
|
||||
average: t('Average'),
|
||||
// Standard menu items
|
||||
copy: t('Copy'),
|
||||
copyWithHeaders: t('Copy with Headers'),
|
||||
paste: t('Paste'),
|
||||
// Column menu and sorting
|
||||
sortAscending: t('Sort Ascending'),
|
||||
sortDescending: t('Sort Descending'),
|
||||
sortUnSort: t('Clear Sort'),
|
||||
}}
|
||||
context={{
|
||||
onColumnHeaderClicked: handleColumnHeaderClick,
|
||||
initialSortState: getInitialSortState(
|
||||
serverPaginationData?.sortBy || [],
|
||||
),
|
||||
lastFilteredColumn: serverPaginationData?.lastFilteredColumn,
|
||||
lastFilteredInputPosition:
|
||||
serverPaginationData?.lastFilteredInputPosition,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{serverPagination && (
|
||||
<Pagination
|
||||
currentPage={serverPaginationData?.currentPage || 0}
|
||||
|
||||
@@ -18,16 +18,28 @@
|
||||
*/
|
||||
import { t } from '@apache-superset/core/translation';
|
||||
import {
|
||||
BinaryQueryObjectFilterClause,
|
||||
DataRecord,
|
||||
DataRecordValue,
|
||||
DateWithFormatter,
|
||||
extractTextFromHTML,
|
||||
getTimeFormatterForGranularity,
|
||||
isEmptyDateInput,
|
||||
} from '@superset-ui/core';
|
||||
import { GenericDataType } from '@apache-superset/core/common';
|
||||
import { useCallback, useEffect, useRef, useState, useMemo } from 'react';
|
||||
import { isEqual } from 'lodash-es';
|
||||
import {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useRef,
|
||||
useState,
|
||||
useMemo,
|
||||
} from 'react';
|
||||
import { debounce, isEqual } from 'lodash-es';
|
||||
|
||||
import {
|
||||
CellClickedEvent,
|
||||
CellContextMenuEvent,
|
||||
SelectionChangedEvent,
|
||||
} from '@superset-ui/core/components/ThemedAgGridReact';
|
||||
import {
|
||||
@@ -37,20 +49,18 @@ import {
|
||||
SortByItem,
|
||||
} from './types';
|
||||
import AgGridDataTable from './AgGridTable';
|
||||
import { updateTableOwnState } from './utils/externalAPIs';
|
||||
import { updateTableOwnState, ClientViewSnapshot } from './utils/externalAPIs';
|
||||
import TimeComparisonVisibility from './AgGridTable/components/TimeComparisonVisibility';
|
||||
import { useColDefs } from './utils/useColDefs';
|
||||
import { buildSelectionCrossFilterDataMask } from './utils/getCrossFilterDataMask';
|
||||
import {
|
||||
buildSelectionCrossFilterDataMask,
|
||||
getCrossFilterDataMask,
|
||||
} from './utils/getCrossFilterDataMask';
|
||||
import { StyledChartContainer } from './styles';
|
||||
import type { FilterState } from './utils/filterStateManager';
|
||||
|
||||
const getGridHeight = (height: number, includeSearch: boolean | undefined) => {
|
||||
let calculatedGridHeight = height;
|
||||
if (includeSearch) {
|
||||
calculatedGridHeight -= 16;
|
||||
}
|
||||
return calculatedGridHeight - 80;
|
||||
};
|
||||
import { formatColumnValue } from './utils/formatValue';
|
||||
import getTimeRangeFromGranularity from './utils/getTimeRangeFromGranularity';
|
||||
import getScrollBarSize from './utils/getScrollBarSize';
|
||||
|
||||
export default function TableChart<D extends DataRecord = DataRecord>(
|
||||
props: AgGridTableChartTransformedProps<D> & {},
|
||||
@@ -61,6 +71,7 @@ export default function TableChart<D extends DataRecord = DataRecord>(
|
||||
data,
|
||||
includeSearch,
|
||||
allowRearrangeColumns,
|
||||
allowRenderHtml,
|
||||
pageSize,
|
||||
serverPagination,
|
||||
rowCount,
|
||||
@@ -88,8 +99,60 @@ export default function TableChart<D extends DataRecord = DataRecord>(
|
||||
metricSqlExpressions,
|
||||
rawSummaryColumns,
|
||||
showNumberedColumn,
|
||||
onContextMenu,
|
||||
formData,
|
||||
} = props;
|
||||
|
||||
// The dashboard's layout engine reports a burst of close-but-not-identical
|
||||
// width/height values while it settles on initial load. Committing each
|
||||
// intermediate value resizes the chart container and re-fits AG Grid's
|
||||
// columns once per value; for any column with wrapText/autoHeight (the
|
||||
// default - see useColDefs), each re-fit can flip a borderline cell across
|
||||
// its wrap boundary and change that row's height, which is what actually
|
||||
// reads as "flicker" rather than the container resize itself.
|
||||
//
|
||||
// A scrollbar-sized threshold (matching plugin-chart-table/v1's guard)
|
||||
// filters out sub-pixel noise, but genuine multi-step settling still gets
|
||||
// through as several real width values in quick succession. Debouncing
|
||||
// every commit after the first collapses that burst into the single final
|
||||
// value once it stops changing, while still painting the first available
|
||||
// size immediately so the chart isn't blank while it waits.
|
||||
const [tableSize, setTableSize] = useState({ width: 0, height: 0 });
|
||||
const hasCommittedInitialSize = useRef(false);
|
||||
|
||||
const debouncedSetTableSize = useMemo(
|
||||
() =>
|
||||
debounce((size: { width: number; height: number }) => {
|
||||
setTableSize(size);
|
||||
}, 250),
|
||||
[],
|
||||
);
|
||||
|
||||
useEffect(
|
||||
() =>
|
||||
// Cleanup debounced size commit
|
||||
() => {
|
||||
debouncedSetTableSize.cancel();
|
||||
},
|
||||
[debouncedSetTableSize],
|
||||
);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const scrollBarSize = getScrollBarSize();
|
||||
const sizeChanged =
|
||||
Math.abs(width - tableSize.width) > scrollBarSize ||
|
||||
Math.abs(height - tableSize.height) > scrollBarSize;
|
||||
if (!sizeChanged) {
|
||||
return;
|
||||
}
|
||||
if (!hasCommittedInitialSize.current) {
|
||||
hasCommittedInitialSize.current = true;
|
||||
setTableSize({ width, height });
|
||||
} else {
|
||||
debouncedSetTableSize({ width, height });
|
||||
}
|
||||
}, [width, height, tableSize, debouncedSetTableSize]);
|
||||
|
||||
const [searchOptions, setSearchOptions] = useState<SearchOption[]>([]);
|
||||
|
||||
// Extract metric column names for SQL conversion
|
||||
@@ -114,6 +177,27 @@ export default function TableChart<D extends DataRecord = DataRecord>(
|
||||
}
|
||||
}, [columns]);
|
||||
|
||||
// Tracks the most recently written ownState so that writes triggered
|
||||
// asynchronously (e.g. clientView from AG Grid's onModelUpdated, which can
|
||||
// fire with a stale closure) merge onto the latest known state instead of
|
||||
// a stale render-time serverPaginationData snapshot. updateTableOwnState
|
||||
// replaces ownState wholesale, so merging at write time - rather than at
|
||||
// render time - is what keeps concurrent writers from clobbering one
|
||||
// another's keys.
|
||||
const ownStateRef = useRef(serverPaginationData);
|
||||
useEffect(() => {
|
||||
ownStateRef.current = serverPaginationData;
|
||||
}, [serverPaginationData]);
|
||||
|
||||
const writeOwnState = useCallback(
|
||||
(patch: Record<string, unknown>) => {
|
||||
const nextOwnState = { ...ownStateRef.current, ...patch };
|
||||
ownStateRef.current = nextOwnState;
|
||||
updateTableOwnState(setDataMask, nextOwnState);
|
||||
},
|
||||
[setDataMask],
|
||||
);
|
||||
|
||||
// A single effect owns every ownState write derived from render state.
|
||||
// updateTableOwnState replaces ownState wholesale, so separate effects that
|
||||
// each spread serverPaginationData in the same render would clobber one
|
||||
@@ -121,7 +205,7 @@ export default function TableChart<D extends DataRecord = DataRecord>(
|
||||
// columns and nudging a re-query for missing totals must be one combined
|
||||
// delta.
|
||||
useEffect(() => {
|
||||
const nextOwnState = { ...serverPaginationData };
|
||||
const patch: Record<string, unknown> = {};
|
||||
let changed = false;
|
||||
|
||||
if (serverPagination && serverPaginationData && rowCount !== undefined) {
|
||||
@@ -132,7 +216,7 @@ export default function TableChart<D extends DataRecord = DataRecord>(
|
||||
// last remaining page.
|
||||
const clampedPage = Math.max(0, Math.min(currentPage, totalPages - 1));
|
||||
if (clampedPage !== currentPage) {
|
||||
nextOwnState.currentPage = clampedPage;
|
||||
patch.currentPage = clampedPage;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
@@ -140,22 +224,22 @@ export default function TableChart<D extends DataRecord = DataRecord>(
|
||||
const primed = (serverPaginationData?.rawSummaryColumns ?? []) as string[];
|
||||
const requested = Boolean(serverPaginationData?.totalsRequested);
|
||||
if (isRawRecords && showTotals && !isEqual(primed, rawSummaryColumns)) {
|
||||
nextOwnState.rawSummaryColumns = rawSummaryColumns;
|
||||
patch.rawSummaryColumns = rawSummaryColumns;
|
||||
changed = true;
|
||||
}
|
||||
// A renderTrigger toggle re-renders without re-querying; requesting totals
|
||||
// through ownState dispatches the standard re-query whose buildQuery
|
||||
// carries the totals query for the active mode.
|
||||
if (showTotals && totals === undefined && !requested) {
|
||||
nextOwnState.totalsRequested = true;
|
||||
patch.totalsRequested = true;
|
||||
changed = true;
|
||||
} else if (!showTotals && requested) {
|
||||
nextOwnState.totalsRequested = false;
|
||||
patch.totalsRequested = false;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
updateTableOwnState(setDataMask, nextOwnState);
|
||||
writeOwnState(patch);
|
||||
}
|
||||
}, [
|
||||
serverPagination,
|
||||
@@ -166,7 +250,7 @@ export default function TableChart<D extends DataRecord = DataRecord>(
|
||||
totals,
|
||||
rawSummaryColumns,
|
||||
serverPaginationData,
|
||||
setDataMask,
|
||||
writeOwnState,
|
||||
]);
|
||||
|
||||
const comparisonColumns = [
|
||||
@@ -209,8 +293,7 @@ export default function TableChart<D extends DataRecord = DataRecord>(
|
||||
}
|
||||
|
||||
// Prepare modified own state for server pagination
|
||||
const modifiedOwnState = {
|
||||
...serverPaginationData,
|
||||
writeOwnState({
|
||||
agGridFilterModel:
|
||||
completeFilterState.originalFilterModel &&
|
||||
Object.keys(completeFilterState.originalFilterModel).length > 0
|
||||
@@ -223,14 +306,11 @@ export default function TableChart<D extends DataRecord = DataRecord>(
|
||||
lastFilteredInputPosition: completeFilterState.inputPosition,
|
||||
currentPage: 0, // Reset to first page when filtering
|
||||
metricSqlExpressions,
|
||||
};
|
||||
|
||||
updateTableOwnState(setDataMask, modifiedOwnState);
|
||||
});
|
||||
},
|
||||
[
|
||||
setDataMask,
|
||||
writeOwnState,
|
||||
serverPagination,
|
||||
serverPaginationData,
|
||||
onChartStateChange,
|
||||
chartState,
|
||||
metricSqlExpressions,
|
||||
@@ -273,15 +353,17 @@ export default function TableChart<D extends DataRecord = DataRecord>(
|
||||
colorPositiveNegative,
|
||||
columnColorFormatters,
|
||||
allowRearrangeColumns,
|
||||
allowRenderHtml,
|
||||
basicColorFormatters,
|
||||
isUsingTimeComparison,
|
||||
emitCrossFilters,
|
||||
alignPositiveNegative,
|
||||
slice_id,
|
||||
conditionalFormatting: formData?.conditional_formatting,
|
||||
comparisonColorEnabled: formData?.comparison_color_enabled,
|
||||
comparisonColorScheme: formData?.comparison_color_scheme,
|
||||
});
|
||||
|
||||
const gridHeight = getGridHeight(height, includeSearch);
|
||||
|
||||
const isActiveFilterValue = useCallback(
|
||||
function isActiveFilterValue(key: string, val: DataRecordValue) {
|
||||
if (!filters || !filters[key]) return false;
|
||||
@@ -348,7 +430,17 @@ export default function TableChart<D extends DataRecord = DataRecord>(
|
||||
|
||||
const handleSelectionChanged = useCallback(
|
||||
(event: SelectionChangedEvent) => {
|
||||
if (!emitCrossFilters || !activeColumnRef.current) return;
|
||||
// Selection changes triggered by the highlight-sync effect (source
|
||||
// 'api') reflect a filter that was already applied elsewhere (context
|
||||
// menu, dashboard filter, etc.), so re-deriving and re-dispatching a
|
||||
// mask from them here would use a stale activeColumnRef and could
|
||||
// clobber that filter with the wrong column.
|
||||
if (
|
||||
!emitCrossFilters ||
|
||||
!activeColumnRef.current ||
|
||||
event.source === 'api'
|
||||
)
|
||||
return;
|
||||
|
||||
const key = activeColumnRef.current;
|
||||
const selectedRows = event.api.getSelectedRows();
|
||||
@@ -368,75 +460,204 @@ export default function TableChart<D extends DataRecord = DataRecord>(
|
||||
[emitCrossFilters, setDataMask, timeGrain, timestampFormatter],
|
||||
);
|
||||
|
||||
const drillColumns = isUsingTimeComparison
|
||||
? (filteredColumns as InputColumn[])
|
||||
: (columns as InputColumn[]);
|
||||
|
||||
const handleContextMenu = useCallback(
|
||||
(event: CellContextMenuEvent) => {
|
||||
if (!onContextMenu || isRawRecords || !event.column || !event.data) {
|
||||
return;
|
||||
}
|
||||
const nativeEvent = event.event as MouseEvent | null | undefined;
|
||||
if (!nativeEvent) return;
|
||||
nativeEvent.preventDefault();
|
||||
nativeEvent.stopPropagation();
|
||||
|
||||
const rowData = event.data as Record<string, DataRecordValue>;
|
||||
const key = event.column.getColId();
|
||||
const cellValue = event.value as DataRecordValue;
|
||||
const colDef = event.column.getColDef();
|
||||
const isMetric = Boolean(
|
||||
colDef.context?.isMetric || colDef.context?.isPercentMetric,
|
||||
);
|
||||
|
||||
const drillToDetailFilters: BinaryQueryObjectFilterClause[] = [];
|
||||
drillColumns.forEach(col => {
|
||||
if (col.isMetric || col.isPercentMetric) return;
|
||||
const dataRecordValue = rowData[col.key];
|
||||
|
||||
if (
|
||||
dataRecordValue == null ||
|
||||
(dataRecordValue instanceof DateWithFormatter &&
|
||||
isEmptyDateInput(dataRecordValue.input))
|
||||
) {
|
||||
drillToDetailFilters.push({
|
||||
col: col.key,
|
||||
op: 'IS NULL' as any,
|
||||
val: null,
|
||||
});
|
||||
} else if (col.dataType === GenericDataType.Temporal && timeGrain) {
|
||||
const startTime =
|
||||
dataRecordValue instanceof Date
|
||||
? dataRecordValue
|
||||
: new Date(dataRecordValue as string | number);
|
||||
|
||||
if (Number.isNaN(startTime.getTime())) {
|
||||
// Malformed temporal value: fall back to an equality filter
|
||||
// instead of building a TEMPORAL_RANGE, since toISOString()
|
||||
// throws on an Invalid Date and would crash the context menu.
|
||||
const sanitizedValue = extractTextFromHTML(dataRecordValue);
|
||||
drillToDetailFilters.push({
|
||||
col: col.key,
|
||||
op: '==',
|
||||
val: sanitizedValue as string | number | boolean,
|
||||
formattedVal: formatColumnValue(col, sanitizedValue)[1],
|
||||
});
|
||||
} else {
|
||||
const [rangeStartTime, rangeEndTime] = getTimeRangeFromGranularity(
|
||||
startTime,
|
||||
timeGrain,
|
||||
);
|
||||
const timeRangeValue = `${rangeStartTime.toISOString()} : ${rangeEndTime.toISOString()}`;
|
||||
|
||||
drillToDetailFilters.push({
|
||||
col: col.key,
|
||||
op: 'TEMPORAL_RANGE',
|
||||
val: timeRangeValue,
|
||||
grain: timeGrain,
|
||||
formattedVal: formatColumnValue(col, dataRecordValue)[1],
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const sanitizedValue = extractTextFromHTML(dataRecordValue);
|
||||
drillToDetailFilters.push({
|
||||
col: col.key,
|
||||
op: '==',
|
||||
val: sanitizedValue as string | number | boolean,
|
||||
formattedVal: formatColumnValue(col, sanitizedValue)[1],
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
const isCellValueNull =
|
||||
cellValue == null ||
|
||||
(cellValue instanceof DateWithFormatter &&
|
||||
isEmptyDateInput(cellValue.input));
|
||||
|
||||
onContextMenu(nativeEvent.clientX, nativeEvent.clientY, {
|
||||
drillToDetail: drillToDetailFilters,
|
||||
crossFilter: isMetric
|
||||
? undefined
|
||||
: getCrossFilterDataMask({
|
||||
key,
|
||||
value: cellValue,
|
||||
filters,
|
||||
timeGrain,
|
||||
isActiveFilterValue,
|
||||
timestampFormatter,
|
||||
}),
|
||||
drillBy: isMetric
|
||||
? undefined
|
||||
: {
|
||||
filters: [
|
||||
isCellValueNull
|
||||
? { col: key, op: 'IS NULL' as any, val: null }
|
||||
: {
|
||||
col: key,
|
||||
op: '==' as any,
|
||||
val: extractTextFromHTML(cellValue),
|
||||
},
|
||||
],
|
||||
groupbyFieldName: 'groupby',
|
||||
},
|
||||
});
|
||||
},
|
||||
[
|
||||
onContextMenu,
|
||||
isRawRecords,
|
||||
drillColumns,
|
||||
timeGrain,
|
||||
filters,
|
||||
isActiveFilterValue,
|
||||
timestampFormatter,
|
||||
],
|
||||
);
|
||||
|
||||
const handleServerPaginationChange = useCallback(
|
||||
(pageNumber: number, pageSize: number) => {
|
||||
const modifiedOwnState = {
|
||||
...serverPaginationData,
|
||||
writeOwnState({
|
||||
currentPage: pageNumber,
|
||||
pageSize,
|
||||
lastFilteredColumn: undefined,
|
||||
lastFilteredInputPosition: undefined,
|
||||
};
|
||||
updateTableOwnState(setDataMask, modifiedOwnState);
|
||||
});
|
||||
},
|
||||
[setDataMask],
|
||||
[writeOwnState],
|
||||
);
|
||||
|
||||
const handlePageSizeChange = useCallback(
|
||||
(pageSize: number) => {
|
||||
const modifiedOwnState = {
|
||||
...serverPaginationData,
|
||||
writeOwnState({
|
||||
currentPage: 0,
|
||||
pageSize,
|
||||
lastFilteredColumn: undefined,
|
||||
lastFilteredInputPosition: undefined,
|
||||
};
|
||||
updateTableOwnState(setDataMask, modifiedOwnState);
|
||||
});
|
||||
},
|
||||
[setDataMask],
|
||||
[writeOwnState],
|
||||
);
|
||||
|
||||
const handleChangeSearchCol = (searchCol: string) => {
|
||||
if (!isEqual(searchCol, serverPaginationData?.searchColumn)) {
|
||||
const modifiedOwnState = {
|
||||
...serverPaginationData,
|
||||
if (!isEqual(searchCol, ownStateRef.current?.searchColumn)) {
|
||||
writeOwnState({
|
||||
searchColumn: searchCol,
|
||||
searchText: '',
|
||||
currentPage: 0, // Reset to first page when the search column changes
|
||||
lastFilteredColumn: undefined,
|
||||
lastFilteredInputPosition: undefined,
|
||||
};
|
||||
updateTableOwnState(setDataMask, modifiedOwnState);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleSearch = useCallback(
|
||||
(searchText: string) => {
|
||||
const modifiedOwnState = {
|
||||
...serverPaginationData,
|
||||
writeOwnState({
|
||||
searchColumn:
|
||||
serverPaginationData?.searchColumn || searchOptions[0]?.value,
|
||||
(ownStateRef.current?.searchColumn as string | undefined) ||
|
||||
searchOptions[0]?.value,
|
||||
searchText,
|
||||
currentPage: 0, // Reset to first page when searching
|
||||
lastFilteredColumn: undefined,
|
||||
lastFilteredInputPosition: undefined,
|
||||
};
|
||||
updateTableOwnState(setDataMask, modifiedOwnState);
|
||||
});
|
||||
},
|
||||
[setDataMask, searchOptions],
|
||||
[writeOwnState, searchOptions],
|
||||
);
|
||||
|
||||
const handleSortByChange = useCallback(
|
||||
(sortBy: SortByItem[]) => {
|
||||
if (!serverPagination) return;
|
||||
const modifiedOwnState = {
|
||||
...serverPaginationData,
|
||||
writeOwnState({
|
||||
sortBy,
|
||||
lastFilteredColumn: undefined,
|
||||
lastFilteredInputPosition: undefined,
|
||||
};
|
||||
updateTableOwnState(setDataMask, modifiedOwnState);
|
||||
});
|
||||
},
|
||||
[setDataMask, serverPagination],
|
||||
[writeOwnState, serverPagination],
|
||||
);
|
||||
|
||||
// Feeds the "Export Current View" menu item (EXPORT_CURRENT_VIEW behavior),
|
||||
// mirroring Table V1's clientView snapshot on ownState. Written through
|
||||
// writeOwnState (rather than spreading serverPaginationData directly)
|
||||
// because onModelUpdated can fire with a stale closure relative to other
|
||||
// ownState writers (e.g. a just-applied filter), and updateTableOwnState
|
||||
// replaces ownState wholesale.
|
||||
const handleClientViewChange = useCallback(
|
||||
(clientView: ClientViewSnapshot) => {
|
||||
writeOwnState({ clientView });
|
||||
},
|
||||
[writeOwnState],
|
||||
);
|
||||
|
||||
const renderTimeComparisonVisibility = (): JSX.Element => (
|
||||
@@ -455,9 +676,22 @@ export default function TableChart<D extends DataRecord = DataRecord>(
|
||||
.join('|');
|
||||
|
||||
return (
|
||||
<StyledChartContainer height={height}>
|
||||
<StyledChartContainer
|
||||
height={tableSize.height}
|
||||
onContextMenu={event => {
|
||||
// Safety net: AG Grid only calls handleContextMenu (which calls
|
||||
// preventDefault) when it resolves the native contextmenu event to
|
||||
// a cell. If that per-cell resolution ever misses - e.g. a second,
|
||||
// near-duplicate contextmenu event dispatched in quick succession by
|
||||
// some mice's right-button switches - the event still bubbles
|
||||
// through this container, so the browser's native menu is
|
||||
// suppressed here regardless of whether AG Grid's own handler ran.
|
||||
if (!isRawRecords) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}}
|
||||
>
|
||||
<AgGridDataTable
|
||||
gridHeight={gridHeight}
|
||||
key={descriptionsKey}
|
||||
data={data || []}
|
||||
colDefsFromProps={colDefs}
|
||||
@@ -478,8 +712,10 @@ export default function TableChart<D extends DataRecord = DataRecord>(
|
||||
metricColumns={metricColumns}
|
||||
id={slice_id}
|
||||
handleCellClicked={handleCellClicked}
|
||||
handleCellContextMenu={handleContextMenu}
|
||||
handleSelectionChanged={handleSelectionChanged}
|
||||
filters={filters}
|
||||
isActiveFilterValue={isActiveFilterValue}
|
||||
percentMetrics={percentMetrics}
|
||||
serverPageLength={serverPageLength}
|
||||
hasServerPageLengthChanged={hasServerPageLengthChanged}
|
||||
@@ -490,9 +726,10 @@ export default function TableChart<D extends DataRecord = DataRecord>(
|
||||
showTotals={
|
||||
showTotals && totals !== undefined && Object.keys(totals).length > 0
|
||||
}
|
||||
width={width}
|
||||
width={tableSize.width}
|
||||
onColumnStateChange={handleColumnStateChange}
|
||||
chartState={chartState}
|
||||
onClientViewChange={handleClientViewChange}
|
||||
/>
|
||||
</StyledChartContainer>
|
||||
);
|
||||
|
||||
@@ -674,6 +674,29 @@ export const buildQueryUncached: BuildQuery<TableChartFormData> = (
|
||||
}
|
||||
}
|
||||
|
||||
// Build the "all records" percent-metric denominator query AFTER all
|
||||
// filter mutations (interactive group-by, search, AG Grid WHERE/HAVING)
|
||||
// above, so its denominator reflects the same filtered result set as the
|
||||
// main query instead of a stale pre-filter snapshot.
|
||||
const calculationMode = formData.percent_metric_calculation || 'row_limit';
|
||||
|
||||
if (
|
||||
calculationMode === 'all_records' &&
|
||||
percentMetrics &&
|
||||
percentMetrics.length > 0
|
||||
) {
|
||||
extraQueries.push({
|
||||
...queryObject,
|
||||
columns: [],
|
||||
metrics: percentMetrics,
|
||||
post_processing: [],
|
||||
row_limit: 0,
|
||||
row_offset: 0,
|
||||
orderby: [],
|
||||
is_timeseries: false,
|
||||
});
|
||||
}
|
||||
|
||||
// Create totals query AFTER all filters (including AG Grid filters) are applied
|
||||
// This ensures we can properly exclude AG Grid WHERE filters from the totals
|
||||
// In raw records mode the summary is a SUM over the numeric columns primed
|
||||
@@ -714,33 +737,21 @@ export const buildQueryUncached: BuildQuery<TableChartFormData> = (
|
||||
: undefined;
|
||||
|
||||
if (showAggregateTotals || rawSummaryColumns.length > 0) {
|
||||
// Create a copy of extras without the AG Grid WHERE clause
|
||||
// AG Grid filters in extras.where can reference calculated columns
|
||||
// which aren't available in the totals subquery
|
||||
const totalsExtras = { ...queryObject.extras };
|
||||
if (ownState.agGridComplexWhere) {
|
||||
// Remove AG Grid WHERE clause from totals query
|
||||
const whereClause = totalsExtras.where;
|
||||
if (whereClause) {
|
||||
// Remove the AG Grid filter part from the WHERE clause using string methods
|
||||
const agGridWhere = ownState.agGridComplexWhere;
|
||||
let newWhereClause = whereClause;
|
||||
|
||||
// Try to remove with " AND " before
|
||||
newWhereClause = newWhereClause.replace(` AND ${agGridWhere}`, '');
|
||||
// Try to remove with " AND " after
|
||||
newWhereClause = newWhereClause.replace(`${agGridWhere} AND `, '');
|
||||
// If it's the only clause, remove it entirely
|
||||
if (newWhereClause === agGridWhere) {
|
||||
newWhereClause = '';
|
||||
}
|
||||
|
||||
if (newWhereClause.trim()) {
|
||||
totalsExtras.where = newWhereClause;
|
||||
} else {
|
||||
delete totalsExtras.where;
|
||||
}
|
||||
}
|
||||
// Start from the original, pre-filter extras (captured before any
|
||||
// AG Grid WHERE/HAVING or download sqlClauses were merged in above)
|
||||
// rather than trying to subtract those fragments back out of the
|
||||
// now-combined `queryObject.extras` string. AG Grid filters can
|
||||
// reference calculated columns that aren't available once the
|
||||
// totals subquery drops all grouping columns (columns: []), and that
|
||||
// applies to HAVING just as much as WHERE, and to the download
|
||||
// sqlClauses path just as much as the live agGridComplexWhere path —
|
||||
// starting clean avoids having to special-case each source.
|
||||
const totalsExtras = { ...extras };
|
||||
if (!totalsExtras.where) {
|
||||
delete totalsExtras.where;
|
||||
}
|
||||
if (!totalsExtras.having) {
|
||||
delete totalsExtras.having;
|
||||
}
|
||||
|
||||
extraQueries.push({
|
||||
|
||||
@@ -39,6 +39,8 @@ import {
|
||||
shouldSkipMetricColumn,
|
||||
isRegularMetric,
|
||||
isPercentMetric,
|
||||
ConditionalFormattingConfig,
|
||||
ObjectFormattingEnum,
|
||||
ColorSchemeEnum,
|
||||
} from '@superset-ui/chart-controls';
|
||||
import { t } from '@apache-superset/core/translation';
|
||||
@@ -194,6 +196,23 @@ const percentMetricsControl: typeof sharedControls.metrics = {
|
||||
validators: [],
|
||||
};
|
||||
|
||||
const percentMetricCalculationControl: ControlConfig<'SelectControl'> = {
|
||||
type: 'SelectControl',
|
||||
label: t('Percentage metric calculation'),
|
||||
description: t(
|
||||
'Row Limit: percentages are calculated based on the subset of data retrieved, respecting the row limit. ' +
|
||||
'All Records: Percentages are calculated based on the total dataset, ignoring the row limit.',
|
||||
),
|
||||
default: 'row_limit',
|
||||
clearable: false,
|
||||
choices: [
|
||||
['row_limit', t('Row limit')],
|
||||
['all_records', t('All records')],
|
||||
],
|
||||
visibility: isAggMode,
|
||||
renderTrigger: false,
|
||||
};
|
||||
|
||||
/*
|
||||
Options for row limit control
|
||||
*/
|
||||
@@ -431,6 +450,12 @@ const config: ControlPanelConfig = {
|
||||
},
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
name: 'percent_metric_calculation',
|
||||
config: percentMetricCalculationControl,
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -481,6 +506,36 @@ const config: ControlPanelConfig = {
|
||||
},
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
name: 'allow_rearrange_columns',
|
||||
config: {
|
||||
type: 'CheckboxControl',
|
||||
label: t('Allow columns to be rearranged'),
|
||||
renderTrigger: true,
|
||||
default: false,
|
||||
description: t(
|
||||
"Allow end user to drag-and-drop column headers to rearrange them. Note their changes won't persist for the next time they open the chart.",
|
||||
),
|
||||
visibility: ({ controls }: ControlPanelsContainerProps) =>
|
||||
isEmpty(controls?.time_compare?.value),
|
||||
},
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
name: 'allow_render_html',
|
||||
config: {
|
||||
type: 'CheckboxControl',
|
||||
label: t('Render columns in HTML format'),
|
||||
renderTrigger: true,
|
||||
default: true,
|
||||
description: t(
|
||||
'Renders table cells as HTML when applicable. For example, HTML <a> tags will be rendered as hyperlinks.',
|
||||
),
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -573,11 +628,14 @@ const config: ControlPanelConfig = {
|
||||
const updatedColtypes: GenericDataType[] = [];
|
||||
|
||||
colnames
|
||||
.map(
|
||||
(colname, index) => [colname, index] as [string, number],
|
||||
)
|
||||
.filter(
|
||||
colname =>
|
||||
([colname]) =>
|
||||
last(colname.split('__')) !== timeComparisonValue,
|
||||
)
|
||||
.forEach((colname, index) => {
|
||||
.forEach(([colname, originalIndex]) => {
|
||||
if (
|
||||
shouldSkipMetricColumn({
|
||||
colname,
|
||||
@@ -614,7 +672,12 @@ const config: ControlPanelConfig = {
|
||||
});
|
||||
} else {
|
||||
updatedColnames.push(colname);
|
||||
updatedColtypes.push(coltypes[index]);
|
||||
// Look up by the column's original position in
|
||||
// colnames/coltypes, not its position after the
|
||||
// filter above — those diverge whenever any
|
||||
// earlier column is a comparison-suffixed one that
|
||||
// got filtered out.
|
||||
updatedColtypes.push(coltypes[originalIndex]);
|
||||
childColumnMap[colname] = false;
|
||||
timeComparisonColumnMap[colname] = false;
|
||||
}
|
||||
@@ -749,24 +812,71 @@ const config: ControlPanelConfig = {
|
||||
: [];
|
||||
|
||||
const chartStatus = chart?.chartStatus;
|
||||
// Normalize legacy `toAllRow`/`toTextColor` flags saved before
|
||||
// `columnFormatting`/`objectFormatting` existed, so "entire row"
|
||||
// formatters set under the old schema keep working.
|
||||
const value = _?.value ?? [];
|
||||
if (value && Array.isArray(value)) {
|
||||
value.forEach(
|
||||
(item: ConditionalFormattingConfig, index, array) => {
|
||||
if (
|
||||
item.colorScheme &&
|
||||
(typeof item.colorScheme !== 'string' ||
|
||||
!['Green', 'Red'].includes(item.colorScheme))
|
||||
) {
|
||||
if (item.columnFormatting === undefined) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
array[index] = {
|
||||
...item,
|
||||
...(item.toTextColor === true && {
|
||||
objectFormatting: ObjectFormattingEnum.TEXT_COLOR,
|
||||
}),
|
||||
...(item.toAllRow === true && {
|
||||
columnFormatting: ObjectFormattingEnum.ENTIRE_ROW,
|
||||
}),
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
const { colnames, coltypes } =
|
||||
chart?.queriesResponse?.[0] ?? {};
|
||||
const numericColumns =
|
||||
Array.isArray(colnames) && Array.isArray(coltypes)
|
||||
? colnames
|
||||
.filter(
|
||||
(colname: string, index: number) =>
|
||||
coltypes[index] === GenericDataType.Numeric,
|
||||
)
|
||||
.map((colname: string) => ({
|
||||
value: colname,
|
||||
label: Array.isArray(verboseMap)
|
||||
? colname
|
||||
: (verboseMap[colname] ?? colname),
|
||||
dataType:
|
||||
colnames && coltypes[colnames?.indexOf(colname)],
|
||||
}))
|
||||
: [];
|
||||
const hasColumns =
|
||||
Array.isArray(colnames) && Array.isArray(coltypes);
|
||||
const allColumns = hasColumns
|
||||
? [
|
||||
{
|
||||
value: ObjectFormattingEnum.ENTIRE_ROW,
|
||||
label: t('entire row'),
|
||||
dataType: GenericDataType.String,
|
||||
},
|
||||
...colnames.map((colname: string, index: number) => ({
|
||||
value: colname,
|
||||
label: Array.isArray(verboseMap)
|
||||
? colname
|
||||
: (verboseMap?.[colname] ?? colname),
|
||||
dataType: coltypes[index],
|
||||
})),
|
||||
]
|
||||
: [];
|
||||
const numericColumns = hasColumns
|
||||
? colnames
|
||||
.filter(
|
||||
(colname: string, index: number) =>
|
||||
coltypes[index] === GenericDataType.Numeric,
|
||||
)
|
||||
.map((colname: string) => ({
|
||||
value: colname,
|
||||
label: Array.isArray(verboseMap)
|
||||
? colname
|
||||
: (verboseMap?.[colname] ?? colname),
|
||||
// Every entry here already passed the Numeric filter
|
||||
// above, so the type is always Numeric — no need to
|
||||
// re-look it up (which breaks on duplicate colnames).
|
||||
dataType: GenericDataType.Numeric,
|
||||
}))
|
||||
: [];
|
||||
const columnOptions = hasTimeComparison
|
||||
? processComparisonColumns(
|
||||
numericColumns || [],
|
||||
@@ -778,6 +888,7 @@ const config: ControlPanelConfig = {
|
||||
removeIrrelevantConditions: chartStatus === 'success',
|
||||
columnOptions,
|
||||
verboseMap,
|
||||
allColumns,
|
||||
extraColorChoices,
|
||||
serverPagination: Boolean(
|
||||
explore?.controls?.server_pagination?.value,
|
||||
|
||||
@@ -44,6 +44,7 @@ const metadata = new ChartMetadata({
|
||||
Behavior.InteractiveChart,
|
||||
Behavior.DrillToDetail,
|
||||
Behavior.DrillBy,
|
||||
'EXPORT_CURRENT_VIEW' as Behavior,
|
||||
],
|
||||
category: t('Table'),
|
||||
canBeAnnotationTypes: ['EVENT', 'INTERVAL'],
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
import {
|
||||
BackendOwnState,
|
||||
ChartStateConverterOptions,
|
||||
QuerySortBy,
|
||||
type AgGridChartState,
|
||||
type AgGridSortModel,
|
||||
@@ -353,7 +354,24 @@ export function convertFilterModel(
|
||||
*/
|
||||
export function convertAgGridStateToOwnState(
|
||||
agGridState: AgGridChartState,
|
||||
options: ChartStateConverterOptions = {},
|
||||
): Partial<BackendOwnState> {
|
||||
// In client mode, AG Grid handles sort/filter/pagination locally, so for
|
||||
// the *live* query none of it needs to reach the backend -- folding it
|
||||
// into ownState there would only trigger an unnecessary requery/remount.
|
||||
// A *download* query has no client-side pass to apply that state though:
|
||||
// dashboard doesn't consume the Explore-only clientView snapshot, so
|
||||
// exports still need it converted to reproduce the displayed
|
||||
// sort/filter/columns (options.forExport).
|
||||
//
|
||||
// Only an explicit `false` is treated as "definitely client mode":
|
||||
// legacy persisted table_state/permalinks predate serverPagination and
|
||||
// have it `undefined`, and treating that the same as `false` would
|
||||
// silently drop their persisted server-side sort/filter on restore.
|
||||
if (agGridState.serverPagination === false && !options.forExport) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const ownState: Partial<BackendOwnState> = {};
|
||||
|
||||
const sortBy = convertSortModel(agGridState.sortModel);
|
||||
|
||||
@@ -184,6 +184,7 @@ export const PaginationContainer = styled.div`
|
||||
color: ${theme.colorTextBase};
|
||||
transform: translateY(-${theme.sizeUnit}px);
|
||||
background: ${theme.colorBgBase};
|
||||
flex-shrink: 0;
|
||||
`}
|
||||
`;
|
||||
|
||||
@@ -353,6 +354,7 @@ export const StyledChartContainer = styled.div<{
|
||||
.dropdown-controls-container {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.time-comparison-dropdown {
|
||||
|
||||
@@ -29,6 +29,7 @@ import {
|
||||
getNumberFormatter,
|
||||
getTimeFormatter,
|
||||
getTimeFormatterForGranularity,
|
||||
normalizeCurrency,
|
||||
NumberFormats,
|
||||
QueryMode,
|
||||
SMART_DATE_ID,
|
||||
@@ -60,7 +61,11 @@ const { DATABASE_DATETIME } = TimeFormats;
|
||||
|
||||
function isNumeric(key: string, data: DataRecord[] = []) {
|
||||
return data.every(
|
||||
x => x[key] === null || x[key] === undefined || typeof x[key] === 'number',
|
||||
x =>
|
||||
x[key] === null ||
|
||||
x[key] === undefined ||
|
||||
x[key] === '' ||
|
||||
typeof x[key] === 'number',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -168,7 +173,33 @@ const getComparisonColFormatter = (
|
||||
return formatter;
|
||||
};
|
||||
|
||||
const processComparisonDataRecords = memoizeOne(
|
||||
// transformProps is a single module-level function shared by every mounted
|
||||
// instance of this chart plugin on a dashboard (one plugin registration,
|
||||
// not one per chart). memoizeOne only remembers the single most-recent
|
||||
// call, so wrapping a function in it directly here means unrelated chart
|
||||
// instances evict each other's cached result whenever they render in the
|
||||
// same tick, forcing a full rebuild - with brand-new array/object
|
||||
// references - even when a given chart's own inputs are unchanged. AG
|
||||
// Grid treats a new colDefs identity as "columns changed" and re-measures
|
||||
// autoHeight/wrapText rows, which is what actually reads as a layout
|
||||
// flicker on a chart that never changed. Keying a separate memoized
|
||||
// function per chart id isolates each chart's cache from its siblings.
|
||||
function memoizePerChart<Args extends unknown[], R>(
|
||||
fn: (...args: Args) => R,
|
||||
isEqual?: (newArgs: Args, lastArgs: Args) => boolean,
|
||||
) {
|
||||
const memoizedByChart = new Map<number, (...args: Args) => R>();
|
||||
return (sliceId: number, ...args: Args): R => {
|
||||
let fnForChart = memoizedByChart.get(sliceId);
|
||||
if (!fnForChart) {
|
||||
fnForChart = isEqual ? memoizeOne(fn, isEqual) : memoizeOne(fn);
|
||||
memoizedByChart.set(sliceId, fnForChart);
|
||||
}
|
||||
return fnForChart(...args);
|
||||
};
|
||||
}
|
||||
|
||||
const processComparisonDataRecords = memoizePerChart(
|
||||
function processComparisonDataRecords(
|
||||
originalData: DataRecord[] | undefined,
|
||||
originalColumns: DataColumnMeta[],
|
||||
@@ -309,7 +340,7 @@ const processComparisonColumns = (
|
||||
|
||||
const serverPageLengthMap = new Map();
|
||||
|
||||
const processDataRecords = memoizeOne(function processDataRecords(
|
||||
const processDataRecords = memoizePerChart(function processDataRecords(
|
||||
data: DataRecord[] | undefined,
|
||||
columns: DataColumnMeta[],
|
||||
) {
|
||||
@@ -336,11 +367,16 @@ const processDataRecords = memoizeOne(function processDataRecords(
|
||||
return data;
|
||||
});
|
||||
|
||||
const processColumns = memoizeOne(function processColumns(
|
||||
const processColumns = memoizePerChart(function processColumns(
|
||||
props: TableChartProps,
|
||||
) {
|
||||
const {
|
||||
datasource: { columnFormats, currencyFormats, verboseMap },
|
||||
datasource: {
|
||||
columnFormats,
|
||||
currencyFormats,
|
||||
verboseMap,
|
||||
currencyCodeColumn,
|
||||
},
|
||||
rawFormData: {
|
||||
table_timestamp_format: tableTimestampFormat,
|
||||
metrics: metrics_,
|
||||
@@ -352,7 +388,12 @@ const processColumns = memoizeOne(function processColumns(
|
||||
queriesData,
|
||||
} = props;
|
||||
const granularity = extractTimegrain(props.rawFormData);
|
||||
const { data: records, colnames, coltypes } = queriesData[0] || {};
|
||||
const {
|
||||
data: records,
|
||||
colnames,
|
||||
coltypes,
|
||||
detected_currency: detectedCurrency,
|
||||
} = queriesData[0] || {};
|
||||
// convert `metrics` and `percentMetrics` to the key names in `data.records`
|
||||
const metrics = (metrics_ ?? []).map(getMetricLabel);
|
||||
const rawPercentMetrics = (percentMetrics_ ?? []).map(getMetricLabel);
|
||||
@@ -363,13 +404,18 @@ const processColumns = memoizeOne(function processColumns(
|
||||
const rawPercentMetricsSet = new Set(rawPercentMetrics);
|
||||
|
||||
const columns: DataColumnMeta[] = (colnames || [])
|
||||
.map((key: string, originalIndex: number) => ({ key, originalIndex }))
|
||||
.filter(
|
||||
key =>
|
||||
({ key }) =>
|
||||
// if a metric was only added to percent_metrics, they should not show up in the table.
|
||||
!(rawPercentMetricsSet.has(key) && !metricsSet.has(key)),
|
||||
)
|
||||
.map((key: string, i) => {
|
||||
const dataType = coltypes[i];
|
||||
.map(({ key, originalIndex }) => {
|
||||
// Look up by the column's original position in colnames/coltypes,
|
||||
// not its position after the filter above — those diverge whenever
|
||||
// an earlier column (e.g. a percent-metric-only one) got filtered
|
||||
// out, which would otherwise shift every later column's dataType.
|
||||
const dataType = coltypes[originalIndex];
|
||||
const config = columnConfig[key] || {};
|
||||
// for the purpose of presentation, only numeric values are treated as metrics
|
||||
// because users can also add things like `MAX(str_col)` as a metric.
|
||||
@@ -431,10 +477,25 @@ const processColumns = memoizeOne(function processColumns(
|
||||
// percent metrics have a default format
|
||||
formatter = getNumberFormatter(numberFormat || PERCENT_3_POINT);
|
||||
} else if (isMetric || (isNumber && (numberFormat || currency))) {
|
||||
formatter = currency?.symbol
|
||||
// Resolve AUTO currency when currency column isn't in query results
|
||||
let resolvedCurrency = currency;
|
||||
if (
|
||||
currency?.symbol === 'AUTO' &&
|
||||
detectedCurrency &&
|
||||
(!currencyCodeColumn || !colnames?.includes(currencyCodeColumn))
|
||||
) {
|
||||
const normalizedCurrency = normalizeCurrency(detectedCurrency);
|
||||
if (normalizedCurrency) {
|
||||
resolvedCurrency = {
|
||||
...currency,
|
||||
symbol: normalizedCurrency,
|
||||
};
|
||||
}
|
||||
}
|
||||
formatter = resolvedCurrency?.symbol
|
||||
? new CurrencyFormatter({
|
||||
d3Format: numberFormat,
|
||||
currency,
|
||||
currency: resolvedCurrency,
|
||||
})
|
||||
: getNumberFormatter(numberFormat);
|
||||
}
|
||||
@@ -448,6 +509,7 @@ const processColumns = memoizeOne(function processColumns(
|
||||
formatter,
|
||||
config,
|
||||
description,
|
||||
currencyCodeColumn,
|
||||
};
|
||||
})
|
||||
.sort((a, b) => {
|
||||
@@ -494,7 +556,7 @@ const transformProps = (
|
||||
queriesData = [],
|
||||
ownState: serverPaginationData,
|
||||
filterState,
|
||||
hooks: { setDataMask = () => {}, onChartStateChange },
|
||||
hooks: { setDataMask = () => {}, onChartStateChange, onContextMenu },
|
||||
emitCrossFilters,
|
||||
theme,
|
||||
} = chartProps;
|
||||
@@ -526,10 +588,10 @@ const transformProps = (
|
||||
comparison_color_enabled: comparisonColorEnabled = false,
|
||||
comparison_color_scheme: comparisonColorScheme = ColorSchemeEnum.Green,
|
||||
show_numbered_column: showNumberedColumn = false,
|
||||
allow_rearrange_columns: allowRearrangeColumns = true,
|
||||
allow_render_html: allowRenderHtml = true,
|
||||
} = formData;
|
||||
|
||||
const allowRearrangeColumns = true;
|
||||
|
||||
// Calculate time comparison settings early since they're used in multiple places
|
||||
const isUsingTimeComparison =
|
||||
!isEmpty(time_compare) &&
|
||||
@@ -682,7 +744,7 @@ const transformProps = (
|
||||
hasServerPageLengthChanged = true;
|
||||
}
|
||||
|
||||
const [, percentMetrics, columns] = processColumns(chartProps);
|
||||
const [, percentMetrics, columns] = processColumns(slice_id, chartProps);
|
||||
|
||||
const timeGrain = extractTimegrain(formData);
|
||||
|
||||
@@ -700,20 +762,34 @@ const transformProps = (
|
||||
);
|
||||
}
|
||||
|
||||
// buildQuery.ts can append an "all records" percent-metric denominator
|
||||
// query *and* a totals query, independently of each other, both landing
|
||||
// in extraQueries before the totals one. A fixed totalQuery index would
|
||||
// silently bind to the wrong query's data (or drop the totals query
|
||||
// entirely) whenever both are present, so replicate buildQuery.ts's own
|
||||
// gating condition here to know whether to skip that extra slot.
|
||||
const hasAllRecordsExtraQuery = Boolean(
|
||||
formData.percent_metrics?.length &&
|
||||
(formData.percent_metric_calculation || 'row_limit') === 'all_records',
|
||||
);
|
||||
|
||||
let baseQuery;
|
||||
let countQuery;
|
||||
let rowCount;
|
||||
let totalQuery;
|
||||
if (serverPagination) {
|
||||
[baseQuery, countQuery, totalQuery] = queriesData;
|
||||
[baseQuery, countQuery] = queriesData;
|
||||
totalQuery = hasAllRecordsExtraQuery ? queriesData[3] : queriesData[2];
|
||||
rowCount = (countQuery?.data?.[0]?.rowcount as number) ?? 0;
|
||||
} else {
|
||||
[baseQuery, totalQuery] = queriesData;
|
||||
[baseQuery] = queriesData;
|
||||
totalQuery = hasAllRecordsExtraQuery ? queriesData[2] : queriesData[1];
|
||||
rowCount = baseQuery?.rowcount ?? 0;
|
||||
}
|
||||
|
||||
const data = processDataRecords(baseQuery?.data, columns);
|
||||
const data = processDataRecords(slice_id, baseQuery?.data, columns);
|
||||
const comparisonData = processComparisonDataRecords(
|
||||
slice_id,
|
||||
baseQuery?.data,
|
||||
columns,
|
||||
comparisonSuffix,
|
||||
@@ -793,12 +869,12 @@ const transformProps = (
|
||||
|
||||
// Map saved metric/calculated column labels to their SQL expressions for filter resolution
|
||||
const metricSqlExpressions: Record<string, string> = {};
|
||||
chartProps.datasource.metrics.forEach(metric => {
|
||||
(chartProps.datasource?.metrics ?? []).forEach(metric => {
|
||||
if (metric.metric_name && metric.expression) {
|
||||
metricSqlExpressions[metric.metric_name] = metric.expression;
|
||||
}
|
||||
});
|
||||
chartProps.datasource.columns.forEach(col => {
|
||||
(chartProps.datasource?.columns ?? []).forEach(col => {
|
||||
if (col.column_name && col.expression) {
|
||||
metricSqlExpressions[col.column_name] = col.expression;
|
||||
if (col.verbose_name && col.verbose_name !== col.column_name) {
|
||||
@@ -811,7 +887,7 @@ const transformProps = (
|
||||
// backed by a dataset (physical or calculated) column can be summed
|
||||
// server-side; free-form SQL expression columns are excluded.
|
||||
const datasetColumnNames = new Set(
|
||||
chartProps.datasource.columns
|
||||
(chartProps.datasource?.columns ?? [])
|
||||
.map(col => col.column_name)
|
||||
.filter((name): name is string => Boolean(name)),
|
||||
);
|
||||
@@ -849,6 +925,7 @@ const transformProps = (
|
||||
filters: filterState.filters,
|
||||
emitCrossFilters,
|
||||
allowRearrangeColumns,
|
||||
allowRenderHtml,
|
||||
slice_id,
|
||||
serverPagination,
|
||||
rowCount,
|
||||
@@ -873,6 +950,7 @@ const transformProps = (
|
||||
chartState,
|
||||
onChartStateChange,
|
||||
showNumberedColumn,
|
||||
onContextMenu,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ import {
|
||||
JsonObject,
|
||||
Metric,
|
||||
AgGridChartState,
|
||||
ContextMenuFilters,
|
||||
} from '@superset-ui/core';
|
||||
import {
|
||||
ColDef,
|
||||
@@ -81,6 +82,7 @@ export type TableChartFormData = QueryFormData & {
|
||||
time_grain_sqla?: TimeGranularity;
|
||||
column_config?: Record<string, TableColumnConfig>;
|
||||
allow_rearrange_columns?: boolean;
|
||||
allow_render_html?: boolean;
|
||||
show_numbered_column?: boolean;
|
||||
};
|
||||
|
||||
@@ -134,6 +136,11 @@ export interface AgGridTableChartTransformedProps<
|
||||
onChartStateChange?: (chartState: JsonObject) => void;
|
||||
chartState?: AgGridChartState;
|
||||
showNumberedColumn: boolean;
|
||||
onContextMenu?: (
|
||||
clientX: number,
|
||||
clientY: number,
|
||||
filters?: ContextMenuFilters,
|
||||
) => void;
|
||||
}
|
||||
|
||||
export interface SortState {
|
||||
@@ -196,6 +203,7 @@ export interface InputColumn {
|
||||
originalLabel?: string;
|
||||
metricName?: string;
|
||||
description?: string;
|
||||
currencyCodeColumn?: string;
|
||||
}
|
||||
|
||||
export type ValueRange = [number, number] | null;
|
||||
|
||||
@@ -20,6 +20,17 @@
|
||||
import { SetDataMaskHook } from '@superset-ui/core';
|
||||
import { SortByItem } from '../types';
|
||||
|
||||
export interface ClientViewColumn {
|
||||
key: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
export interface ClientViewSnapshot {
|
||||
rows: Record<string, unknown>[];
|
||||
columns: ClientViewColumn[];
|
||||
count: number;
|
||||
}
|
||||
|
||||
interface TableOwnState {
|
||||
currentPage?: number;
|
||||
pageSize?: number;
|
||||
@@ -29,6 +40,7 @@ interface TableOwnState {
|
||||
sortBy?: SortByItem[];
|
||||
rawSummaryColumns?: string[];
|
||||
totalsRequested?: boolean;
|
||||
clientView?: ClientViewSnapshot;
|
||||
}
|
||||
|
||||
export const updateTableOwnState = (
|
||||
|
||||
@@ -17,9 +17,11 @@
|
||||
* under the License.
|
||||
*/
|
||||
import {
|
||||
CurrencyFormatter,
|
||||
DataRecordValue,
|
||||
getSmallNumberFormatter,
|
||||
isDefined,
|
||||
isEmptyDateInput,
|
||||
isProbablyHTML,
|
||||
sanitizeHtml,
|
||||
DateWithFormatter,
|
||||
@@ -37,6 +39,8 @@ import { DataColumnMeta, InputColumn } from '../types';
|
||||
function formatValue(
|
||||
formatter: DataColumnMeta['formatter'],
|
||||
value: DataRecordValue,
|
||||
rowData?: Record<string, DataRecordValue>,
|
||||
currencyColumn?: string,
|
||||
): [boolean, string] {
|
||||
// render undefined as empty string
|
||||
if (value === undefined) {
|
||||
@@ -45,13 +49,17 @@ function formatValue(
|
||||
// render null as `N/A`
|
||||
if (
|
||||
value === null ||
|
||||
// null values in temporal columns are wrapped in a Date object, so make sure we
|
||||
// handle them here too
|
||||
(value instanceof DateWithFormatter && value.input === null)
|
||||
// null/empty values in temporal columns are wrapped in a Date object, so make
|
||||
// sure we handle them here too
|
||||
(value instanceof DateWithFormatter && isEmptyDateInput(value.input))
|
||||
) {
|
||||
return [false, 'N/A'];
|
||||
}
|
||||
if (formatter) {
|
||||
// If formatter is a CurrencyFormatter, pass row context for AUTO mode
|
||||
if (formatter instanceof CurrencyFormatter) {
|
||||
return [false, formatter(value as number, rowData, currencyColumn)];
|
||||
}
|
||||
return [false, formatter(value as number)];
|
||||
}
|
||||
if (typeof value === 'string') {
|
||||
@@ -63,8 +71,9 @@ function formatValue(
|
||||
export function formatColumnValue(
|
||||
column: DataColumnMeta,
|
||||
value: DataRecordValue,
|
||||
rowData?: Record<string, DataRecordValue>,
|
||||
) {
|
||||
const { dataType, formatter, config = {} } = column;
|
||||
const { dataType, formatter, config = {}, currencyCodeColumn } = column;
|
||||
const isNumber = dataType === GenericDataType.Numeric;
|
||||
const smallNumberFormatter = getSmallNumberFormatter(
|
||||
formatter,
|
||||
@@ -76,6 +85,8 @@ export function formatColumnValue(
|
||||
? smallNumberFormatter
|
||||
: formatter,
|
||||
value,
|
||||
rowData,
|
||||
currencyCodeColumn,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -83,13 +94,24 @@ export const valueFormatter = (
|
||||
params: ValueFormatterParams,
|
||||
col: InputColumn,
|
||||
): string => {
|
||||
const { value, node } = params;
|
||||
const { value, node, data } = params;
|
||||
if (
|
||||
isDefined(value) &&
|
||||
value !== '' &&
|
||||
!(value instanceof DateWithFormatter && value.input === null)
|
||||
!(value instanceof DateWithFormatter && isEmptyDateInput(value.input))
|
||||
) {
|
||||
return col.formatter?.(value) || value;
|
||||
// Fall back to String(value) rather than the raw value: value can be a
|
||||
// DateWithFormatter/Date (or other object) when col.formatter is unset or
|
||||
// returns a falsy result, and returning that raw object here - though it
|
||||
// satisfies this function's `: string` signature at compile time since
|
||||
// `value`'s param type is loosely typed - crashes React with "Objects are
|
||||
// not valid as a React child" once a cell renderer renders it directly.
|
||||
if (col.formatter instanceof CurrencyFormatter) {
|
||||
return (
|
||||
col.formatter(value, data, col.currencyCodeColumn) || String(value)
|
||||
);
|
||||
}
|
||||
return col.formatter?.(value) || String(value);
|
||||
}
|
||||
if (node?.level === -1) {
|
||||
return '';
|
||||
|
||||
@@ -55,29 +55,81 @@ const getCellStyle = (params: CellStyleParams) => {
|
||||
let backgroundColor;
|
||||
let color;
|
||||
if (hasColumnColorFormatters) {
|
||||
columnColorFormatters!
|
||||
.filter(formatter => {
|
||||
const colTitle = formatter?.column?.includes('Main')
|
||||
? formatter?.column?.replace('Main', '').trim()
|
||||
: formatter?.column;
|
||||
return colTitle === colDef.field;
|
||||
})
|
||||
.forEach(formatter => {
|
||||
const formatterResult =
|
||||
value || value === 0 ? formatter.getColorFromValue(value) : false;
|
||||
if (formatterResult) {
|
||||
if (
|
||||
formatter.objectFormatting === ObjectFormattingEnum.TEXT_COLOR ||
|
||||
formatter.toTextColor
|
||||
) {
|
||||
color = formatterResult;
|
||||
} else if (
|
||||
formatter.objectFormatting !== ObjectFormattingEnum.CELL_BAR
|
||||
) {
|
||||
backgroundColor = formatterResult;
|
||||
}
|
||||
const applyFormatter = (
|
||||
formatter: ColorFormatters[number],
|
||||
valueToFormat: typeof value,
|
||||
) => {
|
||||
const formatterResult =
|
||||
valueToFormat || valueToFormat === 0
|
||||
? formatter.getColorFromValue(valueToFormat)
|
||||
: false;
|
||||
if (formatterResult) {
|
||||
if (
|
||||
formatter.objectFormatting === ObjectFormattingEnum.TEXT_COLOR ||
|
||||
formatter.toTextColor
|
||||
) {
|
||||
color = formatterResult;
|
||||
} else if (
|
||||
formatter.objectFormatting !== ObjectFormattingEnum.CELL_BAR
|
||||
) {
|
||||
backgroundColor = formatterResult;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// formatter.column can be a legacy display label ("Main colname") for
|
||||
// time-comparison columns rather than the row's actual data key, so
|
||||
// resolve it to the real field id before using it to read row values.
|
||||
const resolveColumnKey = (columnKey: string) =>
|
||||
columnKey.startsWith('Main ')
|
||||
? columnKey.slice('Main '.length)
|
||||
: columnKey;
|
||||
|
||||
// Formatters with no formatting target color their own source column,
|
||||
// keyed off this cell's own value. Excludes legacy v1 `toAllRow` rules,
|
||||
// which are entire-row formatters handled below.
|
||||
columnColorFormatters!
|
||||
.filter(
|
||||
formatter =>
|
||||
!formatter.columnFormatting &&
|
||||
!formatter.toAllRow &&
|
||||
resolveColumnKey(formatter.column) === colDef.field,
|
||||
)
|
||||
.forEach(formatter => applyFormatter(formatter, value));
|
||||
|
||||
// Formatters with a real target column color that target column,
|
||||
// keyed off the value in the formatter's own (source) column.
|
||||
columnColorFormatters!
|
||||
.filter(
|
||||
formatter =>
|
||||
formatter.columnFormatting &&
|
||||
formatter.columnFormatting !== ObjectFormattingEnum.ENTIRE_ROW &&
|
||||
resolveColumnKey(formatter.columnFormatting) === colDef.field,
|
||||
)
|
||||
.forEach(formatter =>
|
||||
applyFormatter(
|
||||
formatter,
|
||||
node?.data?.[resolveColumnKey(formatter.column)],
|
||||
),
|
||||
);
|
||||
|
||||
// Entire-row formatters apply to every cell in the row, keyed off the
|
||||
// value in the formatter's own column rather than this cell's column.
|
||||
// `toAllRow` is the legacy v1 flag for the same behavior; migrated
|
||||
// charts carry it over unchanged rather than being rewritten to
|
||||
// `columnFormatting: ENTIRE_ROW`, so both are honored here.
|
||||
columnColorFormatters!
|
||||
.filter(
|
||||
formatter =>
|
||||
formatter.columnFormatting === ObjectFormattingEnum.ENTIRE_ROW ||
|
||||
formatter.toAllRow,
|
||||
)
|
||||
.forEach(formatter =>
|
||||
applyFormatter(
|
||||
formatter,
|
||||
node?.data?.[resolveColumnKey(formatter.column)],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
let cached: number | undefined;
|
||||
|
||||
const css = (x: TemplateStringsArray) => x.join('\n');
|
||||
|
||||
export default function getScrollBarSize(forceRefresh = false) {
|
||||
if (typeof document === 'undefined') {
|
||||
return 0;
|
||||
}
|
||||
if (cached === undefined || forceRefresh) {
|
||||
const inner = document.createElement('div');
|
||||
const outer = document.createElement('div');
|
||||
inner.style.cssText = css`
|
||||
width: auto;
|
||||
height: 100%;
|
||||
overflow: scroll;
|
||||
`;
|
||||
outer.style.cssText = css`
|
||||
position: absolute;
|
||||
visibility: hidden;
|
||||
overflow: hidden;
|
||||
width: 100px;
|
||||
height: 50px;
|
||||
`;
|
||||
outer.append(inner);
|
||||
document.body.append(outer);
|
||||
cached = outer.clientWidth - inner.clientWidth;
|
||||
outer.remove();
|
||||
}
|
||||
return cached;
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* 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 { TimeGranularity } from '@superset-ui/core';
|
||||
|
||||
/**
|
||||
* Calculates the inclusive/exclusive temporal range for a bucket.
|
||||
* standard SQL range pattern: [start, end)
|
||||
*/
|
||||
export default function getTimeRangeFromGranularity(
|
||||
startTime: Date,
|
||||
granularity: TimeGranularity,
|
||||
): [Date, Date] {
|
||||
const time = startTime.getTime();
|
||||
const date = startTime.getUTCDate();
|
||||
const month = startTime.getUTCMonth();
|
||||
const year = startTime.getUTCFullYear();
|
||||
|
||||
// Constants
|
||||
const MS_IN_SECOND = 1000;
|
||||
const MS_IN_MINUTE = 60 * MS_IN_SECOND;
|
||||
const MS_IN_HOUR = 60 * MS_IN_MINUTE;
|
||||
|
||||
switch (granularity) {
|
||||
case TimeGranularity.SECOND:
|
||||
return [startTime, new Date(time + MS_IN_SECOND)];
|
||||
case TimeGranularity.MINUTE:
|
||||
return [startTime, new Date(time + MS_IN_MINUTE)];
|
||||
case TimeGranularity.FIVE_MINUTES:
|
||||
return [startTime, new Date(time + MS_IN_MINUTE * 5)];
|
||||
case TimeGranularity.TEN_MINUTES:
|
||||
return [startTime, new Date(time + MS_IN_MINUTE * 10)];
|
||||
case TimeGranularity.FIFTEEN_MINUTES:
|
||||
return [startTime, new Date(time + MS_IN_MINUTE * 15)];
|
||||
case TimeGranularity.THIRTY_MINUTES:
|
||||
return [startTime, new Date(time + MS_IN_MINUTE * 30)];
|
||||
case TimeGranularity.HOUR:
|
||||
return [startTime, new Date(time + MS_IN_HOUR)];
|
||||
case TimeGranularity.DAY:
|
||||
case TimeGranularity.DATE:
|
||||
return [startTime, new Date(Date.UTC(year, month, date + 1))];
|
||||
case TimeGranularity.WEEK:
|
||||
case TimeGranularity.WEEK_STARTING_SUNDAY:
|
||||
case TimeGranularity.WEEK_STARTING_MONDAY:
|
||||
return [startTime, new Date(Date.UTC(year, month, date + 7))];
|
||||
case TimeGranularity.WEEK_ENDING_SATURDAY:
|
||||
case TimeGranularity.WEEK_ENDING_SUNDAY:
|
||||
// Week-ending buckets are labeled by the bucket's final day.
|
||||
return [
|
||||
new Date(Date.UTC(year, month, date - 6)),
|
||||
new Date(Date.UTC(year, month, date + 1)),
|
||||
];
|
||||
case TimeGranularity.MONTH:
|
||||
return [startTime, new Date(Date.UTC(year, month + 1, 1))];
|
||||
case TimeGranularity.QUARTER:
|
||||
return [
|
||||
startTime,
|
||||
new Date(Date.UTC(year, Math.floor(month / 3) * 3 + 3, 1)),
|
||||
];
|
||||
case TimeGranularity.YEAR:
|
||||
return [startTime, new Date(Date.UTC(year + 1, 0, 1))];
|
||||
default:
|
||||
return [startTime, new Date(Date.UTC(year, month, date + 1))];
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@
|
||||
* under the License.
|
||||
*/
|
||||
import { isEqualArray } from '@superset-ui/core';
|
||||
import { isEqual } from 'lodash-es';
|
||||
import { TableChartProps } from '../types';
|
||||
|
||||
const getDescriptions = (props: TableChartProps) => {
|
||||
@@ -47,23 +48,55 @@ export default function isEqualColumns(
|
||||
|
||||
const descA = getDescriptions(a);
|
||||
const descB = getDescriptions(b);
|
||||
return (
|
||||
a.datasource.columnFormats === b.datasource.columnFormats &&
|
||||
a.datasource.currencyFormats === b.datasource.currencyFormats &&
|
||||
a.datasource.verboseMap === b.datasource.verboseMap &&
|
||||
a.formData.tableTimestampFormat === b.formData.tableTimestampFormat &&
|
||||
a.formData.timeGrainSqla === b.formData.timeGrainSqla &&
|
||||
JSON.stringify(a.formData.columnConfig || null) ===
|
||||
JSON.stringify(b.formData.columnConfig || null) &&
|
||||
isEqualArray(a.formData.metrics, b.formData.metrics) &&
|
||||
isEqualArray(a.queriesData?.[0]?.colnames, b.queriesData?.[0]?.colnames) &&
|
||||
isEqualArray(a.queriesData?.[0]?.coltypes, b.queriesData?.[0]?.coltypes) &&
|
||||
JSON.stringify(a.formData.extraFilters || null) ===
|
||||
JSON.stringify(b.formData.extraFilters || null) &&
|
||||
JSON.stringify(a.formData.extraFormData || null) ===
|
||||
JSON.stringify(b.formData.extraFormData || null) &&
|
||||
JSON.stringify(a.rawFormData.column_config || null) ===
|
||||
JSON.stringify(b.rawFormData.column_config || null) &&
|
||||
JSON.stringify(descA) === JSON.stringify(descB)
|
||||
);
|
||||
|
||||
// Every field below is read with optional chaining because this comparator
|
||||
// also runs against partial/mock props in tests; production TableChartProps
|
||||
// always has these populated.
|
||||
const checks = {
|
||||
// These three are plain, serializable per-column config maps. Superset's
|
||||
// core datasource pipeline can rebuild them with a new object reference
|
||||
// on renders that don't actually change any formatting, so compare by
|
||||
// value here - otherwise an incidental new reference looks like a real
|
||||
// change and forces a full AG Grid column/row rebuild downstream.
|
||||
columnFormats: isEqual(
|
||||
a.datasource?.columnFormats,
|
||||
b.datasource?.columnFormats,
|
||||
),
|
||||
currencyFormats: isEqual(
|
||||
a.datasource?.currencyFormats,
|
||||
b.datasource?.currencyFormats,
|
||||
),
|
||||
verboseMap: isEqual(a.datasource?.verboseMap, b.datasource?.verboseMap),
|
||||
currencyCodeColumn:
|
||||
a.datasource?.currencyCodeColumn === b.datasource?.currencyCodeColumn,
|
||||
detectedCurrency:
|
||||
a.queriesData?.[0]?.detected_currency ===
|
||||
b.queriesData?.[0]?.detected_currency,
|
||||
tableTimestampFormat:
|
||||
a.formData?.tableTimestampFormat === b.formData?.tableTimestampFormat,
|
||||
timeGrainSqla: a.formData?.timeGrainSqla === b.formData?.timeGrainSqla,
|
||||
columnConfig:
|
||||
JSON.stringify(a.formData?.columnConfig || null) ===
|
||||
JSON.stringify(b.formData?.columnConfig || null),
|
||||
metrics: isEqualArray(a.formData?.metrics, b.formData?.metrics),
|
||||
colnames: isEqualArray(
|
||||
a.queriesData?.[0]?.colnames,
|
||||
b.queriesData?.[0]?.colnames,
|
||||
),
|
||||
coltypes: isEqualArray(
|
||||
a.queriesData?.[0]?.coltypes,
|
||||
b.queriesData?.[0]?.coltypes,
|
||||
),
|
||||
extraFilters:
|
||||
JSON.stringify(a.formData?.extraFilters || null) ===
|
||||
JSON.stringify(b.formData?.extraFilters || null),
|
||||
extraFormData:
|
||||
JSON.stringify(a.formData?.extraFormData || null) ===
|
||||
JSON.stringify(b.formData?.extraFormData || null),
|
||||
rawColumnConfig:
|
||||
JSON.stringify(a.rawFormData?.column_config || null) ===
|
||||
JSON.stringify(b.rawFormData?.column_config || null),
|
||||
descriptions: JSON.stringify(descA) === JSON.stringify(descB),
|
||||
};
|
||||
return Object.values(checks).every(Boolean);
|
||||
}
|
||||
|
||||
@@ -28,11 +28,15 @@ import { useCallback, useMemo } from 'react';
|
||||
import {
|
||||
DataRecordValue,
|
||||
DateWithFormatter,
|
||||
isEmptyDateInput,
|
||||
JsonObject,
|
||||
} from '@superset-ui/core';
|
||||
import { GenericDataType } from '@apache-superset/core/common';
|
||||
import { useTheme } from '@apache-superset/core/theme';
|
||||
import { ColorFormatters } from '@superset-ui/chart-controls';
|
||||
import {
|
||||
ColorFormatters,
|
||||
ConditionalFormattingConfig,
|
||||
} from '@superset-ui/chart-controls';
|
||||
import { extent as d3Extent, max as d3Max } from 'd3-array';
|
||||
import {
|
||||
BasicColorFormatterType,
|
||||
@@ -71,11 +75,15 @@ type UseColDefsProps = {
|
||||
colorPositiveNegative: boolean;
|
||||
columnColorFormatters: ColorFormatters;
|
||||
allowRearrangeColumns?: boolean;
|
||||
allowRenderHtml?: boolean;
|
||||
basicColorFormatters?: { [Key: string]: BasicColorFormatterType }[];
|
||||
isUsingTimeComparison?: boolean;
|
||||
emitCrossFilters?: boolean;
|
||||
alignPositiveNegative: boolean;
|
||||
slice_id: number;
|
||||
conditionalFormatting?: ConditionalFormattingConfig[];
|
||||
comparisonColorEnabled?: boolean;
|
||||
comparisonColorScheme?: string;
|
||||
};
|
||||
|
||||
function getValueRange(
|
||||
@@ -131,7 +139,7 @@ const getFilterType = (col: InputColumn) => {
|
||||
|
||||
/**
|
||||
* Filter value getter for temporal columns.
|
||||
* Returns null for DateWithFormatter objects with null input,
|
||||
* Returns null for DateWithFormatter objects with null/empty input,
|
||||
* enabling AG Grid's blank filter to correctly identify null dates.
|
||||
*/
|
||||
const dateFilterValueGetter = (params: {
|
||||
@@ -139,8 +147,8 @@ const dateFilterValueGetter = (params: {
|
||||
colDef: { field?: string };
|
||||
}) => {
|
||||
const value = params.data?.[params.colDef.field as string];
|
||||
// Return null for DateWithFormatter with null input so AG Grid blank filter works
|
||||
if (value instanceof DateWithFormatter && value.input === null) {
|
||||
// Return null for DateWithFormatter with null/empty input so AG Grid blank filter works
|
||||
if (value instanceof DateWithFormatter && isEmptyDateInput(value.input)) {
|
||||
return null;
|
||||
}
|
||||
return value;
|
||||
@@ -236,13 +244,37 @@ export const useColDefs = ({
|
||||
colorPositiveNegative,
|
||||
columnColorFormatters,
|
||||
allowRearrangeColumns,
|
||||
allowRenderHtml,
|
||||
basicColorFormatters,
|
||||
isUsingTimeComparison,
|
||||
emitCrossFilters,
|
||||
alignPositiveNegative,
|
||||
slice_id,
|
||||
conditionalFormatting,
|
||||
comparisonColorEnabled,
|
||||
comparisonColorScheme,
|
||||
}: UseColDefsProps) => {
|
||||
const theme = useTheme();
|
||||
// transformProps.ts computes these fresh on every call (no memoization),
|
||||
// so a reference-based dependency here would recreate getCommonColProps -
|
||||
// and therefore colDefs - on every render regardless of whether the
|
||||
// formatting actually changed. Compare by content instead.
|
||||
//
|
||||
// columnColorFormatters/basicColorFormatters can't be stringified directly:
|
||||
// each entry's getColorFromValue closes over the rule's operator/
|
||||
// thresholds/gradient/color, none of which are mirrored as serializable
|
||||
// fields on the entry itself, so JSON.stringify drops them and two
|
||||
// differently-configured rules for the same column serialize identically.
|
||||
// Depend on the raw, fully-serializable formData that produced those
|
||||
// formatters instead.
|
||||
const stringifiedColumnColorFormatters = JSON.stringify(
|
||||
conditionalFormatting,
|
||||
);
|
||||
const stringifiedBasicColorFormatters = JSON.stringify([
|
||||
conditionalFormatting,
|
||||
comparisonColorEnabled,
|
||||
comparisonColorScheme,
|
||||
]);
|
||||
const getCommonColProps = useCallback(
|
||||
(
|
||||
col: InputColumn,
|
||||
@@ -387,7 +419,7 @@ export const useColDefs = ({
|
||||
cellRenderer: (p: CellRendererProps) =>
|
||||
isTextColumn ? TextCellRenderer(p) : NumericCellRenderer(p),
|
||||
cellRendererParams: {
|
||||
allowRenderHtml: true,
|
||||
allowRenderHtml,
|
||||
columns,
|
||||
hasBasicColorFormatters,
|
||||
col,
|
||||
@@ -401,6 +433,12 @@ export const useColDefs = ({
|
||||
isMetric,
|
||||
isPercentMetric,
|
||||
isNumeric,
|
||||
// colId (`field` above) has "Main " stripped for comparison
|
||||
// columns, but row data is still keyed by the unstripped
|
||||
// originalKey -- consumers reading row values by column (e.g. the
|
||||
// "Export Current View" snapshot) need this to look values up
|
||||
// correctly.
|
||||
dataKey: originalKey,
|
||||
},
|
||||
lockPinned: !allowRearrangeColumns,
|
||||
sortable: !serverPagination || !isPercentMetric,
|
||||
@@ -427,14 +465,15 @@ export const useColDefs = ({
|
||||
columns,
|
||||
data,
|
||||
defaultAlignPN,
|
||||
columnColorFormatters,
|
||||
basicColorFormatters,
|
||||
stringifiedColumnColorFormatters,
|
||||
stringifiedBasicColorFormatters,
|
||||
showCellBars,
|
||||
colorPositiveNegative,
|
||||
isUsingTimeComparison,
|
||||
isRawRecords,
|
||||
emitCrossFilters,
|
||||
allowRearrangeColumns,
|
||||
allowRenderHtml,
|
||||
serverPagination,
|
||||
alignPositiveNegative,
|
||||
theme.colorBgBase,
|
||||
|
||||
+140
-2
@@ -17,7 +17,14 @@
|
||||
* under the License.
|
||||
*/
|
||||
import '@testing-library/jest-dom';
|
||||
import { render, screen, waitFor } from '@superset-ui/core/spec';
|
||||
import {
|
||||
render,
|
||||
screen,
|
||||
waitFor,
|
||||
fireEvent,
|
||||
within,
|
||||
userEvent,
|
||||
} from '@superset-ui/core/spec';
|
||||
import { QueryMode, TimeGranularity, SMART_DATE_ID } from '@superset-ui/core';
|
||||
import { GenericDataType } from '@apache-superset/core/common';
|
||||
import {
|
||||
@@ -259,6 +266,59 @@ test('AgGridTableChart renders Search by dropdown if includeSearch is true and t
|
||||
expect(screen.getByText(/Search by/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('AgGridTableChart resets currentPage when the search column changes', async () => {
|
||||
const props = transformProps({
|
||||
...testData.basic,
|
||||
rawFormData: {
|
||||
...testData.basic.rawFormData,
|
||||
server_pagination: true,
|
||||
include_search: true,
|
||||
},
|
||||
});
|
||||
props.serverPagination = true;
|
||||
props.includeSearch = true;
|
||||
props.rowCount = 50;
|
||||
props.serverPaginationData = {
|
||||
currentPage: 1,
|
||||
pageSize: 20,
|
||||
};
|
||||
|
||||
render(
|
||||
ProviderWrapper({
|
||||
children: (
|
||||
<AgGridTableChart
|
||||
{...props}
|
||||
setDataMask={mockSetDataMask}
|
||||
slice_id={1}
|
||||
/>
|
||||
),
|
||||
}),
|
||||
);
|
||||
|
||||
const searchByContainer = await waitFor(() => {
|
||||
const container = document.querySelector('.search-select');
|
||||
expect(container).toBeInTheDocument();
|
||||
return container as HTMLElement;
|
||||
});
|
||||
const searchByDropdown = within(searchByContainer).getByRole('combobox');
|
||||
await userEvent.click(searchByDropdown);
|
||||
const otherOption = await waitFor(() =>
|
||||
within(screen.getByRole('listbox')).getByText('abc.com'),
|
||||
);
|
||||
await userEvent.click(otherOption);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(mockSetDataMask).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
ownState: expect.objectContaining({
|
||||
searchColumn: 'abc.com',
|
||||
currentPage: 0,
|
||||
}),
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('AgGridTableChart does not render Search by dropdown if includeSearch is true but searchOptions is empty', async () => {
|
||||
const noStringColumnsData = {
|
||||
...testData.basic,
|
||||
@@ -873,9 +933,24 @@ test('AgGridTableChart emits column state with aggFunc through the debounced sav
|
||||
expect(document.querySelector('.ag-container')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// The very first onStateUpdated after mount just reflects the chartState
|
||||
// the grid was initialized with, so it must not trigger a save on its own
|
||||
// (persisting it unconditionally caused a mount -> save -> remount ->
|
||||
// mount loop). Let that initial debounced capture settle before
|
||||
// simulating a real user action - clicking a sortable header - so it
|
||||
// isn't coalesced into the same debounce window and mistaken for the
|
||||
// initial, ignorable capture.
|
||||
await new Promise(resolve => setTimeout(resolve, 1500));
|
||||
|
||||
const sortableHeaderLabel = document.querySelector(
|
||||
'.ag-header-cell-sortable .ag-header-cell-label',
|
||||
);
|
||||
expect(sortableHeaderLabel).toBeTruthy();
|
||||
fireEvent.click(sortableHeaderLabel!);
|
||||
|
||||
// The save path is debounced (SLOW_DEBOUNCE = 500ms); wait for a capture.
|
||||
await waitFor(() => expect(onChartStateChange).toHaveBeenCalled(), {
|
||||
timeout: 3000,
|
||||
timeout: 5000,
|
||||
});
|
||||
|
||||
const savedState =
|
||||
@@ -889,3 +964,66 @@ test('AgGridTableChart emits column state with aggFunc through the debounced sav
|
||||
// (SharedAggregation) module; the community modules always report null.
|
||||
expect(savedColumn).toMatchObject({ aggFunc: null });
|
||||
});
|
||||
|
||||
test('AgGridTableChart renders a temporal column with a blank row without crashing', async () => {
|
||||
// Regression test: a raw-mode temporal column backed by numeric epoch
|
||||
// values, where one row's raw value is '' rather than null/undefined/a
|
||||
// number, used to flip isNumeric() false for the whole column (see
|
||||
// transformProps.ts), degrading its formatter to plain `String`. That made
|
||||
// DateWithFormatter.toString() return String('') for the blank row, which
|
||||
// is falsy - and valueFormatter's old `|| value` fallback then rendered the
|
||||
// raw Date object directly, crashing React with "Objects are not valid as
|
||||
// a React child (found: [object Date])".
|
||||
const props = transformProps({
|
||||
...testData.basic,
|
||||
rawFormData: {
|
||||
...testData.basic.rawFormData,
|
||||
query_mode: QueryMode.Raw,
|
||||
table_timestamp_format: SMART_DATE_ID,
|
||||
server_pagination: false,
|
||||
},
|
||||
queriesData: [
|
||||
{
|
||||
...testData.basic.queriesData[0],
|
||||
colnames: ['__timestamp', 'name'],
|
||||
coltypes: [GenericDataType.Temporal, GenericDataType.String],
|
||||
data: [
|
||||
{ __timestamp: 1069113600000, name: 'foo' },
|
||||
{ __timestamp: 1057016400000, name: 'bar' },
|
||||
{ __timestamp: '', name: 'baz' },
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||
|
||||
render(
|
||||
ProviderWrapper({
|
||||
children: (
|
||||
<AgGridTableChart
|
||||
{...props}
|
||||
setDataMask={mockSetDataMask}
|
||||
slice_id={1}
|
||||
/>
|
||||
),
|
||||
}),
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(document.querySelector('.ag-container')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
const reactChildError = errorSpy.mock.calls
|
||||
.map(call => call.join(' '))
|
||||
.find(message =>
|
||||
message.includes('Objects are not valid as a React child'),
|
||||
);
|
||||
errorSpy.mockRestore();
|
||||
expect(reactChildError).toBeUndefined();
|
||||
|
||||
const cells = document.querySelectorAll('[col-id="__timestamp"]');
|
||||
const cellText = Array.from(cells).map(cell => cell.textContent);
|
||||
expect(cellText).toContain('N/A');
|
||||
expect(cellText).not.toContain('');
|
||||
});
|
||||
|
||||
@@ -834,6 +834,51 @@ describe('plugin-chart-ag-grid-table', () => {
|
||||
expect(totalsQuery.extras).toBeDefined();
|
||||
});
|
||||
|
||||
test('should exclude AG Grid HAVING filters from totals query', () => {
|
||||
const { queries } = buildQuery(
|
||||
{
|
||||
...basicFormData,
|
||||
server_pagination: true,
|
||||
show_totals: true,
|
||||
query_mode: QueryMode.Aggregate,
|
||||
},
|
||||
{
|
||||
ownState: {
|
||||
agGridHavingClause: 'count > 10',
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const mainQuery = queries[0];
|
||||
const totalsQuery = queries[2]; // queries[1] is rowcount, queries[2] is totals
|
||||
|
||||
expect(mainQuery.extras?.having).toBe('count > 10');
|
||||
expect(totalsQuery.extras?.having).toBeUndefined();
|
||||
});
|
||||
|
||||
test('should exclude download HAVING filters (sqlClauses) from totals query', () => {
|
||||
const { queries } = buildQuery(
|
||||
{
|
||||
...basicFormData,
|
||||
show_totals: true,
|
||||
query_mode: QueryMode.Aggregate,
|
||||
result_format: 'csv',
|
||||
},
|
||||
{
|
||||
ownState: {
|
||||
sqlClauses: { count: 'count > 10' },
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const mainQuery = queries[0];
|
||||
// Downloads never get a rowcount query, so totals is queries[1].
|
||||
const totalsQuery = queries[1];
|
||||
|
||||
expect(mainQuery.extras?.having).toBe('count > 10');
|
||||
expect(totalsQuery.extras?.having).toBeUndefined();
|
||||
});
|
||||
|
||||
test('should not modify totals query when no AG Grid filters applied', () => {
|
||||
const { queries } = buildQuery(
|
||||
{
|
||||
@@ -853,6 +898,43 @@ describe('plugin-chart-ag-grid-table', () => {
|
||||
expect(totalsQuery.row_limit).toBe(0);
|
||||
});
|
||||
|
||||
test('all_records percent-metric denominator reflects AG Grid filters but totals do not', () => {
|
||||
// Regression test: the all_records denominator query is built from
|
||||
// the post-filter queryObject (so it matches the main query's result
|
||||
// set), while the totals query intentionally strips AG Grid
|
||||
// WHERE/HAVING so it summarizes the unfiltered chart-level data.
|
||||
const { queries } = buildQuery(
|
||||
{
|
||||
...basicFormData,
|
||||
metrics: ['count'],
|
||||
percent_metrics: ['count'],
|
||||
percent_metric_calculation: 'all_records',
|
||||
show_totals: true,
|
||||
server_pagination: true,
|
||||
query_mode: QueryMode.Aggregate,
|
||||
},
|
||||
{
|
||||
ownState: {
|
||||
agGridComplexWhere: 'age > 18',
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
// [main, rowcount, all_records denominator, totals]
|
||||
const allRecordsQuery = queries[2];
|
||||
const totalsQuery = queries[3];
|
||||
|
||||
expect(allRecordsQuery.extras?.where).toBe('age > 18');
|
||||
expect(allRecordsQuery.columns).toEqual([]);
|
||||
expect(allRecordsQuery.metrics).toEqual(['count']);
|
||||
expect(allRecordsQuery.row_limit).toBe(0);
|
||||
expect(allRecordsQuery.row_offset).toBe(0);
|
||||
expect(allRecordsQuery.orderby).toEqual([]);
|
||||
expect(allRecordsQuery.is_timeseries).toBe(false);
|
||||
|
||||
expect(totalsQuery.extras?.where).toBeUndefined();
|
||||
});
|
||||
|
||||
test('should reapply percent-metric contribution op to totals query', () => {
|
||||
// Regression test for #37627: when a percent metric is configured and
|
||||
// Show Summary (show_totals) is enabled, the totals query must rename
|
||||
|
||||
@@ -184,3 +184,45 @@ test('every Visual formatting control is a renderTrigger', () => {
|
||||
expect(control.config.renderTrigger).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
function findControl(
|
||||
panel: ControlPanelConfig,
|
||||
controlName: string,
|
||||
): CustomControlItem {
|
||||
const item = (panel.controlPanelSections || [])
|
||||
.flatMap(section => section?.controlSetRows || [])
|
||||
.flat()
|
||||
.find(c => isCustomControlItem(c) && c.name === controlName);
|
||||
|
||||
if (!item || !isCustomControlItem(item)) {
|
||||
throw new Error(`Control "${controlName}" not found`);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
test('allow_rearrange_columns defaults to false, matching v1, and hides while time_compare is set', () => {
|
||||
const control = findControl(config, 'allow_rearrange_columns');
|
||||
expect(control.config.type).toBe('CheckboxControl');
|
||||
expect(control.config.default).toBe(false);
|
||||
expect(control.config.renderTrigger).toBe(true);
|
||||
|
||||
const vis = control.config.visibility as VisibilityFn;
|
||||
expect(
|
||||
vis({
|
||||
controls: { time_compare: { value: [] } },
|
||||
} as unknown as ControlPanelsContainerProps),
|
||||
).toBe(true);
|
||||
expect(
|
||||
vis({
|
||||
controls: { time_compare: { value: ['1 year ago'] } },
|
||||
} as unknown as ControlPanelsContainerProps),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
test('allow_render_html defaults to true, matching v1, and has no visibility gate', () => {
|
||||
const control = findControl(config, 'allow_render_html');
|
||||
expect(control.config.type).toBe('CheckboxControl');
|
||||
expect(control.config.default).toBe(true);
|
||||
expect(control.config.renderTrigger).toBe(true);
|
||||
expect(control.config.visibility).toBeUndefined();
|
||||
});
|
||||
|
||||
@@ -178,6 +178,38 @@ test('extraColorChoices not included when time_compare is empty array', () => {
|
||||
expect(result.extraColorChoices).toEqual([]);
|
||||
});
|
||||
|
||||
test('numericColumns resolves dataType by position, not a stale name lookup', () => {
|
||||
const controlConfig = findConditionalFormattingControl();
|
||||
expect(controlConfig).toBeTruthy();
|
||||
|
||||
const explore = createMockExplore(undefined);
|
||||
// Two columns share the name "metric" (e.g. a dimension and a metric
|
||||
// both aliased the same way); only the second occurrence is Numeric.
|
||||
const chart = {
|
||||
chartStatus: 'success' as const,
|
||||
queriesResponse: [
|
||||
{
|
||||
colnames: ['metric', 'metric'],
|
||||
coltypes: [GenericDataType.String, GenericDataType.Numeric],
|
||||
},
|
||||
],
|
||||
};
|
||||
const result = controlConfig!.mapStateToProps!(
|
||||
explore,
|
||||
createMockControlStateForConditionalFormatting(),
|
||||
chart,
|
||||
);
|
||||
|
||||
// Resolving dataType via `colnames.indexOf(colname)` would always find
|
||||
// the first "metric" (String) and misclassify this numeric column.
|
||||
expect(result.columnOptions).toEqual([
|
||||
expect.objectContaining({
|
||||
value: 'metric',
|
||||
dataType: GenericDataType.Numeric,
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
test('consistency between extraColorChoices and columnOptions', () => {
|
||||
const controlConfig = findConditionalFormattingControl();
|
||||
expect(controlConfig).toBeTruthy();
|
||||
|
||||
@@ -0,0 +1,290 @@
|
||||
/**
|
||||
* 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 { render, waitFor } from '@superset-ui/core/spec';
|
||||
import { DateWithFormatter, TimeGranularity } from '@superset-ui/core';
|
||||
import { ProviderWrapper } from '../../plugin-chart-table/test/testHelpers';
|
||||
import testData from '../../plugin-chart-table/test/testData';
|
||||
|
||||
// Only the context-menu handler is exercised below; the mock below fakes
|
||||
// its event argument rather than a real ag-grid CellContextMenuEvent, so
|
||||
// it's typed loosely (unknown) rather than pinned to that library type.
|
||||
interface CapturedGridProps {
|
||||
onCellContextMenu?: (event: Record<string, unknown>) => void;
|
||||
}
|
||||
|
||||
// Capture the props the grid is rendered with, so we can invoke the
|
||||
// onCellContextMenu handler directly without depending on AG Grid's DOM
|
||||
// rendering or the (unregistered) Enterprise context-menu module.
|
||||
const captured: { props?: CapturedGridProps } = {};
|
||||
|
||||
jest.mock('@superset-ui/core/components/ThemedAgGridReact', () => ({
|
||||
__esModule: true,
|
||||
ThemedAgGridReact: (props: CapturedGridProps) => {
|
||||
captured.props = props;
|
||||
return null;
|
||||
},
|
||||
AgGridReact: function AgGridReact() {
|
||||
return null;
|
||||
},
|
||||
AllCommunityModule: {},
|
||||
ClientSideRowModelModule: {},
|
||||
ModuleRegistry: { registerModules: () => undefined },
|
||||
setupAGGridModules: () => undefined,
|
||||
defaultModules: [],
|
||||
themeQuartz: {},
|
||||
colorSchemeDark: {},
|
||||
colorSchemeLight: {},
|
||||
}));
|
||||
|
||||
// Imported after the mock is declared (jest.mock is hoisted above imports).
|
||||
// eslint-disable-next-line import/first
|
||||
import AgGridTableChart from '../src/AgGridTableChart';
|
||||
// eslint-disable-next-line import/first
|
||||
import transformProps from '../src/transformProps';
|
||||
|
||||
function renderChart(
|
||||
onContextMenu: jest.Mock,
|
||||
propsOverrides: Record<string, unknown> = {},
|
||||
) {
|
||||
captured.props = undefined;
|
||||
const props = {
|
||||
...transformProps({
|
||||
...testData.basic,
|
||||
hooks: { ...testData.basic.hooks, onContextMenu },
|
||||
emitCrossFilters: true,
|
||||
}),
|
||||
...propsOverrides,
|
||||
};
|
||||
render(
|
||||
ProviderWrapper({
|
||||
children: (
|
||||
<AgGridTableChart {...props} setDataMask={jest.fn()} slice_id={1} />
|
||||
),
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
function makeColumn(colId: string, context: Record<string, unknown> = {}) {
|
||||
return {
|
||||
getColId: () => colId,
|
||||
getColDef: () => ({ context }),
|
||||
};
|
||||
}
|
||||
|
||||
test('wires an onCellContextMenu handler when onContextMenu is provided', async () => {
|
||||
renderChart(jest.fn());
|
||||
await waitFor(() => expect(captured.props).toBeDefined());
|
||||
|
||||
expect(typeof captured.props?.onCellContextMenu).toBe('function');
|
||||
});
|
||||
|
||||
test('right-clicking a dimension cell emits drillToDetail, crossFilter and drillBy', async () => {
|
||||
const onContextMenu = jest.fn();
|
||||
renderChart(onContextMenu);
|
||||
await waitFor(() => expect(captured.props?.onCellContextMenu).toBeDefined());
|
||||
|
||||
const preventDefault = jest.fn();
|
||||
const stopPropagation = jest.fn();
|
||||
const rowData = {
|
||||
__timestamp: null,
|
||||
name: 'Michael',
|
||||
sum__num: 2467063,
|
||||
'abc.com': 'foo',
|
||||
};
|
||||
|
||||
captured.props?.onCellContextMenu?.({
|
||||
column: makeColumn('name'),
|
||||
data: rowData,
|
||||
value: 'Michael',
|
||||
event: {
|
||||
preventDefault,
|
||||
stopPropagation,
|
||||
clientX: 10,
|
||||
clientY: 20,
|
||||
},
|
||||
});
|
||||
|
||||
expect(preventDefault).toHaveBeenCalled();
|
||||
expect(stopPropagation).toHaveBeenCalled();
|
||||
expect(onContextMenu).toHaveBeenCalledTimes(1);
|
||||
|
||||
const [clientX, clientY, filters] = onContextMenu.mock.calls[0];
|
||||
expect(clientX).toBe(10);
|
||||
expect(clientY).toBe(20);
|
||||
|
||||
// Non-temporal, non-null column → exact-match filter.
|
||||
expect(filters.drillToDetail).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({ col: 'name', op: '==', val: 'Michael' }),
|
||||
expect.objectContaining({ col: 'abc.com', op: '==', val: 'foo' }),
|
||||
]),
|
||||
);
|
||||
// Null column → IS NULL filter, not an exact match on null.
|
||||
expect(filters.drillToDetail).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({ col: '__timestamp', op: 'IS NULL' }),
|
||||
]),
|
||||
);
|
||||
|
||||
expect(filters.crossFilter).toBeDefined();
|
||||
expect(filters.drillBy).toEqual({
|
||||
filters: [{ col: 'name', op: '==', val: 'Michael' }],
|
||||
groupbyFieldName: 'groupby',
|
||||
});
|
||||
});
|
||||
|
||||
test('right-clicking a null cell emits an IS NULL drillBy filter with a null val', async () => {
|
||||
const onContextMenu = jest.fn();
|
||||
renderChart(onContextMenu);
|
||||
await waitFor(() => expect(captured.props?.onCellContextMenu).toBeDefined());
|
||||
|
||||
captured.props?.onCellContextMenu?.({
|
||||
column: makeColumn('__timestamp'),
|
||||
data: { __timestamp: null, name: 'Michael', sum__num: 2467063 },
|
||||
value: null,
|
||||
event: {
|
||||
preventDefault: jest.fn(),
|
||||
stopPropagation: jest.fn(),
|
||||
clientX: 0,
|
||||
clientY: 0,
|
||||
},
|
||||
});
|
||||
|
||||
const [, , filters] = onContextMenu.mock.calls[0];
|
||||
// op and val must agree: IS NULL must carry a null val, not the clicked
|
||||
// cell's (possibly wrapped) value.
|
||||
expect(filters.drillBy).toEqual({
|
||||
filters: [{ col: '__timestamp', op: 'IS NULL', val: null }],
|
||||
groupbyFieldName: 'groupby',
|
||||
});
|
||||
});
|
||||
|
||||
test('right-clicking a blank (empty-string) date cell emits IS NULL, not an equality filter on an invalid date', async () => {
|
||||
// A blank temporal value arrives wrapped as DateWithFormatter(input: ''),
|
||||
// not null/undefined -- the null checks below must treat that the same
|
||||
// as null rather than falling through to the temporal/equality branches,
|
||||
// which would build an invalid Date or serialize the filter value as null
|
||||
// under an '==' op instead of an 'IS NULL' op.
|
||||
const onContextMenu = jest.fn();
|
||||
const blankDate = new DateWithFormatter('');
|
||||
renderChart(onContextMenu);
|
||||
await waitFor(() => expect(captured.props?.onCellContextMenu).toBeDefined());
|
||||
|
||||
captured.props?.onCellContextMenu?.({
|
||||
column: makeColumn('__timestamp'),
|
||||
data: { __timestamp: blankDate, name: 'Michael', sum__num: 2467063 },
|
||||
value: blankDate,
|
||||
event: {
|
||||
preventDefault: jest.fn(),
|
||||
stopPropagation: jest.fn(),
|
||||
clientX: 0,
|
||||
clientY: 0,
|
||||
},
|
||||
});
|
||||
|
||||
const [, , filters] = onContextMenu.mock.calls[0];
|
||||
expect(filters.drillToDetail).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({ col: '__timestamp', op: 'IS NULL' }),
|
||||
]),
|
||||
);
|
||||
expect(filters.drillBy).toEqual({
|
||||
filters: [{ col: '__timestamp', op: 'IS NULL', val: null }],
|
||||
groupbyFieldName: 'groupby',
|
||||
});
|
||||
});
|
||||
|
||||
test('right-clicking a metric cell omits crossFilter and drillBy', async () => {
|
||||
const onContextMenu = jest.fn();
|
||||
renderChart(onContextMenu);
|
||||
await waitFor(() => expect(captured.props?.onCellContextMenu).toBeDefined());
|
||||
|
||||
captured.props?.onCellContextMenu?.({
|
||||
column: makeColumn('sum__num', { isMetric: true }),
|
||||
data: { name: 'Michael', sum__num: 2467063 },
|
||||
value: 2467063,
|
||||
event: {
|
||||
preventDefault: jest.fn(),
|
||||
stopPropagation: jest.fn(),
|
||||
clientX: 0,
|
||||
clientY: 0,
|
||||
},
|
||||
});
|
||||
|
||||
const [, , filters] = onContextMenu.mock.calls[0];
|
||||
expect(filters.crossFilter).toBeUndefined();
|
||||
expect(filters.drillBy).toBeUndefined();
|
||||
// drillToDetail is still populated from the row's dimension columns.
|
||||
expect(filters.drillToDetail.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
test('right-clicking a temporal cell with a time grain emits a TEMPORAL_RANGE filter', async () => {
|
||||
const onContextMenu = jest.fn();
|
||||
renderChart(onContextMenu, { timeGrain: TimeGranularity.DAY });
|
||||
await waitFor(() => expect(captured.props?.onCellContextMenu).toBeDefined());
|
||||
|
||||
captured.props?.onCellContextMenu?.({
|
||||
column: makeColumn('name'),
|
||||
data: {
|
||||
__timestamp: '2020-01-01T12:34:56.000Z',
|
||||
name: 'Michael',
|
||||
sum__num: 2467063,
|
||||
},
|
||||
value: 'Michael',
|
||||
event: {
|
||||
preventDefault: jest.fn(),
|
||||
stopPropagation: jest.fn(),
|
||||
clientX: 0,
|
||||
clientY: 0,
|
||||
},
|
||||
});
|
||||
|
||||
const [, , filters] = onContextMenu.mock.calls[0];
|
||||
const timestampFilter = filters.drillToDetail.find(
|
||||
(f: { col: string }) => f.col === '__timestamp',
|
||||
);
|
||||
expect(timestampFilter.op).toBe('TEMPORAL_RANGE');
|
||||
// DAY granularity's range starts at the row's own timestamp (not
|
||||
// truncated to midnight) and ends at the start of the next UTC day.
|
||||
expect(timestampFilter.val).toBe(
|
||||
'2020-01-01T12:34:56.000Z : 2020-01-02T00:00:00.000Z',
|
||||
);
|
||||
});
|
||||
|
||||
test('does not call onContextMenu in raw records mode', async () => {
|
||||
const onContextMenu = jest.fn();
|
||||
// isRawRecords is derived from query_mode inside transformProps; force it
|
||||
// here to isolate the handler's own guard from that derivation.
|
||||
renderChart(onContextMenu, { isRawRecords: true });
|
||||
await waitFor(() => expect(captured.props?.onCellContextMenu).toBeDefined());
|
||||
|
||||
captured.props?.onCellContextMenu?.({
|
||||
column: makeColumn('name'),
|
||||
data: { name: 'Michael' },
|
||||
value: 'Michael',
|
||||
event: {
|
||||
preventDefault: jest.fn(),
|
||||
stopPropagation: jest.fn(),
|
||||
clientX: 0,
|
||||
clientY: 0,
|
||||
},
|
||||
});
|
||||
|
||||
expect(onContextMenu).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -0,0 +1,172 @@
|
||||
/**
|
||||
* 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 { CurrencyFormatter, DateWithFormatter } from '@superset-ui/core';
|
||||
import { GenericDataType } from '@apache-superset/core/common';
|
||||
import { ValueFormatterParams } from '@superset-ui/core/components/ThemedAgGridReact';
|
||||
import {
|
||||
formatColumnValue,
|
||||
valueFormatter,
|
||||
valueGetter,
|
||||
} from '../src/utils/formatValue';
|
||||
import { DataColumnMeta, InputColumn } from '../src/types';
|
||||
|
||||
const baseCol: InputColumn = {
|
||||
key: 'order_date',
|
||||
label: 'order_date',
|
||||
dataType: GenericDataType.Temporal,
|
||||
isNumeric: false,
|
||||
isMetric: false,
|
||||
isPercentMetric: false,
|
||||
config: {},
|
||||
};
|
||||
|
||||
function makeParams(value: unknown, node?: { level?: number }) {
|
||||
return {
|
||||
value,
|
||||
node,
|
||||
data: {},
|
||||
} as unknown as ValueFormatterParams;
|
||||
}
|
||||
|
||||
test('valueFormatter never returns a raw Date/object when col.formatter is unset', () => {
|
||||
// Regression test: order_date (or any temporal column) is wrapped into a
|
||||
// DateWithFormatter instance before reaching this function. If col.formatter
|
||||
// is undefined - or returns a falsy result - the old `|| value` fallback
|
||||
// returned that raw object, which crashes React with "Objects are not valid
|
||||
// as a React child" once a cell renderer renders it directly.
|
||||
const date = new DateWithFormatter(1069113600000);
|
||||
const result = valueFormatter(makeParams(date), {
|
||||
...baseCol,
|
||||
formatter: undefined,
|
||||
});
|
||||
|
||||
expect(typeof result).toBe('string');
|
||||
expect(result).not.toBe(date);
|
||||
});
|
||||
|
||||
test('valueFormatter falls back to a string when the formatter returns a falsy result', () => {
|
||||
const date = new DateWithFormatter(1069113600000);
|
||||
const formatter = jest.fn().mockReturnValue('');
|
||||
const result = valueFormatter(makeParams(date), {
|
||||
...baseCol,
|
||||
formatter: formatter as unknown as InputColumn['formatter'],
|
||||
});
|
||||
|
||||
expect(typeof result).toBe('string');
|
||||
expect(result).not.toBe(date);
|
||||
});
|
||||
|
||||
test('valueFormatter falls back to a string when the CurrencyFormatter returns a falsy result', () => {
|
||||
const currencyFormatter = new CurrencyFormatter({
|
||||
currency: { symbol: 'USD', symbolPosition: 'prefix' },
|
||||
});
|
||||
jest.spyOn(currencyFormatter, 'format').mockReturnValue('');
|
||||
|
||||
const result = valueFormatter(makeParams(42), {
|
||||
...baseCol,
|
||||
dataType: GenericDataType.Numeric,
|
||||
formatter: currencyFormatter,
|
||||
});
|
||||
|
||||
expect(typeof result).toBe('string');
|
||||
expect(result).toBe('42');
|
||||
});
|
||||
|
||||
test('valueFormatter uses the formatter result when it is truthy', () => {
|
||||
const formatter = jest.fn().mockReturnValue('2003-11-18');
|
||||
const result = valueFormatter(
|
||||
makeParams(new DateWithFormatter(1069113600000)),
|
||||
{
|
||||
...baseCol,
|
||||
formatter: formatter as unknown as InputColumn['formatter'],
|
||||
},
|
||||
);
|
||||
|
||||
expect(result).toBe('2003-11-18');
|
||||
});
|
||||
|
||||
test('valueFormatter returns N/A for a DateWithFormatter wrapping a null input', () => {
|
||||
const nullDate = new DateWithFormatter(null);
|
||||
const result = valueFormatter(makeParams(nullDate), baseCol);
|
||||
|
||||
expect(result).toBe('N/A');
|
||||
});
|
||||
|
||||
test('valueFormatter returns empty string for the root aggregation row', () => {
|
||||
const result = valueFormatter(makeParams(undefined, { level: -1 }), baseCol);
|
||||
|
||||
expect(result).toBe('');
|
||||
});
|
||||
|
||||
test('valueGetter returns the main column value when colDef.isMain is set', () => {
|
||||
const params = {
|
||||
colDef: { isMain: true },
|
||||
column: { getColId: () => 'sum__num' },
|
||||
data: { 'Main sum__num': 42 },
|
||||
} as unknown as Parameters<typeof valueGetter>[0];
|
||||
|
||||
expect(valueGetter(params, baseCol)).toBe(42);
|
||||
});
|
||||
|
||||
test('valueGetter returns undefined for missing numeric column values', () => {
|
||||
const params = {
|
||||
column: { getColId: () => 'sum__num' },
|
||||
data: {},
|
||||
} as unknown as Parameters<typeof valueGetter>[0];
|
||||
|
||||
expect(valueGetter(params, { ...baseCol, isNumeric: true })).toBeUndefined();
|
||||
});
|
||||
|
||||
test('valueGetter returns empty string for missing non-numeric column values', () => {
|
||||
const params = {
|
||||
column: { getColId: () => 'name' },
|
||||
data: {},
|
||||
} as unknown as Parameters<typeof valueGetter>[0];
|
||||
|
||||
expect(valueGetter(params, baseCol)).toBe('');
|
||||
});
|
||||
|
||||
test('formatColumnValue applies the small-number formatter for values under 1 in AUTO currency mode', () => {
|
||||
const column: DataColumnMeta = {
|
||||
key: 'pct',
|
||||
label: 'pct',
|
||||
dataType: GenericDataType.Numeric,
|
||||
isNumeric: true,
|
||||
isMetric: true,
|
||||
isPercentMetric: false,
|
||||
formatter: new CurrencyFormatter({
|
||||
currency: { symbol: 'AUTO', symbolPosition: 'prefix' },
|
||||
}),
|
||||
config: {},
|
||||
};
|
||||
|
||||
const [isHtml, formatted] = formatColumnValue(column, 0.005);
|
||||
|
||||
expect(isHtml).toBe(false);
|
||||
expect(formatted).not.toBe('');
|
||||
});
|
||||
|
||||
test('formatColumnValue renders null as N/A', () => {
|
||||
const column: DataColumnMeta = {
|
||||
...baseCol,
|
||||
formatter: undefined,
|
||||
};
|
||||
|
||||
expect(formatColumnValue(column, null)).toEqual([false, 'N/A']);
|
||||
});
|
||||
@@ -54,11 +54,12 @@ test('transformProps busts its memoization caches when sub-field inputs change (
|
||||
const first = transformProps(testData.basic);
|
||||
|
||||
// `processColumns` is wrapped with a custom equality (`isEqualColumns`) that
|
||||
// compares specific chartProps sub-fields by identity — mutating only the
|
||||
// top-level props reference is NOT enough to bust it. Here we supply a fresh
|
||||
// `datasource.columnFormats` reference, which `isEqualColumns` compares with
|
||||
// `===`, forcing `processColumns` to recompute and return a new `columns`
|
||||
// array.
|
||||
// compares specific chartProps sub-fields by value — mutating only the
|
||||
// top-level props reference is NOT enough to bust it, and neither is
|
||||
// handing it a new-but-value-equal `columnFormats` reference (e.g. another
|
||||
// `{}`). Here we supply a `datasource.columnFormats` with genuinely
|
||||
// different content, forcing `processColumns` to recompute and return a
|
||||
// new `columns` array.
|
||||
//
|
||||
// `processDataRecords` uses memoize-one's default referential equality on
|
||||
// `(data, columns)`. We also hand it a fresh `queriesData[0].data` array, so
|
||||
@@ -67,7 +68,7 @@ test('transformProps busts its memoization caches when sub-field inputs change (
|
||||
...testData.basic,
|
||||
datasource: {
|
||||
...testData.basic.datasource,
|
||||
columnFormats: {},
|
||||
columnFormats: { name: '.2f' },
|
||||
},
|
||||
queriesData: [
|
||||
{
|
||||
|
||||
@@ -16,7 +16,16 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { convertFilterModel } from '../src/stateConversion';
|
||||
import {
|
||||
convertFilterModel,
|
||||
convertAgGridStateToOwnState,
|
||||
} from '../src/stateConversion';
|
||||
|
||||
const baseAgGridState = {
|
||||
columnState: [],
|
||||
sortModel: [{ colId: 'name', sort: 'asc' as const, sortIndex: 0 }],
|
||||
filterModel: {},
|
||||
};
|
||||
|
||||
describe('convertFilterModel', () => {
|
||||
test('emits a clause for a valid numeric comparison filter', () => {
|
||||
@@ -71,3 +80,38 @@ describe('convertFilterModel', () => {
|
||||
expect(result?.sqlClauses?.constructor).toBe('constructor = 5');
|
||||
});
|
||||
});
|
||||
|
||||
describe('convertAgGridStateToOwnState', () => {
|
||||
test('suppresses client-mode state for the live query (serverPagination: false)', () => {
|
||||
const result = convertAgGridStateToOwnState({
|
||||
...baseAgGridState,
|
||||
serverPagination: false,
|
||||
});
|
||||
|
||||
expect(result).toEqual({});
|
||||
});
|
||||
|
||||
test('converts client-mode state anyway when forExport is set, so a download reproduces the displayed sort/filter', () => {
|
||||
const result = convertAgGridStateToOwnState(
|
||||
{ ...baseAgGridState, serverPagination: false },
|
||||
{ forExport: true },
|
||||
);
|
||||
|
||||
expect(result.sortBy).toEqual([{ id: 'name', key: 'name', desc: false }]);
|
||||
});
|
||||
|
||||
test('converts state when serverPagination is undefined, preserving legacy persisted table_state/permalinks saved before this field existed', () => {
|
||||
const result = convertAgGridStateToOwnState(baseAgGridState);
|
||||
|
||||
expect(result.sortBy).toEqual([{ id: 'name', key: 'name', desc: false }]);
|
||||
});
|
||||
|
||||
test('converts state for the live query when serverPagination is true', () => {
|
||||
const result = convertAgGridStateToOwnState({
|
||||
...baseAgGridState,
|
||||
serverPagination: true,
|
||||
});
|
||||
|
||||
expect(result.sortBy).toEqual([{ id: 'name', key: 'name', desc: false }]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -266,6 +266,69 @@ test('uses description from column even when verboseMap renames the column', ()
|
||||
expect(columnMeta!.description).toBe('Original column description');
|
||||
});
|
||||
|
||||
test('does not crash when datasource omits metrics/columns (drill-to-detail datasource)', () => {
|
||||
const props = createMockChartProps({
|
||||
queriesData: [
|
||||
{
|
||||
data: [{ col_x: 10 }],
|
||||
colnames: ['col_x'],
|
||||
coltypes: [GenericDataType.Numeric],
|
||||
rowcount: 1,
|
||||
applied_filters: [],
|
||||
rejected_filters: [],
|
||||
},
|
||||
] as unknown as TableChartProps['queriesData'],
|
||||
datasource: {} as unknown as TableChartProps['datasource'],
|
||||
});
|
||||
|
||||
expect(() => transformProps(props)).not.toThrow();
|
||||
});
|
||||
|
||||
test('does not mistake the all_records percent-metric query for the totals query', () => {
|
||||
// buildQuery.ts appends both an "all records" percent-metric denominator
|
||||
// query and a totals query as independent extraQueries when percent
|
||||
// metrics with percent_metric_calculation "all_records" and show_totals
|
||||
// are both enabled — queriesData has 3 entries, not 2.
|
||||
const props = createMockChartProps({
|
||||
rawFormData: {
|
||||
viz_type: 'table',
|
||||
datasource: '1__table',
|
||||
query_mode: QueryMode.Aggregate,
|
||||
metrics: ['sum__num'],
|
||||
percent_metrics: ['sum__num'],
|
||||
percent_metric_calculation: 'all_records',
|
||||
show_totals: true,
|
||||
column_config: {},
|
||||
table_timestamp_format: '',
|
||||
},
|
||||
queriesData: [
|
||||
{
|
||||
data: [{ name: 'a', sum__num: 1 }],
|
||||
colnames: ['name', 'sum__num'],
|
||||
coltypes: [GenericDataType.String, GenericDataType.Numeric],
|
||||
rowcount: 1,
|
||||
applied_filters: [],
|
||||
rejected_filters: [],
|
||||
},
|
||||
// all_records extra query: raw percent-metric denominator, not totals.
|
||||
{
|
||||
data: [{ sum__num: 100 }],
|
||||
colnames: ['sum__num'],
|
||||
coltypes: [GenericDataType.Numeric],
|
||||
},
|
||||
// totals extra query: the real one.
|
||||
{
|
||||
data: [{ sum__num: 42 }],
|
||||
colnames: ['sum__num'],
|
||||
coltypes: [GenericDataType.Numeric],
|
||||
},
|
||||
] as unknown as TableChartProps['queriesData'],
|
||||
});
|
||||
|
||||
const result = transformProps(props);
|
||||
expect(result.totals).toEqual({ sum__num: 42 });
|
||||
});
|
||||
|
||||
test('excludes Green/Red color-scheme rules from columnColorFormatters', () => {
|
||||
// Green/Red rules are rendered via the increase/decrease path, so they must
|
||||
// not reach getColorFormatters, which would treat the scheme name as a hex
|
||||
@@ -316,6 +379,59 @@ test('excludes Green/Red color-scheme rules from columnColorFormatters', () => {
|
||||
expect(formattedColumns).not.toContain('metric_a');
|
||||
});
|
||||
|
||||
test('allowRearrangeColumns defaults to true when allow_rearrange_columns is unset', () => {
|
||||
// Pre-existing v2 charts saved before this control existed have no
|
||||
// allow_rearrange_columns key at all -- they must keep the always-on
|
||||
// behavior v2 originally shipped with, not v1's false default.
|
||||
const props = createMockChartProps();
|
||||
const result = transformProps(props);
|
||||
expect(result.allowRearrangeColumns).toBe(true);
|
||||
});
|
||||
|
||||
test('allowRearrangeColumns is false when allow_rearrange_columns is explicitly false', () => {
|
||||
const props = createMockChartProps({
|
||||
rawFormData: {
|
||||
viz_type: 'table',
|
||||
datasource: '1__table',
|
||||
query_mode: QueryMode.Aggregate,
|
||||
metrics: [],
|
||||
percent_metrics: [],
|
||||
column_config: {},
|
||||
table_timestamp_format: '',
|
||||
granularity_sqla: 'day',
|
||||
time_range: 'No filter',
|
||||
allow_rearrange_columns: false,
|
||||
} as unknown as TableChartProps['rawFormData'],
|
||||
});
|
||||
const result = transformProps(props);
|
||||
expect(result.allowRearrangeColumns).toBe(false);
|
||||
});
|
||||
|
||||
test('allowRenderHtml defaults to true when allow_render_html is unset', () => {
|
||||
const props = createMockChartProps();
|
||||
const result = transformProps(props);
|
||||
expect(result.allowRenderHtml).toBe(true);
|
||||
});
|
||||
|
||||
test('allowRenderHtml is false when allow_render_html is explicitly false', () => {
|
||||
const props = createMockChartProps({
|
||||
rawFormData: {
|
||||
viz_type: 'table',
|
||||
datasource: '1__table',
|
||||
query_mode: QueryMode.Aggregate,
|
||||
metrics: [],
|
||||
percent_metrics: [],
|
||||
column_config: {},
|
||||
table_timestamp_format: '',
|
||||
granularity_sqla: 'day',
|
||||
time_range: 'No filter',
|
||||
allow_render_html: false,
|
||||
} as unknown as TableChartProps['rawFormData'],
|
||||
});
|
||||
const result = transformProps(props);
|
||||
expect(result.allowRenderHtml).toBe(false);
|
||||
});
|
||||
|
||||
test('retains saved percentage rules with automatic bounds when server pagination is enabled', () => {
|
||||
const props = createMockChartProps({
|
||||
rawFormData: {
|
||||
|
||||
@@ -94,6 +94,39 @@ test('applies the increase/decrease background when the column has one', () => {
|
||||
expect(style.backgroundColor).toBe('#00ff00');
|
||||
});
|
||||
|
||||
test('applies a cross-column formatter to its target column, keyed off the source column value', () => {
|
||||
// Rule reads metric_a (source) and paints metric_b (target, via columnFormatting).
|
||||
const crossColumnFormatter = {
|
||||
column: 'metric_a',
|
||||
columnFormatting: 'metric_b',
|
||||
getColorFromValue: (v: number) => (v === 100 ? '#ff0000' : undefined),
|
||||
objectFormatting: undefined,
|
||||
toTextColor: false,
|
||||
};
|
||||
|
||||
const targetStyle = getCellStyle(
|
||||
buildParams({
|
||||
colDef: { field: 'metric_b' },
|
||||
value: 999,
|
||||
hasColumnColorFormatters: true,
|
||||
columnColorFormatters: [crossColumnFormatter],
|
||||
node: { rowPinned: undefined, data: { metric_a: 100, metric_b: 999 } },
|
||||
}),
|
||||
);
|
||||
expect(targetStyle.backgroundColor).toBe('#ff0000');
|
||||
|
||||
const sourceStyle = getCellStyle(
|
||||
buildParams({
|
||||
colDef: { field: 'metric_a' },
|
||||
value: 100,
|
||||
hasColumnColorFormatters: true,
|
||||
columnColorFormatters: [crossColumnFormatter],
|
||||
node: { rowPinned: undefined, data: { metric_a: 100, metric_b: 999 } },
|
||||
}),
|
||||
);
|
||||
expect(sourceStyle.backgroundColor).toBe('');
|
||||
});
|
||||
|
||||
test('does not apply basic formatting to the pinned summary row', () => {
|
||||
const style = getCellStyle(
|
||||
buildParams({
|
||||
@@ -106,3 +139,37 @@ test('does not apply basic formatting to the pinned summary row', () => {
|
||||
);
|
||||
expect(style.backgroundColor).toBe('');
|
||||
});
|
||||
|
||||
test('applies a legacy v1 toAllRow formatter to every cell in the row', () => {
|
||||
// Migrated v1 charts carry `toAllRow: true` unchanged rather than being
|
||||
// rewritten to `columnFormatting: ENTIRE_ROW`; both must color every cell.
|
||||
const legacyEntireRowFormatter = {
|
||||
column: 'metric_a',
|
||||
toAllRow: true,
|
||||
getColorFromValue: (v: number) => (v === 100 ? '#ff0000' : undefined),
|
||||
objectFormatting: undefined,
|
||||
toTextColor: false,
|
||||
};
|
||||
|
||||
const otherColumnStyle = getCellStyle(
|
||||
buildParams({
|
||||
colDef: { field: 'metric_b' },
|
||||
value: 999,
|
||||
hasColumnColorFormatters: true,
|
||||
columnColorFormatters: [legacyEntireRowFormatter],
|
||||
node: { rowPinned: undefined, data: { metric_a: 100, metric_b: 999 } },
|
||||
}),
|
||||
);
|
||||
expect(otherColumnStyle.backgroundColor).toBe('#ff0000');
|
||||
|
||||
const sourceColumnStyle = getCellStyle(
|
||||
buildParams({
|
||||
colDef: { field: 'metric_a' },
|
||||
value: 100,
|
||||
hasColumnColorFormatters: true,
|
||||
columnColorFormatters: [legacyEntireRowFormatter],
|
||||
node: { rowPinned: undefined, data: { metric_a: 100, metric_b: 999 } },
|
||||
}),
|
||||
);
|
||||
expect(sourceColumnStyle.backgroundColor).toBe('#ff0000');
|
||||
});
|
||||
|
||||
@@ -811,6 +811,79 @@ test('cellStyle defaults non-numeric columns to left alignment', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('cellStyle reflects an edited conditional-formatting rule (color/threshold change, same column)', () => {
|
||||
// columnColorFormatters entries only carry a computed getColorFromValue
|
||||
// closure -- the rule's operator/threshold/color aren't mirrored onto the
|
||||
// entry itself. Memoizing on JSON.stringify(columnColorFormatters) alone
|
||||
// would see the same "shape" on both renders and keep closing over the
|
||||
// first render's (red) formatter. The memo must instead depend on the raw
|
||||
// conditionalFormatting config, which does capture the color/threshold.
|
||||
const numericCol = makeColumn({
|
||||
key: 'count',
|
||||
label: 'Count',
|
||||
dataType: GenericDataType.Numeric,
|
||||
isNumeric: true,
|
||||
isMetric: true,
|
||||
});
|
||||
// getCommonColProps also depends on `columns`/`data` by reference (as it
|
||||
// must, since transformProps.ts doesn't memoize them either), so those
|
||||
// need to stay referentially stable across rerenders here -- otherwise a
|
||||
// new array on every render would mask a broken formatter dependency by
|
||||
// invalidating the memo for an unrelated reason.
|
||||
const stableColumns = [numericCol];
|
||||
const stableData = [{ count: 42 }];
|
||||
|
||||
const cellStyleParams = {
|
||||
value: 42,
|
||||
colDef: { field: 'count' },
|
||||
rowIndex: 0,
|
||||
node: {},
|
||||
} as never;
|
||||
|
||||
const { result, rerender } = renderHook(
|
||||
(props: { color: string; targetValue: number }) =>
|
||||
useColDefs({
|
||||
...defaultProps,
|
||||
columns: stableColumns,
|
||||
data: stableData,
|
||||
columnColorFormatters: [
|
||||
{
|
||||
column: 'count',
|
||||
objectFormatting: ObjectFormattingEnum.BACKGROUND_COLOR,
|
||||
getColorFromValue: (value: unknown) =>
|
||||
value === 42 ? props.color : undefined,
|
||||
},
|
||||
],
|
||||
conditionalFormatting: [
|
||||
{
|
||||
column: 'count',
|
||||
operator: '>',
|
||||
targetValue: props.targetValue,
|
||||
colorScheme: props.color,
|
||||
} as never,
|
||||
],
|
||||
}),
|
||||
{
|
||||
wrapper: defaultThemeWrapper,
|
||||
initialProps: { color: '#ff0000', targetValue: 0 },
|
||||
},
|
||||
);
|
||||
|
||||
const firstCellStyle = getCellStyleFunction(result.current[0].cellStyle);
|
||||
expect(firstCellStyle(cellStyleParams)).toMatchObject({
|
||||
backgroundColor: '#ff0000',
|
||||
});
|
||||
|
||||
// Same column, edited threshold/color -- must produce a fresh colDef
|
||||
// whose cellStyle uses the new formatter, not the stale red one.
|
||||
rerender({ color: '#0000ff', targetValue: 10 });
|
||||
|
||||
const secondCellStyle = getCellStyleFunction(result.current[0].cellStyle);
|
||||
expect(secondCellStyle(cellStyleParams)).toMatchObject({
|
||||
backgroundColor: '#0000ff',
|
||||
});
|
||||
});
|
||||
|
||||
test('cellStyle respects explicit horizontal alignment overrides', () => {
|
||||
const numericCol = makeColumn({
|
||||
key: 'count',
|
||||
|
||||
@@ -35,12 +35,14 @@ jest.mock('src/utils/cachedSupersetGet');
|
||||
// only need a stand-in that lets us trigger onDrillBy with a distinguishable
|
||||
// config, so we can assert ChartContextMenu wires it into the modal.
|
||||
jest.mock('../DrillBy/DrillBySubmenu', () => ({
|
||||
DrillBySubmenu: ({ onDrillBy, dataset }: any) => (
|
||||
DrillBySubmenu: ({ onDrillBy, onCloseMenu, dataset }: any) => (
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
data-test="fake-drill-by-submenu"
|
||||
onClick={() =>
|
||||
onClick={() => {
|
||||
// Mirrors DrillBySubmenu's real handleSelection, which calls
|
||||
// onDrillBy and onCloseMenu together once a column is picked.
|
||||
onDrillBy(
|
||||
{ column_name: 'city', groupby: true },
|
||||
{ id: 1, columns: [], metrics: [] },
|
||||
@@ -48,8 +50,9 @@ jest.mock('../DrillBy/DrillBySubmenu', () => ({
|
||||
filters: [{ col: 'selected_scope' }],
|
||||
groupbyFieldName: 'groupby',
|
||||
},
|
||||
)
|
||||
}
|
||||
);
|
||||
onCloseMenu?.();
|
||||
}}
|
||||
>
|
||||
Fake Drill By
|
||||
</button>
|
||||
@@ -221,6 +224,39 @@ test('drill by modal uses the scope selected in the submenu over the raw context
|
||||
expect(modalConfig.filters).toEqual([{ col: 'selected_scope' }]);
|
||||
});
|
||||
|
||||
test('context menu can be reopened after Drill By closes it via onCloseMenu', async () => {
|
||||
// Ant Design's Dropdown keeps its overlay mounted and toggles an
|
||||
// `ant-dropdown-hidden` class rather than unmounting, so open/closed is
|
||||
// asserted on that class instead of the overlay's presence in the DOM.
|
||||
const isMenuOpen = () =>
|
||||
!screen
|
||||
.getByTestId('chart-context-menu')
|
||||
.closest('.ant-dropdown')
|
||||
?.classList.contains('ant-dropdown-hidden');
|
||||
|
||||
setup();
|
||||
|
||||
const openButton = screen.getByTestId('open-context-menu');
|
||||
userEvent.click(openButton);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(isMenuOpen()).toBe(true);
|
||||
});
|
||||
|
||||
const submenuButton = await screen.findByTestId('fake-drill-by-submenu');
|
||||
userEvent.click(submenuButton);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(isMenuOpen()).toBe(false);
|
||||
});
|
||||
|
||||
userEvent.click(openButton);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(isMenuOpen()).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
test('drill by only offers dimension columns', async () => {
|
||||
// drill_info returns every column so the results grid can label non-dimension
|
||||
// ones; narrowing to dimensions is this component's job, not the API's.
|
||||
|
||||
@@ -24,6 +24,7 @@ import {
|
||||
useCallback,
|
||||
useImperativeHandle,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
@@ -110,6 +111,11 @@ const ChartContextMenu = (
|
||||
);
|
||||
|
||||
const [visible, setVisible] = useState(false);
|
||||
// `visible` state updates aren't synchronous, so a second open() call that
|
||||
// runs before React re-renders would still see the stale `false` closure.
|
||||
// This ref is updated synchronously (both here and in onOpenChange) so the
|
||||
// guard below always reflects the latest known open state.
|
||||
const visibleRef = useRef(false);
|
||||
|
||||
const isDisplayed = (item: ContextMenuItem) =>
|
||||
displayedItems === ContextMenuItem.All ||
|
||||
@@ -162,6 +168,7 @@ const ChartContextMenu = (
|
||||
const [showDrillByModal, setShowDrillByModal] = useState(false);
|
||||
|
||||
const closeContextMenu = useCallback(() => {
|
||||
visibleRef.current = false;
|
||||
setVisible(false);
|
||||
onClose();
|
||||
}, [onClose]);
|
||||
@@ -400,11 +407,26 @@ const ChartContextMenu = (
|
||||
filters,
|
||||
});
|
||||
|
||||
// Since Ant Design's Dropdown does not offer an imperative API
|
||||
// and we can't attach event triggers to charts SVG elements, we
|
||||
// use a hidden span that gets clicked on when receiving click events
|
||||
// from the charts.
|
||||
document.getElementById(`hidden-span-${id}`)?.click();
|
||||
// Some chart libraries (e.g. AG Grid) can dispatch a single logical
|
||||
// right-click as two contextmenu events in quick succession, calling
|
||||
// `open()` twice. Since Ant Design's Dropdown treats a click on an
|
||||
// already-open trigger as a toggle-to-close, re-clicking the hidden
|
||||
// span here on the second call would immediately close the menu we
|
||||
// just opened. Only click it when the menu isn't already visible; the
|
||||
// position/filters update above still applies on every call.
|
||||
//
|
||||
// visibleRef (not the `visible` state) drives this guard: the state
|
||||
// update from the first call's click hasn't been committed by the time
|
||||
// the second call runs, so a state-based check would still read the
|
||||
// stale `false` from this render's closure and click twice anyway.
|
||||
if (!visibleRef.current) {
|
||||
visibleRef.current = true;
|
||||
// Ant Design's Dropdown does not offer an imperative API and we
|
||||
// can't attach event triggers to charts' SVG elements, so we use a
|
||||
// hidden span that gets clicked on when receiving click events from
|
||||
// the charts.
|
||||
document.getElementById(`hidden-span-${id}`)?.click();
|
||||
}
|
||||
},
|
||||
[id, itemsCount],
|
||||
);
|
||||
@@ -426,6 +448,7 @@ const ChartContextMenu = (
|
||||
? menuItems
|
||||
: [{ key: 'no-actions', label: t('No actions'), disabled: true }],
|
||||
onClick: () => {
|
||||
visibleRef.current = false;
|
||||
setVisible(false);
|
||||
onClose();
|
||||
},
|
||||
@@ -435,6 +458,7 @@ const ChartContextMenu = (
|
||||
)}
|
||||
trigger={['click']}
|
||||
onOpenChange={value => {
|
||||
visibleRef.current = value;
|
||||
setVisible(value);
|
||||
if (!value) {
|
||||
onClose();
|
||||
|
||||
@@ -44,16 +44,18 @@ const setup = ({
|
||||
displayedItems = ContextMenuItem.All,
|
||||
additionalConfig = {},
|
||||
roles = undefined,
|
||||
formData = { datasource: '1__table', viz_type: VizType.Pie },
|
||||
}: {
|
||||
onSelection?: () => void;
|
||||
displayedItems?: ContextMenuItem | ContextMenuItem[];
|
||||
additionalConfig?: Record<string, any>;
|
||||
roles?: Record<string, string[][]>;
|
||||
formData?: Record<string, any>;
|
||||
} = {}) => {
|
||||
const { result } = renderHook(() =>
|
||||
useContextMenu(
|
||||
sliceId,
|
||||
{ datasource: '1__table', viz_type: VizType.Pie },
|
||||
formData as { datasource: string; viz_type: string },
|
||||
onSelection,
|
||||
displayedItems,
|
||||
additionalConfig,
|
||||
@@ -365,3 +367,24 @@ test('Dataset drill info API call is not made when user lacks drill permissions'
|
||||
expect(screen.queryByText('Drill by')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('Drill to detail')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('Dataset drill info API call is not made when formData.datasource is not yet hydrated', async () => {
|
||||
// Regression test: right after a client-side navigation back to a
|
||||
// dashboard from Explore, the chart's formData can transiently be missing
|
||||
// `datasource` before the dashboard rehydrates. Firing a request for
|
||||
// dataset "NaN" (Number(undefined)) must not happen - see
|
||||
// useDatasetDrillInfo's Number.isNaN guard.
|
||||
const result = setup({ formData: { viz_type: VizType.Pie } });
|
||||
|
||||
act(() => {
|
||||
result.current.onContextMenu(0, 0, {});
|
||||
});
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 0));
|
||||
|
||||
expect(mockCachedSupersetGet).not.toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
endpoint: expect.stringContaining('/api/v1/dataset/NaN/drill_info/'),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -603,7 +603,9 @@ const Chart = (props: ChartProps) => {
|
||||
const exportOwnState = state
|
||||
? {
|
||||
...baseOwnState,
|
||||
...convertChartStateToOwnState(sliceVizType, state),
|
||||
...convertChartStateToOwnState(sliceVizType, state, {
|
||||
forExport: true,
|
||||
}),
|
||||
}
|
||||
: baseOwnState;
|
||||
|
||||
|
||||
@@ -261,6 +261,66 @@ test('should return equal results when only clientView changes', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('should strip chartState from ownState to prevent spurious re-queries', () => {
|
||||
// Chart.tsx (dashboard) folds the AG Grid chartState (persisted separately
|
||||
// in dashboardState.chartStates) into ownState so the chart plugin can read
|
||||
// it on mount. That fold-in is not a query-affecting change and must not
|
||||
// trigger a re-query when it churns, e.g. right after a user interaction.
|
||||
const mockDataMaskWithChartState: DataMaskStateWithId = {
|
||||
chart1: {
|
||||
id: 'chart1',
|
||||
ownState: {
|
||||
pageSize: 10,
|
||||
currentPage: 0,
|
||||
chartState: {
|
||||
columnState: [{ colId: 'name', width: 200 }],
|
||||
filterModel: {},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const result = getRelevantDataMask(mockDataMaskWithChartState, 'ownState');
|
||||
|
||||
expect(result).toEqual({
|
||||
chart1: {
|
||||
pageSize: 10,
|
||||
currentPage: 0,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test('should return equal results when only chartState changes', () => {
|
||||
// chartState is refreshed on every AG Grid column/sort/filter change; if it
|
||||
// isn't stripped, its churn is read as a chart-state change by
|
||||
// getAffectedOwnDataCharts and re-triggers the chart's query.
|
||||
const dataMaskBefore: DataMaskStateWithId = {
|
||||
chart1: {
|
||||
id: 'chart1',
|
||||
ownState: {
|
||||
pageSize: 10,
|
||||
chartState: { columnState: [{ colId: 'name', width: 200 }] },
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const dataMaskAfter: DataMaskStateWithId = {
|
||||
chart1: {
|
||||
id: 'chart1',
|
||||
ownState: {
|
||||
pageSize: 10,
|
||||
chartState: { columnState: [{ colId: 'name', width: 350 }] },
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const resultBefore = getRelevantDataMask(dataMaskBefore, 'ownState');
|
||||
const resultAfter = getRelevantDataMask(dataMaskAfter, 'ownState');
|
||||
|
||||
expect(resultBefore).toEqual(resultAfter);
|
||||
expect(resultBefore).toEqual({ chart1: { pageSize: 10 } });
|
||||
});
|
||||
|
||||
test('should return extraFormData unchanged (clientView stripping only applies to ownState)', () => {
|
||||
// Verify extraFormData is passed through without modification
|
||||
const mockDataMask: DataMaskStateWithId = {
|
||||
|
||||
@@ -34,16 +34,19 @@ export const getRelevantDataMask = (
|
||||
.filter(item => item[prop])
|
||||
.map(item => {
|
||||
const value = item[prop];
|
||||
// TableChart writes clientView to ownState on every filtered-row change for export
|
||||
// but clientView changes should NOT trigger chart re-queries
|
||||
// Only clone when clientView exists to avoid unnecessary allocations
|
||||
// TableChart writes clientView to ownState on every filtered-row change for export,
|
||||
// and Chart.tsx (dashboard) folds the AG Grid chartState (column/sort/filter state,
|
||||
// persisted separately in dashboardState.chartStates) into the same ownState object
|
||||
// for the chart plugin to read on mount. Neither is query-affecting, so both must be
|
||||
// stripped here or their churn is read as a chart-state change and triggers re-queries.
|
||||
// Only clone when one of them exists to avoid unnecessary allocations.
|
||||
if (
|
||||
prop === 'ownState' &&
|
||||
value &&
|
||||
typeof value === 'object' &&
|
||||
'clientView' in value
|
||||
('clientView' in value || 'chartState' in value)
|
||||
) {
|
||||
return [item.id, omit(value, ['clientView'])];
|
||||
return [item.id, omit(value, ['clientView', 'chartState'])];
|
||||
}
|
||||
return [item.id, value];
|
||||
}),
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
import type {
|
||||
ChartStateConverter,
|
||||
ChartStateConverterOptions,
|
||||
BackendOwnState,
|
||||
JsonObject,
|
||||
} from '@superset-ui/core';
|
||||
@@ -44,14 +45,18 @@ class ChartStateConverterRegistry {
|
||||
* Convert chart-specific state to backend-compatible ownState format.
|
||||
* Returns an empty object if no converter is registered for the viz type.
|
||||
*/
|
||||
convert(vizType: string, chartState: JsonObject): Partial<BackendOwnState> {
|
||||
convert(
|
||||
vizType: string,
|
||||
chartState: JsonObject,
|
||||
options?: ChartStateConverterOptions,
|
||||
): Partial<BackendOwnState> {
|
||||
const converter = this.converters.get(vizType);
|
||||
if (!converter) {
|
||||
return {};
|
||||
}
|
||||
|
||||
try {
|
||||
return converter(chartState);
|
||||
return converter(chartState, options);
|
||||
} catch (error) {
|
||||
// Log error but don't throw - graceful degradation
|
||||
console.warn(
|
||||
@@ -115,8 +120,9 @@ export function registerChartStateConverter(
|
||||
export function convertChartStateToOwnState(
|
||||
vizType: string,
|
||||
chartState: JsonObject,
|
||||
options?: ChartStateConverterOptions,
|
||||
): Partial<BackendOwnState> {
|
||||
return registry.convert(vizType, chartState);
|
||||
return registry.convert(vizType, chartState, options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -874,8 +874,12 @@ function ExploreViewContainer(props: ExploreViewContainerProps) {
|
||||
|
||||
const previousOwnState = usePrevious(props.ownState);
|
||||
useEffect(() => {
|
||||
// clientView (export snapshot) and chartState (AG Grid column/sort/filter
|
||||
// state read on mount) are folded into ownState but aren't query-affecting;
|
||||
// excluding them here is what the dashboard-side getRelevantDataMask does
|
||||
// for the same reason - see src/dashboard/util/activeAllDashboardFilters.ts.
|
||||
const strip = (s: JsonObject | undefined) =>
|
||||
s && typeof s === 'object' ? omit(s, ['clientView']) : s;
|
||||
omit(s && typeof s === 'object' ? s : {}, ['clientView', 'chartState']);
|
||||
if (!isEqual(strip(previousOwnState), strip(props.ownState))) {
|
||||
onQuery();
|
||||
reRenderChart();
|
||||
|
||||
+31
-17
@@ -512,13 +512,15 @@ export const useExploreAdditionalActionsMenu = (
|
||||
permalinkChartState,
|
||||
]);
|
||||
|
||||
// Minimal client-side CSV builder used for "Current View" when pagination is disabled
|
||||
// Minimal client-side CSV builder used for "Current View" when pagination is disabled.
|
||||
// `rows` may legitimately be empty (a filter that matches nothing) -- only
|
||||
// `columns` is required to produce a valid header-only export.
|
||||
const downloadClientCSV = (
|
||||
rows: ClientViewRow[],
|
||||
columns: ClientViewColumn[],
|
||||
filename: string,
|
||||
) => {
|
||||
if (!rows?.length || !columns?.length) return;
|
||||
if (!columns?.length) return;
|
||||
const header = columns
|
||||
.map(c => escapeCsvValue(c.label ?? c.key ?? ''))
|
||||
.join(',');
|
||||
@@ -536,13 +538,15 @@ export const useExploreAdditionalActionsMenu = (
|
||||
URL.revokeObjectURL(link.href);
|
||||
};
|
||||
|
||||
// Robust client-side JSON for "Current View"
|
||||
// Robust client-side JSON for "Current View". `rows` may legitimately be
|
||||
// empty (a filter that matches nothing) -- only `columns` is required to
|
||||
// produce a valid header-only export.
|
||||
const downloadClientJSON = (
|
||||
rows: ClientViewRow[],
|
||||
columns: ClientViewColumn[],
|
||||
filename: string,
|
||||
) => {
|
||||
if (!rows?.length || !columns?.length) return;
|
||||
if (!columns?.length) return;
|
||||
|
||||
const norm = (v: unknown): unknown => {
|
||||
if (v instanceof Date) return v.toISOString();
|
||||
@@ -587,13 +591,15 @@ export const useExploreAdditionalActionsMenu = (
|
||||
URL.revokeObjectURL(link.href);
|
||||
};
|
||||
|
||||
// Client-side XLSX for "Current View" (uses 'xlsx' already in deps)
|
||||
// Client-side XLSX for "Current View" (uses 'xlsx' already in deps).
|
||||
// `rows` may legitimately be empty (a filter that matches nothing) -- only
|
||||
// `columns` is required to produce a valid header-only export.
|
||||
const downloadClientXLSX = async (
|
||||
rows: ClientViewRow[],
|
||||
columns: ClientViewColumn[],
|
||||
filename: string,
|
||||
) => {
|
||||
if (!rows?.length || !columns?.length) return;
|
||||
if (!columns?.length) return;
|
||||
try {
|
||||
const XLSX = (await import(/* webpackChunkName: "xlsx" */ 'xlsx'))
|
||||
.default;
|
||||
@@ -618,12 +624,20 @@ export const useExploreAdditionalActionsMenu = (
|
||||
return o;
|
||||
});
|
||||
|
||||
const ws = XLSX.utils.json_to_sheet(data, { skipHeader: false });
|
||||
// json_to_sheet infers headers from the first data object's keys, so
|
||||
// with zero rows it would emit a completely blank sheet -- pass the
|
||||
// column labels explicitly so an empty filtered view still exports a
|
||||
// header-only sheet instead of nothing.
|
||||
const headers = columns.map(c => c.label ?? c.key);
|
||||
const ws = XLSX.utils.json_to_sheet(data, {
|
||||
header: headers,
|
||||
skipHeader: false,
|
||||
});
|
||||
const wb = XLSX.utils.book_new();
|
||||
XLSX.utils.book_append_sheet(wb, ws, 'Current View');
|
||||
|
||||
// Autosize columns (roughly) by header length
|
||||
const colWidths = Object.keys(data[0] || {}).map(h => ({
|
||||
const colWidths = headers.map(h => ({
|
||||
wch: Math.max(10, String(h).length + 2),
|
||||
}));
|
||||
ws['!cols'] = colWidths;
|
||||
@@ -856,10 +870,10 @@ export const useExploreAdditionalActionsMenu = (
|
||||
// Pass ownState so client/UI state (e.g., filters) can be respected when supported.
|
||||
if (
|
||||
!latestQueryFormData?.server_pagination &&
|
||||
ownState?.clientView?.rows?.length &&
|
||||
ownState?.clientView?.columns?.length
|
||||
ownState?.clientView &&
|
||||
ownState.clientView.columns?.length
|
||||
) {
|
||||
const { rows, columns } = ownState.clientView;
|
||||
const { rows = [], columns = [] } = ownState.clientView;
|
||||
downloadClientCSV(
|
||||
rows,
|
||||
columns,
|
||||
@@ -894,10 +908,10 @@ export const useExploreAdditionalActionsMenu = (
|
||||
onClick: () => {
|
||||
if (
|
||||
!latestQueryFormData?.server_pagination &&
|
||||
ownState?.clientView?.rows?.length &&
|
||||
ownState?.clientView?.columns?.length
|
||||
ownState?.clientView &&
|
||||
ownState.clientView.columns?.length
|
||||
) {
|
||||
const { rows, columns } = ownState.clientView;
|
||||
const { rows = [], columns = [] } = ownState.clientView;
|
||||
downloadClientJSON(
|
||||
rows,
|
||||
columns,
|
||||
@@ -956,11 +970,11 @@ export const useExploreAdditionalActionsMenu = (
|
||||
onClick: async () => {
|
||||
if (
|
||||
!latestQueryFormData?.server_pagination &&
|
||||
ownState?.clientView?.rows?.length &&
|
||||
ownState?.clientView?.columns?.length
|
||||
ownState?.clientView &&
|
||||
ownState.clientView.columns?.length
|
||||
) {
|
||||
// Client-side filtered view → XLSX
|
||||
const { rows, columns } = ownState.clientView;
|
||||
const { rows = [], columns = [] } = ownState.clientView;
|
||||
await downloadClientXLSX(
|
||||
rows,
|
||||
columns,
|
||||
|
||||
+33
@@ -278,6 +278,39 @@ test('shows 413 error toast when Export Current View CSV server path fails with
|
||||
});
|
||||
});
|
||||
|
||||
test('Export Current View CSV takes the client path for a filter that matches zero rows, rather than falling back to an unfiltered backend export', async () => {
|
||||
global.URL.revokeObjectURL = jest.fn();
|
||||
|
||||
render(
|
||||
<TestComponent
|
||||
{...defaultProps}
|
||||
latestQueryFormData={{
|
||||
datasource: '1__table',
|
||||
viz_type: 'table',
|
||||
}}
|
||||
ownState={{
|
||||
clientView: {
|
||||
rows: [],
|
||||
columns: [{ key: 'name', label: 'Name' }],
|
||||
},
|
||||
}}
|
||||
/>,
|
||||
{ useRedux: true },
|
||||
);
|
||||
|
||||
userEvent.hover(await screen.findByText('Data Export Options'));
|
||||
userEvent.hover(await screen.findByText('Export Current View'));
|
||||
userEvent.click(await screen.findByText('Export to .CSV'));
|
||||
|
||||
// The client path builds and clicks a download link directly rather than
|
||||
// calling exportChart; asserting exportChart was never called is what
|
||||
// distinguishes it from the backend fallback path (which doesn't know
|
||||
// about the empty client-side filter and would export every row).
|
||||
await waitFor(() => {
|
||||
expect(mockExportChart).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
const CHART_SELECTOR = '.panel-body .chart-container';
|
||||
const SLICE_NAME = 'My chart';
|
||||
const CHART_ID = 42;
|
||||
|
||||
@@ -303,24 +303,61 @@ test('useDatasetDrillInfo creates new verbose_map from columns and metrics', asy
|
||||
expect(result.current.result?.verbose_map).not.toHaveProperty('old_key');
|
||||
});
|
||||
|
||||
test('useDatasetDrillInfo handles NaN datasource ID from malformed string', async () => {
|
||||
test('useDatasetDrillInfo does not fetch when datasource ID resolves to NaN', async () => {
|
||||
// Regression test: a chart's slice entity can still be unhydrated right
|
||||
// after a client-side navigation back to a dashboard from Explore, so
|
||||
// datasetId may transiently resolve to NaN. The hook must not fire a
|
||||
// request for dataset "NaN" and should stay in loading, retrying once a
|
||||
// real datasetId arrives (see the SliceHeaderControls -> Chart.tsx
|
||||
// `state.sliceEntities.slices[id] || EMPTY_OBJECT` fallback).
|
||||
const { result, rerender } = renderHook(
|
||||
({ id }: { id: string | number }) => useDatasetDrillInfo(id, 456),
|
||||
{ initialProps: { id: 'abc' } },
|
||||
);
|
||||
|
||||
expect(result.current.status).toBe('loading');
|
||||
expect(mockedCachedSupersetGet).not.toHaveBeenCalled();
|
||||
|
||||
const mockDataset = { id: 123, columns: [], metrics: [] };
|
||||
mockedCachedSupersetGet.mockResolvedValue({
|
||||
json: {
|
||||
result: { id: NaN, columns: [], metrics: [] },
|
||||
},
|
||||
json: { result: mockDataset },
|
||||
} as any);
|
||||
|
||||
const { result } = renderHook(() => useDatasetDrillInfo('abc', 456));
|
||||
rerender({ id: '123__table' });
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.status).toBe('complete');
|
||||
});
|
||||
|
||||
// Verify hook calls endpoint with NaN (API will handle validation)
|
||||
expect(mockedCachedSupersetGet).toHaveBeenCalledWith({
|
||||
endpoint: '/api/v1/dataset/NaN/drill_info/?q=(dashboard_id:456)',
|
||||
endpoint: '/api/v1/dataset/123/drill_info/?q=(dashboard_id:456)',
|
||||
});
|
||||
expect(result.current.status).toBe('complete');
|
||||
});
|
||||
|
||||
test('useDatasetDrillInfo resets to loading when datasetId regresses to NaN after resolving another dataset', async () => {
|
||||
// Regression test: if the hook already completed for one dataset and then
|
||||
// receives a transient malformed id (e.g. a fresh navigation clears the
|
||||
// resolved datasetId before the new one hydrates), it must not keep
|
||||
// exposing the previous dataset's Complete result -- the context menu
|
||||
// would otherwise offer drill metadata for the wrong dataset.
|
||||
const mockDataset = { id: 123, columns: [], metrics: [] };
|
||||
mockedCachedSupersetGet.mockResolvedValue({
|
||||
json: { result: mockDataset },
|
||||
} as any);
|
||||
|
||||
const { result, rerender } = renderHook(
|
||||
({ id }: { id: string | number }) => useDatasetDrillInfo(id, 456),
|
||||
{ initialProps: { id: 123 } },
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.status).toBe('complete');
|
||||
});
|
||||
expect(result.current.result).toMatchObject({ id: 123 });
|
||||
|
||||
rerender({ id: 'abc' });
|
||||
|
||||
expect(result.current.status).toBe('loading');
|
||||
expect(result.current.result).toBeNull();
|
||||
});
|
||||
|
||||
test('useDatasetDrillInfo fetches dataset via extension when extension and formData provided', async () => {
|
||||
|
||||
@@ -86,11 +86,28 @@ export const useDatasetDrillInfo = (
|
||||
});
|
||||
return;
|
||||
}
|
||||
const numericDatasetId = getDatasetId(datasetId);
|
||||
if (Number.isNaN(numericDatasetId)) {
|
||||
// datasetId isn't resolved yet (e.g. the dashboard's slice entity hasn't
|
||||
// hydrated after a client-side navigation back from Explore). Reset to
|
||||
// Loading rather than firing a request for dataset "NaN" -- and rather
|
||||
// than leaving a previous id's Complete/Error result in place, which
|
||||
// would let the context menu expose drill metadata for the wrong
|
||||
// dataset until this one resolves. The effect reruns once datasetId
|
||||
// settles to a real value.
|
||||
setResource({
|
||||
status: ResourceStatus.Loading,
|
||||
result: null,
|
||||
error: null,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// `bestEffort` callers recover from a failure themselves, so it is not worth
|
||||
// logging: a deployment that registers the drill-by extension because this
|
||||
// endpoint is unreachable would otherwise log on every dashboard load.
|
||||
const fetchDrillInfo = async ({ bestEffort = false } = {}) => {
|
||||
const endpoint = `/api/v1/dataset/${getDatasetId(datasetId)}/drill_info/?q=(dashboard_id:${dashboardId})`;
|
||||
const endpoint = `/api/v1/dataset/${numericDatasetId}/drill_info/?q=(dashboard_id:${dashboardId})`;
|
||||
try {
|
||||
const { json } = await cachedSupersetGet({ endpoint });
|
||||
return json.result;
|
||||
@@ -105,7 +122,6 @@ export const useDatasetDrillInfo = (
|
||||
|
||||
const fetchDataset = async () => {
|
||||
try {
|
||||
const numericDatasetId = getDatasetId(datasetId);
|
||||
const loadDrillByOptionsExtension = getExtensionsRegistry().get(
|
||||
'load.drillby.options',
|
||||
);
|
||||
|
||||
Generated
+81
-81
@@ -24,7 +24,7 @@
|
||||
"@types/ws": "^8.18.1",
|
||||
"esbuild": "^0.28.2",
|
||||
"globals": "^17.11.0",
|
||||
"oxfmt": "^0.65.0",
|
||||
"oxfmt": "^0.66.0",
|
||||
"oxlint": "^1.81.0",
|
||||
"oxlint-tsgolint": "^7.0.2001",
|
||||
"tscw-config": "^1.1.2",
|
||||
@@ -522,9 +522,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@oxfmt/binding-android-arm-eabi": {
|
||||
"version": "0.65.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-android-arm-eabi/-/binding-android-arm-eabi-0.65.0.tgz",
|
||||
"integrity": "sha512-M10Gs1SSpTNI6ahGx3M/OlIdUF4hkaP6OgUb+MS79t/Pgflk3r1nW5gPFqsZGUAXg0H1AfANT9AvLdBSTIhZKg==",
|
||||
"version": "0.66.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-android-arm-eabi/-/binding-android-arm-eabi-0.66.0.tgz",
|
||||
"integrity": "sha512-2Me9eoptv6ERdEuI2P8AOlYdHHraXebJaM6SC0kc2Dfb+mLrep2db+fedBPKaYn673h/vBgvP4tkOdAbaudX6w==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
@@ -539,9 +539,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@oxfmt/binding-android-arm64": {
|
||||
"version": "0.65.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-android-arm64/-/binding-android-arm64-0.65.0.tgz",
|
||||
"integrity": "sha512-6DXH5sftNlaHpWJG50hFMF+Qxtq5D2TmahvcDPxWNcGIf8qrC9Y0YgHYcYZ2hlWzaccKXh/f3GcssH8vtkl4JA==",
|
||||
"version": "0.66.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-android-arm64/-/binding-android-arm64-0.66.0.tgz",
|
||||
"integrity": "sha512-u7O+bSSF0HGsDKkQQxBqvLGVepu93RA+JKu+ONqvfh4sCnCEbj31wZj4iG5gk3XfRwrmYj0/8catkO2LcblQKQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@@ -556,9 +556,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@oxfmt/binding-darwin-arm64": {
|
||||
"version": "0.65.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-darwin-arm64/-/binding-darwin-arm64-0.65.0.tgz",
|
||||
"integrity": "sha512-K9m7lr53pcOLETNsC88sWes/GWHUGjZyHx95UhYcSXy0r30haLdeXlSufSenEAtoLaW753WN8/l4M7GYcRt6cg==",
|
||||
"version": "0.66.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-darwin-arm64/-/binding-darwin-arm64-0.66.0.tgz",
|
||||
"integrity": "sha512-/ikyMIVjX/sdo7KtjxoEsSUosfPzveVhT9RWMx9yGqFDKFJ89JAEKuEeLBmurDjrkb4w8tOnAdSO3SBaplY3bw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@@ -573,9 +573,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@oxfmt/binding-darwin-x64": {
|
||||
"version": "0.65.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-darwin-x64/-/binding-darwin-x64-0.65.0.tgz",
|
||||
"integrity": "sha512-sTNwIx1gre3MyiHOPLu7IGW4UyMScYL4DTmJT01p4vzB0En+OJUQz6KuH8t0PpsClRSaMuY3b0QmtoPItfO8Lg==",
|
||||
"version": "0.66.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-darwin-x64/-/binding-darwin-x64-0.66.0.tgz",
|
||||
"integrity": "sha512-q5xUsKeFqawa9NXa6ZGXWimFV19m8MogKPdTaSVDAAk2EQKBmBZRDeluwcl1p8ty/OFc9s9888OKEh3xfPVH0g==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
@@ -590,9 +590,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@oxfmt/binding-freebsd-x64": {
|
||||
"version": "0.65.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-freebsd-x64/-/binding-freebsd-x64-0.65.0.tgz",
|
||||
"integrity": "sha512-lYZMVIiIpnjGu5hJb2jxA8NYQ/e0OTGuaiAf4dqlGPNnPmUTu23FZRMltmjro/KkQm1uE4NT4n5yJ2zWmKcpfA==",
|
||||
"version": "0.66.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-freebsd-x64/-/binding-freebsd-x64-0.66.0.tgz",
|
||||
"integrity": "sha512-CR+x4VzMY0pRXLK/xFQ/RzsSFkP5t2Z2mef0QY6OP/rTRcMUoMLCOM62/3Fp/t0K+UDoBKxvMyeb6D0zPMjleA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
@@ -607,9 +607,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@oxfmt/binding-linux-arm-gnueabihf": {
|
||||
"version": "0.65.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-0.65.0.tgz",
|
||||
"integrity": "sha512-gIdXFAt/bURnjxuoedDEWdZ0PEWEmdDcm8qdpoFYYvW3QMk/5D4vUaH4mlMeRpeTdST4izUgHVO6RawQ4QulJw==",
|
||||
"version": "0.66.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-0.66.0.tgz",
|
||||
"integrity": "sha512-ZEYmO/LbH9tTQCADILHGZE4GeOXOAj2VzedHkASNwjmwlwtutJCLpCJbIs37wRGTFgWRoEcD72jpMX+IBJUGjQ==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
@@ -624,9 +624,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@oxfmt/binding-linux-arm-musleabihf": {
|
||||
"version": "0.65.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-arm-musleabihf/-/binding-linux-arm-musleabihf-0.65.0.tgz",
|
||||
"integrity": "sha512-jJVyADto7gA2AaX5qAjAexrxx9PJQaKWOe8PICE7yKMbjBRyOHcmj9TtVJ+MZYDUQ3hodU0AcoTj0jFQ1W4C6Q==",
|
||||
"version": "0.66.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-arm-musleabihf/-/binding-linux-arm-musleabihf-0.66.0.tgz",
|
||||
"integrity": "sha512-hNtR9/oU0CeTkq7JnRkmBQwqe17v2ZaAMLC4VcN7IIOWeRyWDk0knSPWS9iiLmtbZ2RRBBtsG01jQgkZmKCJeQ==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
@@ -641,9 +641,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@oxfmt/binding-linux-arm64-gnu": {
|
||||
"version": "0.65.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-0.65.0.tgz",
|
||||
"integrity": "sha512-p3RFkB+u7u+8up99b/NEcI1hdpLDiGgJYNwDorB60n7eH+eKposAKuMBxx+NqB3b+sJP4CZmYDh9G7X62tUsKg==",
|
||||
"version": "0.66.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-0.66.0.tgz",
|
||||
"integrity": "sha512-uwOVQ8i6I1LT/+eDzfsgrrcZp8Fn6NPVUPn8fF5gdFGekFf0PddF+LEuwsD0/pbNUcKZhDj2rQ5UpITh9gF4iQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@@ -661,9 +661,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@oxfmt/binding-linux-arm64-musl": {
|
||||
"version": "0.65.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-arm64-musl/-/binding-linux-arm64-musl-0.65.0.tgz",
|
||||
"integrity": "sha512-5Prb0uFzJHr+OUD/qS/TmU526wD+PaHDsm3KoRiUXbMIDpTSErjeQYkK3OQeshAvD/PuLa9WGEi9WPajjdOZJg==",
|
||||
"version": "0.66.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-arm64-musl/-/binding-linux-arm64-musl-0.66.0.tgz",
|
||||
"integrity": "sha512-tTkF2Dmx4nGAjmBlZb+UtTGqR/EK4ZrW9qBfzte07a9XWqzoGGKzpFFlyNDhQe+Uwql94+ReCTeNbhOXscw1Dg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@@ -681,9 +681,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@oxfmt/binding-linux-ppc64-gnu": {
|
||||
"version": "0.65.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-0.65.0.tgz",
|
||||
"integrity": "sha512-S8svxTp81obnF3admN9yd+u2rOYXtyzThLGBTg1PY6TPtGcC09BaaXLQD+TBSMa7yvqhCDZ8DFri+S/yG60qCg==",
|
||||
"version": "0.66.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-0.66.0.tgz",
|
||||
"integrity": "sha512-F3cKHUav4yXOHn6GFnwpBhSYsJOYKKf9eqO/9jlEuqPxNw9zb98E9ZFct79gcg8pibUGkbveEu9WDlmXJpDzKw==",
|
||||
"cpu": [
|
||||
"ppc64"
|
||||
],
|
||||
@@ -701,9 +701,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@oxfmt/binding-linux-riscv64-gnu": {
|
||||
"version": "0.65.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-riscv64-gnu/-/binding-linux-riscv64-gnu-0.65.0.tgz",
|
||||
"integrity": "sha512-WtXBr75G/h2qOHy8SiGtC1R6aS3jt4mE52v1D8AtwMXIgoOmSNP9lKvbSaTRoL0e5wsMPoi6T72QWDYPu+S+nA==",
|
||||
"version": "0.66.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-riscv64-gnu/-/binding-linux-riscv64-gnu-0.66.0.tgz",
|
||||
"integrity": "sha512-K5fDaNZfDyQMYA/3qL21bqyN0X9T15LLwwbFPt2aHc94+ZG7bh0vZEsy2y7NlRnjjHFSwN+Hzg6ldJtbOriH4Q==",
|
||||
"cpu": [
|
||||
"riscv64"
|
||||
],
|
||||
@@ -721,9 +721,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@oxfmt/binding-linux-riscv64-musl": {
|
||||
"version": "0.65.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-riscv64-musl/-/binding-linux-riscv64-musl-0.65.0.tgz",
|
||||
"integrity": "sha512-YwSLVvpaz4o/nv/miiPEBJz+eJ+VmbgNIrao6RccK9ce+L5EA8wP+ZD0uFeq6wKOza6zoWv/dR0sj6lip6R3EA==",
|
||||
"version": "0.66.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-riscv64-musl/-/binding-linux-riscv64-musl-0.66.0.tgz",
|
||||
"integrity": "sha512-44Yc+I+qOmTElRcEhm5hUKIUJEQIOugymz4ua4tB0Wox7tGAfIbjzmXz/HDAtw1Ij6gmBwZlzh4hc9679RhWeA==",
|
||||
"cpu": [
|
||||
"riscv64"
|
||||
],
|
||||
@@ -741,9 +741,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@oxfmt/binding-linux-s390x-gnu": {
|
||||
"version": "0.65.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-0.65.0.tgz",
|
||||
"integrity": "sha512-XQTPqgvyrgkKcFq+Tp2eK6JS7sqqJ+nRmy2Fav4j3I+i4dJoPJm7YwEdoeSDX9xkqj9jZ/lWfF3bXUWztIrn6A==",
|
||||
"version": "0.66.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-0.66.0.tgz",
|
||||
"integrity": "sha512-1e29Eg9hEj2kRBB19M0seIehPbbXHCk35GvImjDvb79rjjYjXCRmtbUNHJcgoktZAMIzXrTbxDBKmTc1V4bg3A==",
|
||||
"cpu": [
|
||||
"s390x"
|
||||
],
|
||||
@@ -761,9 +761,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@oxfmt/binding-linux-x64-gnu": {
|
||||
"version": "0.65.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-x64-gnu/-/binding-linux-x64-gnu-0.65.0.tgz",
|
||||
"integrity": "sha512-cjZlx6S/VkeCNWCbwZriTnLnZeTcV3DEyeRGSw/2wwLP9viq+C0bJ4bC1k/ZLkFxDcB1lUgSasPkYGP1bdraOg==",
|
||||
"version": "0.66.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-x64-gnu/-/binding-linux-x64-gnu-0.66.0.tgz",
|
||||
"integrity": "sha512-vODY1UQo10gngn0+D4xHKU84F1Twm1LqrzV4SqPXvmQKSd87paehvZ6jqA5wKs6XQrlWul9clYMDVHcoW9CPMA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
@@ -781,9 +781,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@oxfmt/binding-linux-x64-musl": {
|
||||
"version": "0.65.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-x64-musl/-/binding-linux-x64-musl-0.65.0.tgz",
|
||||
"integrity": "sha512-2azCjxdLtK4zCcIOU1dlXlU0xxfbPi6EjwWx7Ac7teWPidIIDOcIhudup83xNCKYhtqeVd/gaVDOxbUq4syXWA==",
|
||||
"version": "0.66.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-x64-musl/-/binding-linux-x64-musl-0.66.0.tgz",
|
||||
"integrity": "sha512-YDzXx2JsT4+HL4MdkVrYjO55NS5lUKNm8rLC4ZPou8+seu0v0jhecSh+ufoO6+xEa8gccEezMlI2WHJi4ApUgw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
@@ -801,9 +801,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@oxfmt/binding-openharmony-arm64": {
|
||||
"version": "0.65.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-openharmony-arm64/-/binding-openharmony-arm64-0.65.0.tgz",
|
||||
"integrity": "sha512-KXQ7xi1e/voP0IQaw6fG6XY4Z5+Llf1XmRSZS1t7pVFCecFJ0iXaboKmVwjFtp5MLlT5iWQrJ2U1C3GJdZ2u+Q==",
|
||||
"version": "0.66.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-openharmony-arm64/-/binding-openharmony-arm64-0.66.0.tgz",
|
||||
"integrity": "sha512-mJjUYd8lj0+j4JkYyEM+5qKBf1Rnrpgjn/SVYKJhicVDqLz566ooa7Fs8zflPqt+dnZDV7X054rVIQX6ZcQNlQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@@ -818,9 +818,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@oxfmt/binding-win32-arm64-msvc": {
|
||||
"version": "0.65.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-0.65.0.tgz",
|
||||
"integrity": "sha512-2FbbjG5jEqLSLKVJwBap84uJfpn5Y5A53KEO0aUNr+zeiRB9nyPUIFMcSbZVMFLitfBytFWRNngozXYjb6Rsbw==",
|
||||
"version": "0.66.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-0.66.0.tgz",
|
||||
"integrity": "sha512-soV+0vESv7e5ntCHWC61x4gg8OSak6IHHnWsZmHrJFlvMj2AK+kmldErCNkVkrvc1Ts2/++rJXn+IuAb2WMXhw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@@ -835,9 +835,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@oxfmt/binding-win32-ia32-msvc": {
|
||||
"version": "0.65.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-0.65.0.tgz",
|
||||
"integrity": "sha512-LJ+ZacAPSjegDOnSLyA1TMWAhdDrsK4el3REdr1oL2UtVBCMhO2II/Sb3cEW6mF2MfLhl8hDNCSvc7KSbgk3LQ==",
|
||||
"version": "0.66.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-0.66.0.tgz",
|
||||
"integrity": "sha512-YCPi23uRIEYuIKTZohAkKbPFpujQ5QBuUM5iDv+UqbCmTPAkaFsxjsSuB8xlBpRT0G7eP/4HMF+cPDSqHtOD9A==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
@@ -852,9 +852,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@oxfmt/binding-win32-x64-msvc": {
|
||||
"version": "0.65.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-win32-x64-msvc/-/binding-win32-x64-msvc-0.65.0.tgz",
|
||||
"integrity": "sha512-higu9cWEO6XXFzATD1jf0mCK34rNfN2H9JrJie7QB1IhleVpTh0QlLH9Ip2C1H/Nd5n0v5pvRtC+5R0uE4HpVg==",
|
||||
"version": "0.66.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxfmt/binding-win32-x64-msvc/-/binding-win32-x64-msvc-0.66.0.tgz",
|
||||
"integrity": "sha512-bwTQcv/JVRPkOqQtMF0X7vpvpncDQiBcXHxZ9S2hR12Hlo8bvBdUR5x5XnxzDZ3kM0qoZw1rv7KaD66Ly+pFWA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
@@ -2923,9 +2923,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/oxfmt": {
|
||||
"version": "0.65.0",
|
||||
"resolved": "https://registry.npmjs.org/oxfmt/-/oxfmt-0.65.0.tgz",
|
||||
"integrity": "sha512-SgS5VgnP42T0zl3zWD+xoH8FCqg1SAFnSRoOT/qeoa6gxcYIqrDMOmcXIg/EWSN92Du4ogB4riuKhKd6Y4CGhw==",
|
||||
"version": "0.66.0",
|
||||
"resolved": "https://registry.npmjs.org/oxfmt/-/oxfmt-0.66.0.tgz",
|
||||
"integrity": "sha512-FfvqR8RFtV6JJpRrpkfqyVCQ7HDvZ/VriWFx7veftCgL1B5ZO9qNr+1rvPieycMQnNfVG0PWyJQiy7p0hq1I5w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -2938,28 +2938,28 @@
|
||||
"node": "^20.19.0 || >=22.12.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/Boshen"
|
||||
"url": "https://github.com/sponsors/oxc-project"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@oxfmt/binding-android-arm-eabi": "0.65.0",
|
||||
"@oxfmt/binding-android-arm64": "0.65.0",
|
||||
"@oxfmt/binding-darwin-arm64": "0.65.0",
|
||||
"@oxfmt/binding-darwin-x64": "0.65.0",
|
||||
"@oxfmt/binding-freebsd-x64": "0.65.0",
|
||||
"@oxfmt/binding-linux-arm-gnueabihf": "0.65.0",
|
||||
"@oxfmt/binding-linux-arm-musleabihf": "0.65.0",
|
||||
"@oxfmt/binding-linux-arm64-gnu": "0.65.0",
|
||||
"@oxfmt/binding-linux-arm64-musl": "0.65.0",
|
||||
"@oxfmt/binding-linux-ppc64-gnu": "0.65.0",
|
||||
"@oxfmt/binding-linux-riscv64-gnu": "0.65.0",
|
||||
"@oxfmt/binding-linux-riscv64-musl": "0.65.0",
|
||||
"@oxfmt/binding-linux-s390x-gnu": "0.65.0",
|
||||
"@oxfmt/binding-linux-x64-gnu": "0.65.0",
|
||||
"@oxfmt/binding-linux-x64-musl": "0.65.0",
|
||||
"@oxfmt/binding-openharmony-arm64": "0.65.0",
|
||||
"@oxfmt/binding-win32-arm64-msvc": "0.65.0",
|
||||
"@oxfmt/binding-win32-ia32-msvc": "0.65.0",
|
||||
"@oxfmt/binding-win32-x64-msvc": "0.65.0"
|
||||
"@oxfmt/binding-android-arm-eabi": "0.66.0",
|
||||
"@oxfmt/binding-android-arm64": "0.66.0",
|
||||
"@oxfmt/binding-darwin-arm64": "0.66.0",
|
||||
"@oxfmt/binding-darwin-x64": "0.66.0",
|
||||
"@oxfmt/binding-freebsd-x64": "0.66.0",
|
||||
"@oxfmt/binding-linux-arm-gnueabihf": "0.66.0",
|
||||
"@oxfmt/binding-linux-arm-musleabihf": "0.66.0",
|
||||
"@oxfmt/binding-linux-arm64-gnu": "0.66.0",
|
||||
"@oxfmt/binding-linux-arm64-musl": "0.66.0",
|
||||
"@oxfmt/binding-linux-ppc64-gnu": "0.66.0",
|
||||
"@oxfmt/binding-linux-riscv64-gnu": "0.66.0",
|
||||
"@oxfmt/binding-linux-riscv64-musl": "0.66.0",
|
||||
"@oxfmt/binding-linux-s390x-gnu": "0.66.0",
|
||||
"@oxfmt/binding-linux-x64-gnu": "0.66.0",
|
||||
"@oxfmt/binding-linux-x64-musl": "0.66.0",
|
||||
"@oxfmt/binding-openharmony-arm64": "0.66.0",
|
||||
"@oxfmt/binding-win32-arm64-msvc": "0.66.0",
|
||||
"@oxfmt/binding-win32-ia32-msvc": "0.66.0",
|
||||
"@oxfmt/binding-win32-x64-msvc": "0.66.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"svelte": "^5.0.0",
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
"@types/ws": "^8.18.1",
|
||||
"esbuild": "^0.28.2",
|
||||
"globals": "^17.11.0",
|
||||
"oxfmt": "^0.65.0",
|
||||
"oxfmt": "^0.66.0",
|
||||
"oxlint": "^1.81.0",
|
||||
"oxlint-tsgolint": "^7.0.2001",
|
||||
"tscw-config": "^1.1.2",
|
||||
|
||||
@@ -43,6 +43,7 @@ from superset.migrations.shared.migrate_viz.processors import (
|
||||
MigratePivotTable,
|
||||
MigrateSankey,
|
||||
MigrateSunburst,
|
||||
MigrateTableChart,
|
||||
MigrateTreeMap,
|
||||
)
|
||||
from superset.migrations.shared.utils import paginated_update, try_load_json
|
||||
@@ -61,6 +62,7 @@ class VizType(str, Enum):
|
||||
PIVOT_TABLE = "pivot_table"
|
||||
SANKEY = "sankey"
|
||||
SUNBURST = "sunburst"
|
||||
TABLE = "table"
|
||||
TREEMAP = "treemap"
|
||||
|
||||
|
||||
@@ -77,6 +79,7 @@ MIGRATIONS: dict[VizType, Type[MigrateViz]] = {
|
||||
VizType.PIVOT_TABLE: MigratePivotTable,
|
||||
VizType.SANKEY: MigrateSankey,
|
||||
VizType.SUNBURST: MigrateSunburst,
|
||||
VizType.TABLE: MigrateTableChart,
|
||||
VizType.TREEMAP: MigrateTreeMap,
|
||||
}
|
||||
|
||||
|
||||
@@ -261,7 +261,7 @@ def masked_encrypted_extra_validator(value: str) -> None:
|
||||
encrypted_extra_validator(value)
|
||||
|
||||
|
||||
def extra_validator(value: str) -> str:
|
||||
def extra_validator(value: str) -> str: # noqa: C901
|
||||
"""
|
||||
Validate that extra is a valid JSON string, and that metadata_params
|
||||
keys are on the call signature for SQLAlchemy Metadata
|
||||
@@ -274,6 +274,11 @@ def extra_validator(value: str) -> str:
|
||||
[_("Field cannot be decoded by JSON. %(msg)s", msg=str(ex))]
|
||||
) from ex
|
||||
|
||||
if not isinstance(extra_, dict):
|
||||
raise ValidationError(
|
||||
[_("Extra field must be a mapping from string keys to values.")]
|
||||
)
|
||||
|
||||
metadata_signature = inspect.signature(MetaData)
|
||||
for key in extra_.get("metadata_params", {}):
|
||||
if key not in metadata_signature.parameters:
|
||||
|
||||
@@ -175,7 +175,6 @@ class CouchbaseEngineSpec(BasicParametersMixin, BaseEngineSpec):
|
||||
port=parameters.get("port"),
|
||||
query=query_params,
|
||||
)
|
||||
print(uri)
|
||||
# SQLAlchemy 2.0 made URL.__str__() hide the password by default
|
||||
# (it rendered in full under 1.4); render_as_string(hide_password=
|
||||
# False) is required here since this URI is stored/used to actually
|
||||
@@ -186,7 +185,6 @@ class CouchbaseEngineSpec(BasicParametersMixin, BaseEngineSpec):
|
||||
def get_parameters_from_uri(
|
||||
cls, uri: str, encrypted_extra: Optional[dict[str, Any]] = None
|
||||
) -> BaseBasicParametersType:
|
||||
print("get_parameters is called : ", uri)
|
||||
url = make_url_safe(uri)
|
||||
query = {
|
||||
key: value
|
||||
|
||||
@@ -40,6 +40,8 @@ class Slice(Base): # type: ignore
|
||||
viz_type = Column(String(250))
|
||||
params = Column(Text)
|
||||
query_context = Column(Text)
|
||||
datasource_id: int = Column(Integer)
|
||||
datasource_type: str = Column(String(200))
|
||||
|
||||
|
||||
FORM_DATA_BAK_FIELD_NAME = "form_data_bak"
|
||||
@@ -156,16 +158,24 @@ class MigrateViz:
|
||||
def upgrade_slice(cls, slc: Slice) -> None:
|
||||
try:
|
||||
clz = cls(slc.params)
|
||||
# Back up params exactly as they were stored, before synthesizing
|
||||
# "datasource" below, so downgrade_slice() restores the original
|
||||
# chart verbatim rather than a copy carrying an injected key it
|
||||
# never had.
|
||||
form_data_bak = copy.deepcopy(clz.data)
|
||||
# Some charts don't carry a "datasource" key in params — outside
|
||||
# of migrations, callers always read it via Slice.form_data,
|
||||
# which injects "datasource" from the datasource_id/
|
||||
# datasource_type columns on every access. _build_query() (and
|
||||
# anything else touching self.data) needs that same key, so
|
||||
# synthesize it here the same way for the charts missing it.
|
||||
if "datasource" not in clz.data and slc.datasource_id is not None:
|
||||
clz.data["datasource"] = f"{slc.datasource_id}__{slc.datasource_type}"
|
||||
|
||||
clz._pre_action()
|
||||
clz._migrate()
|
||||
clz._post_action()
|
||||
|
||||
# viz_type depends on the migration and should be set after its execution
|
||||
# because a source viz can be mapped to different target viz types
|
||||
slc.viz_type = clz.target_viz_type
|
||||
|
||||
backup: Any | dict[str, Any] = {FORM_DATA_BAK_FIELD_NAME: form_data_bak}
|
||||
|
||||
query_context = try_load_json(slc.query_context)
|
||||
@@ -175,17 +185,14 @@ class MigrateViz:
|
||||
# A stored query_context is expected to be an object carrying
|
||||
# a non-null "queries" list, but an atypical/malformed one
|
||||
# (e.g. hand-edited via the API) missing that key, or with
|
||||
# "queries": null, must not raise here: viz_type was already
|
||||
# flipped above, so an uncaught exception at this point
|
||||
# would leave the slice half-migrated (new viz_type, but
|
||||
# stale params/query_context in the old shape). Back up the
|
||||
# whole context in that case so downgrade can restore it
|
||||
# verbatim instead of losing it (see FULL_CONTEXT_BAK_KEY).
|
||||
# Both cases must share this sentinel path rather than
|
||||
# backing up a bare `None` -- that value is indistinguishable
|
||||
# from "no context was ever stored", which would make
|
||||
# downgrade discard the slice's original datasource/form_data
|
||||
# instead of restoring this context.
|
||||
# "queries": null, is still backed up wholesale here rather
|
||||
# than raising on membership-testing it below, so downgrade
|
||||
# can restore it verbatim instead of losing it (see
|
||||
# FULL_CONTEXT_BAK_KEY). Both cases must share this sentinel
|
||||
# path rather than backing up a bare `None` -- that value is
|
||||
# indistinguishable from "no context was ever stored", which
|
||||
# would make downgrade discard the slice's original
|
||||
# datasource/form_data instead of restoring this context.
|
||||
if "queries" in query_context and query_context["queries"] is not None:
|
||||
queries_bak = copy.deepcopy(query_context["queries"])
|
||||
else:
|
||||
@@ -201,16 +208,23 @@ class MigrateViz:
|
||||
# number or a JSON list -- both accepted by the schema
|
||||
# validator) can't carry "queries"/"form_data" keys; back it
|
||||
# up wholesale like the cases above and rebuild a fresh one,
|
||||
# rather than raising on membership-testing a non-dict (which
|
||||
# would leave the slice half-migrated, per the note above).
|
||||
# rather than raising on membership-testing a non-dict.
|
||||
queries_bak = {FULL_CONTEXT_BAK_KEY: copy.deepcopy(query_context)}
|
||||
query_context = clz._build_query()
|
||||
else:
|
||||
query_context = clz._build_query()
|
||||
|
||||
slc.query_context = json.dumps(query_context)
|
||||
backup[QUERIES_BAK_FIELD_NAME] = queries_bak
|
||||
slc.params = json.dumps({**clz.data, **backup})
|
||||
new_params = json.dumps({**clz.data, **backup})
|
||||
new_query_context = json.dumps(query_context)
|
||||
|
||||
# Only mutate the slice once every step above has succeeded, so a
|
||||
# failure never leaves viz_type out of sync with params/query_context.
|
||||
# viz_type depends on the migration and should be set after its execution
|
||||
# because a source viz can be mapped to different target viz types
|
||||
slc.viz_type = clz.target_viz_type
|
||||
slc.query_context = new_query_context
|
||||
slc.params = new_params
|
||||
|
||||
except Exception as e:
|
||||
logger.warning("Failed to migrate slice %s: %s", slc.id, e)
|
||||
@@ -219,36 +233,48 @@ class MigrateViz:
|
||||
def downgrade_slice(cls, slc: Slice) -> None:
|
||||
try:
|
||||
form_data = try_load_json(slc.params)
|
||||
form_data_bak = form_data.get(FORM_DATA_BAK_FIELD_NAME, {})
|
||||
if (
|
||||
"viz_type" in form_data_bak
|
||||
and form_data_bak["viz_type"] == cls.source_viz_type
|
||||
"viz_type"
|
||||
not in (form_data_bak := form_data.get(FORM_DATA_BAK_FIELD_NAME, {}))
|
||||
or form_data_bak["viz_type"] != cls.source_viz_type
|
||||
):
|
||||
slc.params = json.dumps(form_data_bak)
|
||||
slc.viz_type = form_data_bak.get("viz_type")
|
||||
query_context = try_load_json(slc.query_context)
|
||||
queries_bak = form_data.get(QUERIES_BAK_FIELD_NAME)
|
||||
if (
|
||||
isinstance(queries_bak, dict)
|
||||
and FULL_CONTEXT_BAK_KEY in queries_bak
|
||||
):
|
||||
# The original context had no "queries" key, so it was
|
||||
# backed up wholesale on upgrade -- restore it verbatim
|
||||
# rather than patching "queries" onto the upgraded
|
||||
# context.
|
||||
slc.query_context = json.dumps(queries_bak[FULL_CONTEXT_BAK_KEY])
|
||||
elif queries_bak is not None:
|
||||
# A falsy-but-present backup (e.g. an original
|
||||
# "queries": []) is still a real context to restore, not
|
||||
# the "there was nothing to restore" case below --
|
||||
# treating it as None would discard the slice's original
|
||||
# datasource and form_data.
|
||||
query_context["queries"] = queries_bak
|
||||
if "form_data" in query_context:
|
||||
query_context["form_data"] = form_data_bak
|
||||
slc.query_context = json.dumps(query_context)
|
||||
else:
|
||||
slc.query_context = None
|
||||
return
|
||||
|
||||
new_params = json.dumps(form_data_bak)
|
||||
new_viz_type = form_data_bak.get("viz_type")
|
||||
|
||||
# Sentinel so a "leave query_context untouched" branch below is
|
||||
# distinguishable from "explicitly set it to None".
|
||||
unchanged = object()
|
||||
new_query_context: Any = unchanged
|
||||
|
||||
query_context = try_load_json(slc.query_context)
|
||||
queries_bak = form_data.get(QUERIES_BAK_FIELD_NAME)
|
||||
if isinstance(queries_bak, dict) and FULL_CONTEXT_BAK_KEY in queries_bak:
|
||||
# The original context had no "queries" key (or wasn't an
|
||||
# object at all), so it was backed up wholesale on upgrade --
|
||||
# restore it verbatim rather than patching "queries" onto the
|
||||
# upgraded context.
|
||||
new_query_context = json.dumps(queries_bak[FULL_CONTEXT_BAK_KEY])
|
||||
elif queries_bak is not None:
|
||||
# A falsy-but-present backup (e.g. an original
|
||||
# "queries": []) is still a real context to restore, not
|
||||
# the "there was nothing to restore" case below -- treating
|
||||
# it as None would discard the slice's original datasource
|
||||
# and form_data.
|
||||
query_context["queries"] = queries_bak
|
||||
if "form_data" in query_context:
|
||||
query_context["form_data"] = form_data_bak
|
||||
new_query_context = json.dumps(query_context)
|
||||
else:
|
||||
new_query_context = None
|
||||
|
||||
# Only mutate the slice once every step above has succeeded, so a
|
||||
# failure never leaves viz_type out of sync with params/query_context.
|
||||
slc.params = new_params
|
||||
slc.viz_type = new_viz_type
|
||||
if new_query_context is not unchanged:
|
||||
slc.query_context = new_query_context
|
||||
|
||||
except Exception as e:
|
||||
logger.warning("Failed to downgrade slice %s: %s", slc.id, e)
|
||||
|
||||
@@ -26,13 +26,16 @@ from superset.migrations.shared.migrate_viz.query_functions import (
|
||||
get_metric_label,
|
||||
get_x_axis_column,
|
||||
histogram_operator,
|
||||
is_adhoc_metric_simple,
|
||||
is_physical_column,
|
||||
is_time_comparison,
|
||||
is_x_axis_set,
|
||||
normalize_order_by,
|
||||
omit,
|
||||
pivot_operator,
|
||||
prophet_operator,
|
||||
rank_operator,
|
||||
remove_duplicates,
|
||||
remove_form_data_suffix,
|
||||
rename_operator,
|
||||
resample_operator,
|
||||
@@ -654,3 +657,315 @@ class MigrateSankey(MigrateViz):
|
||||
return [result]
|
||||
|
||||
return build_query_context(self.data, process)
|
||||
|
||||
|
||||
def _get_table_chart_time_offsets(
|
||||
form_data: dict[str, Any], base_query_object: dict[str, Any]
|
||||
) -> list[Any]:
|
||||
"""
|
||||
Resolve time_compare into the list of shifts buildQuery.ts sends as
|
||||
time_offsets. table charts use a single-select time_compare control
|
||||
whose choices include the special 'custom'/'inherit' shifts, which
|
||||
resolve to start_date_offset/'inherit' rather than being used verbatim.
|
||||
|
||||
Chart-level shifts only apply when is_time_comparison(...) holds,
|
||||
mirroring buildQuery.ts; the dashboard-level extra_form_data override
|
||||
below is applied regardless, since it can force a comparison the chart
|
||||
itself isn't configured for.
|
||||
"""
|
||||
time_compare_shifts = ensure_is_array(form_data.get("time_compare"))
|
||||
non_custom_or_inherit_shifts = [
|
||||
shift for shift in time_compare_shifts if shift not in ("custom", "inherit")
|
||||
]
|
||||
custom_or_inherit_shifts = [
|
||||
shift for shift in time_compare_shifts if shift in ("custom", "inherit")
|
||||
]
|
||||
|
||||
time_offsets: list[Any] = []
|
||||
if is_time_comparison(form_data, base_query_object):
|
||||
time_offsets = list(non_custom_or_inherit_shifts)
|
||||
if "custom" in custom_or_inherit_shifts:
|
||||
time_offsets.append(form_data.get("start_date_offset"))
|
||||
if "inherit" in custom_or_inherit_shifts:
|
||||
time_offsets.append("inherit")
|
||||
|
||||
# Dashboard filter override - allows dashboard-level time shifts to
|
||||
# OVERRIDE chart-level time shift settings, mirroring buildQuery.ts.
|
||||
extra_form_data_time_compare = (form_data.get("extra_form_data") or {}).get(
|
||||
"time_compare"
|
||||
)
|
||||
if extra_form_data_time_compare:
|
||||
# extra_form_data.time_compare is typed as a single string on the
|
||||
# frontend, but self.data comes from deserialized JSON with no
|
||||
# runtime type guarantee — normalize defensively so an already-list
|
||||
# value doesn't get double-nested into [[...]].
|
||||
time_offsets = list(ensure_is_array(extra_form_data_time_compare))
|
||||
return time_offsets
|
||||
|
||||
|
||||
def _reorder_table_chart_temporal_column(
|
||||
columns: list[Any],
|
||||
time_grain_sqla: Any,
|
||||
temporal_columns_lookup: dict[str, Any],
|
||||
) -> list[Any]:
|
||||
"""
|
||||
Move the first physical column with a temporal_columns_lookup entry to
|
||||
the front of the columns list as a BASE_AXIS adhoc column, mirroring
|
||||
buildQuery.ts's temporal-column handling in aggregate mode.
|
||||
"""
|
||||
temporal_column = None
|
||||
filtered_columns = []
|
||||
for col in columns:
|
||||
should_be_temporal = (
|
||||
is_physical_column(col)
|
||||
and time_grain_sqla
|
||||
and temporal_columns_lookup.get(col)
|
||||
)
|
||||
if should_be_temporal and temporal_column is None:
|
||||
temporal_column = {
|
||||
"timeGrain": time_grain_sqla,
|
||||
"columnType": "BASE_AXIS",
|
||||
"sqlExpression": col,
|
||||
"label": col,
|
||||
"expressionType": "SQL",
|
||||
}
|
||||
else:
|
||||
filtered_columns.append(col)
|
||||
return [temporal_column] + filtered_columns if temporal_column else filtered_columns
|
||||
|
||||
|
||||
def _to_totals_aggregate(value: Any) -> str:
|
||||
"""
|
||||
Narrow a raw totals_aggregate form-data value, mirroring
|
||||
toTotalsAggregate() in @superset-ui/chart-controls. Anything other than
|
||||
an explicit SUM/AVG -- including charts saved before the control
|
||||
existed -- keeps each metric's own aggregation.
|
||||
"""
|
||||
return value if value in ("SUM", "AVG") else "ORIGINAL"
|
||||
|
||||
|
||||
def _get_table_chart_totals_metrics(
|
||||
metrics: list[Any], totals_aggregate: str
|
||||
) -> list[Any]:
|
||||
"""
|
||||
Build the metrics for the totals query, mirroring getTotalsMetrics() in
|
||||
@superset-ui/chart-controls: with SUM or AVG, each SIMPLE (adhoc) metric
|
||||
is cloned with its aggregate replaced, since the totals query has no
|
||||
GROUP BY. Custom-SQL and saved (string) metrics have no safe way to
|
||||
rewrite an arbitrary aggregate, so they pass through unchanged.
|
||||
"""
|
||||
if totals_aggregate == "ORIGINAL":
|
||||
return metrics
|
||||
return [
|
||||
{**metric, "aggregate": totals_aggregate}
|
||||
if is_adhoc_metric_simple(metric)
|
||||
else metric
|
||||
for metric in metrics
|
||||
]
|
||||
|
||||
|
||||
class MigrateTableChart(MigrateViz):
|
||||
source_viz_type = "table"
|
||||
target_viz_type = "ag-grid-table"
|
||||
# allow_rearrange_columns/allow_render_html are kept as-is: v2 reads them
|
||||
# under the same names (see rename_keys below), so nothing to remove.
|
||||
# (allow_rearrange_columns still gets a value materialized in
|
||||
# _pre_action below when the source chart omits the key.)
|
||||
remove_keys: set[str] = set()
|
||||
rename_keys: dict[str, str] = {} # no renames needed; names match 1:1
|
||||
|
||||
def _pre_action(self) -> None:
|
||||
# page_length: 0 means "All rows" (no pagination) in both v1 and v2.
|
||||
# v2's control panel doesn't offer 0 as a page_length dropdown
|
||||
# choice, but it's still a working runtime value there -- e.g.
|
||||
# getPageSize() in transformProps.ts picks 0 automatically for any
|
||||
# chart under 5000 cells when page_length isn't set at all -- so
|
||||
# keep it as-is rather than rewriting it to a paginated value.
|
||||
|
||||
# Table charts are explicitly excluded from Matrixify
|
||||
# (MATRIXIFY_INCOMPATIBLE_CHARTS), so drop any matrixify_* keys
|
||||
# rather than migrating them.
|
||||
for key in [k for k in self.data if k.startswith("matrixify_")]:
|
||||
self.data.pop(key)
|
||||
|
||||
# v1's control (and TableChart) default allow_rearrange_columns to
|
||||
# False, and older saved charts may omit the key entirely. v2's
|
||||
# transformProps.ts instead defaults a missing key to True, since
|
||||
# for v2-native charts that predate the control it means "keep the
|
||||
# always-on behavior v2 originally shipped with". Materialize v1's
|
||||
# default explicitly here so a migrated chart keeps its original
|
||||
# (non-draggable) behavior instead of picking up v2's unrelated
|
||||
# default for its own pre-existing charts.
|
||||
if "allow_rearrange_columns" not in self.data:
|
||||
self.data["allow_rearrange_columns"] = False
|
||||
|
||||
def _build_aggregate_mode_query(
|
||||
self, base_query_object: dict[str, Any], time_offsets: list[Any]
|
||||
) -> tuple[list[Any], list[Any], Any, list[Any]]:
|
||||
"""
|
||||
Returns (metrics, columns, orderby, post_processing) for aggregate
|
||||
mode, mirroring buildQuery.ts's QueryMode.Aggregate branch: sort-by
|
||||
metric/default ordering, percent-metric contribution, time
|
||||
comparison, and moving the temporal column to the front.
|
||||
"""
|
||||
metrics = base_query_object.get("metrics") or []
|
||||
orderby = base_query_object.get("orderby") or []
|
||||
columns = list(base_query_object.get("columns") or [])
|
||||
post_processing: list[Any] = []
|
||||
|
||||
sort_by_metric_options = ensure_is_array(
|
||||
self.data.get("timeseries_limit_metric")
|
||||
)
|
||||
sort_by_metric = sort_by_metric_options[0] if sort_by_metric_options else None
|
||||
if sort_by_metric:
|
||||
orderby = [[sort_by_metric, not self.data.get("order_desc", False)]]
|
||||
elif metrics:
|
||||
orderby = [[metrics[0], False]]
|
||||
|
||||
if percent_metrics := ensure_is_array(self.data.get("percent_metrics")):
|
||||
percent_metric_base_labels = [get_metric_label(m) for m in percent_metrics]
|
||||
if is_time_comparison(self.data, base_query_object):
|
||||
# Mirror buildQuery.ts's addComparisonPercentMetrics: expand
|
||||
# each percent metric with its time-offset suffixes so
|
||||
# shifted percent columns are computed/renamed too.
|
||||
percent_metric_labels_with_time_comparison = [
|
||||
label
|
||||
for metric_label in percent_metric_base_labels
|
||||
for label in [
|
||||
metric_label,
|
||||
*[f"{metric_label}__{shift}" for shift in time_offsets],
|
||||
]
|
||||
]
|
||||
else:
|
||||
percent_metric_labels_with_time_comparison = percent_metric_base_labels
|
||||
percent_metric_labels = remove_duplicates(
|
||||
percent_metric_labels_with_time_comparison, get_metric_label
|
||||
)
|
||||
metrics = remove_duplicates(metrics + percent_metrics, get_metric_label)
|
||||
post_processing.append(
|
||||
{
|
||||
"operation": "contribution",
|
||||
"options": {
|
||||
"columns": percent_metric_labels,
|
||||
"rename_columns": [f"%{m}" for m in percent_metric_labels],
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
if time_offsets:
|
||||
time_compare = time_compare_operator(self.data, base_query_object)
|
||||
if time_compare:
|
||||
post_processing.append(time_compare)
|
||||
|
||||
# Dashboard-level grain override takes precedence over the
|
||||
# chart-level time_grain_sqla, mirroring buildQuery.ts.
|
||||
extra_form_data_time_grain = (self.data.get("extra_form_data") or {}).get(
|
||||
"time_grain_sqla"
|
||||
)
|
||||
time_grain_sqla = extra_form_data_time_grain or self.data.get("time_grain_sqla")
|
||||
columns = _reorder_table_chart_temporal_column(
|
||||
columns,
|
||||
time_grain_sqla,
|
||||
self.data.get("temporal_columns_lookup") or {},
|
||||
)
|
||||
|
||||
return metrics, columns, orderby, post_processing
|
||||
|
||||
def _build_table_chart_extra_queries(
|
||||
self, query_object: dict[str, Any]
|
||||
) -> list[dict[str, Any]]:
|
||||
"""
|
||||
Extra queries appended after the main query: an unlimited
|
||||
percent-metrics-only query for percent_metric_calculation ==
|
||||
'all_records', and a totals query when show_totals is on.
|
||||
"""
|
||||
percent_metrics = ensure_is_array(self.data.get("percent_metrics"))
|
||||
calculation_mode = self.data.get("percent_metric_calculation") or "row_limit"
|
||||
metrics = query_object.get("metrics")
|
||||
contribution_post_processing = next(
|
||||
(
|
||||
pp
|
||||
for pp in query_object.get("post_processing") or []
|
||||
if pp.get("operation") == "contribution"
|
||||
),
|
||||
None,
|
||||
)
|
||||
|
||||
extra_queries = []
|
||||
|
||||
if calculation_mode == "all_records" and percent_metrics:
|
||||
extra_queries.append(
|
||||
{
|
||||
**query_object,
|
||||
"columns": [],
|
||||
"metrics": percent_metrics,
|
||||
"post_processing": [],
|
||||
"row_limit": 0,
|
||||
"row_offset": 0,
|
||||
"orderby": [],
|
||||
"is_timeseries": False,
|
||||
}
|
||||
)
|
||||
|
||||
if metrics and self.data.get("show_totals"):
|
||||
totals_aggregate = _to_totals_aggregate(self.data.get("totals_aggregate"))
|
||||
extra_queries.append(
|
||||
{
|
||||
**omit(query_object, ["order_desc", "orderby"]),
|
||||
"columns": [],
|
||||
"metrics": _get_table_chart_totals_metrics(
|
||||
metrics, totals_aggregate
|
||||
),
|
||||
"row_limit": 0,
|
||||
"row_offset": 0,
|
||||
"post_processing": (
|
||||
[contribution_post_processing]
|
||||
if contribution_post_processing
|
||||
else []
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
return extra_queries
|
||||
|
||||
def _build_query(self) -> dict[str, Any]:
|
||||
# Table v1 and v2 share the same buildQuery shape (groupby/metrics/
|
||||
# percent_metrics/row_limit/order_by_cols/percent_metric_calculation),
|
||||
# so this mirrors plugin-chart-table/src/buildQuery.ts and
|
||||
# plugin-chart-ag-grid-table/src/buildQuery.ts, minus the
|
||||
# request-time-only branches (server pagination paging/search state,
|
||||
# download row-limit overrides) that don't apply to a persisted
|
||||
# query_context.
|
||||
query_mode = self.data.get("query_mode")
|
||||
all_columns = ensure_is_array(self.data.get("all_columns"))
|
||||
raw_mode = query_mode == "raw" or (query_mode is None and len(all_columns) > 0)
|
||||
|
||||
def process(base_query_object: dict[str, Any]) -> list[dict[str, Any]]:
|
||||
time_offsets = _get_table_chart_time_offsets(self.data, base_query_object)
|
||||
|
||||
if raw_mode:
|
||||
metrics = base_query_object.get("metrics")
|
||||
columns = base_query_object.get("columns") or []
|
||||
orderby = base_query_object.get("orderby") or []
|
||||
post_processing: list[Any] = []
|
||||
else:
|
||||
metrics, columns, orderby, post_processing = (
|
||||
self._build_aggregate_mode_query(base_query_object, time_offsets)
|
||||
)
|
||||
|
||||
query_object = {
|
||||
**base_query_object,
|
||||
"columns": columns,
|
||||
"orderby": orderby,
|
||||
"metrics": metrics,
|
||||
"post_processing": post_processing,
|
||||
"time_offsets": time_offsets,
|
||||
}
|
||||
|
||||
extra_queries = (
|
||||
[] if raw_mode else self._build_table_chart_extra_queries(query_object)
|
||||
)
|
||||
|
||||
return [query_object, *extra_queries]
|
||||
|
||||
return build_query_context(self.data, process)
|
||||
|
||||
@@ -40,6 +40,12 @@ class DatasourceType(Enum):
|
||||
Dataset = "dataset"
|
||||
SlTable = "sl_table"
|
||||
SavedQuery = "saved_query"
|
||||
SemanticView = "semantic_view"
|
||||
|
||||
|
||||
DATASOURCE_TYPE_MAP = {
|
||||
datasource_type.value: datasource_type for datasource_type in DatasourceType
|
||||
}
|
||||
|
||||
|
||||
UNARY_OPERATORS = ["IS NOT NULL", "IS NULL"]
|
||||
@@ -67,10 +73,7 @@ class DatasourceKey:
|
||||
def __init__(self, key: str):
|
||||
id_str, type_str = key.split("__", 1)
|
||||
self.id = int(id_str)
|
||||
# Default to Table; if type_str is 'query', then use Query.
|
||||
self.type = DatasourceType.Table
|
||||
if type_str == "query":
|
||||
self.type = DatasourceType.Query
|
||||
self.type = DATASOURCE_TYPE_MAP.get(type_str, DatasourceType.Table)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"{self.id}__{self.type.value}"
|
||||
|
||||
@@ -595,6 +595,25 @@ def test_extra_validator_interpolates_json_decode_error() -> None:
|
||||
assert "%(" not in message
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [123, None, [1, 2], True, "abc"])
|
||||
def test_extra_validator_rejects_non_dict_top_level_value(value: Any) -> None:
|
||||
"""
|
||||
Test that extra_validator rejects a top-level extra value that is valid
|
||||
JSON but not a mapping (int, null, list, bool, string), instead of
|
||||
letting AttributeError propagate from extra_.get("metadata_params").
|
||||
"""
|
||||
from superset.databases.schemas import DatabasePostSchema
|
||||
|
||||
schema = DatabasePostSchema()
|
||||
payload = {
|
||||
"database_name": "test_db",
|
||||
"extra": json.dumps(value),
|
||||
}
|
||||
with pytest.raises(ValidationError) as exc_info:
|
||||
schema.load(payload)
|
||||
assert "must be a mapping" in str(exc_info.value)
|
||||
|
||||
|
||||
def test_cache_timeout_rejects_values_below_minus_one() -> None:
|
||||
"""
|
||||
Test that cache_timeout rejects values less than -1.
|
||||
|
||||
@@ -0,0 +1,427 @@
|
||||
# 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.
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
|
||||
from superset.migrations.shared.migrate_viz import MigrateTableChart
|
||||
from superset.utils import json
|
||||
from tests.unit_tests.migrations.viz.utils import migrate_and_assert
|
||||
|
||||
SOURCE_FORM_DATA: dict[str, Any] = {
|
||||
"datasource": "1__table",
|
||||
"any_other_key": "untouched",
|
||||
"viz_type": "table",
|
||||
"query_mode": "aggregate",
|
||||
"groupby": ["name"],
|
||||
"metrics": ["count"],
|
||||
"percent_metrics": [],
|
||||
"all_columns": [],
|
||||
"row_limit": 1000,
|
||||
"order_desc": True,
|
||||
"table_timestamp_format": "smart_date",
|
||||
"page_length": 20,
|
||||
"include_search": False,
|
||||
"show_cell_bars": True,
|
||||
"align_pn": False,
|
||||
"color_pn": True,
|
||||
"allow_rearrange_columns": True,
|
||||
"allow_render_html": True,
|
||||
}
|
||||
|
||||
TARGET_FORM_DATA: dict[str, Any] = {
|
||||
"datasource": "1__table",
|
||||
"any_other_key": "untouched",
|
||||
"viz_type": "ag-grid-table",
|
||||
"query_mode": "aggregate",
|
||||
"groupby": ["name"],
|
||||
"metrics": ["count"],
|
||||
"percent_metrics": [],
|
||||
"all_columns": [],
|
||||
"row_limit": 1000,
|
||||
"order_desc": True,
|
||||
"table_timestamp_format": "smart_date",
|
||||
"page_length": 20,
|
||||
"include_search": False,
|
||||
"show_cell_bars": True,
|
||||
"align_pn": False,
|
||||
"color_pn": True,
|
||||
"allow_rearrange_columns": True,
|
||||
"allow_render_html": True,
|
||||
"form_data_bak": SOURCE_FORM_DATA,
|
||||
}
|
||||
|
||||
|
||||
def test_migration() -> None:
|
||||
migrate_and_assert(MigrateTableChart, SOURCE_FORM_DATA, TARGET_FORM_DATA)
|
||||
|
||||
|
||||
def test_migration_without_datasource_key_in_params() -> None:
|
||||
"""Some slices don't have a "datasource" key inside params, relying
|
||||
instead on the datasource_id/datasource_type columns — that key is
|
||||
normally injected on the fly by Slice.form_data, which the migration
|
||||
framework bypasses by reading params directly. upgrade_slice must
|
||||
synthesize the same "id__type" string from those columns, or
|
||||
_build_query() raises KeyError('datasource') for charts missing it."""
|
||||
from superset.models.slice import Slice
|
||||
from superset.utils import json
|
||||
|
||||
source: dict[str, Any] = {
|
||||
k: v for k, v in SOURCE_FORM_DATA.items() if k != "datasource"
|
||||
}
|
||||
dumped_form_data: str = json.dumps(source)
|
||||
|
||||
slc: Slice = Slice(
|
||||
viz_type=MigrateTableChart.source_viz_type,
|
||||
datasource_id=1,
|
||||
datasource_type="table",
|
||||
params=dumped_form_data,
|
||||
query_context=f'{{"form_data": {dumped_form_data}, "queries": []}}',
|
||||
)
|
||||
|
||||
MigrateTableChart.upgrade_slice(slc)
|
||||
|
||||
assert slc.viz_type == MigrateTableChart.target_viz_type
|
||||
new_form_data: dict[str, Any] = json.loads(slc.params)
|
||||
assert new_form_data["datasource"] == "1__table"
|
||||
|
||||
|
||||
def test_migration_preserves_semantic_view_datasource_type() -> None:
|
||||
"""DatasourceKey used to only recognize "query" as a non-table type,
|
||||
defaulting everything else (e.g. "semantic_view") to "table". Slices
|
||||
with no pre-existing query_context get one built from scratch via
|
||||
DatasourceKey, which must keep the original type rather than silently
|
||||
repointing the chart at a table with the same id."""
|
||||
from superset.models.slice import Slice
|
||||
|
||||
source: dict[str, Any] = {**SOURCE_FORM_DATA, "datasource": "7__semantic_view"}
|
||||
dumped_form_data: str = json.dumps(source)
|
||||
|
||||
slc: Slice = Slice(
|
||||
viz_type=MigrateTableChart.source_viz_type,
|
||||
datasource_type="table",
|
||||
params=dumped_form_data,
|
||||
query_context=None,
|
||||
)
|
||||
|
||||
MigrateTableChart.upgrade_slice(slc)
|
||||
|
||||
new_query_context: dict[str, Any] = json.loads(slc.query_context)
|
||||
assert new_query_context["datasource"] == {"id": 7, "type": "semantic_view"}
|
||||
|
||||
|
||||
def test_migration_raw_mode() -> None:
|
||||
source: dict[str, Any] = {
|
||||
**SOURCE_FORM_DATA,
|
||||
"query_mode": "raw",
|
||||
"groupby": [],
|
||||
"metrics": [],
|
||||
"all_columns": ["name", "sales"],
|
||||
}
|
||||
target: dict[str, Any] = {
|
||||
**TARGET_FORM_DATA,
|
||||
"query_mode": "raw",
|
||||
"groupby": [],
|
||||
"metrics": [],
|
||||
"all_columns": ["name", "sales"],
|
||||
"form_data_bak": source,
|
||||
}
|
||||
migrate_and_assert(MigrateTableChart, source, target)
|
||||
|
||||
|
||||
def test_migration_page_length_all_is_preserved() -> None:
|
||||
"""page_length: 0 means 'All rows' (no pagination) in both v1 and v2,
|
||||
so it should carry over unchanged rather than being rewritten to a
|
||||
paginated value."""
|
||||
source: dict[str, Any] = {**SOURCE_FORM_DATA, "page_length": 0}
|
||||
target: dict[str, Any] = {
|
||||
**TARGET_FORM_DATA,
|
||||
"page_length": 0,
|
||||
"form_data_bak": source,
|
||||
}
|
||||
migrate_and_assert(MigrateTableChart, source, target)
|
||||
|
||||
|
||||
def test_migration_page_length_all_as_string_is_preserved() -> None:
|
||||
source: dict[str, Any] = {**SOURCE_FORM_DATA, "page_length": "0"}
|
||||
target: dict[str, Any] = {
|
||||
**TARGET_FORM_DATA,
|
||||
"page_length": "0",
|
||||
"form_data_bak": source,
|
||||
}
|
||||
migrate_and_assert(MigrateTableChart, source, target)
|
||||
|
||||
|
||||
def test_migration_percent_metric_calculation_all_records_carries_over() -> None:
|
||||
"""percent_metric_calculation now has a v2 equivalent (control panel +
|
||||
buildQuery all_records branch), so it should carry over unchanged."""
|
||||
source: dict[str, Any] = {
|
||||
**SOURCE_FORM_DATA,
|
||||
"percent_metrics": ["sum__sales"],
|
||||
"percent_metric_calculation": "all_records",
|
||||
}
|
||||
target: dict[str, Any] = {
|
||||
**TARGET_FORM_DATA,
|
||||
"percent_metrics": ["sum__sales"],
|
||||
"percent_metric_calculation": "all_records",
|
||||
"form_data_bak": source,
|
||||
}
|
||||
migrate_and_assert(MigrateTableChart, source, target)
|
||||
|
||||
|
||||
def test_migration_entire_row_conditional_formatting_carries_over() -> None:
|
||||
"""'entire row' conditional formatting now has a v2 equivalent (control
|
||||
panel + getCellStyle.ts), so it should carry over unchanged."""
|
||||
conditional_formatting: list[dict[str, Any]] = [
|
||||
{
|
||||
"operator": ">",
|
||||
"targetValue": 0,
|
||||
"colorScheme": "#ACE1C4",
|
||||
"column": "sales",
|
||||
"columnFormatting": "ENTIRE_ROW",
|
||||
}
|
||||
]
|
||||
source: dict[str, Any] = {
|
||||
**SOURCE_FORM_DATA,
|
||||
"conditional_formatting": conditional_formatting,
|
||||
}
|
||||
target: dict[str, Any] = {
|
||||
**TARGET_FORM_DATA,
|
||||
"conditional_formatting": conditional_formatting,
|
||||
"form_data_bak": source,
|
||||
}
|
||||
migrate_and_assert(MigrateTableChart, source, target)
|
||||
|
||||
|
||||
def test_migration_strips_matrixify_keys() -> None:
|
||||
"""Matrixify has no v2 control panel surface at all. Table charts can't
|
||||
reach the Matrixify tab through today's Explore UI, but a chart saved
|
||||
during the ~5 months before that exclusion was added (or edited directly
|
||||
via the API) can still carry matrixify_* keys. Those keys should be
|
||||
dropped and the migration should proceed normally rather than skipping
|
||||
the slice."""
|
||||
source: dict[str, Any] = {
|
||||
**SOURCE_FORM_DATA,
|
||||
"matrixify_enable": True,
|
||||
"matrixify_mode_rows": "dimensions",
|
||||
"matrixify_dimension_rows": "category",
|
||||
}
|
||||
target: dict[str, Any] = {**TARGET_FORM_DATA, "form_data_bak": source}
|
||||
migrate_and_assert(MigrateTableChart, source, target)
|
||||
|
||||
|
||||
def test_migration_defaults_omitted_allow_rearrange_columns_to_false() -> None:
|
||||
"""v1's control (and TableChart) default allow_rearrange_columns to
|
||||
False, and charts saved before that control existed may omit the key
|
||||
entirely. v2's transformProps.ts instead defaults a missing key to
|
||||
True (its own pre-existing behavior for v2-native charts), so the
|
||||
migration must materialize v1's False default explicitly rather than
|
||||
letting a migrated chart pick up v2's unrelated default."""
|
||||
source: dict[str, Any] = {
|
||||
k: v for k, v in SOURCE_FORM_DATA.items() if k != "allow_rearrange_columns"
|
||||
}
|
||||
target: dict[str, Any] = {
|
||||
**{k: v for k, v in TARGET_FORM_DATA.items() if k != "form_data_bak"},
|
||||
"allow_rearrange_columns": False,
|
||||
"form_data_bak": source,
|
||||
}
|
||||
migrate_and_assert(MigrateTableChart, source, target)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"auto_currency_form_data",
|
||||
[
|
||||
{
|
||||
**SOURCE_FORM_DATA,
|
||||
"column_config": {
|
||||
"sales": {
|
||||
"currencyFormat": {"symbol": "AUTO", "symbolPosition": "prefix"}
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
)
|
||||
def test_migration_auto_currency_carries_over(
|
||||
auto_currency_form_data: dict[str, Any],
|
||||
) -> None:
|
||||
"""AUTO currency resolution now has a v2 equivalent (transformProps.ts +
|
||||
formatValue.ts), so column_config carries over unchanged."""
|
||||
target: dict[str, Any] = {
|
||||
**TARGET_FORM_DATA,
|
||||
"column_config": auto_currency_form_data["column_config"],
|
||||
"form_data_bak": auto_currency_form_data,
|
||||
}
|
||||
migrate_and_assert(MigrateTableChart, auto_currency_form_data, target)
|
||||
|
||||
|
||||
def test_build_query_extra_form_data_time_compare_overrides_chart_level() -> None:
|
||||
"""A dashboard-level time_compare override (extra_form_data.time_compare)
|
||||
must replace the chart-level time_compare shifts in the migrated
|
||||
query_context, mirroring buildQuery.ts's override precedence."""
|
||||
form_data: dict[str, Any] = {
|
||||
"datasource": "1__table",
|
||||
"viz_type": "table",
|
||||
"query_mode": "aggregate",
|
||||
"groupby": ["name"],
|
||||
"metrics": ["count"],
|
||||
"time_compare": ["1 year ago"],
|
||||
"extra_form_data": {"time_compare": "4 weeks ago"},
|
||||
}
|
||||
main_query = MigrateTableChart(json.dumps(form_data))._build_query()["queries"][0]
|
||||
assert main_query["time_offsets"] == ["4 weeks ago"]
|
||||
|
||||
|
||||
def test_build_query_extra_form_data_time_grain_sqla_overrides_chart_level() -> None:
|
||||
"""A dashboard-level time_grain_sqla override (extra_form_data) must be
|
||||
used to decide temporal-column promotion, mirroring buildQuery.ts's
|
||||
`extra_form_data?.time_grain_sqla || formData.time_grain_sqla`
|
||||
precedence, even when the chart has no top-level time_grain_sqla set."""
|
||||
form_data: dict[str, Any] = {
|
||||
"datasource": "1__table",
|
||||
"viz_type": "table",
|
||||
"query_mode": "aggregate",
|
||||
"groupby": ["ds", "name"],
|
||||
"metrics": ["count"],
|
||||
"temporal_columns_lookup": {"ds": True},
|
||||
"extra_form_data": {"time_grain_sqla": "P1D"},
|
||||
}
|
||||
main_query = MigrateTableChart(json.dumps(form_data))._build_query()["queries"][0]
|
||||
assert main_query["columns"][0] == {
|
||||
"timeGrain": "P1D",
|
||||
"columnType": "BASE_AXIS",
|
||||
"sqlExpression": "ds",
|
||||
"label": "ds",
|
||||
"expressionType": "SQL",
|
||||
}
|
||||
|
||||
|
||||
def test_build_query_extra_form_data_time_compare_override_not_double_nested() -> None:
|
||||
"""extra_form_data.time_compare is typed as a single string on the
|
||||
frontend, but self.data comes from deserialized JSON with no runtime
|
||||
type guarantee. If a malformed/legacy record already carries it as a
|
||||
list, the override must not double-nest it into [[...]]."""
|
||||
form_data: dict[str, Any] = {
|
||||
"datasource": "1__table",
|
||||
"viz_type": "table",
|
||||
"query_mode": "aggregate",
|
||||
"groupby": ["name"],
|
||||
"metrics": ["count"],
|
||||
"extra_form_data": {"time_compare": ["4 weeks ago"]},
|
||||
}
|
||||
main_query = MigrateTableChart(json.dumps(form_data))._build_query()["queries"][0]
|
||||
assert main_query["time_offsets"] == ["4 weeks ago"]
|
||||
|
||||
|
||||
def test_build_query_percent_metric_expands_with_time_comparison() -> None:
|
||||
"""When time comparison is enabled, percent-metric contribution columns
|
||||
must include the time-offset-suffixed labels (e.g. "metric__1 year
|
||||
ago"), mirroring buildQuery.ts's addComparisonPercentMetrics, so shifted
|
||||
percent columns are computed/renamed rather than only the base metric."""
|
||||
form_data: dict[str, Any] = {
|
||||
"datasource": "1__table",
|
||||
"viz_type": "table",
|
||||
"query_mode": "aggregate",
|
||||
"groupby": ["name"],
|
||||
"metrics": ["sum__sales"],
|
||||
"percent_metrics": ["sum__sales"],
|
||||
"time_compare": ["1 year ago"],
|
||||
"comparison_type": "values",
|
||||
}
|
||||
main_query = MigrateTableChart(json.dumps(form_data))._build_query()["queries"][0]
|
||||
contribution = next(
|
||||
pp for pp in main_query["post_processing"] if pp["operation"] == "contribution"
|
||||
)
|
||||
assert contribution["options"]["columns"] == [
|
||||
"sum__sales",
|
||||
"sum__sales__1 year ago",
|
||||
]
|
||||
assert contribution["options"]["rename_columns"] == [
|
||||
"%sum__sales",
|
||||
"%sum__sales__1 year ago",
|
||||
]
|
||||
|
||||
|
||||
def test_build_query_stale_time_compare_without_comparison_type_is_ignored() -> None:
|
||||
"""time_compare shifts require a valid comparison_type, mirroring
|
||||
isTimeComparison() in both Table buildQuery implementations. A chart
|
||||
with a stale time_compare left over from a prior configuration but no
|
||||
(or an invalid) comparison_type should not request offset queries the
|
||||
runtime chart itself would never send."""
|
||||
form_data: dict[str, Any] = {
|
||||
"datasource": "1__table",
|
||||
"viz_type": "table",
|
||||
"query_mode": "aggregate",
|
||||
"groupby": ["name"],
|
||||
"metrics": ["count"],
|
||||
"time_compare": ["1 year ago"],
|
||||
}
|
||||
main_query = MigrateTableChart(json.dumps(form_data))._build_query()["queries"][0]
|
||||
assert main_query["time_offsets"] == []
|
||||
|
||||
|
||||
def test_build_query_totals_query_applies_totals_aggregate() -> None:
|
||||
"""Both runtime buildQuery.ts implementations call
|
||||
getTotalsMetrics(metrics, toTotalsAggregate(formData.totals_aggregate))
|
||||
when building the totals query. A chart saved with show_totals=True,
|
||||
totals_aggregate='AVG', and a SIMPLE SUM(...) metric must therefore get
|
||||
a persisted totals query that computes AVG, not the main query's SUM."""
|
||||
form_data: dict[str, Any] = {
|
||||
"datasource": "1__table",
|
||||
"viz_type": "table",
|
||||
"query_mode": "aggregate",
|
||||
"groupby": ["name"],
|
||||
"metrics": [
|
||||
{
|
||||
"expressionType": "SIMPLE",
|
||||
"column": {"column_name": "sales"},
|
||||
"aggregate": "SUM",
|
||||
"label": "sum__sales",
|
||||
}
|
||||
],
|
||||
"show_totals": True,
|
||||
"totals_aggregate": "AVG",
|
||||
}
|
||||
queries = MigrateTableChart(json.dumps(form_data))._build_query()["queries"]
|
||||
totals_query = next(q for q in queries if q["columns"] == [])
|
||||
assert totals_query["metrics"] == [
|
||||
{
|
||||
"expressionType": "SIMPLE",
|
||||
"column": {"column_name": "sales"},
|
||||
"aggregate": "AVG",
|
||||
"label": "sum__sales",
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
def test_build_query_raw_mode_stale_time_compare_is_ignored() -> None:
|
||||
"""A chart switched to raw mode retains its old time_compare/
|
||||
comparison_type controls (hidden rather than cleared) while metrics is
|
||||
cleared to []. With no metrics to offset, isTimeComparison()'s
|
||||
get_metric_offsets_map() is empty, so time_offsets should stay empty
|
||||
rather than requesting shifts a raw-mode chart never sends."""
|
||||
form_data: dict[str, Any] = {
|
||||
"datasource": "1__table",
|
||||
"viz_type": "table",
|
||||
"query_mode": "raw",
|
||||
"groupby": [],
|
||||
"metrics": [],
|
||||
"all_columns": ["name", "sales"],
|
||||
"time_compare": ["1 year ago"],
|
||||
"comparison_type": "values",
|
||||
}
|
||||
main_query = MigrateTableChart(json.dumps(form_data))._build_query()["queries"][0]
|
||||
assert main_query["time_offsets"] == []
|
||||
Reference in New Issue
Block a user