mirror of
https://github.com/apache/superset.git
synced 2026-05-06 00:14:21 +00:00
Compare commits
33 Commits
enxdev/ref
...
pre-cost-e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
992226527f | ||
|
|
a9cd58508b | ||
|
|
122bb68e5a | ||
|
|
914ce9aa4f | ||
|
|
bb572983cd | ||
|
|
ff76ab647f | ||
|
|
f554848c9f | ||
|
|
dc0c389488 | ||
|
|
22b3cc0480 | ||
|
|
604d72cc98 | ||
|
|
913e068113 | ||
|
|
1a4e2173f5 | ||
|
|
c49789167b | ||
|
|
1be2287b3a | ||
|
|
e741a3167f | ||
|
|
5f11f9097a | ||
|
|
8783579aa8 | ||
|
|
c25b4221f8 | ||
|
|
9c771fb2ba | ||
|
|
7f44992c4b | ||
|
|
8df5860826 | ||
|
|
b794b192d1 | ||
|
|
3177131d52 | ||
|
|
89bf77b5c9 | ||
|
|
30e5684006 | ||
|
|
3f8472ca7b | ||
|
|
efa8cb6fa4 | ||
|
|
ab59b7e9b0 | ||
|
|
c99843b13a | ||
|
|
da55a6c94a | ||
|
|
7a1c056374 | ||
|
|
1e5a4e9bdc | ||
|
|
9b88527883 |
@@ -51,7 +51,7 @@ jobs:
|
||||
SUPERSET_TESTENV: true
|
||||
SUPERSET_SECRET_KEY: not-a-secret
|
||||
run: |
|
||||
pytest --durations-min=0.5 --cov-report= --cov=superset/sql/ ./tests/unit_tests/sql/ --cache-clear --cov-fail-under=100
|
||||
pytest --durations-min=0.5 --cov=superset/sql/ ./tests/unit_tests/sql/ --cache-clear --cov-fail-under=100
|
||||
- name: Upload code coverage
|
||||
uses: codecov/codecov-action@v5
|
||||
with:
|
||||
|
||||
@@ -89,9 +89,9 @@ repos:
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.9.7
|
||||
hooks:
|
||||
- id: ruff-format
|
||||
- id: ruff
|
||||
args: [--fix]
|
||||
- id: ruff-format
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: pylint
|
||||
@@ -105,9 +105,10 @@ repos:
|
||||
- |
|
||||
TARGET_BRANCH=${GITHUB_BASE_REF:-master}
|
||||
git fetch origin "$TARGET_BRANCH"
|
||||
files=$(git diff --name-only --diff-filter=ACM origin/"$TARGET_BRANCH"..HEAD | grep '^superset/.*\.py$' || true)
|
||||
BASE=$(git merge-base origin/"$TARGET_BRANCH" HEAD)
|
||||
files=$(git diff --name-only --diff-filter=ACM "$BASE"..HEAD | grep '^superset/.*\.py$' || true)
|
||||
if [ -n "$files" ]; then
|
||||
pylint --rcfile=.pylintrc --load-plugins=superset.extensions.pylint $files
|
||||
pylint --rcfile=.pylintrc --load-plugins=superset.extensions.pylint --reports=no $files
|
||||
else
|
||||
echo "No Python files to lint."
|
||||
fi
|
||||
|
||||
@@ -59,7 +59,7 @@ RUN mkdir -p /app/superset/static/assets \
|
||||
# NOTE: we mount packages and plugins as they are referenced in package.json as workspaces
|
||||
# ideally we'd COPY only their package.json. Here npm ci will be cached as long
|
||||
# as the full content of these folders don't change, yielding a decent cache reuse rate.
|
||||
# Note that's it's not possible selectively COPY of mount using blobs.
|
||||
# Note that it's not possible to selectively COPY or mount using blobs.
|
||||
RUN --mount=type=bind,source=./superset-frontend/package.json,target=./package.json \
|
||||
--mount=type=bind,source=./superset-frontend/package-lock.json,target=./package-lock.json \
|
||||
--mount=type=cache,target=/root/.cache \
|
||||
|
||||
45
LLMS.md
45
LLMS.md
@@ -22,6 +22,11 @@ Apache Superset is a data visualization platform with Flask/Python backend and R
|
||||
- **MyPy compliance** - Run `pre-commit run mypy` to validate
|
||||
- **SQLAlchemy typing** - Use proper model annotations
|
||||
|
||||
### UUID Migration
|
||||
- **Prefer UUIDs over auto-incrementing IDs** - New models should use UUID primary keys
|
||||
- **External API exposure** - Use UUIDs in public APIs instead of internal integer IDs
|
||||
- **Existing models** - Add UUID fields alongside integer IDs for gradual migration
|
||||
|
||||
## Key Directories
|
||||
|
||||
```
|
||||
@@ -89,6 +94,10 @@ superset/
|
||||
- **`selectOption()`** - Select component helper
|
||||
- **React Testing Library** - NO Enzyme (removed)
|
||||
|
||||
### Test Database Patterns
|
||||
- **Mock patterns**: Use `MagicMock()` for config objects, avoid `AsyncMock` for synchronous code
|
||||
- **API tests**: Update expected columns when adding new model fields
|
||||
|
||||
### Running Tests
|
||||
```bash
|
||||
# Frontend
|
||||
@@ -120,6 +129,10 @@ curl -f http://localhost:8088/health || echo "❌ Setup required - see https://s
|
||||
- `pyproject.toml` - Python tooling (ruff, mypy configs)
|
||||
- `requirements/` folder - Python dependencies (base.txt, development.txt)
|
||||
|
||||
## SQLAlchemy Query Best Practices
|
||||
- **Use negation operator**: `~Model.field` instead of `== False` to avoid ruff E712 errors
|
||||
- **Example**: `~Model.is_active` instead of `Model.is_active == False`
|
||||
|
||||
## Pre-commit Validation
|
||||
|
||||
**Use pre-commit hooks for quality validation:**
|
||||
@@ -128,13 +141,43 @@ curl -f http://localhost:8088/health || echo "❌ Setup required - see https://s
|
||||
# Install hooks
|
||||
pre-commit install
|
||||
|
||||
# IMPORTANT: Stage your changes first!
|
||||
git add . # Pre-commit only checks staged files
|
||||
|
||||
# Quick validation (faster than --all-files)
|
||||
pre-commit run # Staged files only
|
||||
pre-commit run # Staged files only
|
||||
pre-commit run mypy # Python type checking
|
||||
pre-commit run prettier # Code formatting
|
||||
pre-commit run eslint # Frontend linting
|
||||
```
|
||||
|
||||
**Important pre-commit usage notes:**
|
||||
- **Stage files first**: Run `git add .` before `pre-commit run` to check only changed files (much faster)
|
||||
- **Virtual environment**: Activate your Python virtual environment before running pre-commit
|
||||
```bash
|
||||
# Common virtual environment locations (yours may differ):
|
||||
source .venv/bin/activate # if using .venv
|
||||
source venv/bin/activate # if using venv
|
||||
source ~/venvs/superset/bin/activate # if using a central location
|
||||
```
|
||||
If you get a "command not found" error, ask the user which virtual environment to activate
|
||||
- **Auto-fixes**: Some hooks auto-fix issues (e.g., trailing whitespace). Re-run after fixes are applied
|
||||
|
||||
## Common File Patterns
|
||||
|
||||
### API Structure
|
||||
- **`/api.py`** - REST endpoints with decorators and OpenAPI docstrings
|
||||
- **`/schemas.py`** - Marshmallow validation schemas for OpenAPI spec
|
||||
- **`/commands/`** - Business logic classes with @transaction() decorators
|
||||
- **`/models/`** - SQLAlchemy database models
|
||||
- **OpenAPI docs**: Auto-generated at `/swagger/v1` from docstrings and schemas
|
||||
|
||||
### Migration Files
|
||||
- **Location**: `superset/migrations/versions/`
|
||||
- **Naming**: `YYYY-MM-DD_HH-MM_hash_description.py`
|
||||
- **Utilities**: Use helpers from `superset.migrations.shared.utils` for database compatibility
|
||||
- **Pattern**: Import utilities instead of raw SQLAlchemy operations
|
||||
|
||||
## Platform-Specific Instructions
|
||||
|
||||
- **[CLAUDE.md](CLAUDE.md)** - For Claude/Anthropic tools
|
||||
|
||||
@@ -23,6 +23,7 @@ This file documents any backwards-incompatible changes in Superset and
|
||||
assists people when migrating to a new version.
|
||||
|
||||
## Next
|
||||
- [33084](https://github.com/apache/superset/pull/33084) The DISALLOWED_SQL_FUNCTIONS configuration now includes additional potentially sensitive database functions across PostgreSQL, MySQL, SQLite, MS SQL Server, and ClickHouse. Existing queries using these functions may now be blocked. Review your SQL Lab queries and dashboards if you encounter "disallowed function" errors after upgrading
|
||||
- [34235](https://github.com/apache/superset/pull/34235) CSV exports now use `utf-8-sig` encoding by default to include a UTF-8 BOM, improving compatibility with Excel.
|
||||
- [34258](https://github.com/apache/superset/pull/34258) changing the default in Dockerfile to INCLUDE_CHROMIUM="false" (from "true") in the past. This ensures the `lean` layer is lean by default, and people can opt-in to the `chromium` layer by setting the build arg `INCLUDE_CHROMIUM=true`. This is a breaking change for anyone using the `lean` layer, as it will no longer include Chromium by default.
|
||||
- [34204](https://github.com/apache/superset/pull/33603) OpenStreetView has been promoted as the new default for Deck.gl visualization since it can be enabled by default without requiring an API key. If you have Mapbox set up and want to disable OpenStreeView in your environment, please follow the steps documented here [https://superset.apache.org/docs/configuration/map-tiles].
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
# If you choose to use this type of deployment make sure to
|
||||
# create you own docker environment file (docker/.env) with your own
|
||||
# unique random secure passwords and SECRET_KEY.
|
||||
#
|
||||
# For verbose logging during development:
|
||||
# - Set SUPERSET_LOG_LEVEL=debug in docker/.env-local for detailed Superset logs
|
||||
# -----------------------------------------------------------------------
|
||||
x-superset-image: &superset-image apachesuperset.docker.scarf.sh/apache/superset:${TAG:-latest-dev}
|
||||
x-superset-volumes:
|
||||
|
||||
157
docker-compose-light.yml
Normal file
157
docker-compose-light.yml
Normal file
@@ -0,0 +1,157 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
# Lightweight docker-compose for running multiple Superset instances
|
||||
# This includes only essential services: database, Redis, and Superset app
|
||||
#
|
||||
# IMPORTANT: To run multiple instances in parallel:
|
||||
# - Use different project names: docker-compose -p project1 -f docker-compose-light.yml up
|
||||
# - Use different NODE_PORT values: NODE_PORT=9002 docker-compose -p project2 -f docker-compose-light.yml up
|
||||
# - Volumes are isolated by project name (e.g., project1_db_home_light, project2_db_home_light)
|
||||
# - Database name is intentionally different (superset_light) to prevent accidental cross-connections
|
||||
#
|
||||
# For verbose logging during development:
|
||||
# - Set SUPERSET_LOG_LEVEL=debug in docker/.env-local for detailed Superset logs
|
||||
# -----------------------------------------------------------------------
|
||||
x-superset-user: &superset-user root
|
||||
x-superset-volumes: &superset-volumes
|
||||
# /app/pythonpath_docker will be appended to the PYTHONPATH in the final container
|
||||
- ./docker:/app/docker
|
||||
- ./superset:/app/superset
|
||||
- ./superset-frontend:/app/superset-frontend
|
||||
- superset_home_light:/app/superset_home
|
||||
- ./tests:/app/tests
|
||||
x-common-build: &common-build
|
||||
context: .
|
||||
target: ${SUPERSET_BUILD_TARGET:-dev} # can use `dev` (default) or `lean`
|
||||
cache_from:
|
||||
- apache/superset-cache:3.10-slim-bookworm
|
||||
args:
|
||||
DEV_MODE: "true"
|
||||
INCLUDE_CHROMIUM: ${INCLUDE_CHROMIUM:-false}
|
||||
INCLUDE_FIREFOX: ${INCLUDE_FIREFOX:-false}
|
||||
BUILD_TRANSLATIONS: ${BUILD_TRANSLATIONS:-false}
|
||||
|
||||
services:
|
||||
db-light:
|
||||
env_file:
|
||||
- path: docker/.env # default
|
||||
required: true
|
||||
- path: docker/.env-local # optional override
|
||||
required: false
|
||||
image: postgres:16
|
||||
restart: unless-stopped
|
||||
# No host port mapping - only accessible within Docker network
|
||||
volumes:
|
||||
- db_home_light:/var/lib/postgresql/data
|
||||
- ./docker/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
|
||||
environment:
|
||||
# Override database name to avoid conflicts
|
||||
POSTGRES_DB: superset_light
|
||||
|
||||
superset-light:
|
||||
env_file:
|
||||
- path: docker/.env # default
|
||||
required: true
|
||||
- path: docker/.env-local # optional override
|
||||
required: false
|
||||
build:
|
||||
<<: *common-build
|
||||
command: ["/app/docker/docker-bootstrap.sh", "app"]
|
||||
restart: unless-stopped
|
||||
# No host port mapping - accessed via webpack dev server proxy
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
user: *superset-user
|
||||
depends_on:
|
||||
superset-init-light:
|
||||
condition: service_completed_successfully
|
||||
volumes: *superset-volumes
|
||||
environment:
|
||||
# Override DB connection for light service
|
||||
DATABASE_HOST: db-light
|
||||
DATABASE_DB: superset_light
|
||||
POSTGRES_DB: superset_light
|
||||
EXAMPLES_HOST: db-light
|
||||
EXAMPLES_DB: superset_light
|
||||
EXAMPLES_USER: superset
|
||||
EXAMPLES_PASSWORD: superset
|
||||
# Use light-specific config that disables Redis
|
||||
SUPERSET_CONFIG_PATH: /app/docker/pythonpath_dev/superset_config_docker_light.py
|
||||
|
||||
superset-init-light:
|
||||
build:
|
||||
<<: *common-build
|
||||
command: ["/app/docker/docker-init.sh"]
|
||||
env_file:
|
||||
- path: docker/.env # default
|
||||
required: true
|
||||
- path: docker/.env-local # optional override
|
||||
required: false
|
||||
depends_on:
|
||||
db-light:
|
||||
condition: service_started
|
||||
user: *superset-user
|
||||
volumes: *superset-volumes
|
||||
environment:
|
||||
# Override DB connection for light service
|
||||
DATABASE_HOST: db-light
|
||||
DATABASE_DB: superset_light
|
||||
POSTGRES_DB: superset_light
|
||||
EXAMPLES_HOST: db-light
|
||||
EXAMPLES_DB: superset_light
|
||||
EXAMPLES_USER: superset
|
||||
EXAMPLES_PASSWORD: superset
|
||||
# Use light-specific config that disables Redis
|
||||
SUPERSET_CONFIG_PATH: /app/docker/pythonpath_dev/superset_config_docker_light.py
|
||||
healthcheck:
|
||||
disable: true
|
||||
|
||||
superset-node-light:
|
||||
build:
|
||||
context: .
|
||||
target: superset-node
|
||||
args:
|
||||
# This prevents building the frontend bundle since we'll mount local folder
|
||||
# and build it on startup while firing docker-frontend.sh in dev mode, where
|
||||
# it'll mount and watch local files and rebuild as you update them
|
||||
DEV_MODE: "true"
|
||||
BUILD_TRANSLATIONS: ${BUILD_TRANSLATIONS:-false}
|
||||
environment:
|
||||
# set this to false if you have perf issues running the npm i; npm run dev in-docker
|
||||
# if you do so, you have to run this manually on the host, which should perform better!
|
||||
BUILD_SUPERSET_FRONTEND_IN_DOCKER: true
|
||||
NPM_RUN_PRUNE: false
|
||||
SCARF_ANALYTICS: "${SCARF_ANALYTICS:-}"
|
||||
# configuring the dev-server to use the host.docker.internal to connect to the backend
|
||||
superset: "http://superset-light:8088"
|
||||
ports:
|
||||
- "127.0.0.1:${NODE_PORT:-9001}:9000" # Parameterized port
|
||||
command: ["/app/docker/docker-frontend.sh"]
|
||||
env_file:
|
||||
- path: docker/.env # default
|
||||
required: true
|
||||
- path: docker/.env-local # optional override
|
||||
required: false
|
||||
volumes: *superset-volumes
|
||||
|
||||
volumes:
|
||||
superset_home_light:
|
||||
external: false
|
||||
db_home_light:
|
||||
external: false
|
||||
@@ -20,6 +20,9 @@
|
||||
# If you choose to use this type of deployment make sure to
|
||||
# create you own docker environment file (docker/.env) with your own
|
||||
# unique random secure passwords and SECRET_KEY.
|
||||
#
|
||||
# For verbose logging during development:
|
||||
# - Set SUPERSET_LOG_LEVEL=debug in docker/.env-local for detailed Superset logs
|
||||
# -----------------------------------------------------------------------
|
||||
x-superset-volumes:
|
||||
&superset-volumes # /app/pythonpath_docker will be appended to the PYTHONPATH in the final container
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
# If you choose to use this type of deployment make sure to
|
||||
# create you own docker environment file (docker/.env) with your own
|
||||
# unique random secure passwords and SECRET_KEY.
|
||||
#
|
||||
# For verbose logging during development:
|
||||
# - Set SUPERSET_LOG_LEVEL=debug in docker/.env-local for detailed Superset logs
|
||||
# -----------------------------------------------------------------------
|
||||
x-superset-user: &superset-user root
|
||||
x-superset-volumes: &superset-volumes
|
||||
|
||||
@@ -53,7 +53,12 @@ PYTHONPATH=/app/pythonpath:/app/docker/pythonpath_dev
|
||||
REDIS_HOST=redis
|
||||
REDIS_PORT=6379
|
||||
|
||||
# Development and logging configuration
|
||||
# FLASK_DEBUG: Enables Flask dev features (auto-reload, better error pages) - keep 'true' for development
|
||||
FLASK_DEBUG=true
|
||||
# SUPERSET_LOG_LEVEL: Controls Superset application logging verbosity (debug, info, warning, error, critical)
|
||||
SUPERSET_LOG_LEVEL=info
|
||||
|
||||
SUPERSET_APP_ROOT="/"
|
||||
SUPERSET_ENV=development
|
||||
SUPERSET_LOAD_EXAMPLES=yes
|
||||
@@ -66,4 +71,3 @@ SUPERSET_SECRET_KEY=TEST_NON_DEV_SECRET
|
||||
ENABLE_PLAYWRIGHT=false
|
||||
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
|
||||
BUILD_SUPERSET_FRONTEND_IN_DOCKER=true
|
||||
SUPERSET_LOG_LEVEL=info
|
||||
|
||||
1
docker/pythonpath_dev/.gitignore
vendored
1
docker/pythonpath_dev/.gitignore
vendored
@@ -20,4 +20,5 @@
|
||||
# DON'T ignore the .gitignore
|
||||
!.gitignore
|
||||
!superset_config.py
|
||||
!superset_config_docker_light.py
|
||||
!superset_config_local.example
|
||||
|
||||
@@ -129,7 +129,7 @@ if os.getenv("CYPRESS_CONFIG") == "true":
|
||||
#
|
||||
try:
|
||||
import superset_config_docker
|
||||
from superset_config_docker import * # noqa
|
||||
from superset_config_docker import * # noqa: F403
|
||||
|
||||
logger.info(
|
||||
f"Loaded your Docker configuration at [{superset_config_docker.__file__}]"
|
||||
|
||||
37
docker/pythonpath_dev/superset_config_docker_light.py
Normal file
37
docker/pythonpath_dev/superset_config_docker_light.py
Normal file
@@ -0,0 +1,37 @@
|
||||
# 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.
|
||||
#
|
||||
# Configuration for docker-compose-light.yml - disables Redis and uses minimal services
|
||||
|
||||
# Import all settings from the main config first
|
||||
from flask_caching.backends.filesystemcache import FileSystemCache
|
||||
from superset_config import * # noqa: F403
|
||||
|
||||
# Override caching to use simple in-memory cache instead of Redis
|
||||
RESULTS_BACKEND = FileSystemCache("/app/superset_home/sqllab")
|
||||
|
||||
CACHE_CONFIG = {
|
||||
"CACHE_TYPE": "SimpleCache",
|
||||
"CACHE_DEFAULT_TIMEOUT": 300,
|
||||
"CACHE_KEY_PREFIX": "superset_light_",
|
||||
}
|
||||
DATA_CACHE_CONFIG = CACHE_CONFIG
|
||||
THUMBNAIL_CACHE_CONFIG = CACHE_CONFIG
|
||||
|
||||
|
||||
# Disable Celery entirely for lightweight mode
|
||||
CELERY_CONFIG = None # type: ignore[assignment,misc]
|
||||
@@ -10,44 +10,85 @@ version: 1
|
||||
apache-superset>=6.0
|
||||
:::
|
||||
|
||||
Superset now rides on **Ant Design v5’s token-based theming**.
|
||||
Superset now rides on **Ant Design v5's token-based theming**.
|
||||
Every Antd token works, plus a handful of Superset-specific ones for charts and dashboard chrome.
|
||||
|
||||
## 1 — Create a theme
|
||||
## Managing Themes via CRUD Interface
|
||||
|
||||
1. Open the official [Ant Design Theme Editor](https://ant.design/theme-editor)
|
||||
2. Design your palette, typography, and component overrides.
|
||||
3. Open the `CONFIG` modal and paste the JSON.
|
||||
Superset now includes a built-in **Theme Management** interface accessible from the admin menu under **Settings > Themes**.
|
||||
|
||||
### Creating a New Theme
|
||||
|
||||
1. Navigate to **Settings > Themes** in the Superset interface
|
||||
2. Click **+ Theme** to create a new theme
|
||||
3. Use the [Ant Design Theme Editor](https://ant.design/theme-editor) to design your theme:
|
||||
- Design your palette, typography, and component overrides
|
||||
- Open the `CONFIG` modal and copy the JSON configuration
|
||||
4. Paste the JSON into the theme definition field in Superset
|
||||
5. Give your theme a descriptive name and save
|
||||
|
||||
You can also extend with Superset-specific tokens (documented in the default theme object) before you import.
|
||||
|
||||
## 2 — Apply it instance-wide
|
||||
### Applying Themes to Dashboards
|
||||
|
||||
Once created, themes can be applied to individual dashboards:
|
||||
- Edit any dashboard and select your custom theme from the theme dropdown
|
||||
- Each dashboard can have its own theme, allowing for branded or context-specific styling
|
||||
|
||||
## Alternative: Instance-wide Configuration
|
||||
|
||||
For system-wide theming, you can configure default themes via Python configuration:
|
||||
|
||||
### Setting Default Themes
|
||||
|
||||
```python
|
||||
# superset_config.py
|
||||
THEME = {
|
||||
# Paste your JSON theme definition here
|
||||
|
||||
# Default theme (light mode)
|
||||
THEME_DEFAULT = {
|
||||
"token": {
|
||||
"colorPrimary": "#2893B3",
|
||||
"colorSuccess": "#5ac189",
|
||||
# ... your theme JSON configuration
|
||||
}
|
||||
}
|
||||
|
||||
# Dark theme configuration
|
||||
THEME_DARK = {
|
||||
"algorithm": "dark",
|
||||
"token": {
|
||||
"colorPrimary": "#2893B3",
|
||||
# ... your dark theme overrides
|
||||
}
|
||||
}
|
||||
|
||||
# Theme behavior settings
|
||||
THEME_SETTINGS = {
|
||||
"enforced": False, # If True, forces default theme always
|
||||
"allowSwitching": True, # Allow users to switch between themes
|
||||
"allowOSPreference": True, # Auto-detect system theme preference
|
||||
}
|
||||
```
|
||||
|
||||
Restart Superset to apply changes
|
||||
### Copying Themes from CRUD Interface
|
||||
|
||||
## 3 — Tweak live in the app (beta)
|
||||
To use a theme created via the CRUD interface as your system default:
|
||||
|
||||
Set the feature flag in your `superset_config`
|
||||
```python
|
||||
DEFAULT_FEATURE_FLAGS: dict[str, bool] = {
|
||||
{{ ... }}
|
||||
THEME_ALLOW_THEME_EDITOR_BETA = True,
|
||||
}
|
||||
```
|
||||
1. Navigate to **Settings > Themes** and edit your desired theme
|
||||
2. Copy the complete JSON configuration from the theme definition field
|
||||
3. Paste it directly into your `superset_config.py` as shown above
|
||||
|
||||
- Enables a JSON editor panel inside Superset as a new icon in the navbar
|
||||
- Intended for testing/design and rapid in-context iteration
|
||||
- End-user theme switching & preferences coming later
|
||||
Restart Superset to apply changes.
|
||||
|
||||
## 4 — Potential Next Steps
|
||||
## Theme Development Workflow
|
||||
|
||||
- CRUD UI for managing multiple themes
|
||||
- Per-dashboard & per-workspace theme assignment
|
||||
- User-selectable theme preferences
|
||||
1. **Design**: Use the [Ant Design Theme Editor](https://ant.design/theme-editor) to iterate on your design
|
||||
2. **Test**: Create themes in Superset's CRUD interface for testing
|
||||
3. **Apply**: Assign themes to specific dashboards or configure instance-wide
|
||||
4. **Iterate**: Modify theme JSON directly in the CRUD interface or re-import from the theme editor
|
||||
|
||||
## Advanced Features
|
||||
|
||||
- **System Themes**: Superset includes built-in light and dark themes
|
||||
- **Per-Dashboard Theming**: Each dashboard can have its own visual identity
|
||||
- **JSON Editor**: Edit theme configurations directly within Superset's interface
|
||||
|
||||
@@ -26,11 +26,14 @@ Superset locally is using Docker Compose on a Linux or Mac OSX
|
||||
computer. Superset does not have official support for Windows. It's also the easiest
|
||||
way to launch a fully functioning **development environment** quickly.
|
||||
|
||||
Note that there are 3 major ways we support to run `docker compose`:
|
||||
Note that there are 4 major ways we support to run `docker compose`:
|
||||
|
||||
1. **docker-compose.yml:** for interactive development, where we mount your local folder with the
|
||||
frontend/backend files that you can edit and experience the changes you
|
||||
make in the app in real time
|
||||
1. **docker-compose-light.yml:** a lightweight configuration with minimal services (database,
|
||||
Superset app, and frontend dev server) for development. Uses in-memory caching instead of Redis
|
||||
and is designed for running multiple instances simultaneously
|
||||
1. **docker-compose-non-dev.yml** where we just build a more immutable image based on the
|
||||
local branch and get all the required images running. Changes in the local branch
|
||||
at the time you fire this up will be reflected, but changes to the code
|
||||
@@ -44,7 +47,7 @@ Note that there are 3 major ways we support to run `docker compose`:
|
||||
The `dev` builds include the `psycopg2-binary` required to connect
|
||||
to the Postgres database launched as part of the `docker compose` builds.
|
||||
|
||||
More on these two approaches after setting up the requirements for either.
|
||||
More on these approaches after setting up the requirements for either.
|
||||
|
||||
## Requirements
|
||||
|
||||
@@ -103,13 +106,36 @@ and help you start fresh. In the context of `docker compose` setting
|
||||
from within docker. This will slow down the startup, but will fix various npm-related issues.
|
||||
:::
|
||||
|
||||
### Option #2 - build a set of immutable images from the local branch
|
||||
### Option #2 - lightweight development with multiple instances
|
||||
|
||||
For a lighter development setup that uses fewer resources and supports running multiple instances:
|
||||
|
||||
```bash
|
||||
# Single lightweight instance (default port 9001)
|
||||
docker compose -f docker-compose-light.yml up
|
||||
|
||||
# Multiple instances with different ports
|
||||
NODE_PORT=9001 docker compose -p superset-1 -f docker-compose-light.yml up
|
||||
NODE_PORT=9002 docker compose -p superset-2 -f docker-compose-light.yml up
|
||||
NODE_PORT=9003 docker compose -p superset-3 -f docker-compose-light.yml up
|
||||
```
|
||||
|
||||
This configuration includes:
|
||||
- PostgreSQL database (internal network only)
|
||||
- Superset application server
|
||||
- Frontend development server with webpack hot reloading
|
||||
- In-memory caching (no Redis)
|
||||
- Isolated volumes and networks per instance
|
||||
|
||||
Access each instance at `http://localhost:{NODE_PORT}` (e.g., `http://localhost:9001`).
|
||||
|
||||
### Option #3 - build a set of immutable images from the local branch
|
||||
|
||||
```bash
|
||||
docker compose -f docker-compose-non-dev.yml up
|
||||
```
|
||||
|
||||
### Option #3 - boot up an official release
|
||||
### Option #4 - boot up an official release
|
||||
|
||||
```bash
|
||||
# Set the version you want to run
|
||||
|
||||
@@ -65,5 +65,6 @@
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
}
|
||||
},
|
||||
"packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ dependencies = [
|
||||
"slack_sdk>=3.19.0, <4",
|
||||
"sqlalchemy>=1.4, <2",
|
||||
"sqlalchemy-utils>=0.38.3, <0.39",
|
||||
"sqlglot>=26.1.3, <27",
|
||||
"sqlglot>=27.3.0, <28",
|
||||
# newer pandas needs 0.9+
|
||||
"tabulate>=0.9.0, <1.0",
|
||||
"typing-extensions>=4, <5",
|
||||
@@ -111,7 +111,7 @@ athena = ["pyathena[pandas]>=2, <3"]
|
||||
aurora-data-api = ["preset-sqlalchemy-aurora-data-api>=0.2.8,<0.3"]
|
||||
bigquery = [
|
||||
"pandas-gbq>=0.19.1",
|
||||
"sqlalchemy-bigquery>=1.6.1",
|
||||
"sqlalchemy-bigquery>=1.15.0",
|
||||
"google-cloud-bigquery>=3.10.0",
|
||||
]
|
||||
clickhouse = ["clickhouse-connect>=0.5.14, <1.0"]
|
||||
@@ -311,15 +311,16 @@ select = [
|
||||
"Q",
|
||||
"S",
|
||||
"T",
|
||||
"TID",
|
||||
"W",
|
||||
]
|
||||
|
||||
ignore = [
|
||||
"S101",
|
||||
"PT006",
|
||||
"T201",
|
||||
"N999",
|
||||
]
|
||||
|
||||
extend-select = ["I"]
|
||||
|
||||
# Allow fix for all enabled rules (when `--fix`) is provided.
|
||||
@@ -329,6 +330,16 @@ unfixable = []
|
||||
# Allow unused variables when underscore-prefixed.
|
||||
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
|
||||
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
"scripts/*" = ["TID251"]
|
||||
"setup.py" = ["TID251"]
|
||||
"superset/config.py" = ["TID251"]
|
||||
"superset/cli/update.py" = ["TID251"]
|
||||
"superset/key_value/types.py" = ["TID251"]
|
||||
"superset/translations/utils.py" = ["TID251"]
|
||||
"superset/extensions/__init__.py" = ["TID251"]
|
||||
"superset/utils/json.py" = ["TID251"]
|
||||
|
||||
[tool.ruff.lint.isort]
|
||||
case-sensitive = false
|
||||
combine-as-imports = true
|
||||
@@ -345,6 +356,9 @@ section-order = [
|
||||
"local-folder"
|
||||
]
|
||||
|
||||
[tool.ruff.lint.flake8-tidy-imports]
|
||||
banned-api = { json = { msg = "Use superset.utils.json instead" }, simplejson = { msg = "Use superset.utils.json instead" } }
|
||||
|
||||
[tool.ruff.format]
|
||||
# Like Black, use double quotes for strings.
|
||||
quote-style = "double"
|
||||
|
||||
@@ -378,7 +378,7 @@ sqlalchemy-utils==0.38.3
|
||||
# via
|
||||
# apache-superset (pyproject.toml)
|
||||
# flask-appbuilder
|
||||
sqlglot==26.28.1
|
||||
sqlglot==27.3.0
|
||||
# via apache-superset (pyproject.toml)
|
||||
sshtunnel==0.4.0
|
||||
# via apache-superset (pyproject.toml)
|
||||
|
||||
@@ -795,14 +795,14 @@ sqlalchemy==1.4.54
|
||||
# shillelagh
|
||||
# sqlalchemy-bigquery
|
||||
# sqlalchemy-utils
|
||||
sqlalchemy-bigquery==1.12.0
|
||||
sqlalchemy-bigquery==1.15.0
|
||||
# via apache-superset
|
||||
sqlalchemy-utils==0.38.3
|
||||
# via
|
||||
# -c requirements/base.txt
|
||||
# apache-superset
|
||||
# flask-appbuilder
|
||||
sqlglot==26.28.1
|
||||
sqlglot==27.3.0
|
||||
# via
|
||||
# -c requirements/base.txt
|
||||
# apache-superset
|
||||
|
||||
@@ -77,7 +77,7 @@ const themeDecorator = (Story, context) => {
|
||||
minHeight: '100vh',
|
||||
width: '100%',
|
||||
padding: 24,
|
||||
backgroundColor: themeObject.theme.colorBgContainer,
|
||||
backgroundColor: themeObject.theme.colorBgBase,
|
||||
}}
|
||||
>
|
||||
<Story {...context} />
|
||||
|
||||
@@ -54,7 +54,7 @@ const drillBy = (targetDrillByColumn: string, isLegacy = false) => {
|
||||
interceptV1ChartData();
|
||||
}
|
||||
|
||||
cy.get('.ant-dropdown:not(.ant-dropdown-hidden)')
|
||||
cy.get('.ant-dropdown:not(.ant-dropdown-hidden)', { timeout: 15000 })
|
||||
.should('be.visible')
|
||||
.find("[role='menu'] [role='menuitem']")
|
||||
.contains(/^Drill by$/)
|
||||
@@ -529,7 +529,7 @@ describe('Drill by modal', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('Bar Chart', () => {
|
||||
it.skip('Bar Chart', () => {
|
||||
testEchart('echarts_timeseries_bar', 'Bar Chart', [
|
||||
[85, 94],
|
||||
[490, 68],
|
||||
@@ -612,7 +612,7 @@ describe('Drill by modal', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('Mixed Chart', () => {
|
||||
it.skip('Mixed Chart', () => {
|
||||
cy.get('[data-test-viz-type="mixed_timeseries"] canvas').then($canvas => {
|
||||
// click 'boy'
|
||||
cy.wrap($canvas).scrollIntoView();
|
||||
|
||||
35
superset-frontend/package-lock.json
generated
35
superset-frontend/package-lock.json
generated
@@ -53,8 +53,8 @@
|
||||
"@visx/scale": "^3.5.0",
|
||||
"@visx/tooltip": "^3.0.0",
|
||||
"@visx/xychart": "^3.5.1",
|
||||
"ag-grid-community": "33.1.1",
|
||||
"ag-grid-react": "33.1.1",
|
||||
"ag-grid-community": "^34.0.2",
|
||||
"ag-grid-react": "34.0.2",
|
||||
"antd": "^5.24.6",
|
||||
"chrono-node": "^2.7.8",
|
||||
"classnames": "^2.2.5",
|
||||
@@ -77,7 +77,6 @@
|
||||
"geostyler-style": "7.5.0",
|
||||
"geostyler-wfs-parser": "^2.0.3",
|
||||
"googleapis": "^130.0.0",
|
||||
"html-webpack-plugin": "^5.6.3",
|
||||
"immer": "^10.1.1",
|
||||
"interweave": "^13.1.0",
|
||||
"jquery": "^3.7.1",
|
||||
@@ -276,7 +275,7 @@
|
||||
"webpack-visualizer-plugin2": "^1.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^20.16.0",
|
||||
"node": "^20.18.1",
|
||||
"npm": "^10.8.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
@@ -18748,27 +18747,27 @@
|
||||
}
|
||||
},
|
||||
"node_modules/ag-charts-types": {
|
||||
"version": "11.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ag-charts-types/-/ag-charts-types-11.1.1.tgz",
|
||||
"integrity": "sha512-bRmUcf5VVhEEekhX8Vk0NSwa8Te8YM/zchjyYKR2CX4vDYiwoohM1Jg9RFvbIhVbLC1S6QrPEbx5v2C6RDfpSA==",
|
||||
"version": "12.0.2",
|
||||
"resolved": "https://registry.npmjs.org/ag-charts-types/-/ag-charts-types-12.0.2.tgz",
|
||||
"integrity": "sha512-AWM1Y+XW+9VMmV3AbzdVEnreh/I2C9Pmqpc2iLmtId3Xbvmv7O56DqnuDb9EXjK5uPxmyUerTP+utL13UGcztw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/ag-grid-community": {
|
||||
"version": "33.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ag-grid-community/-/ag-grid-community-33.1.1.tgz",
|
||||
"integrity": "sha512-CNubIro0ipj4nfQ5WJPG9Isp7UI6MMDvNzrPdHNf3W+IoM8Uv3RUhjEn7xQqpQHuu6o/tMjrqpacipMUkhzqnw==",
|
||||
"version": "34.0.2",
|
||||
"resolved": "https://registry.npmjs.org/ag-grid-community/-/ag-grid-community-34.0.2.tgz",
|
||||
"integrity": "sha512-hVJp5vrmwHRB10YjfSOVni5YJkO/v+asLjT72S4YnIFSx8lAgyPmByNJgtojk1aJ5h6Up93jTEmGDJeuKiWWLA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ag-charts-types": "11.1.1"
|
||||
"ag-charts-types": "12.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/ag-grid-react": {
|
||||
"version": "33.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ag-grid-react/-/ag-grid-react-33.1.1.tgz",
|
||||
"integrity": "sha512-xJ+t2gpqUUwpFqAeDvKz/GLVR4unkOghfQBr8iIY9RAdGFarYFClJavsOa8XPVVUqEB9OIuPVFnOdtocbX0jeA==",
|
||||
"version": "34.0.2",
|
||||
"resolved": "https://registry.npmjs.org/ag-grid-react/-/ag-grid-react-34.0.2.tgz",
|
||||
"integrity": "sha512-1KBXkTvwtZiYVlSuDzBkiqfHjZgsATOmpLZdAtdmsCSOOOEWai0F9zHHgBuHfyciAE4nrbQWfojkx8IdnwsKFw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ag-grid-community": "33.1.1",
|
||||
"ag-grid-community": "34.0.2",
|
||||
"prop-types": "^15.8.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
@@ -61169,8 +61168,8 @@
|
||||
"@react-icons/all-files": "^4.1.0",
|
||||
"@types/d3-array": "^2.9.0",
|
||||
"@types/react-table": "^7.7.20",
|
||||
"ag-grid-community": "^33.1.1",
|
||||
"ag-grid-react": "^33.1.1",
|
||||
"ag-grid-community": "^34.0.2",
|
||||
"ag-grid-react": "^34.0.2",
|
||||
"classnames": "^2.5.1",
|
||||
"d3-array": "^2.4.0",
|
||||
"lodash": "^4.17.21",
|
||||
@@ -61206,8 +61205,10 @@
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@ant-design/icons": "^5.2.6",
|
||||
"@reduxjs/toolkit": "*",
|
||||
"@superset-ui/chart-controls": "*",
|
||||
"@superset-ui/core": "*",
|
||||
"@types/react-redux": "*",
|
||||
"geostyler": "^14.1.3",
|
||||
"geostyler-data": "^1.0.0",
|
||||
"geostyler-openlayers-parser": "^4.0.0",
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
"test": "cross-env NODE_ENV=test NODE_OPTIONS=\"--max-old-space-size=8192\" jest --max-workers=80% --silent",
|
||||
"test-loud": "cross-env NODE_ENV=test NODE_OPTIONS=\"--max-old-space-size=8192\" jest --max-workers=80%",
|
||||
"type": "tsc --noEmit",
|
||||
"update-maps": "jupyter nbconvert --to notebook --execute --inplace 'plugins/legacy-plugin-chart-country-map/scripts/Country Map GeoJSON Generator.ipynb' -Xfrozen_modules=off",
|
||||
"update-maps": "cd plugins/legacy-plugin-chart-country-map/scripts && jupyter nbconvert --to notebook --execute --inplace --allow-errors --ExecutePreprocessor.timeout=1200 'Country Map GeoJSON Generator.ipynb'",
|
||||
"validate-release": "../RELEASING/validate_this_release.sh"
|
||||
},
|
||||
"browserslist": [
|
||||
@@ -121,8 +121,8 @@
|
||||
"@visx/scale": "^3.5.0",
|
||||
"@visx/tooltip": "^3.0.0",
|
||||
"@visx/xychart": "^3.5.1",
|
||||
"ag-grid-community": "33.1.1",
|
||||
"ag-grid-react": "33.1.1",
|
||||
"ag-grid-community": "^34.0.2",
|
||||
"ag-grid-react": "34.0.2",
|
||||
"antd": "^5.24.6",
|
||||
"chrono-node": "^2.7.8",
|
||||
"classnames": "^2.2.5",
|
||||
@@ -145,7 +145,6 @@
|
||||
"geostyler-style": "7.5.0",
|
||||
"geostyler-wfs-parser": "^2.0.3",
|
||||
"googleapis": "^130.0.0",
|
||||
"html-webpack-plugin": "^5.6.3",
|
||||
"immer": "^10.1.1",
|
||||
"interweave": "^13.1.0",
|
||||
"jquery": "^3.7.1",
|
||||
@@ -350,7 +349,7 @@
|
||||
"regenerator-runtime": "^0.14.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^20.16.0",
|
||||
"node": "^20.18.1",
|
||||
"npm": "^10.8.1"
|
||||
},
|
||||
"overrides": {
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
*/
|
||||
import { ReactNode } from 'react';
|
||||
import { t, css } from '@superset-ui/core';
|
||||
import { InfoCircleOutlined } from '@ant-design/icons';
|
||||
import { InfoTooltip, Tooltip } from '@superset-ui/core/components';
|
||||
import { InfoTooltip, Tooltip, Icons } from '@superset-ui/core/components';
|
||||
|
||||
type ValidationError = string;
|
||||
|
||||
@@ -93,7 +92,7 @@ export function ControlHeader({
|
||||
<div className="ControlHeader" data-test={`${name}-header`}>
|
||||
<div className="pull-left">
|
||||
<label className="control-label" htmlFor={name}>
|
||||
{leftNode && <span>{leftNode}</span>}
|
||||
{leftNode && <>{leftNode}</>}
|
||||
<span
|
||||
role={onClick ? 'button' : undefined}
|
||||
{...(onClick ? { onClick, tabIndex: 0 } : {})}
|
||||
@@ -104,9 +103,9 @@ export function ControlHeader({
|
||||
{warning && (
|
||||
<span>
|
||||
<Tooltip id="error-tooltip" placement="top" title={warning}>
|
||||
<InfoCircleOutlined
|
||||
<Icons.InfoCircleOutlined
|
||||
iconSize="m"
|
||||
css={theme => css`
|
||||
font-size: ${theme.sizeUnit * 3}px;
|
||||
color: ${theme.colorError};
|
||||
`}
|
||||
/>
|
||||
@@ -116,9 +115,9 @@ export function ControlHeader({
|
||||
{danger && (
|
||||
<span>
|
||||
<Tooltip id="error-tooltip" placement="top" title={danger}>
|
||||
<InfoCircleOutlined
|
||||
<Icons.InfoCircleOutlined
|
||||
iconSize="m"
|
||||
css={theme => css`
|
||||
font-size: ${theme.sizeUnit * 3}px;
|
||||
color: ${theme.colorError};
|
||||
`}
|
||||
/>{' '}
|
||||
@@ -132,9 +131,9 @@ export function ControlHeader({
|
||||
placement="top"
|
||||
title={validationErrors.join(' ')}
|
||||
>
|
||||
<InfoCircleOutlined
|
||||
<Icons.InfoCircleOutlined
|
||||
iconSize="m"
|
||||
css={theme => css`
|
||||
font-size: ${theme.sizeUnit * 3}px;
|
||||
color: ${theme.colorError};
|
||||
`}
|
||||
/>{' '}
|
||||
|
||||
@@ -24,7 +24,7 @@ import { css, styled, useTheme, t } from '@superset-ui/core';
|
||||
|
||||
const StyledCalculatorIcon = styled(CalculatorOutlined)`
|
||||
${({ theme }) => css`
|
||||
color: ${theme.colorText};
|
||||
color: ${theme.colors.grayscale.base};
|
||||
font-size: ${theme.fontSizeSM}px;
|
||||
& svg {
|
||||
margin-left: ${theme.sizeUnit}px;
|
||||
|
||||
@@ -30,7 +30,7 @@ const controlsWithoutXAxis: ControlSetRow[] = [
|
||||
['groupby'],
|
||||
[contributionModeControl],
|
||||
['adhoc_filters'],
|
||||
['limit'],
|
||||
['limit', 'group_others_when_limit_reached'],
|
||||
['timeseries_limit_metric'],
|
||||
['order_desc'],
|
||||
['row_limit'],
|
||||
|
||||
@@ -283,6 +283,19 @@ const series_limit: SharedControlConfig<'SelectControl'> = {
|
||||
),
|
||||
};
|
||||
|
||||
const group_others_when_limit_reached: SharedControlConfig<'CheckboxControl'> =
|
||||
{
|
||||
type: 'CheckboxControl',
|
||||
label: t('Group remaining as "Others"'),
|
||||
default: false,
|
||||
description: t(
|
||||
'Groups remaining series into an "Others" category when series limit is reached. ' +
|
||||
'This prevents incomplete time series data from being displayed.',
|
||||
),
|
||||
visibility: ({ form_data }: { form_data: any }) =>
|
||||
Boolean(form_data?.limit || form_data?.series_limit),
|
||||
};
|
||||
|
||||
const y_axis_format: SharedControlConfig<'SelectControl', SelectDefaultOption> =
|
||||
{
|
||||
type: 'SelectControl',
|
||||
@@ -446,6 +459,7 @@ export default {
|
||||
time_shift_color,
|
||||
series_columns: dndColumnsControl,
|
||||
series_limit,
|
||||
group_others_when_limit_reached,
|
||||
series_limit_metric: dndSortByControl,
|
||||
legacy_order_by: dndSortByControl,
|
||||
truncate_metric,
|
||||
|
||||
@@ -27,8 +27,8 @@ export default function FallbackComponent({ error, height, width }: Props) {
|
||||
return (
|
||||
<div
|
||||
css={(theme: SupersetTheme) => ({
|
||||
backgroundColor: theme.colorTextBase,
|
||||
color: theme.colorBgContainer,
|
||||
backgroundColor: theme.colors.grayscale.dark2,
|
||||
color: theme.colors.grayscale.light5,
|
||||
overflow: 'auto',
|
||||
padding: 32,
|
||||
})}
|
||||
|
||||
@@ -35,6 +35,11 @@ import { useTheme, css } from '@superset-ui/core';
|
||||
import { Global } from '@emotion/react';
|
||||
|
||||
export { getTooltipHTML } from './Tooltip';
|
||||
export { useJsonValidation } from './useJsonValidation';
|
||||
export type {
|
||||
JsonValidationAnnotation,
|
||||
UseJsonValidationOptions,
|
||||
} from './useJsonValidation';
|
||||
|
||||
export interface AceCompleterKeywordData {
|
||||
name: string;
|
||||
@@ -265,7 +270,7 @@ export function AsyncAceEditor(
|
||||
/* Adjust tooltip styles */
|
||||
.ace_tooltip {
|
||||
margin-left: ${token.margin}px;
|
||||
padding: 0px;
|
||||
padding: ${token.sizeUnit * 2}px;
|
||||
background-color: ${token.colorBgElevated} !important;
|
||||
color: ${token.colorText} !important;
|
||||
border: 1px solid ${token.colorBorderSecondary};
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* 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 { renderHook } from '@testing-library/react-hooks';
|
||||
import { useJsonValidation } from './useJsonValidation';
|
||||
|
||||
describe('useJsonValidation', () => {
|
||||
it('returns empty array for valid JSON', () => {
|
||||
const { result } = renderHook(() => useJsonValidation('{"key": "value"}'));
|
||||
expect(result.current).toEqual([]);
|
||||
});
|
||||
|
||||
it('returns empty array when disabled', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useJsonValidation('invalid json', { enabled: false }),
|
||||
);
|
||||
expect(result.current).toEqual([]);
|
||||
});
|
||||
|
||||
it('returns empty array for empty input', () => {
|
||||
const { result } = renderHook(() => useJsonValidation(''));
|
||||
expect(result.current).toEqual([]);
|
||||
});
|
||||
|
||||
it('extracts line and column from error message with parentheses', () => {
|
||||
// Since we can't control the exact error message from JSON.parse,
|
||||
// let's test with a mock that demonstrates the pattern matching
|
||||
const mockError = {
|
||||
message:
|
||||
"Expected ',' or '}' after property value in JSON at position 19 (line 3 column 2)",
|
||||
};
|
||||
|
||||
// Test the regex pattern directly
|
||||
const match = mockError.message.match(/\(line (\d+) column (\d+)\)/);
|
||||
expect(match).toBeTruthy();
|
||||
expect(match![1]).toBe('3');
|
||||
expect(match![2]).toBe('2');
|
||||
});
|
||||
|
||||
it('returns error on first line when no line/column info in message', () => {
|
||||
const invalidJson = '{invalid}';
|
||||
const { result } = renderHook(() => useJsonValidation(invalidJson));
|
||||
|
||||
expect(result.current).toHaveLength(1);
|
||||
expect(result.current[0]).toMatchObject({
|
||||
type: 'error',
|
||||
row: 0,
|
||||
column: 0,
|
||||
text: expect.stringContaining('Invalid JSON'),
|
||||
});
|
||||
});
|
||||
|
||||
it('uses custom error prefix', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useJsonValidation('{invalid}', { errorPrefix: 'Custom error' }),
|
||||
);
|
||||
|
||||
expect(result.current[0].text).toContain('Custom error');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* 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 { useMemo } from 'react';
|
||||
|
||||
export interface JsonValidationAnnotation {
|
||||
type: 'error' | 'warning' | 'info';
|
||||
row: number;
|
||||
column: number;
|
||||
text: string;
|
||||
}
|
||||
|
||||
export interface UseJsonValidationOptions {
|
||||
/** Whether to enable JSON validation. Default: true */
|
||||
enabled?: boolean;
|
||||
/** Custom error message prefix. Default: 'Invalid JSON' */
|
||||
errorPrefix?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook for JSON validation that returns AceEditor-compatible annotations.
|
||||
* Based on the SQL Lab validation pattern.
|
||||
*
|
||||
* @param jsonValue - The JSON string to validate
|
||||
* @param options - Validation options
|
||||
* @returns Array of annotation objects for AceEditor
|
||||
*/
|
||||
export function useJsonValidation(
|
||||
jsonValue?: string,
|
||||
options: UseJsonValidationOptions = {},
|
||||
): JsonValidationAnnotation[] {
|
||||
const { enabled = true, errorPrefix = 'Invalid JSON' } = options;
|
||||
|
||||
return useMemo(() => {
|
||||
// Skip validation if disabled or empty value
|
||||
if (!enabled || !jsonValue?.trim()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
try {
|
||||
JSON.parse(jsonValue);
|
||||
return []; // Valid JSON - no annotations
|
||||
} catch (error: any) {
|
||||
const errorMessage = error.message || 'syntax error';
|
||||
|
||||
// Try to extract line/column from error message
|
||||
// Look for pattern: (line X column Y) - often at the end of error messages
|
||||
let row = 0;
|
||||
let column = 0;
|
||||
|
||||
const match = errorMessage.match(/\(line (\d+) column (\d+)\)/);
|
||||
if (match) {
|
||||
row = parseInt(match[1], 10) - 1; // Convert to 0-based
|
||||
column = parseInt(match[2], 10) - 1;
|
||||
}
|
||||
|
||||
return [
|
||||
{
|
||||
type: 'error' as const,
|
||||
row,
|
||||
column,
|
||||
text: `${errorPrefix}: ${errorMessage}`,
|
||||
},
|
||||
];
|
||||
}
|
||||
}, [enabled, jsonValue, errorPrefix]);
|
||||
}
|
||||
@@ -65,18 +65,16 @@ export function Button(props: ButtonProps) {
|
||||
let antdType: ButtonType = 'default';
|
||||
let variant: ButtonVariantType = 'solid';
|
||||
let color: ButtonColorType = 'primary';
|
||||
let ghost: boolean = false;
|
||||
|
||||
if (!buttonStyle || buttonStyle === 'primary') {
|
||||
variant = 'solid';
|
||||
antdType = 'primary';
|
||||
} else if (buttonStyle === 'secondary') {
|
||||
variant = 'outlined';
|
||||
variant = 'filled';
|
||||
color = 'primary';
|
||||
} else if (buttonStyle === 'tertiary') {
|
||||
variant = 'outlined';
|
||||
color = 'default';
|
||||
ghost = true;
|
||||
} else if (buttonStyle === 'dashed') {
|
||||
variant = 'dashed';
|
||||
antdType = 'dashed';
|
||||
@@ -102,7 +100,6 @@ export function Button(props: ButtonProps) {
|
||||
|
||||
const button = (
|
||||
<AntdButton
|
||||
ghost={ghost}
|
||||
href={disabled ? undefined : href}
|
||||
disabled={disabled}
|
||||
type={antdType}
|
||||
|
||||
@@ -52,7 +52,7 @@ export const CheckboxHalfChecked = () => {
|
||||
>
|
||||
<path
|
||||
d="M16 0H2C0.9 0 0 0.9 0 2V16C0 17.1 0.9 18 2 18H16C17.1 18 18 17.1 18 16V2C18 0.9 17.1 0 16 0Z"
|
||||
fill={theme.colorBorder}
|
||||
fill={theme.colors.grayscale.light1}
|
||||
/>
|
||||
<path d="M14 10H4V8H14V10Z" fill="white" />
|
||||
</svg>
|
||||
@@ -71,7 +71,7 @@ export const CheckboxUnchecked = () => {
|
||||
>
|
||||
<path
|
||||
d="M16 0H2C0.9 0 0 0.9 0 2V16C0 17.1 0.9 18 2 18H16C17.1 18 18 17.1 18 16V2C18 0.9 17.1 0 16 0Z"
|
||||
fill={theme.colorBorderSecondary}
|
||||
fill={theme.colors.grayscale.light2}
|
||||
/>
|
||||
<path d="M16 2V16H2V2H16V2Z" fill="white" />
|
||||
</svg>
|
||||
|
||||
@@ -20,7 +20,7 @@ import { useEffect, useState } from 'react';
|
||||
import SyntaxHighlighterBase from 'react-syntax-highlighter/dist/cjs/light';
|
||||
import github from 'react-syntax-highlighter/dist/cjs/styles/hljs/github';
|
||||
import tomorrow from 'react-syntax-highlighter/dist/cjs/styles/hljs/tomorrow-night';
|
||||
import { themeObject } from '@superset-ui/core';
|
||||
import { useTheme, isThemeDark } from '@superset-ui/core';
|
||||
|
||||
export type SupportedLanguage = 'sql' | 'htmlbars' | 'markdown' | 'json';
|
||||
|
||||
@@ -77,6 +77,7 @@ export const CodeSyntaxHighlighter: React.FC<CodeSyntaxHighlighterProps> = ({
|
||||
wrapLines = true,
|
||||
style: overrideStyle,
|
||||
}) => {
|
||||
const theme = useTheme();
|
||||
const [isLanguageReady, setIsLanguageReady] = useState(
|
||||
registeredLanguages.has(language),
|
||||
);
|
||||
@@ -92,14 +93,14 @@ export const CodeSyntaxHighlighter: React.FC<CodeSyntaxHighlighterProps> = ({
|
||||
loadLanguage();
|
||||
}, [language]);
|
||||
|
||||
const isDark = themeObject.isThemeDark();
|
||||
const isDark = isThemeDark(theme);
|
||||
const themeStyle = overrideStyle || (isDark ? tomorrow : github);
|
||||
|
||||
const defaultCustomStyle: React.CSSProperties = {
|
||||
background: themeObject.theme.colorBgElevated,
|
||||
padding: themeObject.theme.sizeUnit * 4,
|
||||
background: theme.colorBgElevated,
|
||||
padding: theme.sizeUnit * 4,
|
||||
border: 0,
|
||||
borderRadius: themeObject.theme.borderRadius,
|
||||
borderRadius: theme.borderRadius,
|
||||
...customStyle,
|
||||
};
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { useTheme } from '@superset-ui/core';
|
||||
import { useTheme, css } from '@superset-ui/core';
|
||||
import { Typography } from '@superset-ui/core/components/Typography';
|
||||
import { Icons } from '@superset-ui/core/components';
|
||||
|
||||
@@ -29,7 +29,7 @@ interface CollapseLabelInModalProps {
|
||||
export const CollapseLabelInModal: React.FC<CollapseLabelInModalProps> = ({
|
||||
title,
|
||||
subtitle,
|
||||
validateCheckStatus = false,
|
||||
validateCheckStatus,
|
||||
testId,
|
||||
}) => {
|
||||
const theme = useTheme();
|
||||
@@ -37,36 +37,38 @@ export const CollapseLabelInModal: React.FC<CollapseLabelInModalProps> = ({
|
||||
return (
|
||||
<div data-test={testId}>
|
||||
<Typography.Title
|
||||
style={{
|
||||
marginTop: 0,
|
||||
marginBottom: theme.sizeUnit / 2,
|
||||
fontSize: theme.fontSizeLG,
|
||||
}}
|
||||
css={css`
|
||||
&& {
|
||||
margin-top: 0;
|
||||
margin-bottom: ${theme.sizeUnit / 2}px;
|
||||
font-size: ${theme.fontSizeLG}px;
|
||||
}
|
||||
`}
|
||||
>
|
||||
{title}{' '}
|
||||
{validateCheckStatus ? (
|
||||
<Icons.CheckCircleOutlined
|
||||
style={{ color: theme.colorSuccess }}
|
||||
aria-label="check-circle"
|
||||
role="img"
|
||||
/>
|
||||
) : (
|
||||
<span
|
||||
style={{
|
||||
color: theme.colorErrorText,
|
||||
fontSize: theme.fontSizeLG,
|
||||
}}
|
||||
>
|
||||
*
|
||||
</span>
|
||||
)}
|
||||
{validateCheckStatus !== undefined &&
|
||||
(validateCheckStatus ? (
|
||||
<Icons.CheckCircleOutlined
|
||||
iconColor={theme.colorSuccess}
|
||||
aria-label="check-circle"
|
||||
/>
|
||||
) : (
|
||||
<span
|
||||
css={css`
|
||||
color: ${theme.colorErrorText};
|
||||
font-size: ${theme.fontSizeLG}px;
|
||||
`}
|
||||
>
|
||||
*
|
||||
</span>
|
||||
))}
|
||||
</Typography.Title>
|
||||
<Typography.Paragraph
|
||||
style={{
|
||||
margin: 0,
|
||||
fontSize: theme.fontSizeSM,
|
||||
color: theme.colorTextDescription,
|
||||
}}
|
||||
css={css`
|
||||
margin: 0;
|
||||
font-size: ${theme.fontSizeSM}px;
|
||||
color: ${theme.colorTextDescription};
|
||||
`}
|
||||
>
|
||||
{subtitle}
|
||||
</Typography.Paragraph>
|
||||
|
||||
@@ -68,6 +68,7 @@ export function ConfirmStatusChange({
|
||||
onConfirm={confirm}
|
||||
onHide={hide}
|
||||
open={open}
|
||||
name="please confirm"
|
||||
title={title}
|
||||
/>
|
||||
</>
|
||||
|
||||
@@ -27,7 +27,7 @@ const StyledDiv = styled.div`
|
||||
padding-top: 8px;
|
||||
width: 50%;
|
||||
label {
|
||||
color: ${({ theme }) => theme.colorText};
|
||||
color: ${({ theme }) => theme.colors.grayscale.base};
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -37,6 +37,7 @@ export function DeleteModal({
|
||||
onHide,
|
||||
open,
|
||||
title,
|
||||
name,
|
||||
}: DeleteModalProps) {
|
||||
const [disableChange, setDisableChange] = useState(true);
|
||||
const [confirmation, setConfirmation] = useState<string>('');
|
||||
@@ -78,6 +79,7 @@ export function DeleteModal({
|
||||
primaryButtonName={t('Delete')}
|
||||
primaryButtonStyle="danger"
|
||||
show={open}
|
||||
name={name}
|
||||
title={title}
|
||||
centered
|
||||
>
|
||||
|
||||
@@ -25,4 +25,5 @@ export interface DeleteModalProps {
|
||||
onHide: () => void;
|
||||
open: boolean;
|
||||
title: ReactNode;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ const MenuDots = styled.div`
|
||||
width: ${({ theme }) => theme.sizeUnit * 0.75}px;
|
||||
height: ${({ theme }) => theme.sizeUnit * 0.75}px;
|
||||
border-radius: 50%;
|
||||
background-color: ${({ theme }) => theme.colorBorder};
|
||||
background-color: ${({ theme }) => theme.colors.grayscale.light1};
|
||||
|
||||
font-weight: ${({ theme }) => theme.fontWeightNormal};
|
||||
display: inline-flex;
|
||||
@@ -53,7 +53,7 @@ const MenuDots = styled.div`
|
||||
width: ${({ theme }) => theme.sizeUnit * 0.75}px;
|
||||
height: ${({ theme }) => theme.sizeUnit * 0.75}px;
|
||||
border-radius: 50%;
|
||||
background-color: ${({ theme }) => theme.colorBorder};
|
||||
background-color: ${({ theme }) => theme.colors.grayscale.light1};
|
||||
}
|
||||
|
||||
&::before {
|
||||
|
||||
@@ -398,13 +398,13 @@ export const DropdownContainer = forwardRef(
|
||||
}
|
||||
::-webkit-scrollbar-thumb {
|
||||
border-radius: 9px;
|
||||
background-color: ${theme.colorBorder};
|
||||
background-color: ${theme.colors.grayscale.light1};
|
||||
border: 3px solid transparent;
|
||||
background-clip: content-box;
|
||||
}
|
||||
::-webkit-scrollbar-track {
|
||||
background-color: ${theme.colorBgContainer};
|
||||
border-left: 1px solid ${theme.colorBorderSecondary};
|
||||
background-color: ${theme.colors.grayscale.light4};
|
||||
border-left: 1px solid ${theme.colors.grayscale.light2};
|
||||
}
|
||||
}
|
||||
`}
|
||||
@@ -436,7 +436,7 @@ export const DropdownContainer = forwardRef(
|
||||
color={
|
||||
(dropdownTriggerCount ?? overflowingCount) > 0
|
||||
? theme.colorPrimary
|
||||
: theme.colorBorder
|
||||
: theme.colors.grayscale.light1
|
||||
}
|
||||
showZero
|
||||
css={css`
|
||||
@@ -445,7 +445,7 @@ export const DropdownContainer = forwardRef(
|
||||
/>
|
||||
<Icons.DownOutlined
|
||||
iconSize="m"
|
||||
iconColor={theme.colorBorder}
|
||||
iconColor={theme.colors.grayscale.light1}
|
||||
css={css`
|
||||
.anticon {
|
||||
display: flex;
|
||||
|
||||
@@ -128,7 +128,7 @@ const ImageContainer = ({
|
||||
<Empty
|
||||
description={false}
|
||||
image={mappedImage}
|
||||
imageStyle={getImageHeight(size)}
|
||||
styles={{ image: getImageHeight(size) }}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { css, useTheme, themeObject } from '../..';
|
||||
import { css, useTheme, getFontSize } from '../..';
|
||||
import { AntdIconType, BaseIconProps, CustomIconType, IconType } from './types';
|
||||
|
||||
const genAriaLabel = (fileName: string) => {
|
||||
@@ -52,7 +52,7 @@ export const BaseIconComponent: React.FC<
|
||||
const style = {
|
||||
color: iconColor,
|
||||
fontSize: iconSize
|
||||
? `${themeObject.getFontSize(iconSize)}px`
|
||||
? `${getFontSize(theme, iconSize)}px`
|
||||
: `${theme.fontSize}px`,
|
||||
cursor: rest?.onClick ? 'pointer' : undefined,
|
||||
};
|
||||
@@ -76,12 +76,12 @@ export const BaseIconComponent: React.FC<
|
||||
style={style}
|
||||
width={
|
||||
iconSize
|
||||
? `${themeObject.getFontSize(iconSize) || theme.fontSize}px`
|
||||
? `${getFontSize(theme, iconSize) || theme.fontSize}px`
|
||||
: `${theme.fontSize}px`
|
||||
}
|
||||
height={
|
||||
iconSize
|
||||
? `${themeObject.getFontSize(iconSize) || theme.fontSize}px`
|
||||
? `${getFontSize(theme, iconSize) || theme.fontSize}px`
|
||||
: `${theme.fontSize}px`
|
||||
}
|
||||
{...(rest as CustomIconType)}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
import { KeyboardEvent, useMemo } from 'react';
|
||||
import { SerializedStyles, CSSObject } from '@emotion/react';
|
||||
import { kebabCase } from 'lodash';
|
||||
import { css, t, useTheme, themeObject } from '@superset-ui/core';
|
||||
import { css, t, useTheme, getFontSize } from '@superset-ui/core';
|
||||
import {
|
||||
CloseCircleOutlined,
|
||||
InfoCircleOutlined,
|
||||
@@ -68,7 +68,7 @@ export const InfoTooltip = ({
|
||||
|
||||
const iconCss = css`
|
||||
color: ${variant?.color ?? theme.colorIcon};
|
||||
font-size: ${themeObject.getFontSize(iconSize)}px;
|
||||
font-size: ${getFontSize(theme, iconSize)}px;
|
||||
`;
|
||||
|
||||
const handleKeyDown = (event: KeyboardEvent<HTMLSpanElement>) => {
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
import { Tag } from '@superset-ui/core/components/Tag';
|
||||
import { css } from '@emotion/react';
|
||||
import { useTheme, themeObject } from '@superset-ui/core';
|
||||
import { useTheme, getColorVariants } from '@superset-ui/core';
|
||||
import { DatasetTypeLabel } from './reusable/DatasetTypeLabel';
|
||||
import { PublishedLabel } from './reusable/PublishedLabel';
|
||||
import type { LabelProps } from './types';
|
||||
@@ -37,7 +37,7 @@ export function Label(props: LabelProps) {
|
||||
...rest
|
||||
} = props;
|
||||
|
||||
const baseColor = themeObject.getColorVariants(type);
|
||||
const baseColor = getColorVariants(theme, type);
|
||||
const color = baseColor.active;
|
||||
const borderColor = baseColor.border;
|
||||
const backgroundColor = baseColor.bg;
|
||||
|
||||
@@ -53,7 +53,7 @@ const StyledCard = styled(Card)`
|
||||
|
||||
const Cover = styled.div`
|
||||
height: 264px;
|
||||
border-bottom: 1px solid ${({ theme }) => theme.colorBorderSecondary};
|
||||
border-bottom: 1px solid ${({ theme }) => theme.colors.grayscale.light2};
|
||||
overflow: hidden;
|
||||
|
||||
.cover-footer {
|
||||
|
||||
@@ -30,7 +30,7 @@ const MetadataWrapper = styled.div`
|
||||
|
||||
const MetadataText = styled.span`
|
||||
font-size: ${({ theme }) => theme.fontSizeXS}px;
|
||||
color: ${({ theme }) => theme.colorBorder};
|
||||
color: ${({ theme }) => theme.colors.grayscale.light1};
|
||||
font-weight: ${({ theme }) => theme.fontWeightStrong};
|
||||
`;
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ export function FormModal({
|
||||
formSubmitHandler,
|
||||
bodyStyle = {},
|
||||
requiredFields = [],
|
||||
name,
|
||||
}: FormModalProps) {
|
||||
const [form] = Form.useForm();
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
@@ -78,6 +79,7 @@ export function FormModal({
|
||||
|
||||
return (
|
||||
<Modal
|
||||
name={name}
|
||||
show={show}
|
||||
title={title}
|
||||
onHide={handleClose}
|
||||
|
||||
@@ -121,8 +121,8 @@ export const StyledModal = styled(BaseModal)<StyledModalProps>`
|
||||
|
||||
.ant-modal-body {
|
||||
flex: 0 1 auto;
|
||||
padding: ${theme.sizeUnit * 4}px;
|
||||
padding-bottom: ${theme.sizeUnit * 2}px;
|
||||
padding: ${theme.sizeUnit * 4}px ${theme.sizeUnit * 6}px;
|
||||
|
||||
overflow: auto;
|
||||
${!resizable && height && `height: ${height};`}
|
||||
}
|
||||
@@ -333,7 +333,7 @@ const CustomModal = ({
|
||||
}
|
||||
footer={!hideFooter ? modalFooter : null}
|
||||
hideFooter={hideFooter}
|
||||
wrapProps={{ 'data-test': `${name || title}-modal`, ...wrapProps }}
|
||||
wrapProps={{ 'data-test': `${name || 'antd'}-modal`, ...wrapProps }}
|
||||
modalRender={modal =>
|
||||
resizable || draggable ? (
|
||||
<Draggable
|
||||
|
||||
@@ -110,6 +110,7 @@ export const ModalTrigger = forwardRef(
|
||||
className={className}
|
||||
show={showModal}
|
||||
onHide={close}
|
||||
name={modalTitle}
|
||||
title={modalTitle}
|
||||
footer={modalFooter}
|
||||
hideFooter={!modalFooter}
|
||||
|
||||
@@ -60,12 +60,12 @@ const menuItemStyles = (theme: any) => css`
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: ${theme.colorFill};
|
||||
background: ${theme.colors.grayscale.light3};
|
||||
}
|
||||
|
||||
&.active {
|
||||
font-weight: ${theme.fontWeightStrong};
|
||||
background: ${theme.colorBorderSecondary};
|
||||
background: ${theme.colors.grayscale.light2};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,14 +66,16 @@ export default function PopoverSection({
|
||||
<Icons.InfoCircleOutlined
|
||||
role="img"
|
||||
iconSize="s"
|
||||
iconColor={theme.colorBorder}
|
||||
iconColor={theme.colors.grayscale.light1}
|
||||
/>
|
||||
</Tooltip>
|
||||
)}
|
||||
<Icons.CheckOutlined
|
||||
iconSize="s"
|
||||
role="img"
|
||||
iconColor={isSelected ? theme.colorPrimary : theme.colorText}
|
||||
iconColor={
|
||||
isSelected ? theme.colorPrimary : theme.colors.grayscale.base
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
|
||||
@@ -45,7 +45,7 @@ const RefreshLabel = ({
|
||||
onClick={disabled ? undefined : onClick}
|
||||
css={(theme: SupersetTheme) => ({
|
||||
cursor: 'pointer',
|
||||
color: theme.colorText,
|
||||
color: theme.colors.grayscale.base,
|
||||
'&:hover': { color: theme.colorPrimary },
|
||||
})}
|
||||
/>
|
||||
|
||||
@@ -103,17 +103,17 @@ export const StyledLoadingText = styled.div`
|
||||
${({ theme }) => `
|
||||
margin-left: ${theme.sizeUnit * 3}px;
|
||||
line-height: ${theme.sizeUnit * 8}px;
|
||||
color: ${theme.colorBorder};
|
||||
color: ${theme.colors.grayscale.light1};
|
||||
`}
|
||||
`;
|
||||
|
||||
export const StyledHelperText = styled.div`
|
||||
${({ theme }) => `
|
||||
padding: ${theme.sizeUnit * 2}px ${theme.sizeUnit * 3}px;
|
||||
color: ${theme.colorText};
|
||||
color: ${theme.colors.grayscale.base};
|
||||
font-size: ${theme.fontSizeSM}px;
|
||||
cursor: default;
|
||||
border-bottom: 1px solid ${theme.colorBorderSecondary};
|
||||
border-bottom: 1px solid ${theme.colors.grayscale.light2};
|
||||
`}
|
||||
`;
|
||||
|
||||
@@ -139,6 +139,6 @@ export const StyledErrorMessage = styled.div`
|
||||
export const StyledBulkActionsContainer = styled(Flex)`
|
||||
${({ theme }) => `
|
||||
padding: ${theme.sizeUnit}px;
|
||||
border-top: 1px solid ${theme.colorFill};
|
||||
border-top: 1px solid ${theme.colors.grayscale.light3};
|
||||
`}
|
||||
`;
|
||||
|
||||
@@ -20,7 +20,7 @@ import { styled } from '../../../..';
|
||||
import { Constants } from '../../..';
|
||||
|
||||
const GrayCell = styled.span`
|
||||
color: ${({ theme }) => theme.colorBorder};
|
||||
color: ${({ theme }) => theme.colors.grayscale.light1};
|
||||
`;
|
||||
|
||||
function NullCell() {
|
||||
|
||||
@@ -74,7 +74,7 @@ function HeaderWithRadioGroup(props: HeaderWithRadioGroupProps) {
|
||||
>
|
||||
<Icons.SettingOutlined
|
||||
iconSize="m"
|
||||
iconColor={theme.colorBorder}
|
||||
iconColor={theme.colors.grayscale.light1}
|
||||
css={css`
|
||||
margin-top: ${theme.sizeUnit * 0.75}px;
|
||||
margin-right: ${theme.sizeUnit}px;
|
||||
|
||||
@@ -83,7 +83,7 @@ const Tabs = Object.assign(StyledTabs, {
|
||||
const StyledEditableTabs = styled(StyledTabs)`
|
||||
${({ theme }) => `
|
||||
.ant-tabs-content-holder {
|
||||
background: ${theme.colorBgContainer};
|
||||
background: ${theme.colors.grayscale.light5};
|
||||
}
|
||||
|
||||
& > .ant-tabs-nav {
|
||||
@@ -99,7 +99,7 @@ const StyledEditableTabs = styled(StyledTabs)`
|
||||
`;
|
||||
|
||||
const StyledCloseOutlined = styled(Icons.CloseOutlined)`
|
||||
color: ${({ theme }) => theme.colorText};
|
||||
color: ${({ theme }) => theme.colors.grayscale.base};
|
||||
`;
|
||||
export const EditableTabs = Object.assign(StyledEditableTabs, {
|
||||
TabPane: StyledTabPane,
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
* under the License.
|
||||
*/
|
||||
import { render } from '@superset-ui/core/spec';
|
||||
import TelemetryPixel from '.';
|
||||
import { TelemetryPixel } from '.';
|
||||
|
||||
const OLD_ENV = process.env;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ interface TelemetryPixelProps {
|
||||
|
||||
const PIXEL_ID = '0d3461e1-abb1-4691-a0aa-5ed50de66af0';
|
||||
|
||||
const TelemetryPixel = ({
|
||||
export const TelemetryPixel = ({
|
||||
version = 'unknownVersion',
|
||||
sha = 'unknownSHA',
|
||||
build = 'unknownBuild',
|
||||
@@ -56,4 +56,3 @@ const TelemetryPixel = ({
|
||||
/>
|
||||
);
|
||||
};
|
||||
export default TelemetryPixel;
|
||||
|
||||
@@ -1,150 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { Modal, Tooltip, Flex, Select } from 'antd';
|
||||
import { Button, JsonEditor } from '@superset-ui/core/components';
|
||||
import {
|
||||
themeObject,
|
||||
exampleThemes,
|
||||
SerializableThemeConfig,
|
||||
Theme,
|
||||
AnyThemeConfig,
|
||||
} from '@superset-ui/core';
|
||||
import { useState } from 'react';
|
||||
import { Icons } from '@superset-ui/core/components/Icons';
|
||||
|
||||
interface ThemeEditorProps {
|
||||
tooltipTitle?: string;
|
||||
modalTitle?: string;
|
||||
theme?: Theme;
|
||||
setTheme?: (config: AnyThemeConfig) => void;
|
||||
}
|
||||
|
||||
const ThemeEditor: React.FC<ThemeEditorProps> = ({
|
||||
tooltipTitle = 'Edit Theme',
|
||||
modalTitle = 'Theme Editor',
|
||||
theme,
|
||||
setTheme,
|
||||
}) => {
|
||||
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
|
||||
const jsonTheme =
|
||||
JSON.stringify(theme?.toSerializedConfig(), null, 2) || '{}';
|
||||
const [jsonMetadata, setJsonMetadata] = useState<string>(jsonTheme);
|
||||
const [selectedTheme, setSelectedTheme] = useState<string | null>(null);
|
||||
|
||||
// Get theme names for the Select options
|
||||
const themeOptions: { value: string; label: string }[] = Object.keys(
|
||||
exampleThemes,
|
||||
).map(key => ({
|
||||
value: key,
|
||||
label: key,
|
||||
}));
|
||||
|
||||
const handleOpenModal = (): void => {
|
||||
setIsModalOpen(true);
|
||||
setJsonMetadata(JSON.stringify(theme?.toSerializedConfig(), null, 2));
|
||||
};
|
||||
|
||||
const handleCancel = (): void => {
|
||||
setIsModalOpen(false);
|
||||
};
|
||||
|
||||
const handleSave = (): void => {
|
||||
try {
|
||||
const parsedTheme = JSON.parse(jsonMetadata);
|
||||
setTheme?.(parsedTheme);
|
||||
setIsModalOpen(false);
|
||||
} catch (error) {
|
||||
console.error('Invalid JSON in theme editor:', error);
|
||||
alert('Error parsing JSON. Please check your input.');
|
||||
}
|
||||
};
|
||||
|
||||
const handleThemeChange = (value: string): void => {
|
||||
setSelectedTheme(value);
|
||||
// When a theme is selected, update the JSON editor with the theme definition
|
||||
const themeData = exampleThemes[value] || ({} as SerializableThemeConfig);
|
||||
setJsonMetadata(JSON.stringify(themeData, null, 2));
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tooltip title={tooltipTitle} placement="bottom">
|
||||
<Button
|
||||
buttonStyle="link"
|
||||
icon={
|
||||
<Icons.BgColorsOutlined
|
||||
iconSize="l"
|
||||
iconColor={themeObject.theme.colorPrimary}
|
||||
/>
|
||||
}
|
||||
onClick={handleOpenModal}
|
||||
aria-label="Edit theme"
|
||||
size="large"
|
||||
/>
|
||||
</Tooltip>
|
||||
<Modal
|
||||
title={modalTitle}
|
||||
open={isModalOpen}
|
||||
onCancel={handleCancel}
|
||||
width={800}
|
||||
centered
|
||||
styles={{
|
||||
body: {
|
||||
padding: '24px',
|
||||
},
|
||||
}}
|
||||
footer={
|
||||
<Flex justify="end" gap="small">
|
||||
<Button onClick={handleCancel} buttonStyle="secondary">
|
||||
Cancel
|
||||
</Button>
|
||||
<Button type="primary" onClick={handleSave}>
|
||||
Apply Theme
|
||||
</Button>
|
||||
</Flex>
|
||||
}
|
||||
>
|
||||
<Flex vertical gap="middle">
|
||||
<div>
|
||||
Select a theme template:
|
||||
<Select
|
||||
placeholder="Choose a theme"
|
||||
style={{ width: '100%', marginTop: '8px' }}
|
||||
options={themeOptions}
|
||||
onChange={handleThemeChange}
|
||||
value={selectedTheme}
|
||||
/>
|
||||
</div>
|
||||
<JsonEditor
|
||||
showLoadingForImport
|
||||
name="json_metadata"
|
||||
value={jsonMetadata}
|
||||
onChange={setJsonMetadata}
|
||||
tabSize={2}
|
||||
width="100%"
|
||||
height="200px"
|
||||
wrapEnabled
|
||||
/>
|
||||
</Flex>
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default ThemeEditor;
|
||||
@@ -1,79 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { Tooltip } from 'antd';
|
||||
import { Dropdown, Icons } from '@superset-ui/core/components';
|
||||
import { t } from '@superset-ui/core';
|
||||
import { ThemeAlgorithm, ThemeMode } from '../../theme/types';
|
||||
|
||||
export interface ThemeSelectProps {
|
||||
setThemeMode: (newMode: ThemeMode) => void;
|
||||
tooltipTitle?: string;
|
||||
themeMode: ThemeMode;
|
||||
}
|
||||
|
||||
const ThemeSelect: React.FC<ThemeSelectProps> = ({
|
||||
setThemeMode,
|
||||
tooltipTitle = 'Select theme',
|
||||
themeMode,
|
||||
}) => {
|
||||
const handleSelect = (mode: ThemeMode) => {
|
||||
setThemeMode(mode);
|
||||
};
|
||||
|
||||
const themeIconMap: Record<ThemeAlgorithm | ThemeMode, React.ReactNode> = {
|
||||
[ThemeAlgorithm.DEFAULT]: <Icons.SunOutlined />,
|
||||
[ThemeAlgorithm.DARK]: <Icons.MoonOutlined />,
|
||||
[ThemeMode.SYSTEM]: <Icons.FormatPainterOutlined />,
|
||||
[ThemeAlgorithm.COMPACT]: <Icons.CompressOutlined />,
|
||||
};
|
||||
|
||||
return (
|
||||
<Tooltip title={tooltipTitle} placement="bottom">
|
||||
<Dropdown
|
||||
menu={{
|
||||
items: [
|
||||
{
|
||||
key: ThemeMode.DEFAULT,
|
||||
label: t('Light'),
|
||||
onClick: () => handleSelect(ThemeMode.DEFAULT),
|
||||
icon: <Icons.SunOutlined />,
|
||||
},
|
||||
{
|
||||
key: ThemeMode.DARK,
|
||||
label: t('Dark'),
|
||||
onClick: () => handleSelect(ThemeMode.DARK),
|
||||
icon: <Icons.MoonOutlined />,
|
||||
},
|
||||
{
|
||||
key: ThemeMode.SYSTEM,
|
||||
label: t('Match system'),
|
||||
onClick: () => handleSelect(ThemeMode.SYSTEM),
|
||||
icon: <Icons.FormatPainterOutlined />,
|
||||
},
|
||||
],
|
||||
}}
|
||||
trigger={['click']}
|
||||
>
|
||||
{themeIconMap[themeMode] || <Icons.FormatPainterOutlined />}
|
||||
</Dropdown>
|
||||
</Tooltip>
|
||||
);
|
||||
};
|
||||
|
||||
export default ThemeSelect;
|
||||
@@ -0,0 +1,273 @@
|
||||
/**
|
||||
* 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,
|
||||
screen,
|
||||
userEvent,
|
||||
waitFor,
|
||||
within,
|
||||
} from '@superset-ui/core/spec';
|
||||
import { ThemeMode } from '@superset-ui/core';
|
||||
import { Menu } from '@superset-ui/core/components';
|
||||
import { ThemeSubMenu } from '.';
|
||||
|
||||
// Mock the translation function
|
||||
jest.mock('@superset-ui/core', () => ({
|
||||
...jest.requireActual('@superset-ui/core'),
|
||||
t: (key: string) => key,
|
||||
}));
|
||||
|
||||
describe('ThemeSubMenu', () => {
|
||||
const defaultProps = {
|
||||
allowOSPreference: true,
|
||||
setThemeMode: jest.fn(),
|
||||
themeMode: ThemeMode.DEFAULT,
|
||||
hasLocalOverride: false,
|
||||
onClearLocalSettings: jest.fn(),
|
||||
};
|
||||
|
||||
const renderThemeSubMenu = (props = defaultProps) =>
|
||||
render(
|
||||
<Menu>
|
||||
<ThemeSubMenu {...props} />
|
||||
</Menu>,
|
||||
);
|
||||
|
||||
const findMenuWithText = async (text: string) => {
|
||||
await waitFor(() => {
|
||||
const found = screen
|
||||
.getAllByRole('menu')
|
||||
.some(m => within(m).queryByText(text));
|
||||
|
||||
if (!found) throw new Error(`Menu with text "${text}" not yet rendered`);
|
||||
});
|
||||
|
||||
return screen.getAllByRole('menu').find(m => within(m).queryByText(text))!;
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it('renders Light and Dark theme options by default', async () => {
|
||||
renderThemeSubMenu();
|
||||
|
||||
userEvent.hover(await screen.findByRole('menuitem'));
|
||||
const menu = await findMenuWithText('Light');
|
||||
|
||||
expect(within(menu!).getByText('Light')).toBeInTheDocument();
|
||||
expect(within(menu!).getByText('Dark')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('does not render Match system option when allowOSPreference is false', async () => {
|
||||
renderThemeSubMenu({ ...defaultProps, allowOSPreference: false });
|
||||
userEvent.hover(await screen.findByRole('menuitem'));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.queryByText('Match system')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it('renders with allowOSPreference as true by default', async () => {
|
||||
renderThemeSubMenu();
|
||||
|
||||
userEvent.hover(await screen.findByRole('menuitem'));
|
||||
const menu = await findMenuWithText('Match system');
|
||||
|
||||
expect(within(menu).getByText('Match system')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders clear option when both hasLocalOverride and onClearLocalSettings are provided', async () => {
|
||||
const mockClear = jest.fn();
|
||||
renderThemeSubMenu({
|
||||
...defaultProps,
|
||||
hasLocalOverride: true,
|
||||
onClearLocalSettings: mockClear,
|
||||
});
|
||||
|
||||
userEvent.hover(await screen.findByRole('menuitem'));
|
||||
const menu = await findMenuWithText('Clear local theme');
|
||||
|
||||
expect(within(menu).getByText('Clear local theme')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('does not render clear option when hasLocalOverride is false', async () => {
|
||||
const mockClear = jest.fn();
|
||||
renderThemeSubMenu({
|
||||
...defaultProps,
|
||||
hasLocalOverride: false,
|
||||
onClearLocalSettings: mockClear,
|
||||
});
|
||||
|
||||
userEvent.hover(await screen.findByRole('menuitem'));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.queryByText('Clear local theme')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it('calls setThemeMode with DEFAULT when Light is clicked', async () => {
|
||||
const mockSet = jest.fn();
|
||||
renderThemeSubMenu({ ...defaultProps, setThemeMode: mockSet });
|
||||
|
||||
userEvent.hover(await screen.findByRole('menuitem'));
|
||||
const menu = await findMenuWithText('Light');
|
||||
userEvent.click(within(menu).getByText('Light'));
|
||||
|
||||
expect(mockSet).toHaveBeenCalledWith(ThemeMode.DEFAULT);
|
||||
});
|
||||
|
||||
it('calls setThemeMode with DARK when Dark is clicked', async () => {
|
||||
const mockSet = jest.fn();
|
||||
renderThemeSubMenu({ ...defaultProps, setThemeMode: mockSet });
|
||||
|
||||
userEvent.hover(await screen.findByRole('menuitem'));
|
||||
const menu = await findMenuWithText('Dark');
|
||||
userEvent.click(within(menu).getByText('Dark'));
|
||||
|
||||
expect(mockSet).toHaveBeenCalledWith(ThemeMode.DARK);
|
||||
});
|
||||
|
||||
it('calls setThemeMode with SYSTEM when Match system is clicked', async () => {
|
||||
const mockSet = jest.fn();
|
||||
renderThemeSubMenu({ ...defaultProps, setThemeMode: mockSet });
|
||||
|
||||
userEvent.hover(await screen.findByRole('menuitem'));
|
||||
const menu = await findMenuWithText('Match system');
|
||||
userEvent.click(within(menu).getByText('Match system'));
|
||||
|
||||
expect(mockSet).toHaveBeenCalledWith(ThemeMode.SYSTEM);
|
||||
});
|
||||
|
||||
it('calls onClearLocalSettings when Clear local theme is clicked', async () => {
|
||||
const mockClear = jest.fn();
|
||||
renderThemeSubMenu({
|
||||
...defaultProps,
|
||||
hasLocalOverride: true,
|
||||
onClearLocalSettings: mockClear,
|
||||
});
|
||||
|
||||
userEvent.hover(await screen.findByRole('menuitem'));
|
||||
const menu = await findMenuWithText('Clear local theme');
|
||||
userEvent.click(within(menu).getByText('Clear local theme'));
|
||||
|
||||
expect(mockClear).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('displays sun icon for DEFAULT theme', () => {
|
||||
renderThemeSubMenu({ ...defaultProps, themeMode: ThemeMode.DEFAULT });
|
||||
expect(screen.getByTestId('sun')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('displays moon icon for DARK theme', () => {
|
||||
renderThemeSubMenu({ ...defaultProps, themeMode: ThemeMode.DARK });
|
||||
expect(screen.getByTestId('moon')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('displays format-painter icon for SYSTEM theme', () => {
|
||||
renderThemeSubMenu({ ...defaultProps, themeMode: ThemeMode.SYSTEM });
|
||||
expect(screen.getByTestId('format-painter')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('displays override icon when hasLocalOverride is true', () => {
|
||||
renderThemeSubMenu({ ...defaultProps, hasLocalOverride: true });
|
||||
expect(screen.getByTestId('format-painter')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders Theme group header', async () => {
|
||||
renderThemeSubMenu();
|
||||
|
||||
userEvent.hover(await screen.findByRole('menuitem'));
|
||||
const menu = await findMenuWithText('Theme');
|
||||
|
||||
expect(within(menu).getByText('Theme')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders sun icon for Light theme option', async () => {
|
||||
renderThemeSubMenu();
|
||||
|
||||
userEvent.hover(await screen.findByRole('menuitem'));
|
||||
const menu = await findMenuWithText('Light');
|
||||
const lightOption = within(menu).getByText('Light').closest('li');
|
||||
|
||||
expect(within(lightOption!).getByTestId('sun')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders moon icon for Dark theme option', async () => {
|
||||
renderThemeSubMenu();
|
||||
|
||||
userEvent.hover(await screen.findByRole('menuitem'));
|
||||
const menu = await findMenuWithText('Dark');
|
||||
const darkOption = within(menu).getByText('Dark').closest('li');
|
||||
|
||||
expect(within(darkOption!).getByTestId('moon')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders format-painter icon for Match system option', async () => {
|
||||
renderThemeSubMenu({ ...defaultProps, allowOSPreference: true });
|
||||
|
||||
userEvent.hover(await screen.findByRole('menuitem'));
|
||||
const menu = await findMenuWithText('Match system');
|
||||
const matchOption = within(menu).getByText('Match system').closest('li');
|
||||
|
||||
expect(
|
||||
within(matchOption!).getByTestId('format-painter'),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders clear icon for Clear local theme option', async () => {
|
||||
renderThemeSubMenu({
|
||||
...defaultProps,
|
||||
hasLocalOverride: true,
|
||||
onClearLocalSettings: jest.fn(),
|
||||
});
|
||||
|
||||
userEvent.hover(await screen.findByRole('menuitem'));
|
||||
const menu = await findMenuWithText('Clear local theme');
|
||||
const clearOption = within(menu)
|
||||
.getByText('Clear local theme')
|
||||
.closest('li');
|
||||
|
||||
expect(within(clearOption!).getByTestId('clear')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders divider before clear option when clear option is present', async () => {
|
||||
renderThemeSubMenu({
|
||||
...defaultProps,
|
||||
hasLocalOverride: true,
|
||||
onClearLocalSettings: jest.fn(),
|
||||
});
|
||||
|
||||
userEvent.hover(await screen.findByRole('menuitem'));
|
||||
|
||||
const menu = await findMenuWithText('Clear local theme');
|
||||
const divider = within(menu).queryByRole('separator');
|
||||
|
||||
expect(divider).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('does not render divider when clear option is not present', async () => {
|
||||
renderThemeSubMenu({ ...defaultProps });
|
||||
|
||||
userEvent.hover(await screen.findByRole('menuitem'));
|
||||
const divider = document.querySelector('.ant-menu-item-divider');
|
||||
|
||||
expect(divider).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,170 @@
|
||||
/**
|
||||
* 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 { useMemo } from 'react';
|
||||
import { Icons, Menu } from '@superset-ui/core/components';
|
||||
import {
|
||||
css,
|
||||
styled,
|
||||
t,
|
||||
ThemeMode,
|
||||
useTheme,
|
||||
ThemeAlgorithm,
|
||||
} from '@superset-ui/core';
|
||||
|
||||
const StyledThemeSubMenu = styled(Menu.SubMenu)`
|
||||
${({ theme }) => css`
|
||||
[data-icon='caret-down'] {
|
||||
color: ${theme.colorIcon};
|
||||
font-size: ${theme.fontSizeXS}px;
|
||||
margin-left: ${theme.sizeUnit}px;
|
||||
}
|
||||
&.ant-menu-submenu-active {
|
||||
.ant-menu-title-content {
|
||||
color: ${theme.colorPrimary};
|
||||
}
|
||||
}
|
||||
`}
|
||||
`;
|
||||
|
||||
const StyledThemeSubMenuItem = styled(Menu.Item)<{ selected: boolean }>`
|
||||
${({ theme, selected }) => css`
|
||||
&:hover {
|
||||
color: ${theme.colorPrimary} !important;
|
||||
cursor: pointer !important;
|
||||
}
|
||||
${selected &&
|
||||
css`
|
||||
background-color: ${theme.colors.primary.light4} !important;
|
||||
color: ${theme.colors.primary.dark1} !important;
|
||||
`}
|
||||
`}
|
||||
`;
|
||||
|
||||
export interface ThemeSubMenuOption {
|
||||
key: ThemeMode;
|
||||
label: string;
|
||||
icon: React.ReactNode;
|
||||
onClick: () => void;
|
||||
}
|
||||
|
||||
export interface ThemeSubMenuProps {
|
||||
setThemeMode: (newMode: ThemeMode) => void;
|
||||
themeMode: ThemeMode;
|
||||
hasLocalOverride?: boolean;
|
||||
onClearLocalSettings?: () => void;
|
||||
allowOSPreference?: boolean;
|
||||
}
|
||||
|
||||
export const ThemeSubMenu: React.FC<ThemeSubMenuProps> = ({
|
||||
setThemeMode,
|
||||
themeMode,
|
||||
hasLocalOverride = false,
|
||||
onClearLocalSettings,
|
||||
allowOSPreference = true,
|
||||
}: ThemeSubMenuProps) => {
|
||||
const theme = useTheme();
|
||||
|
||||
const handleSelect = (mode: ThemeMode) => {
|
||||
setThemeMode(mode);
|
||||
};
|
||||
|
||||
const themeIconMap: Record<ThemeAlgorithm | ThemeMode, React.ReactNode> =
|
||||
useMemo(
|
||||
() => ({
|
||||
[ThemeAlgorithm.DEFAULT]: <Icons.SunOutlined />,
|
||||
[ThemeAlgorithm.DARK]: <Icons.MoonOutlined />,
|
||||
[ThemeMode.SYSTEM]: <Icons.FormatPainterOutlined />,
|
||||
[ThemeAlgorithm.COMPACT]: <Icons.CompressOutlined />,
|
||||
}),
|
||||
[],
|
||||
);
|
||||
|
||||
const selectedThemeModeIcon = useMemo(
|
||||
() =>
|
||||
hasLocalOverride ? (
|
||||
<Icons.FormatPainterOutlined
|
||||
style={{ color: theme.colors.error.base }}
|
||||
/>
|
||||
) : (
|
||||
themeIconMap[themeMode]
|
||||
),
|
||||
[hasLocalOverride, theme.colors.error.base, themeIconMap, themeMode],
|
||||
);
|
||||
|
||||
const themeOptions: ThemeSubMenuOption[] = [
|
||||
{
|
||||
key: ThemeMode.DEFAULT,
|
||||
label: t('Light'),
|
||||
icon: <Icons.SunOutlined />,
|
||||
onClick: () => handleSelect(ThemeMode.DEFAULT),
|
||||
},
|
||||
{
|
||||
key: ThemeMode.DARK,
|
||||
label: t('Dark'),
|
||||
icon: <Icons.MoonOutlined />,
|
||||
onClick: () => handleSelect(ThemeMode.DARK),
|
||||
},
|
||||
...(allowOSPreference
|
||||
? [
|
||||
{
|
||||
key: ThemeMode.SYSTEM,
|
||||
label: t('Match system'),
|
||||
icon: <Icons.FormatPainterOutlined />,
|
||||
onClick: () => handleSelect(ThemeMode.SYSTEM),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
];
|
||||
|
||||
// Add clear settings option only when there's a local theme active
|
||||
const clearOption =
|
||||
onClearLocalSettings && hasLocalOverride
|
||||
? {
|
||||
key: 'clear-local',
|
||||
label: t('Clear local theme'),
|
||||
icon: <Icons.ClearOutlined />,
|
||||
onClick: onClearLocalSettings,
|
||||
}
|
||||
: null;
|
||||
|
||||
return (
|
||||
<StyledThemeSubMenu
|
||||
key="theme-sub-menu"
|
||||
title={selectedThemeModeIcon}
|
||||
icon={<Icons.CaretDownOutlined iconSize="xs" />}
|
||||
>
|
||||
<Menu.ItemGroup title={t('Theme')} />
|
||||
{themeOptions.map(option => (
|
||||
<StyledThemeSubMenuItem
|
||||
key={option.key}
|
||||
onClick={option.onClick}
|
||||
selected={option.key === themeMode}
|
||||
>
|
||||
{option.icon} {option.label}
|
||||
</StyledThemeSubMenuItem>
|
||||
))}
|
||||
{clearOption && [
|
||||
<Menu.Divider key="theme-divider" />,
|
||||
<Menu.Item key={clearOption.key} onClick={clearOption.onClick}>
|
||||
{clearOption.icon} {clearOption.label}
|
||||
</Menu.Item>,
|
||||
]}
|
||||
</StyledThemeSubMenu>
|
||||
);
|
||||
};
|
||||
@@ -79,7 +79,7 @@ const StyledVisibleItem = styled.span`
|
||||
|
||||
const StyledTooltipItem = styled.div`
|
||||
.link {
|
||||
color: ${({ theme }) => theme.colorBgContainer};
|
||||
color: ${({ theme }) => theme.colors.grayscale.light5};
|
||||
display: block;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
import { styled, css } from '@superset-ui/core';
|
||||
import { Typography as AntdTypography } from 'antd';
|
||||
|
||||
export type { TitleProps } from 'antd/es/typography/Title';
|
||||
export type { ParagraphProps } from 'antd/es/typography/Paragraph';
|
||||
|
||||
const StyledLink = styled(AntdTypography.Link)`
|
||||
|
||||
@@ -16,52 +16,16 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { t, styled, css } from '@superset-ui/core';
|
||||
import { Icons, Modal, Typography } from '@superset-ui/core/components';
|
||||
import { Button } from '@superset-ui/core/components/Button';
|
||||
import { t, css, useTheme } from '@superset-ui/core';
|
||||
import {
|
||||
Icons,
|
||||
Modal,
|
||||
Typography,
|
||||
Button,
|
||||
Flex,
|
||||
} from '@superset-ui/core/components';
|
||||
import type { FC, ReactElement } from 'react';
|
||||
|
||||
const StyledModalTitle = styled(Typography.Title)`
|
||||
&& {
|
||||
font-weight: 600;
|
||||
margin: 0;
|
||||
}
|
||||
`;
|
||||
|
||||
const StyledModalBody = styled(Typography.Text)`
|
||||
${({ theme }) => css`
|
||||
padding: 0 ${theme.sizeUnit * 2}px;
|
||||
|
||||
&& {
|
||||
margin: 0;
|
||||
}
|
||||
`}
|
||||
`;
|
||||
|
||||
const StyledDiscardBtn = styled(Button)`
|
||||
${({ theme }) => css`
|
||||
min-width: ${theme.sizeUnit * 22}px;
|
||||
height: ${theme.sizeUnit * 8}px;
|
||||
`}
|
||||
`;
|
||||
|
||||
const StyledSaveBtn = styled(Button)`
|
||||
${({ theme }) => css`
|
||||
min-width: ${theme.sizeUnit * 17}px;
|
||||
height: ${theme.sizeUnit * 8}px;
|
||||
span > :first-of-type {
|
||||
margin-right: 0;
|
||||
}
|
||||
`}
|
||||
`;
|
||||
|
||||
const StyledWarningIcon = styled(Icons.WarningOutlined)`
|
||||
${({ theme }) => css`
|
||||
color: ${theme.colorWarning};
|
||||
margin-right: ${theme.sizeUnit * 4}px;
|
||||
`}
|
||||
`;
|
||||
|
||||
export type UnsavedChangesModalProps = {
|
||||
showModal: boolean;
|
||||
onHide: () => void;
|
||||
@@ -78,52 +42,66 @@ export const UnsavedChangesModal: FC<UnsavedChangesModalProps> = ({
|
||||
onConfirmNavigation,
|
||||
title = 'Unsaved Changes',
|
||||
body = "If you don't save, changes will be lost.",
|
||||
}: UnsavedChangesModalProps): ReactElement => (
|
||||
<Modal
|
||||
centered
|
||||
responsive
|
||||
onHide={onHide}
|
||||
show={showModal}
|
||||
width="444px"
|
||||
title={
|
||||
<div
|
||||
css={css`
|
||||
align-items: center;
|
||||
display: flex;
|
||||
`}
|
||||
>
|
||||
<StyledWarningIcon iconSize="xl" />
|
||||
<StyledModalTitle type="secondary" level={5}>
|
||||
{title}
|
||||
</StyledModalTitle>
|
||||
</div>
|
||||
}
|
||||
footer={
|
||||
<div
|
||||
css={css`
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
width: 100%;
|
||||
`}
|
||||
>
|
||||
<StyledDiscardBtn
|
||||
htmlType="button"
|
||||
buttonSize="small"
|
||||
onClick={onConfirmNavigation}
|
||||
}): ReactElement => {
|
||||
const theme = useTheme();
|
||||
|
||||
return (
|
||||
<Modal
|
||||
name={title}
|
||||
centered
|
||||
responsive
|
||||
onHide={onHide}
|
||||
show={showModal}
|
||||
width="444px"
|
||||
title={
|
||||
<Flex>
|
||||
<Icons.WarningOutlined
|
||||
iconColor={theme.colorWarning}
|
||||
css={css`
|
||||
margin-right: ${theme.sizeUnit * 2}px;
|
||||
`}
|
||||
iconSize="l"
|
||||
/>
|
||||
<Typography.Title
|
||||
css={css`
|
||||
&& {
|
||||
margin: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
`}
|
||||
level={5}
|
||||
>
|
||||
{title}
|
||||
</Typography.Title>
|
||||
</Flex>
|
||||
}
|
||||
footer={
|
||||
<Flex
|
||||
justify="flex-end"
|
||||
css={css`
|
||||
width: 100%;
|
||||
`}
|
||||
>
|
||||
{t('Discard')}
|
||||
</StyledDiscardBtn>
|
||||
<StyledSaveBtn
|
||||
htmlType="button"
|
||||
buttonSize="small"
|
||||
buttonStyle="primary"
|
||||
onClick={handleSave}
|
||||
>
|
||||
{t('Save')}
|
||||
</StyledSaveBtn>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<StyledModalBody type="secondary">{body}</StyledModalBody>
|
||||
</Modal>
|
||||
);
|
||||
<Button
|
||||
htmlType="button"
|
||||
buttonSize="small"
|
||||
buttonStyle="secondary"
|
||||
onClick={onConfirmNavigation}
|
||||
>
|
||||
{t('Discard')}
|
||||
</Button>
|
||||
<Button
|
||||
htmlType="button"
|
||||
buttonSize="small"
|
||||
buttonStyle="primary"
|
||||
onClick={handleSave}
|
||||
>
|
||||
{t('Save')}
|
||||
</Button>
|
||||
</Flex>
|
||||
}
|
||||
>
|
||||
<Typography.Text>{body}</Typography.Text>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -148,6 +148,7 @@ export {
|
||||
Typography,
|
||||
type TypographyProps,
|
||||
type ParagraphProps,
|
||||
type TitleProps,
|
||||
} from './Typography';
|
||||
|
||||
export { Image, type ImageProps } from './Image';
|
||||
@@ -163,6 +164,8 @@ export * from './Steps';
|
||||
export * from './Table';
|
||||
export * from './TableView';
|
||||
export * from './Tag';
|
||||
export * from './TelemetryPixel';
|
||||
export * from './ThemeSubMenu';
|
||||
export * from './UnsavedChangesModal';
|
||||
export * from './constants';
|
||||
export * from './Result';
|
||||
|
||||
@@ -32,7 +32,7 @@ export const CACHE_KEY = '@SUPERSET-UI/CONNECTION';
|
||||
export const DEFAULT_FETCH_RETRY_OPTIONS: FetchRetryOptions = {
|
||||
retries: 3,
|
||||
retryDelay: 1000,
|
||||
retryOn: [503],
|
||||
retryOn: [502, 503, 504],
|
||||
};
|
||||
|
||||
export const COMMON_ERR_MESSAGES = {
|
||||
|
||||
@@ -63,6 +63,7 @@ export default function buildQueryObject<T extends QueryFormData>(
|
||||
series_columns,
|
||||
series_limit,
|
||||
series_limit_metric,
|
||||
group_others_when_limit_reached,
|
||||
...residualFormData
|
||||
} = formData;
|
||||
const {
|
||||
@@ -128,6 +129,7 @@ export default function buildQueryObject<T extends QueryFormData>(
|
||||
normalizeSeriesLimitMetric(series_limit_metric) ??
|
||||
timeseries_limit_metric ??
|
||||
undefined,
|
||||
group_others_when_limit_reached: group_others_when_limit_reached ?? false,
|
||||
order_desc: typeof order_desc === 'undefined' ? true : order_desc,
|
||||
url_params: url_params || undefined,
|
||||
custom_params,
|
||||
|
||||
@@ -32,7 +32,7 @@ export const GlobalStyles = () => {
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: ${theme.colorBgContainer};
|
||||
background-color: ${theme.colorBgBase};
|
||||
color: ${theme.colorText};
|
||||
-webkit-font-smoothing: antialiased;
|
||||
margin: 0;
|
||||
|
||||
@@ -189,24 +189,6 @@ describe('Theme', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('getFontSize', () => {
|
||||
it('returns correct font size for given key', () => {
|
||||
const theme = Theme.fromConfig();
|
||||
|
||||
// Test different font size keys
|
||||
expect(theme.getFontSize('xs')).toBe('8');
|
||||
expect(theme.getFontSize('m')).toBeTruthy();
|
||||
expect(theme.getFontSize('xxl')).toBe('28');
|
||||
});
|
||||
|
||||
it('defaults to medium font size when no key is provided', () => {
|
||||
const theme = Theme.fromConfig();
|
||||
const mediumSize = theme.getFontSize('m');
|
||||
|
||||
expect(theme.getFontSize()).toBe(mediumSize);
|
||||
});
|
||||
});
|
||||
|
||||
describe('toSerializedConfig', () => {
|
||||
it('serializes theme config correctly', () => {
|
||||
const theme = Theme.fromConfig({
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
import React from 'react';
|
||||
import { theme as antdThemeImport, ConfigProvider } from 'antd';
|
||||
import tinycolor from 'tinycolor2';
|
||||
|
||||
// @fontsource/* v5.1+ doesn't play nice with eslint-import plugin v2.31+
|
||||
/* eslint-disable import/extensions */
|
||||
@@ -44,6 +43,7 @@ import {
|
||||
} from '@emotion/react';
|
||||
import createCache from '@emotion/cache';
|
||||
import { noop } from 'lodash';
|
||||
import { isThemeDark } from './utils/themeUtils';
|
||||
import { GlobalStyles } from './GlobalStyles';
|
||||
|
||||
import {
|
||||
@@ -53,9 +53,7 @@ import {
|
||||
SupersetTheme,
|
||||
allowedAntdTokens,
|
||||
SharedAntdTokens,
|
||||
ColorVariants,
|
||||
DeprecatedThemeColors,
|
||||
FontSizeKey,
|
||||
} from './types';
|
||||
|
||||
import {
|
||||
@@ -102,15 +100,6 @@ export class Theme {
|
||||
|
||||
private antdConfig: AntdThemeConfig;
|
||||
|
||||
private static readonly sizeMap: Record<FontSizeKey, string> = {
|
||||
xs: 'fontSizeXS',
|
||||
s: 'fontSizeSM',
|
||||
m: 'fontSize',
|
||||
l: 'fontSizeLG',
|
||||
xl: 'fontSizeXL',
|
||||
xxl: 'fontSizeXXL',
|
||||
};
|
||||
|
||||
private constructor({ config }: { config?: AnyThemeConfig }) {
|
||||
this.SupersetThemeProvider = this.SupersetThemeProvider.bind(this);
|
||||
|
||||
@@ -183,7 +172,7 @@ export class Theme {
|
||||
// Second phase: Now that theme is initialized, we can determine if it's dark
|
||||
// and generate the legacy colors correctly
|
||||
const systemColors = getSystemColors(tokens);
|
||||
const isDark = this.isThemeDark(); // Now we can safely call this
|
||||
const isDark = isThemeDark(this.theme); // Use utility function with theme
|
||||
this.theme.colors = getDeprecatedColors(systemColors, isDark);
|
||||
|
||||
// Update the providers with the fully formed theme
|
||||
@@ -201,22 +190,6 @@ export class Theme {
|
||||
return serializeThemeConfig(this.antdConfig);
|
||||
}
|
||||
|
||||
private getToken(token: string): any {
|
||||
return (this.theme as Record<string, any>)[token];
|
||||
}
|
||||
|
||||
public getFontSize(size?: FontSizeKey): string {
|
||||
const fontSizeKey = Theme.sizeMap[size || 'm'];
|
||||
return this.getToken(fontSizeKey) || this.getToken('fontSize');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current theme is dark based on background color
|
||||
*/
|
||||
isThemeDark(): boolean {
|
||||
return tinycolor(this.theme.colorBgContainer).isDark();
|
||||
}
|
||||
|
||||
toggleDarkMode(isDark: boolean): void {
|
||||
// Create a new config based on the current one
|
||||
const newConfig = { ...this.antdConfig };
|
||||
@@ -250,45 +223,6 @@ export class Theme {
|
||||
return JSON.stringify(serializeThemeConfig(this.antdConfig), null, 2);
|
||||
}
|
||||
|
||||
getColorVariants(color: string): ColorVariants {
|
||||
const firstLetterCapped = color.charAt(0).toUpperCase() + color.slice(1);
|
||||
if (color === 'default' || color === 'grayscale') {
|
||||
const isDark = this.isThemeDark();
|
||||
|
||||
const flipBrightness = (baseColor: string): string => {
|
||||
if (!isDark) return baseColor;
|
||||
const { r, g, b } = tinycolor(baseColor).toRgb();
|
||||
const invertedColor = tinycolor({ r: 255 - r, g: 255 - g, b: 255 - b });
|
||||
return invertedColor.toHexString();
|
||||
};
|
||||
|
||||
return {
|
||||
active: flipBrightness('#222'),
|
||||
textActive: flipBrightness('#444'),
|
||||
text: flipBrightness('#555'),
|
||||
textHover: flipBrightness('#666'),
|
||||
hover: flipBrightness('#888'),
|
||||
borderHover: flipBrightness('#AAA'),
|
||||
border: flipBrightness('#CCC'),
|
||||
bgHover: flipBrightness('#DDD'),
|
||||
bg: flipBrightness('#F4F4F4'),
|
||||
};
|
||||
}
|
||||
|
||||
const theme = this.getToken.bind(this);
|
||||
return {
|
||||
active: theme(`color${firstLetterCapped}Active`),
|
||||
textActive: theme(`color${firstLetterCapped}TextActive`),
|
||||
text: theme(`color${firstLetterCapped}Text`),
|
||||
textHover: theme(`color${firstLetterCapped}TextHover`),
|
||||
hover: theme(`color${firstLetterCapped}Hover`),
|
||||
borderHover: theme(`color${firstLetterCapped}BorderHover`),
|
||||
border: theme(`color${firstLetterCapped}Border`),
|
||||
bgHover: theme(`color${firstLetterCapped}BgHover`),
|
||||
bg: theme(`color${firstLetterCapped}Bg`),
|
||||
};
|
||||
}
|
||||
|
||||
private updateProviders(
|
||||
theme: SupersetTheme,
|
||||
antdConfig: AntdThemeConfig,
|
||||
|
||||
@@ -26,7 +26,9 @@ import {
|
||||
type ThemeStorage,
|
||||
type ThemeControllerOptions,
|
||||
type ThemeContextType,
|
||||
type SupersetThemeConfig,
|
||||
ThemeAlgorithm,
|
||||
ThemeMode,
|
||||
} from './types';
|
||||
|
||||
export {
|
||||
@@ -66,7 +68,16 @@ const themeObject: Theme = Theme.fromConfig({
|
||||
const { theme } = themeObject;
|
||||
const supersetTheme = theme;
|
||||
|
||||
export { Theme, themeObject, styled, theme, supersetTheme };
|
||||
export {
|
||||
Theme,
|
||||
ThemeAlgorithm,
|
||||
ThemeMode,
|
||||
themeObject,
|
||||
styled,
|
||||
theme,
|
||||
supersetTheme,
|
||||
};
|
||||
|
||||
export type {
|
||||
SupersetTheme,
|
||||
SerializableThemeConfig,
|
||||
@@ -74,4 +85,8 @@ export type {
|
||||
ThemeStorage,
|
||||
ThemeControllerOptions,
|
||||
ThemeContextType,
|
||||
SupersetThemeConfig,
|
||||
};
|
||||
|
||||
// Export theme utility functions
|
||||
export * from './utils/themeUtils';
|
||||
|
||||
@@ -411,6 +411,7 @@ export interface ThemeControllerOptions {
|
||||
onChange?: (theme: Theme) => void;
|
||||
canUpdateTheme?: () => boolean;
|
||||
canUpdateMode?: () => boolean;
|
||||
isGlobalContext?: boolean;
|
||||
}
|
||||
|
||||
export interface ThemeContextType {
|
||||
@@ -419,4 +420,25 @@ export interface ThemeContextType {
|
||||
setTheme: (config: AnyThemeConfig) => void;
|
||||
setThemeMode: (newMode: ThemeMode) => void;
|
||||
resetTheme: () => void;
|
||||
setTemporaryTheme: (config: AnyThemeConfig) => void;
|
||||
clearLocalOverrides: () => void;
|
||||
getCurrentCrudThemeId: () => string | null;
|
||||
hasDevOverride: () => boolean;
|
||||
canSetMode: () => boolean;
|
||||
canSetTheme: () => boolean;
|
||||
canDetectOSPreference: () => boolean;
|
||||
createDashboardThemeProvider: (themeId: string) => Promise<Theme | null>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration object for complete theme setup including default, dark themes and settings
|
||||
*/
|
||||
export interface SupersetThemeConfig {
|
||||
theme_default: AnyThemeConfig;
|
||||
theme_dark?: AnyThemeConfig;
|
||||
theme_settings?: {
|
||||
enforced?: boolean;
|
||||
allowSwitching?: boolean;
|
||||
allowOSPreference?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
/**
|
||||
* 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 { getFontSize, getColorVariants, isThemeDark } from './themeUtils';
|
||||
import { Theme } from '../Theme';
|
||||
import { ThemeAlgorithm } from '../types';
|
||||
|
||||
// Mock emotion's cache to avoid actual DOM operations
|
||||
jest.mock('@emotion/cache', () => ({
|
||||
__esModule: true,
|
||||
default: jest.fn().mockReturnValue({}),
|
||||
}));
|
||||
|
||||
describe('themeUtils', () => {
|
||||
let lightTheme: Theme;
|
||||
let darkTheme: Theme;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
|
||||
// Create actual theme instances for testing
|
||||
lightTheme = Theme.fromConfig({
|
||||
token: {
|
||||
colorPrimary: '#1890ff',
|
||||
fontSizeXS: '8',
|
||||
fontSize: '14',
|
||||
fontSizeLG: '16',
|
||||
},
|
||||
});
|
||||
|
||||
darkTheme = Theme.fromConfig({
|
||||
algorithm: ThemeAlgorithm.DARK,
|
||||
token: {
|
||||
colorPrimary: '#1890ff',
|
||||
fontSizeXS: '8',
|
||||
fontSize: '14',
|
||||
fontSizeLG: '16',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
describe('getFontSize', () => {
|
||||
it('returns correct font size for given key', () => {
|
||||
expect(getFontSize(lightTheme.theme, 'xs')).toBe('8');
|
||||
expect(getFontSize(lightTheme.theme, 'm')).toBe('14');
|
||||
expect(getFontSize(lightTheme.theme, 'l')).toBe('16');
|
||||
});
|
||||
|
||||
it('defaults to medium font size when no key is provided', () => {
|
||||
expect(getFontSize(lightTheme.theme)).toBe('14');
|
||||
});
|
||||
|
||||
it('uses antd default when specific size not overridden', () => {
|
||||
// Create theme with minimal config - antd will provide defaults
|
||||
const minimalTheme = Theme.fromConfig({
|
||||
token: { fontSize: '14' },
|
||||
});
|
||||
|
||||
// Ant Design provides fontSizeXS: '8' by default
|
||||
expect(getFontSize(minimalTheme.theme, 'xs')).toBe('8');
|
||||
expect(getFontSize(minimalTheme.theme, 'm')).toBe('14');
|
||||
});
|
||||
});
|
||||
|
||||
describe('isThemeDark', () => {
|
||||
it('returns false for light theme', () => {
|
||||
expect(isThemeDark(lightTheme.theme)).toBe(false);
|
||||
});
|
||||
|
||||
it('returns true for dark theme', () => {
|
||||
expect(isThemeDark(darkTheme.theme)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getColorVariants', () => {
|
||||
it('returns correct variants for primary color', () => {
|
||||
const variants = getColorVariants(lightTheme.theme, 'primary');
|
||||
|
||||
expect(variants.text).toBeDefined();
|
||||
expect(variants.bg).toBeDefined();
|
||||
expect(variants.border).toBeDefined();
|
||||
expect(variants.active).toBeDefined();
|
||||
});
|
||||
|
||||
it('returns grayscale variants for default color in light theme', () => {
|
||||
const variants = getColorVariants(lightTheme.theme, 'default');
|
||||
|
||||
expect(variants.active).toBe('#222');
|
||||
expect(variants.textActive).toBe('#444');
|
||||
expect(variants.text).toBe('#555');
|
||||
expect(variants.bg).toBe('#F4F4F4');
|
||||
});
|
||||
|
||||
it('returns inverted grayscale variants for default color in dark theme', () => {
|
||||
const variants = getColorVariants(darkTheme.theme, 'default');
|
||||
|
||||
// In dark theme, colors should be inverted
|
||||
expect(variants.active).toBe('#dddddd'); // Inverted #222
|
||||
expect(variants.textActive).toBe('#bbbbbb'); // Inverted #444
|
||||
expect(variants.text).toBe('#aaaaaa'); // Inverted #555
|
||||
});
|
||||
|
||||
it('returns same variants for grayscale color as default', () => {
|
||||
const defaultVariants = getColorVariants(lightTheme.theme, 'default');
|
||||
const grayscaleVariants = getColorVariants(lightTheme.theme, 'grayscale');
|
||||
|
||||
expect(defaultVariants).toEqual(grayscaleVariants);
|
||||
});
|
||||
|
||||
it('handles missing color tokens gracefully', () => {
|
||||
const variants = getColorVariants(lightTheme.theme, 'nonexistent');
|
||||
|
||||
// Should return undefined for missing tokens
|
||||
expect(variants.active).toBeUndefined();
|
||||
expect(variants.text).toBeUndefined();
|
||||
expect(variants.bg).toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,113 @@
|
||||
/**
|
||||
* 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 tinycolor from 'tinycolor2';
|
||||
import type { SupersetTheme, FontSizeKey, ColorVariants } from '../types';
|
||||
|
||||
const fontSizeMap: Record<FontSizeKey, keyof SupersetTheme> = {
|
||||
xs: 'fontSizeXS',
|
||||
s: 'fontSizeSM',
|
||||
m: 'fontSize',
|
||||
l: 'fontSizeLG',
|
||||
xl: 'fontSizeXL',
|
||||
xxl: 'fontSizeXXL',
|
||||
};
|
||||
|
||||
/**
|
||||
* Get font size from theme tokens based on size key
|
||||
* @param theme - Theme tokens from useTheme()
|
||||
* @param size - Font size key
|
||||
* @returns Font size as string
|
||||
*/
|
||||
export function getFontSize(theme: SupersetTheme, size?: FontSizeKey): string {
|
||||
const key = fontSizeMap[size || 'm'];
|
||||
return String(theme[key] || theme.fontSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get color variants for a given color type from theme tokens
|
||||
* @param theme - Theme tokens from useTheme()
|
||||
* @param color - Color type (e.g., 'primary', 'error', 'success')
|
||||
* @returns ColorVariants object with bg, border, text colors etc.
|
||||
*/
|
||||
export function getColorVariants(
|
||||
theme: SupersetTheme,
|
||||
color: string,
|
||||
): ColorVariants {
|
||||
const firstLetterCapped = color.charAt(0).toUpperCase() + color.slice(1);
|
||||
|
||||
if (color === 'default' || color === 'grayscale') {
|
||||
const isDark = isThemeDark(theme);
|
||||
|
||||
const flipBrightness = (baseColor: string): string => {
|
||||
if (!isDark) return baseColor;
|
||||
const { r, g, b } = tinycolor(baseColor).toRgb();
|
||||
const invertedColor = tinycolor({ r: 255 - r, g: 255 - g, b: 255 - b });
|
||||
return invertedColor.toHexString();
|
||||
};
|
||||
|
||||
return {
|
||||
active: flipBrightness('#222'),
|
||||
textActive: flipBrightness('#444'),
|
||||
text: flipBrightness('#555'),
|
||||
textHover: flipBrightness('#666'),
|
||||
hover: flipBrightness('#888'),
|
||||
borderHover: flipBrightness('#AAA'),
|
||||
border: flipBrightness('#CCC'),
|
||||
bgHover: flipBrightness('#DDD'),
|
||||
bg: flipBrightness('#F4F4F4'),
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
active: theme[
|
||||
`color${firstLetterCapped}Active` as keyof SupersetTheme
|
||||
] as string,
|
||||
textActive: theme[
|
||||
`color${firstLetterCapped}TextActive` as keyof SupersetTheme
|
||||
] as string,
|
||||
text: theme[
|
||||
`color${firstLetterCapped}Text` as keyof SupersetTheme
|
||||
] as string,
|
||||
textHover: theme[
|
||||
`color${firstLetterCapped}TextHover` as keyof SupersetTheme
|
||||
] as string,
|
||||
hover: theme[
|
||||
`color${firstLetterCapped}Hover` as keyof SupersetTheme
|
||||
] as string,
|
||||
borderHover: theme[
|
||||
`color${firstLetterCapped}BorderHover` as keyof SupersetTheme
|
||||
] as string,
|
||||
border: theme[
|
||||
`color${firstLetterCapped}Border` as keyof SupersetTheme
|
||||
] as string,
|
||||
bgHover: theme[
|
||||
`color${firstLetterCapped}BgHover` as keyof SupersetTheme
|
||||
] as string,
|
||||
bg: theme[`color${firstLetterCapped}Bg` as keyof SupersetTheme] as string,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current theme is dark mode based on background color
|
||||
* @param theme - Theme tokens from useTheme()
|
||||
* @returns true if theme is dark, false if light
|
||||
*/
|
||||
export function isThemeDark(theme: SupersetTheme): boolean {
|
||||
return tinycolor(theme.colorBgContainer).isDark();
|
||||
}
|
||||
@@ -30,6 +30,7 @@ export enum FeatureFlag {
|
||||
AvoidColorsCollision = 'AVOID_COLORS_COLLISION',
|
||||
ChartPluginsExperimental = 'CHART_PLUGINS_EXPERIMENTAL',
|
||||
ConfirmDashboardDiff = 'CONFIRM_DASHBOARD_DIFF',
|
||||
CssTemplates = 'CSS_TEMPLATES',
|
||||
DashboardVirtualization = 'DASHBOARD_VIRTUALIZATION',
|
||||
DashboardRbac = 'DASHBOARD_RBAC',
|
||||
DatapanelClosedByDefault = 'DATAPANEL_CLOSED_BY_DEFAULT',
|
||||
@@ -53,8 +54,6 @@ export enum FeatureFlag {
|
||||
SqlValidatorsByEngine = 'SQL_VALIDATORS_BY_ENGINE',
|
||||
SshTunneling = 'SSH_TUNNELING',
|
||||
TaggingSystem = 'TAGGING_SYSTEM',
|
||||
ThemeEnableDarkThemeSwitch = 'THEME_ENABLE_DARK_THEME_SWITCH',
|
||||
ThemeAllowThemeEditorBeta = 'THEME_ALLOW_THEME_EDITOR_BETA',
|
||||
Thumbnails = 'THUMBNAILS',
|
||||
UseAnalogousColors = 'USE_ANALOGOUS_COLORS',
|
||||
ForceSqlLabRunAsync = 'SQLLAB_FORCE_RUN_ASYNC',
|
||||
|
||||
@@ -24,7 +24,7 @@ import { ResizeCallbackData } from 'react-resizable';
|
||||
import ResizablePanel, { Size } from './ResizablePanel';
|
||||
|
||||
export const SupersetBody = styled.div`
|
||||
background: ${({ theme }) => theme.colorBgContainer};
|
||||
background: ${({ theme }) => theme.colors.grayscale.light4};
|
||||
padding: 16px;
|
||||
min-height: 100%;
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ export const BasicCountryMapStory = (
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
color: theme.colorText,
|
||||
color: theme.colors.grayscale.base,
|
||||
textAlign: 'center',
|
||||
padding: 20,
|
||||
}}
|
||||
|
||||
@@ -124,7 +124,7 @@ function Calendar(element, props) {
|
||||
colorScale,
|
||||
min: legendColors[0],
|
||||
max: legendColors[legendColors.length - 1],
|
||||
empty: theme.colorBgContainer,
|
||||
empty: theme.colors.grayscale.light5,
|
||||
},
|
||||
displayLegend: showLegend,
|
||||
itemName: '',
|
||||
|
||||
@@ -32,8 +32,8 @@ const Calendar = ({ className, ...otherProps }) => {
|
||||
.d3-tip {
|
||||
line-height: 1;
|
||||
padding: ${theme.sizeUnit * 3}px;
|
||||
background: ${theme.colorTextBase};
|
||||
color: ${theme.colorBgContainer};
|
||||
background: ${theme.colors.grayscale.dark2};
|
||||
color: ${theme.colors.grayscale.light5};
|
||||
border-radius: 4px;
|
||||
pointer-events: none;
|
||||
z-index: 1000;
|
||||
@@ -46,7 +46,7 @@ const Calendar = ({ className, ...otherProps }) => {
|
||||
font-size: ${theme.fontSizeXS};
|
||||
width: 100%;
|
||||
line-height: 1;
|
||||
color: ${theme.colorTextBase};
|
||||
color: ${theme.colors.grayscale.dark2};
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
}
|
||||
@@ -112,8 +112,8 @@ export default styled(Calendar)`
|
||||
.superset-legacy-chart-calendar .d3-tip {
|
||||
line-height: 1;
|
||||
padding: ${theme.sizeUnit * 3}px;
|
||||
background: ${theme.colorTextBase};
|
||||
color: ${theme.colorBgContainer};
|
||||
background: ${theme.colors.grayscale.dark2};
|
||||
color: ${theme.colors.grayscale.light5};
|
||||
border-radius: ${theme.borderRadius}px;
|
||||
pointer-events: none;
|
||||
z-index: 1000;
|
||||
@@ -124,7 +124,7 @@ export default styled(Calendar)`
|
||||
}
|
||||
|
||||
.cal-heatmap-container .graph-label {
|
||||
fill: ${theme.colorText};
|
||||
fill: ${theme.colors.grayscale.base};
|
||||
font-size: ${theme.fontSizeXS}px;
|
||||
}
|
||||
|
||||
@@ -134,11 +134,11 @@ export default styled(Calendar)`
|
||||
}
|
||||
|
||||
.cal-heatmap-container .graph-rect {
|
||||
fill: ${theme.colorBorderSecondary};
|
||||
fill: ${theme.colors.grayscale.light2};
|
||||
}
|
||||
|
||||
.cal-heatmap-container .graph-subdomain-group rect:hover {
|
||||
stroke: ${theme.colorTextBase};
|
||||
stroke: ${theme.colors.grayscale.dark2};
|
||||
stroke-width: 1px;
|
||||
}
|
||||
|
||||
@@ -152,88 +152,88 @@ export default styled(Calendar)`
|
||||
}
|
||||
|
||||
.cal-heatmap-container .qi {
|
||||
background-color: ${theme.colorText};
|
||||
fill: ${theme.colorText};
|
||||
background-color: ${theme.colors.grayscale.base};
|
||||
fill: ${theme.colors.grayscale.base};
|
||||
}
|
||||
|
||||
.cal-heatmap-container .q1 {
|
||||
background-color: ${theme.colorError};
|
||||
fill: ${theme.colorError};
|
||||
background-color: ${theme.colors.warning.light2};
|
||||
fill: ${theme.colors.warning.light2};
|
||||
}
|
||||
|
||||
.cal-heatmap-container .q2 {
|
||||
background-color: ${theme.colorError};
|
||||
fill: ${theme.colorError};
|
||||
background-color: ${theme.colors.warning.light1};
|
||||
fill: ${theme.colors.warning.light1};
|
||||
}
|
||||
|
||||
.cal-heatmap-container .q3 {
|
||||
background-color: ${theme.colorSuccessHover};
|
||||
fill: ${theme.colorSuccessHover};
|
||||
background-color: ${theme.colors.success.light1};
|
||||
fill: ${theme.colors.success.light1};
|
||||
}
|
||||
|
||||
.cal - heatmap - container.q4 {
|
||||
background - color: ${theme.colorSuccess};
|
||||
fill: ${theme.colorSuccess};
|
||||
}
|
||||
.cal-heatmap-container .q4 {
|
||||
background-color: ${theme.colorSuccess};
|
||||
fill: ${theme.colorSuccess};
|
||||
}
|
||||
|
||||
.cal - heatmap - container.q5 {
|
||||
background - color: ${theme.colorSuccessActive};
|
||||
fill: ${theme.colorSuccessActive};
|
||||
}
|
||||
.cal-heatmap-container .q5 {
|
||||
background-color: ${theme.colors.success.dark1};
|
||||
fill: ${theme.colors.success.dark1};
|
||||
}
|
||||
|
||||
.cal - heatmap - container rect.highlight {
|
||||
stroke: ${theme.colorText};
|
||||
stroke - width: 1;
|
||||
}
|
||||
.cal-heatmap-container rect.highlight {
|
||||
stroke: ${theme.colorText};
|
||||
stroke-width: 1;
|
||||
}
|
||||
|
||||
.cal - heatmap - container text.highlight {
|
||||
fill: ${theme.colorText};
|
||||
}
|
||||
.cal-heatmap-container text.highlight {
|
||||
fill: ${theme.colorText};
|
||||
}
|
||||
|
||||
.cal - heatmap - container rect.highlight - now {
|
||||
stroke: ${theme.colorError};
|
||||
}
|
||||
.cal-heatmap-container rect.highlight-now {
|
||||
stroke: ${theme.colorError};
|
||||
}
|
||||
|
||||
.cal - heatmap - container text.highlight - now {
|
||||
fill: ${theme.colorError};
|
||||
font - weight: ${theme.fontWeightStrong};
|
||||
}
|
||||
.cal-heatmap-container text.highlight-now {
|
||||
fill: ${theme.colorError};
|
||||
font-weight: ${theme.fontWeightStrong};
|
||||
}
|
||||
|
||||
.cal - heatmap - container.domain - background {
|
||||
fill: none;
|
||||
shape - rendering: crispedges;
|
||||
}
|
||||
.cal-heatmap-container .domain-background {
|
||||
fill: none;
|
||||
shape-rendering: crispedges;
|
||||
}
|
||||
|
||||
.ch - tooltip {
|
||||
padding: ${theme.sizeUnit * 2} px;
|
||||
background: ${theme.colorText};
|
||||
color: ${theme.colorBorder};
|
||||
font - size: ${theme.fontSizeSM} px;
|
||||
line - height: 1.4;
|
||||
width: 140px;
|
||||
position: absolute;
|
||||
z - index: 99999;
|
||||
text - align: center;
|
||||
border - radius: ${theme.borderRadius} px;
|
||||
box - shadow: 2px 2px 2px ${theme.colorTextBase};
|
||||
display: none;
|
||||
box - sizing: border - box;
|
||||
}
|
||||
.ch-tooltip {
|
||||
padding: ${theme.sizeUnit * 2}px;
|
||||
background: ${theme.colorText};
|
||||
color: ${theme.colors.grayscale.light1};
|
||||
font-size: ${theme.fontSizeSM}px;
|
||||
line-height: 1.4;
|
||||
width: 140px;
|
||||
position: absolute;
|
||||
z-index: 99999;
|
||||
text-align: center;
|
||||
border-radius: ${theme.borderRadius}px;
|
||||
box-shadow: 2px 2px 2px ${theme.colors.grayscale.dark2};
|
||||
display: none;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.ch - tooltip::after {
|
||||
position: absolute;
|
||||
width: 0;
|
||||
height: 0;
|
||||
border - color: transparent;
|
||||
border - style: solid;
|
||||
content: '';
|
||||
padding: 0;
|
||||
display: block;
|
||||
bottom: -${theme.sizeUnit} px;
|
||||
left: 50 %;
|
||||
margin - left: -${theme.sizeUnit} px;
|
||||
border - width: ${theme.sizeUnit}px ${theme.sizeUnit}px 0;
|
||||
border - top - color: ${theme.colorSplit};
|
||||
}
|
||||
`}
|
||||
.ch-tooltip::after {
|
||||
position: absolute;
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-color: transparent;
|
||||
border-style: solid;
|
||||
content: '';
|
||||
padding: 0;
|
||||
display: block;
|
||||
bottom: -${theme.sizeUnit}px;
|
||||
left: 50%;
|
||||
margin-left: -${theme.sizeUnit}px;
|
||||
border-width: ${theme.sizeUnit}px ${theme.sizeUnit}px 0;
|
||||
border-top-color: ${theme.colorSplit};
|
||||
}
|
||||
`}
|
||||
`;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -30,7 +30,7 @@ const CountryMap = ({ className, ...otherProps }) => (
|
||||
export default styled(CountryMap)`
|
||||
${({ theme }) => `
|
||||
.superset-legacy-chart-country-map svg {
|
||||
background-color: ${theme.colorBgContainer};
|
||||
background-color: ${theme.colors.grayscale.light5};
|
||||
}
|
||||
|
||||
.superset-legacy-chart-country-map {
|
||||
@@ -38,13 +38,13 @@ export default styled(CountryMap)`
|
||||
}
|
||||
|
||||
.superset-legacy-chart-country-map .background {
|
||||
fill: ${theme.colorBgContainer};
|
||||
fill: ${theme.colors.grayscale.light5};
|
||||
pointer-events: all;
|
||||
}
|
||||
|
||||
.superset-legacy-chart-country-map .map-layer {
|
||||
fill: ${theme.colorBgContainer};
|
||||
stroke: ${theme.colorBorder};
|
||||
fill: ${theme.colors.grayscale.light5};
|
||||
stroke: ${theme.colors.grayscale.light1};
|
||||
}
|
||||
|
||||
.superset-legacy-chart-country-map .effect-layer {
|
||||
@@ -69,7 +69,7 @@ export default styled(CountryMap)`
|
||||
|
||||
.superset-legacy-chart-country-map path.region {
|
||||
cursor: pointer;
|
||||
stroke: ${theme.colorBorderSecondary};
|
||||
stroke: ${theme.colors.grayscale.light2};
|
||||
}
|
||||
`}
|
||||
`;
|
||||
|
||||
@@ -65,7 +65,7 @@ const StyledDiv = styled.div`
|
||||
}
|
||||
|
||||
.superset-legacy-chart-horizon .horizon-row {
|
||||
border-bottom: solid 1px ${theme.colorBorderSecondary};
|
||||
border-bottom: solid 1px ${theme.colors.grayscale.light2};
|
||||
border-top: 0;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
|
||||
@@ -70,7 +70,7 @@ const StyledDiv = styled.div`
|
||||
}
|
||||
|
||||
.reactable-data tr:hover {
|
||||
background-color: ${theme.colorFill};
|
||||
background-color: ${theme.colors.grayscale.light3};
|
||||
}
|
||||
|
||||
.reactable-data tr .false {
|
||||
@@ -90,14 +90,14 @@ const StyledDiv = styled.div`
|
||||
}
|
||||
|
||||
.reactable-data .control td {
|
||||
background-color: ${theme.colorFill};
|
||||
background-color: ${theme.colors.grayscale.light3};
|
||||
}
|
||||
|
||||
.reactable-header-sortable:hover,
|
||||
.reactable-header-sortable:focus,
|
||||
.reactable-header-sort-asc,
|
||||
.reactable-header-sort-desc {
|
||||
background-color: ${theme.colorFill};
|
||||
background-color: ${theme.colors.grayscale.light3};
|
||||
position: relative;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ export default styled(ParallelCoordinates)`
|
||||
overflow: auto;
|
||||
div.row {
|
||||
&:hover {
|
||||
background-color: ${theme.colorBorderSecondary};
|
||||
background-color: ${theme.colors.grayscale.light2};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,14 +62,14 @@ export default styled(ParallelCoordinates)`
|
||||
fill: transparent;
|
||||
}
|
||||
.parcoords rect.background:hover {
|
||||
fill: ${addAlpha(theme.colorText, 0.2)};
|
||||
fill: ${addAlpha(theme.colors.grayscale.base, 0.2)};
|
||||
}
|
||||
.parcoords .resize rect {
|
||||
fill: ${addAlpha(theme.colorTextBase, 0.1)};
|
||||
fill: ${addAlpha(theme.colors.grayscale.dark2, 0.1)};
|
||||
}
|
||||
.parcoords rect.extent {
|
||||
fill: ${addAlpha(theme.colorBgContainer, 0.25)};
|
||||
stroke: ${addAlpha(theme.colorTextBase, 0.6)};
|
||||
fill: ${addAlpha(theme.colors.grayscale.light5, 0.25)};
|
||||
stroke: ${addAlpha(theme.colors.grayscale.dark2, 0.6)};
|
||||
}
|
||||
.parcoords .axis line,
|
||||
.parcoords .axis path {
|
||||
@@ -93,7 +93,7 @@ export default styled(ParallelCoordinates)`
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
background-color: ${theme.colorBgContainer};
|
||||
background-color: ${theme.colors.grayscale.light5};
|
||||
}
|
||||
|
||||
/* data table styles */
|
||||
@@ -106,7 +106,7 @@ export default styled(ParallelCoordinates)`
|
||||
margin: 0px;
|
||||
}
|
||||
.parcoords .row:nth-of-type(odd) {
|
||||
background: ${addAlpha(theme.colorTextBase, 0.05)};
|
||||
background: ${addAlpha(theme.colors.grayscale.dark2, 0.05)};
|
||||
}
|
||||
.parcoords .header {
|
||||
font-weight: ${theme.fontWeightStrong};
|
||||
|
||||
@@ -40,8 +40,8 @@ export default styled(Partition)`
|
||||
}
|
||||
|
||||
.superset-legacy-chart-partition rect {
|
||||
stroke: ${theme.colorBorderSecondary};
|
||||
fill: ${theme.colorBorder};
|
||||
stroke: ${theme.colors.grayscale.light2};
|
||||
fill: ${theme.colors.grayscale.light1};
|
||||
fill-opacity: 80%;
|
||||
transition: fill-opacity 180ms linear;
|
||||
cursor: pointer;
|
||||
@@ -57,7 +57,7 @@ export default styled(Partition)`
|
||||
}
|
||||
|
||||
.superset-legacy-chart-partition g:hover text {
|
||||
fill: ${theme.colorTextBase};
|
||||
fill: ${theme.colors.grayscale.dark2};
|
||||
}
|
||||
|
||||
.superset-legacy-chart-partition .partition-tooltip {
|
||||
@@ -67,14 +67,14 @@ export default styled(Partition)`
|
||||
opacity: 0;
|
||||
padding: ${theme.sizeUnit}px;
|
||||
pointer-events: none;
|
||||
background-color: ${theme.colorTextBase};
|
||||
background-color: ${theme.colors.grayscale.dark2};
|
||||
border-radius: ${theme.borderRadius}px;
|
||||
}
|
||||
|
||||
.partition-tooltip td {
|
||||
padding-left: ${theme.sizeUnit}px;
|
||||
font-size: ${theme.fontSizeSM}px;
|
||||
color: ${theme.colorBgContainer};
|
||||
color: ${theme.colors.grayscale.light5};
|
||||
}
|
||||
`}
|
||||
`;
|
||||
|
||||
@@ -29,8 +29,8 @@ const Rose = ({ className, ...otherProps }) => (
|
||||
.tooltip {
|
||||
line-height: 1;
|
||||
padding: ${theme.sizeUnit * 3}px;
|
||||
background: ${theme.colorTextBase};
|
||||
color: ${theme.colorBgContainer};
|
||||
background: ${theme.colors.grayscale.dark2};
|
||||
color: ${theme.colors.grayscale.light5};
|
||||
border-radius: 4px;
|
||||
pointer-events: none;
|
||||
z-index: 1000;
|
||||
@@ -46,7 +46,7 @@ export default styled(Rose)`
|
||||
${({ theme }) => `
|
||||
.superset-legacy-chart-rose path {
|
||||
transition: fill-opacity 180ms linear;
|
||||
stroke: ${theme.colorBgContainer};
|
||||
stroke: ${theme.colors.grayscale.light5};
|
||||
stroke-width: 1px;
|
||||
stroke-opacity: 1;
|
||||
fill-opacity: 0.75;
|
||||
|
||||
@@ -39,7 +39,7 @@ export default styled(WorldMapComponent)`
|
||||
.superset-legacy-chart-world-map {
|
||||
position: relative;
|
||||
svg {
|
||||
background-color: ${({ theme }) => theme.colorBgContainer};
|
||||
background-color: ${({ theme }) => theme.colors.grayscale.light5};
|
||||
}
|
||||
}
|
||||
.hoverinfo {
|
||||
|
||||
@@ -203,14 +203,14 @@ function WorldMap(element, props) {
|
||||
height,
|
||||
data: processedData,
|
||||
fills: {
|
||||
defaultFill: theme.colorBorderSecondary,
|
||||
defaultFill: theme.colors.grayscale.light2,
|
||||
},
|
||||
geographyConfig: {
|
||||
popupOnHover: !inContextMenu,
|
||||
highlightOnHover: !inContextMenu,
|
||||
borderWidth: 1,
|
||||
borderColor: theme.colorSplit,
|
||||
highlightBorderColor: theme.colorBgContainer,
|
||||
highlightBorderColor: theme.colors.grayscale.light5,
|
||||
highlightFillColor: color,
|
||||
highlightBorderWidth: 1,
|
||||
popupTemplate: (geo, d) =>
|
||||
@@ -232,7 +232,7 @@ function WorldMap(element, props) {
|
||||
animate: true,
|
||||
highlightOnHover: !inContextMenu,
|
||||
highlightFillColor: color,
|
||||
highlightBorderColor: theme.colorText,
|
||||
highlightBorderColor: theme.colors.grayscale.dark2,
|
||||
highlightBorderWidth: 2,
|
||||
highlightBorderOpacity: 1,
|
||||
highlightFillOpacity: 0.85,
|
||||
|
||||
@@ -27,8 +27,8 @@ const StyledLegend = styled.div`
|
||||
${({ theme }) => `
|
||||
font-size: ${theme.fontSizeSM}px;
|
||||
position: absolute;
|
||||
background: ${theme.colorBgContainer};
|
||||
box-shadow: 0 0 ${theme.sizeUnit}px ${theme.colorBorderSecondary};
|
||||
background: ${theme.colors.grayscale.light5};
|
||||
box-shadow: 0 0 ${theme.sizeUnit}px ${theme.colors.grayscale.light2};
|
||||
margin: ${theme.sizeUnit * 6}px;
|
||||
padding: ${theme.sizeUnit * 3}px ${theme.sizeUnit * 5}px;
|
||||
outline: none;
|
||||
@@ -42,7 +42,7 @@ const StyledLegend = styled.div`
|
||||
|
||||
& li a {
|
||||
display: flex;
|
||||
color: ${theme.colorText};
|
||||
color: ${theme.colors.grayscale.base};
|
||||
text-decoration: none;
|
||||
padding: ${theme.sizeUnit}px 0;
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ const StyledDiv = styled.div<{ top: number; left: number }>`
|
||||
left: ${left}px;
|
||||
padding: ${theme.sizeUnit * 2}px;
|
||||
margin: ${theme.sizeUnit * 2}px;
|
||||
background: ${theme.colorTextBase};
|
||||
color: ${theme.colorBgContainer};
|
||||
background: ${theme.colors.grayscale.dark2};
|
||||
color: ${theme.colors.grayscale.light5};
|
||||
maxWidth: 300px;
|
||||
fontSize: ${theme.fontSizeSM}px;
|
||||
zIndex: 9;
|
||||
|
||||
@@ -164,15 +164,15 @@ export default styled(NVD3)`
|
||||
.d3-tip.nv-event-annotation-layer-NATIVE {
|
||||
width: 200px;
|
||||
border-radius: 2px;
|
||||
background-color: ${({ theme }) => theme.colorText};
|
||||
background-color: ${({ theme }) => theme.colors.grayscale.base};
|
||||
fill-opacity: 0.6;
|
||||
margin: ${({ theme }) => theme.sizeUnit * 2}px;
|
||||
padding: ${({ theme }) => theme.sizeUnit * 2}px;
|
||||
color: ${({ theme }) => theme.colorBgContainer};
|
||||
color: ${({ theme }) => theme.colors.grayscale.light5};
|
||||
&:after {
|
||||
content: '\\25BC';
|
||||
font-size: ${({ theme }) => theme.fontSize};
|
||||
color: ${({ theme }) => theme.colorText};
|
||||
color: ${({ theme }) => theme.colors.grayscale.base};
|
||||
position: absolute;
|
||||
bottom: -14px;
|
||||
left: 94px;
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
"@react-icons/all-files": "^4.1.0",
|
||||
"@types/d3-array": "^2.9.0",
|
||||
"@types/react-table": "^7.7.20",
|
||||
"ag-grid-community": "^33.1.1",
|
||||
"ag-grid-react": "^33.1.1",
|
||||
"ag-grid-community": "^34.0.2",
|
||||
"ag-grid-react": "^34.0.2",
|
||||
"classnames": "^2.5.1",
|
||||
"d3-array": "^2.4.0",
|
||||
"lodash": "^4.17.21",
|
||||
|
||||
@@ -40,7 +40,7 @@ import {
|
||||
} from 'ag-grid-community';
|
||||
import { AgGridReact } from 'ag-grid-react';
|
||||
import { type FunctionComponent } from 'react';
|
||||
import { JsonObject, DataRecordValue, DataRecord } from '@superset-ui/core';
|
||||
import { JsonObject, DataRecordValue, DataRecord, t } from '@superset-ui/core';
|
||||
import { SearchOutlined } from '@ant-design/icons';
|
||||
import { debounce, isEqual } from 'lodash';
|
||||
import Pagination from './components/Pagination';
|
||||
@@ -326,6 +326,79 @@ const AgGridDataTable: FunctionComponent<AgGridTableProps> = memo(
|
||||
paginationPageSizeSelector={PAGE_SIZE_OPTIONS}
|
||||
suppressDragLeaveHidesColumns
|
||||
pinnedBottomRowData={showTotals ? [cleanedTotals] : undefined}
|
||||
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(
|
||||
|
||||
@@ -17,10 +17,6 @@
|
||||
* under the License.
|
||||
*/
|
||||
import { formatSelectOptions } from '@superset-ui/chart-controls';
|
||||
import { addLocaleData } from '@superset-ui/core';
|
||||
import i18n from './i18n';
|
||||
|
||||
addLocaleData(i18n);
|
||||
|
||||
export const SERVER_PAGE_SIZE_OPTIONS = formatSelectOptions<number>([
|
||||
10, 20, 50, 100, 200,
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { Locale } from '@superset-ui/core';
|
||||
|
||||
const en = {
|
||||
'Query Mode': [''],
|
||||
Aggregate: [''],
|
||||
'Raw Records': [''],
|
||||
'Emit Filter Events': [''],
|
||||
'Show Cell Bars': [''],
|
||||
'page_size.show': ['Show'],
|
||||
'page_size.all': ['All'],
|
||||
'page_size.entries': ['entries'],
|
||||
'table.previous_page': ['Previous'],
|
||||
'table.next_page': ['Next'],
|
||||
'search.num_records': ['%s record', '%s records...'],
|
||||
};
|
||||
|
||||
const translations: Partial<Record<Locale, typeof en>> = {
|
||||
en,
|
||||
fr: {
|
||||
'Query Mode': [''],
|
||||
Aggregate: [''],
|
||||
'Raw Records': [''],
|
||||
'Emit Filter Events': [''],
|
||||
'Show Cell Bars': [''],
|
||||
'page_size.show': ['Afficher'],
|
||||
'page_size.all': ['tous'],
|
||||
'page_size.entries': ['entrées'],
|
||||
'table.previous_page': ['Précédent'],
|
||||
'table.next_page': ['Suivante'],
|
||||
'search.num_records': ['%s enregistrement', '%s enregistrements...'],
|
||||
},
|
||||
zh: {
|
||||
'Query Mode': ['查询模式'],
|
||||
Aggregate: ['分组聚合'],
|
||||
'Raw Records': ['原始数据'],
|
||||
'Emit Filter Events': ['关联看板过滤器'],
|
||||
'Show Cell Bars': ['为指标添加条状图背景'],
|
||||
'page_size.show': ['每页显示'],
|
||||
'page_size.all': ['全部'],
|
||||
'page_size.entries': ['条'],
|
||||
'table.previous_page': ['上一页'],
|
||||
'table.next_page': ['下一页'],
|
||||
'search.num_records': ['%s条记录...'],
|
||||
},
|
||||
};
|
||||
|
||||
export default translations;
|
||||
@@ -130,13 +130,13 @@ export const MenuContainer = styled.div`
|
||||
gap: ${theme.sizeUnit * 2}px;
|
||||
|
||||
&:hover {
|
||||
background-color: ${theme.colorBgContainer};
|
||||
background-color: ${theme.colors.primary.light4};
|
||||
}
|
||||
}
|
||||
|
||||
.menu-divider {
|
||||
height: 1px;
|
||||
background-color: ${theme.colorBorderSecondary};
|
||||
background-color: ${theme.colors.grayscale.light2};
|
||||
margin: ${theme.sizeUnit}px 0;
|
||||
}
|
||||
`}
|
||||
@@ -165,16 +165,16 @@ export const PopoverContainer = styled.div`
|
||||
|
||||
export const PaginationContainer = styled.div`
|
||||
${({ theme }) => `
|
||||
border: 1px solid ${theme.colorBorderSecondary};
|
||||
border: 1px solid ${theme.colors.grayscale.light2};
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
padding: ${theme.sizeUnit * 2}px ${theme.sizeUnit * 4}px;
|
||||
border-top: 1px solid ${theme.colorBorderSecondary};
|
||||
border-top: 1px solid ${theme.colors.grayscale.light2};
|
||||
font-size: ${theme.fontSize}px;
|
||||
color: ${theme.colorTextBase};
|
||||
transform: translateY(-${theme.sizeUnit}px);
|
||||
background: ${theme.colorBgContainer};
|
||||
background: ${theme.colorBgBase};
|
||||
`}
|
||||
`;
|
||||
|
||||
@@ -222,7 +222,7 @@ export const PageButton = styled.div<{ disabled?: boolean }>`
|
||||
svg {
|
||||
height: ${theme.sizeUnit * 3}px;
|
||||
width: ${theme.sizeUnit * 3}px;
|
||||
fill: ${disabled ? theme.colorBorder : theme.colorTextBase};
|
||||
fill: ${disabled ? theme.colors.grayscale.light1 : theme.colors.grayscale.dark2};
|
||||
}
|
||||
`}
|
||||
`;
|
||||
@@ -239,14 +239,14 @@ export const InfoText = styled.div`
|
||||
max-width: 242px;
|
||||
${({ theme }) => `
|
||||
padding: 0 ${theme.sizeUnit * 2}px;
|
||||
color: ${theme.colorText};
|
||||
color: ${theme.colors.grayscale.base};
|
||||
font-size: ${theme.fontSizeSM}px;
|
||||
`}
|
||||
`;
|
||||
|
||||
export const ColumnLabel = styled.span`
|
||||
${({ theme }) => `
|
||||
color: ${theme.colorText};
|
||||
color: ${theme.colors.grayscale.dark2};
|
||||
`}
|
||||
`;
|
||||
|
||||
@@ -279,9 +279,9 @@ export const StyledChartContainer = styled.div<{
|
||||
${({ theme, height }) => css`
|
||||
height: ${height}px;
|
||||
|
||||
--ag-background-color: ${theme.colorBgContainer};
|
||||
--ag-background-color: ${theme.colorBgBase};
|
||||
--ag-foreground-color: ${theme.colorText};
|
||||
--ag-header-background-color: ${theme.colorBgContainer};
|
||||
--ag-header-background-color: ${theme.colorBgBase};
|
||||
--ag-header-foreground-color: ${theme.colorText};
|
||||
|
||||
.dt-is-filter {
|
||||
@@ -292,7 +292,7 @@ export const StyledChartContainer = styled.div<{
|
||||
}
|
||||
|
||||
.dt-is-active-filter {
|
||||
background: ${theme.colorBgLayout};
|
||||
background: ${theme.colors.primary.light3};
|
||||
:hover {
|
||||
background-color: ${theme.colorPrimaryBgHover};
|
||||
}
|
||||
@@ -379,7 +379,7 @@ export const StyledChartContainer = styled.div<{
|
||||
.input-wrapper svg {
|
||||
pointer-events: none;
|
||||
transform: translate(${theme.sizeUnit * 7}px, ${theme.sizeUnit / 2}px);
|
||||
color: ${theme.colorText};
|
||||
color: ${theme.colors.grayscale.base};
|
||||
}
|
||||
|
||||
.input-wrapper input {
|
||||
@@ -389,16 +389,16 @@ export const StyledChartContainer = styled.div<{
|
||||
${theme.sizeUnit * 1.5}px ${theme.sizeUnit * 8}px;
|
||||
line-height: 1.8;
|
||||
border-radius: ${theme.borderRadius}px;
|
||||
border: 1px solid ${theme.colorBorderSecondary};
|
||||
border: 1px solid ${theme.colors.grayscale.light2};
|
||||
background-color: transparent;
|
||||
outline: none;
|
||||
|
||||
&:focus {
|
||||
border-color: ${theme.colorPrimary};
|
||||
border-color: ${theme.colors.primary.base};
|
||||
}
|
||||
|
||||
&::placeholder {
|
||||
color: ${theme.colorBorder};
|
||||
color: ${theme.colors.grayscale.light1};
|
||||
}
|
||||
}
|
||||
`}
|
||||
|
||||
@@ -35,8 +35,10 @@
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@ant-design/icons": "^5.2.6",
|
||||
"@reduxjs/toolkit": "*",
|
||||
"@superset-ui/chart-controls": "*",
|
||||
"@superset-ui/core": "*",
|
||||
"@types/react-redux": "*",
|
||||
"geostyler": "^14.1.3",
|
||||
"geostyler-data": "^1.0.0",
|
||||
"geostyler-openlayers-parser": "^4.0.0",
|
||||
|
||||
@@ -52,6 +52,8 @@ export class ChartLayer extends Layer {
|
||||
|
||||
theme: SupersetTheme;
|
||||
|
||||
locale: string;
|
||||
|
||||
/**
|
||||
* Create a ChartLayer.
|
||||
*
|
||||
@@ -91,6 +93,10 @@ export class ChartLayer extends Layer {
|
||||
this.theme = options.theme;
|
||||
}
|
||||
|
||||
if (options.locale) {
|
||||
this.locale = options.locale;
|
||||
}
|
||||
|
||||
const spinner = document.createElement('img');
|
||||
spinner.src = Loader;
|
||||
spinner.style.position = 'relative';
|
||||
@@ -183,6 +189,7 @@ export class ChartLayer extends Layer {
|
||||
chartWidth,
|
||||
chartHeight,
|
||||
this.theme,
|
||||
this.locale,
|
||||
);
|
||||
ReactDOM.render(chartComponent, container);
|
||||
|
||||
@@ -218,6 +225,7 @@ export class ChartLayer extends Layer {
|
||||
chartWidth,
|
||||
chartHeight,
|
||||
this.theme,
|
||||
this.locale,
|
||||
);
|
||||
ReactDOM.render(chartComponent, chart.htmlElement);
|
||||
|
||||
|
||||
@@ -16,8 +16,10 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { configureStore } from '@reduxjs/toolkit';
|
||||
import { getChartComponentRegistry, ThemeProvider } from '@superset-ui/core';
|
||||
import { FC, useEffect, useState } from 'react';
|
||||
import { Provider as ReduxProvider } from 'react-redux';
|
||||
import { ChartWrapperProps } from '../types';
|
||||
|
||||
export const ChartWrapper: FC<ChartWrapperProps> = ({
|
||||
@@ -26,6 +28,7 @@ export const ChartWrapper: FC<ChartWrapperProps> = ({
|
||||
height,
|
||||
width,
|
||||
chartConfig,
|
||||
locale,
|
||||
}) => {
|
||||
const [Chart, setChart] = useState<any>();
|
||||
|
||||
@@ -39,13 +42,21 @@ export const ChartWrapper: FC<ChartWrapperProps> = ({
|
||||
getChartFromRegistry(vizType);
|
||||
}, [vizType]);
|
||||
|
||||
// Create a mock store that is needed by
|
||||
// eCharts components to access the locale.
|
||||
const mockStore = configureStore({
|
||||
reducer: (state = { common: { locale } }) => state,
|
||||
});
|
||||
|
||||
return (
|
||||
<ThemeProvider theme={theme}>
|
||||
{Chart === undefined ? (
|
||||
<></>
|
||||
) : (
|
||||
<Chart {...chartConfig.properties} height={height} width={width} />
|
||||
)}
|
||||
<ReduxProvider store={mockStore}>
|
||||
{Chart === undefined ? (
|
||||
<></>
|
||||
) : (
|
||||
<Chart {...chartConfig.properties} height={height} width={width} />
|
||||
)}
|
||||
</ReduxProvider>
|
||||
</ThemeProvider>
|
||||
);
|
||||
};
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user