gabotorresruiz opened a new pull request, #42874:
URL: https://github.com/apache/superset/pull/42874

   ### SUMMARY
   
   Superset's theme system supports custom tokens beyond Ant Design's (for 
example `brandLogoUrl`, `echartsOptionsOverrides`, and the `label*` / `button*` 
tokens in `SupersetSpecificTokens`). Deployments, white-label distributors, and 
custom chart plugins legitimately define their **own** tokens and consume them 
via `useTheme`. Today the theme editor validates token names against a fixed 
allowlist (`antdTokenNames.ts`), so any such deployment-specific token is 
flagged as an "Unknown token" warning with no supported way to register it.
   
   This adds an `EXTRA_THEME_TOKENS` config that lets a deployment register 
extra custom token names. It follows the exact pattern already used for 
`EXTRA_CATEGORICAL_COLOR_SCHEMES` / `EXTRA_SEQUENTIAL_COLOR_SCHEMES`: a config 
default, shipped to the frontend in the common bootstrap payload, and merged 
into the theme editor's valid-token set at runtime.
   
   Design notes:
   - `EXTRA_THEME_TOKENS: list[str] = []` in `config.py` (empty default, fully 
opt-in, no behavior change for existing deployments).
   - Exposed via `common_bootstrap_payload` in `views/base.py`, typed in 
`bootstrapTypes.ts`, defaulted in `constants.ts`.
   - `antdTokenNames.ts` merges `common.extra_theme_tokens` into the 
valid-token set and treats them as Superset custom tokens (not Ant Design) for 
correct categorization.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   Before: a deployment-defined token (e.g. `myBrandToken`) in a theme's JSON 
shows an "Unknown token 'myBrandToken' — may be ignored by Ant Design" warning 
in the theme editor.
   
   After: with `EXTRA_THEME_TOKENS = ["myBrandToken"]`, the token validates 
cleanly and the warning is gone. Ant Design still ignores tokens it does not 
recognize; this only affects editor validation.
   
   ### TESTING INSTRUCTIONS
   
   1. Set `EXTRA_THEME_TOKENS = ["myBrandToken"]` in `superset_config.py`.
   2. Open the theme editor and add `"myBrandToken": "..."` inside a theme's 
`token` object.
   3. Confirm no "Unknown token" warning is shown for it (an unregistered token 
like `"foo"` still warns).
   4. Unit tests: `superset-frontend/src/theme/utils/antdTokenNames.test.ts` 
covers the injected-token path (valid, categorized as a Superset custom token).
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [x] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to