You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by en...@apache.org on 2026/08/27 13:12:54 UTC
(superset) 03/46: feat(widgets): declare column/metric x-control extras on shared fields
This is an automated email from the ASF dual-hosted git repository.
EnxDev pushed a commit to branch enxdev/poc/dashboard-v2-editing-ui-flow
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 2e85d7b2901efbab1ff184c731d959ce19f3fe46
Author: Enzo Martellucci <en...@gmail.com>
AuthorDate: Thu Aug 20 15:21:04 2026 +0200
feat(widgets): declare column/metric x-control extras on shared fields
Add json_schema_extra hints to DataBinding and BalloonsControls fields
so the frontend Inspector can render dataset-aware column/metric pickers:
- DataBinding.metrics: x-control "metric-multi" (was "code")
- DataBinding.dimensions: x-control "column-multi" (new)
- BalloonsControls.colorDimension: x-control "column" (new)
Also improve metrics field documentation to clarify the picker behavior.
Co-Authored-By: Claude Sonnet 5 <no...@anthropic.com>
---
superset/widgets/controls.py | 9 ++++++---
tests/unit_tests/widgets/test_registry.py | 12 ++++++++++++
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/superset/widgets/controls.py b/superset/widgets/controls.py
index c55e540de83..08c020ad7a9 100644
--- a/superset/widgets/controls.py
+++ b/superset/widgets/controls.py
@@ -58,14 +58,16 @@ class DataBinding(BaseModel):
'like "SUM(sales)" — a plain string is looked up as a saved-metric '
"name, not evaluated as an expression."
),
- # Entries are heterogeneous (a name string or an ad-hoc object), so the
- # generic panel edits the list as JSON rather than a typed array.
- json_schema_extra={"x-control": "code", "x-language": "json"},
+ # A saved-metric name renders as a picker over the dataset's metrics;
+ # an ad-hoc object falls back to the raw JSON editor (see
+ # `MetricMultiControl` on the frontend).
+ json_schema_extra={"x-control": "metric-multi", "x-language": "json"},
)
dimensions: list[str] = Field(
default_factory=list,
title="Dimensions",
description="Columns to group by (the categories / series).",
+ json_schema_extra={"x-control": "column-multi"},
)
row_limit: int = Field(
default=1000,
@@ -215,6 +217,7 @@ class BalloonsControls(BaseModel):
'E.g. to color by gender: set this to "gender" AND include "gender" '
'in dimensions (e.g. dimensions ["name", "gender"]).'
),
+ json_schema_extra={"x-control": "column"},
)
customize: Customization = Field(
default_factory=Customization,
diff --git a/tests/unit_tests/widgets/test_registry.py b/tests/unit_tests/widgets/test_registry.py
index 66637e19098..fc1e4111bc0 100644
--- a/tests/unit_tests/widgets/test_registry.py
+++ b/tests/unit_tests/widgets/test_registry.py
@@ -126,3 +126,15 @@ def test_validate_control_values_flags_color_dimension_not_grouped() -> None:
def test_validate_control_values_empty_when_no_values() -> None:
# Nothing to validate (required-field checks live elsewhere).
assert _block("balloons").validate_control_values(None) == []
+
+
+def test_data_binding_declares_column_and_metric_controls() -> None:
+ schema = _block("balloons").get_control_schema(None, None)
+ data_binding_props = schema["$defs"]["DataBinding"]["properties"]
+ assert data_binding_props["dimensions"]["x-control"] == "column-multi"
+ assert data_binding_props["metrics"]["x-control"] == "metric-multi"
+
+
+def test_color_dimension_declares_column_control() -> None:
+ schema = _block("balloons").get_control_schema(None, None)
+ assert schema["properties"]["colorDimension"]["x-control"] == "column"