Skip to content

Commit

Permalink
Fix: Painter params of column spec are not 'None' anymore
Browse files Browse the repository at this point in the history
Change-Id: I2e080d3f2f745659382a21fc1bba1ee6e5b9f027
  • Loading branch information
si-23 committed Jan 12, 2023
1 parent e9a3c50 commit efb1a85
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
14 changes: 4 additions & 10 deletions cmk/gui/views/painter/v0/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,8 @@ def __init__(

def _from_view(self, column_spec: ColumnSpec) -> None:
self._painter_name = column_spec.name
if column_spec.parameters is not None:
self._painter_params = column_spec.parameters
self._custom_title = self._painter_params.get("column_title", None)
self._painter_params = column_spec.parameters
self._custom_title = self._painter_params.get("column_title", None)

self._link_spec = column_spec.link_spec

Expand Down Expand Up @@ -398,14 +397,9 @@ def painter_parameters(self) -> PainterParameters | None:
"""The parameters configured in the view for this painter. In case the
painter has params, it defaults to the valuespec default value and
in case the painter has no params, it returns None."""
vs_painter_params = self.painter().parameters
if not vs_painter_params:
if not (vs_painter_params := self.painter().parameters):
return None

if self._painter_params is None:
return vs_painter_params.default_value()

return self._painter_params
return self._painter_params if self._painter_params else vs_painter_params.default_value()

def title(self, use_short: bool = True) -> str:
if self._custom_title:
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/cmk/gui/plugins/views/test_painters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1719,7 +1719,7 @@ def _painter_name_spec(painter_ident):
return painter_ident, {"uuid": "e13957f5-1b0b-43a7-a452-3bff7187542e"}
if painter_ident == "svc_metrics_forecast":
return painter_ident, {"uuid": "3c659189-29f3-411a-8456-6a07fdae4d51"}
return painter_ident, None
return painter_ident, {}


def _set_expected_queries(painter_ident, live):
Expand Down

0 comments on commit efb1a85

Please sign in to comment.