Module: check_mk
Branch: master
Commit: 9734ef3c93f31af42d8540144e54dbe7a32a93bd
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9734ef3c93f31a…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Feb 27 14:44:19 2019 +0100
7189 Bookmark lists: Individual topics per bookmark can now be choosen from predefined
topics
The individual topics that are defined in an existing bookmark list can now be choosen
from
a dropdown field when creating new bookmark entries with individual topic.
CMK-1754
Change-Id: I378af578e8de3402bf712aa0f6bb21e7e771a9bc
---
.werks/7189 | 11 +++++++++++
cmk/gui/plugins/sidebar/bookmarks.py | 29 +++++++++++++++++++++++++----
2 files changed, 36 insertions(+), 4 deletions(-)
diff --git a/.werks/7189 b/.werks/7189
new file mode 100644
index 0000000..a8a300c
--- /dev/null
+++ b/.werks/7189
@@ -0,0 +1,11 @@
+Title: Bookmark lists: Individual topics per bookmark can now be choosen from predefined
topics
+Level: 1
+Component: multisite
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1551274970
+Class: feature
+
+The individual topics that are defined in an existing bookmark list can now be choosen
from
+a dropdown field when creating new bookmark entries with individual topic.
diff --git a/cmk/gui/plugins/sidebar/bookmarks.py b/cmk/gui/plugins/sidebar/bookmarks.py
index 454fa5e..7b8cace 100644
--- a/cmk/gui/plugins/sidebar/bookmarks.py
+++ b/cmk/gui/plugins/sidebar/bookmarks.py
@@ -42,6 +42,7 @@ from cmk.gui.valuespec import (
IconSelector,
Alternative,
FixedValue,
+ OptionalDropdownChoice,
)
from . import (
@@ -135,24 +136,44 @@ class BookmarkList(pagetypes.Overridable):
@classmethod
def _vs_topic(cls):
+ choices = cls._topic_choices()
+
return Alternative(
elements=[
FixedValue(
None,
title=_("Use default topic"),
- totext=_("(default topic)"),
+ totext=_(""),
),
- TextUnicode(
+ OptionalDropdownChoice(
title=_("Individual topic"),
- size=30,
- allow_empty=False,
+ choices=choices,
+ default_value=choices[0][0] if choices else "",
+ explicit=TextUnicode(
+ size=30,
+ allow_empty=False,
+ ),
+ otherlabel="%s" % _("Add new topic"),
),
],
title=_("Topic") + "<sup>*</sup>",
style="dropdown",
+ orientation="horizontal",
)
@classmethod
+ def _topic_choices(cls):
+ topics = set()
+ for instance in cls.instances_sorted():
+ if (instance.is_mine() and instance.may_see()) or \
+ (not instance.is_mine() and instance.is_public() and instance.may_see()):
+ for topic, _bookmarks in instance.bookmarks_by_topic():
+ if topic is None:
+ topic = instance.default_bookmark_topic()
+ topics.add(topic)
+ return [(t, t) for t in sorted(list(topics))]
+
+ @classmethod
def validate_url(cls, value, varprefix):
parsed = urlparse.urlparse(value)