Skip to content

Commit

Permalink
fixed correct highlight of LegacyValuespec errors
Browse files Browse the repository at this point in the history
Change-Id: If0dceb1d220e2b1940ebaf57b3ee659d4fd7423d
  • Loading branch information
schnetzzz committed Nov 7, 2023
1 parent 15fd22f commit 51ab0f1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
12 changes: 9 additions & 3 deletions cmk/gui/validation/ir/valuespec_to_ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def valuespec_integer(valuespec_instance: valuespec.Integer) -> compiler.Integer
from cmk.gui import valuespec
from cmk.gui.validation.ir import elements
from cmk.gui.validation.ir.elements import DictionaryKeySpec, LegacyValueSpecDetails
from cmk.gui.validation.visitors.vue_lib import GenericComponent

Stack = list[str]
T = typing.TypeVar("T")
Expand Down Expand Up @@ -129,9 +130,14 @@ def get_validator(vs_instance: valuespec.ValueSpec | None) -> list[elements.Vali
if vs_instance is None:
return None

def validator(value: typing.Any, _all_values: typing.Any) -> None:
vs_instance.validate_datatype(value, varprefix="")
vs_instance.validate_value(value, varprefix="")
def validator(value: typing.Any, component: GenericComponent) -> None:
# This code does not belong here. GenericComponent is part of vue
# valuespec_to_ir.py is part of FormElement
# Since elements.py/valuespec_to_ir.py are currently part of a major restructuring
# -> I do not care
varprefix = component.config.get("varprefix", "")
vs_instance.validate_datatype(value, varprefix=varprefix)
vs_instance.validate_value(value, varprefix=varprefix)

return [validator]

Expand Down
5 changes: 3 additions & 2 deletions cmk/gui/wato/pages/global_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,9 @@ def page(self) -> None:
if use_vue_rendering():
forms.section(_("Current setting as VUE"))
render_vue(self._valuespec, self._vue_field_id(), value)

forms.section(_("Current setting"))
forms.section(_("Legacy valuespec (input data is ignored)"))
else:
forms.section(_("Current setting"))
self._valuespec.render_input("ve", value)
self._valuespec.set_focus("ve")
html.help(self._valuespec.help())
Expand Down
1 change: 1 addition & 0 deletions cmk/gui/wato/pages/rulesets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1981,6 +1981,7 @@ def page(self) -> None:
if use_vue_rendering():
forms.section(_("Current setting as VUE"))
render_vue(self._ruleset.valuespec(), self._vue_field_id(), self._rule.value)
forms.section(_("Legacy valuespec (input data is ignored"))

valuespec.validate_datatype(self._rule.value, "ve")
valuespec.render_input("ve", self._rule.value)
Expand Down

0 comments on commit 51ab0f1

Please sign in to comment.