You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by di...@apache.org on 2024/11/26 14:25:28 UTC

(superset) branch geido/fix/shared-label-colors-export created (now 8b84832e30)

This is an automated email from the ASF dual-hosted git repository.

diegopucci pushed a change to branch geido/fix/shared-label-colors-export
in repository https://gitbox.apache.org/repos/asf/superset.git


      at 8b84832e30 fix(Dashboard): Backward compatible shared_label_colors field for export

This branch includes the following new commits:

     new 8b84832e30 fix(Dashboard): Backward compatible shared_label_colors field for export

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(superset) 01/01: fix(Dashboard): Backward compatible shared_label_colors field for export

Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

diegopucci pushed a commit to branch geido/fix/shared-label-colors-export
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 8b84832e30a76035f5717457056b00f08e87a551
Author: Diego Pucci <di...@gmail.com>
AuthorDate: Tue Nov 26 16:25:12 2024 +0200

    fix(Dashboard): Backward compatible shared_label_colors field for export
---
 superset/dashboards/schemas.py | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/superset/dashboards/schemas.py b/superset/dashboards/schemas.py
index d855e22b87..88f9db526a 100644
--- a/superset/dashboards/schemas.py
+++ b/superset/dashboards/schemas.py
@@ -116,6 +116,22 @@ def validate_json_metadata(value: Union[bytes, bytearray, str]) -> None:
         raise ValidationError(errors)
 
 
+class SharedLabelsColorsField(fields.Field):
+    """
+    A custom field that accepts either a list of strings or a dictionary.
+    """
+
+    def _deserialize(self, value, attr, data, **kwargs):
+        if isinstance(value, list):
+            if all(isinstance(item, str) for item in value):
+                return value
+        elif isinstance(value, dict):
+            # Convert dict values to a list (for backward compatibility)
+            return []
+
+        raise ValidationError("Not a valid list")
+
+
 class DashboardJSONMetadataSchema(Schema):
     # native_filter_configuration is for dashboard-native filters
     native_filter_configuration = fields.List(fields.Dict(), allow_none=True)
@@ -137,7 +153,7 @@ class DashboardJSONMetadataSchema(Schema):
     color_namespace = fields.Str(allow_none=True)
     positions = fields.Dict(allow_none=True)
     label_colors = fields.Dict()
-    shared_label_colors = fields.List(fields.Str())
+    shared_label_colors = SharedLabelsColorsField()
     map_label_colors = fields.Dict()
     color_scheme_domain = fields.List(fields.Str())
     cross_filters_enabled = fields.Boolean(dump_default=True)