mikebridge commented on code in PR #44025:
URL: https://github.com/apache/superset/pull/44025#discussion_r3995226360
##########
superset/commands/dashboard/update.py:
##########
@@ -283,17 +295,45 @@ def run(self) -> Model:
class UpdateDashboardColorsConfigCommand(UpdateDashboardCommand):
+ # The blanket gate is skipped so background colors sync (fired while a
+ # dashboard is merely viewed) keeps working for externally managed
+ # dashboards -- but only for the DERIVED color values. The authoritative
+ # inputs are the dashboard's real content, owned by the external source
+ # of truth; validate() refuses a payload that would change them.
+ _refuses_externally_managed = False
+
+ #: json_metadata keys a colors-config save may NOT change on an
+ #: externally managed dashboard. The other accepted keys
+ #: (color_scheme_domain, shared_label_colors, map_label_colors) are
+ #: derived from these plus chart state (see
+ #: DashboardDAO.update_colors_config).
+ _AUTHORITATIVE_COLOR_KEYS: tuple[str, ...] = ("color_scheme",
"label_colors")
+
def __init__(
self, model_id: int, data: dict[str, Any], mark_updated: bool = True
) -> None:
super().__init__(model_id, data)
self._mark_updated = mark_updated
+ def validate(self) -> None:
+ super().validate()
+ assert self._model
+ if self._model.is_managed_externally and
self._changes_authoritative_colors():
+ raise DashboardForbiddenError()
+
+ def _changes_authoritative_colors(self) -> bool:
+ assert self._model
+ metadata = json.loads(self._model.json_metadata or "{}")
+ return any(
+ key in self._properties and self._properties[key] !=
metadata.get(key)
+ for key in self._AUTHORITATIVE_COLOR_KEYS
Review Comment:
Addressed in 20f6d1d910 — `_changes_authoritative_colors` now uses a
`_METADATA_MISSING` sentinel so an explicit `color_scheme: null` against a
metadata blob lacking the key is detected as a change; parametrized pins cover
null-vs-absent in both directions.
--
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]