diff --git a/cmk/gui/wato/_notification_parameter/_ms_teams.py b/cmk/gui/wato/_notification_parameter/_ms_teams.py
index a86c93abe27..76d33aeb1ef 100644
--- a/cmk/gui/wato/_notification_parameter/_ms_teams.py
+++ b/cmk/gui/wato/_notification_parameter/_ms_teams.py
@@ -4,6 +4,8 @@
# conditions defined in the file COPYING, which is part of this source code package.
+from typing import cast
+
from cmk.utils.ms_teams_constants import (
ms_teams_tmpl_host_details,
ms_teams_tmpl_host_summary,
@@ -13,21 +15,32 @@
ms_teams_tmpl_svc_title,
)
-from cmk.gui.i18n import _
-from cmk.gui.valuespec import (
- CascadingDropdown,
+from cmk.gui.form_specs.private import SingleChoiceElementExtended, SingleChoiceExtended
+from cmk.gui.form_specs.vue.visitors.recomposers.unknown_form_spec import recompose
+from cmk.gui.valuespec import Dictionary as ValueSpecDictionary
+from cmk.gui.watolib.password_store import passwordstore_choices_without_user
+
+from cmk.rulesets.v1 import Help, Label, Message, Title
+from cmk.rulesets.v1.form_specs import (
+ CascadingSingleChoice,
+ CascadingSingleChoiceElement,
+ DefaultValue,
+ DictElement,
Dictionary,
- DropdownChoice,
+ FieldSize,
FixedValue,
- HTTPUrl,
- TextAreaUnicode,
- TextInput,
+ migrate_to_proxy,
+ MultilineText,
+ Proxy,
+ String,
)
-from cmk.gui.wato import HTTPProxyReference
-from cmk.gui.watolib.password_store import passwordstore_choices
+from cmk.rulesets.v1.form_specs.validators import LengthInRange
from ._base import NotificationParameter
-from ._helpers import get_url_prefix_specs, local_site_url, notification_macro_help
+from ._helpers import (
+ _get_url_prefix_setting,
+ notification_macro_help_fs,
+)
class NotificationParameterMsTeams(NotificationParameter):
@@ -36,107 +49,107 @@ def ident(self) -> str:
return "msteams"
@property
- def spec(self) -> Dictionary:
+ def spec(self) -> ValueSpecDictionary:
+ # TODO needed because of mixed Form Spec and old style setup
+ return cast(ValueSpecDictionary, recompose(self._form_spec()).valuespec)
+
+ def _form_spec(self):
return Dictionary(
- title=_("Create notification with the following parameters"),
- elements=[
- (
- "webhook_url",
- CascadingDropdown(
- title=_("Webhook URL"),
- help=_(
+ title=Title("Create notification with the following parameters"),
+ elements={
+ "webhook_url": DictElement(
+ parameter_form=CascadingSingleChoice(
+ title=Title("Webhook URL"),
+ help_text=Help(
"Create a workflow 'Post to a channel when a "
"webhook request is received' for a channel in MS "
"Teams and use the generated webook URL.
"
"This URL can also be collected from the Password "
"Store from Checkmk."
),
- choices=[
- (
- "webhook_url",
- _("Webhook URL"),
- HTTPUrl(size=80, allow_empty=False),
+ elements=[
+ CascadingSingleChoiceElement(
+ name="webhook_url",
+ title=Title("Webhook URL"),
+ parameter_form=String(custom_validate=[LengthInRange(min_value=1)]),
),
- (
- "store",
- _("URL from password store"),
- DropdownChoice(
- sorted=True,
- choices=passwordstore_choices,
+ CascadingSingleChoiceElement(
+ name="store",
+ title=Title("URL from password store"),
+ parameter_form=SingleChoiceExtended(
+ no_elements_text=Message(
+ "There are no elements defined for this selection yet."
+ ),
+ elements=[
+ SingleChoiceElementExtended(
+ title=Title("%s") % title, name=ident
+ )
+ for ident, title in passwordstore_choices_without_user()
+ if ident is not None
+ ],
+ type=str,
),
),
],
- sorted=False,
),
),
- ("proxy_url", HTTPProxyReference()),
- ("url_prefix", get_url_prefix_specs(local_site_url)),
- (
- "host_title",
- TextInput(
- title=_("Title for host notifications"),
- help=notification_macro_help(),
- default_value=ms_teams_tmpl_host_title(),
- size=64,
+ "proxy_url": DictElement(parameter_form=Proxy(migrate=migrate_to_proxy)),
+ "url_prefix": _get_url_prefix_setting(),
+ "host_title": DictElement(
+ parameter_form=String(
+ title=Title("Title for host notifications"),
+ help_text=notification_macro_help_fs(),
+ prefill=DefaultValue(ms_teams_tmpl_host_title()),
+ field_size=FieldSize.LARGE,
),
),
- (
- "service_title",
- TextInput(
- title=_("Title for service notifications"),
- help=notification_macro_help(),
- default_value=ms_teams_tmpl_svc_title(),
- size=64,
+ "service_title": DictElement(
+ parameter_form=String(
+ title=Title("Title for service notifications"),
+ help_text=notification_macro_help_fs(),
+ prefill=DefaultValue(ms_teams_tmpl_svc_title()),
+ field_size=FieldSize.LARGE,
),
),
- (
- "host_summary",
- TextInput(
- title=_("Summary for host notifications"),
- help=notification_macro_help(),
- default_value=ms_teams_tmpl_host_summary(),
- size=64,
+ "host_summary": DictElement(
+ parameter_form=String(
+ title=Title("Summary for host notifications"),
+ help_text=notification_macro_help_fs(),
+ prefill=DefaultValue(ms_teams_tmpl_host_summary()),
+ field_size=FieldSize.LARGE,
),
),
- (
- "service_summary",
- TextInput(
- title=_("Summary for service notifications"),
- help=notification_macro_help(),
- default_value=ms_teams_tmpl_svc_summary(),
- size=64,
+ "service_summary": DictElement(
+ parameter_form=String(
+ title=Title("Summary for service notifications"),
+ help_text=notification_macro_help_fs(),
+ prefill=DefaultValue(ms_teams_tmpl_svc_summary()),
+ field_size=FieldSize.LARGE,
),
),
- (
- "host_details",
- TextAreaUnicode(
- title=_("Details for host notifications"),
- help=notification_macro_help(),
- rows=9,
- cols=58,
+ "host_details": DictElement(
+ parameter_form=MultilineText(
+ title=Title("Details for host notifications"),
+ help_text=notification_macro_help_fs(),
monospaced=True,
- default_value=ms_teams_tmpl_host_details(),
+ prefill=DefaultValue(ms_teams_tmpl_host_details()),
),
),
- (
- "service_details",
- TextAreaUnicode(
- title=_("Details for service notifications"),
- help=notification_macro_help(),
- rows=11,
- cols=58,
+ "service_details": DictElement(
+ parameter_form=MultilineText(
+ title=Title("Details for service notifications"),
+ help_text=notification_macro_help_fs(),
monospaced=True,
- default_value=ms_teams_tmpl_svc_details(),
+ prefill=DefaultValue(ms_teams_tmpl_svc_details()),
),
),
- (
- "affected_host_groups",
- FixedValue(
+ "affected_host_groups": DictElement(
+ parameter_form=FixedValue(
value=True,
- title=_("Show affected host groups"),
- totext=_("Show affected host groups"),
- help=_("Show affected host groups in the created message."),
+ title=Title("Show affected host groups"),
+ label=Label("Show affected host groups"),
+ help_text=Help("Show affected host groups in the created message."),
),
),
- ],
+ },
)