Module: check_mk
Branch: master
Commit: d87a4174f3f36bb112b45b3e7d273fe06ff5fe70
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d87a4174f3f36b…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Dec 6 15:10:25 2018 +0100
Improved handling of locked attributes
The attribute locking (which was introduced with the commit
66eab3c7d01f803b433376640e9348a2b03971a1) has been reworked a bit.
* The single attribute has been split into two dependent attributes
"locked_by" and "locked_attributes" to be able to search for only
the "locked_by" value.
* The attributes are now displayed with their title instead of the internal ID
* Totally hide disabled checkboxes for the locked attributes instead
of displaying them without functionality. This is now equal to
the user attribute locking.
* Each connection of the dynamic configuration now links to a list of
hosts that are managed by this connection. This is done using the
existing host search logic.
Change-Id: I5f3de560377b7654824c8fb6b74c4ba2cc75dd86
---
cmk/gui/plugins/wato/builtin_attributes.py | 57 ++++++++++++++++++------------
cmk/gui/plugins/wato/utils/__init__.py | 7 ++--
web/htdocs/check_mk.css | 4 +++
3 files changed, 44 insertions(+), 24 deletions(-)
diff --git a/cmk/gui/plugins/wato/builtin_attributes.py
b/cmk/gui/plugins/wato/builtin_attributes.py
index ec2f31b..a6d3794 100644
--- a/cmk/gui/plugins/wato/builtin_attributes.py
+++ b/cmk/gui/plugins/wato/builtin_attributes.py
@@ -51,6 +51,7 @@ from cmk.gui.valuespec import (
TextUnicode,
SiteChoice,
ID,
+ Transform,
)
from cmk.gui.exceptions import MKUserError
@@ -581,28 +582,40 @@ declare_host_attribute(
declare_host_attribute(
ValueSpecAttribute(
- "locked",
- Dictionary(
- title=_("Locked"),
- help=_("The host is (partially) managed by an automatic data source like
the "
- "Dynamic Configuration."),
- elements=[
- ("locked_by",
- Tuple(
- orientation="horizontal",
- title_br=False,
- elements=[
- SiteChoice(),
- ID(title=_("Program"),),
- ID(title=_("Connection ID"),),
- ],
- title=_("Locked by"),
- )),
- ("attributes", ListOf(
- ID(),
- title=_("Locked attributes"),
- )),
- ],
+ "locked_by",
+ Transform(
+ Tuple(
+ orientation="horizontal",
+ title_br=False,
+ elements=[
+ SiteChoice(),
+ ID(title=_("Program"),),
+ ID(title=_("Connection ID"),),
+ ],
+ title=_("Locked by"),
+ help=_("The host is (partially) managed by an automatic data source
like the "
+ "Dynamic Configuration."),
+ ),
+ forth=tuple,
+ back=list,
+ )),
+ show_in_table=False,
+ show_in_form=True,
+ show_in_folder=True,
+ show_in_host_search=True,
+ show_inherited_value=False,
+ editable=False,
+)
+
+declare_host_attribute(
+ ValueSpecAttribute(
+ "locked_attributes",
+ ListOf(
+ DropdownChoice(
+ choices=lambda: [(a.name(), a.title()) for a in
watolib.g_host_attribute.values()],
+ sorted=True,
+ ),
+ title=_("Locked attributes"),
)),
show_in_table=False,
show_in_form=True,
diff --git a/cmk/gui/plugins/wato/utils/__init__.py
b/cmk/gui/plugins/wato/utils/__init__.py
index 8a30fba..5dfeab2 100644
--- a/cmk/gui/plugins/wato/utils/__init__.py
+++ b/cmk/gui/plugins/wato/utils/__init__.py
@@ -1660,8 +1660,9 @@ def configure_attributes(new,
if not host:
continue
- locked = host.attribute("locked")
- if locked and attrname in locked["attributes"]:
+ locked_by = host.attribute("locked_by")
+ locked_attributes = host.attribute("locked_attributes")
+ if locked_by and locked_attributes and attrname in locked_attributes:
num_have_locked_it += 1
if host.has_explicit_attribute(attrname):
@@ -1759,6 +1760,8 @@ def configure_attributes(new,
active = False
is_editable = attr.editable() and attr.may_edit() and num_have_locked_it ==
0
+ if for_what == "host_search":
+ is_editable = True
if not new and not is_editable:
# Bug in pylint 1.9.2
https://github.com/PyCQA/pylint/issues/1984,
already fixed in master.
diff --git a/web/htdocs/check_mk.css b/web/htdocs/check_mk.css
index 33589c5..7849e74 100644
--- a/web/htdocs/check_mk.css
+++ b/web/htdocs/check_mk.css
@@ -134,6 +134,10 @@ input[type="checkbox"] {
display: none;
}
+input[type="checkbox"][disabled] + label:before {
+ display: none;
+}
+
input[type="checkbox"] + label:before {
box-shadow: 0.1px 1.0px 1.2px 0 #888 inset;
border: 1px #73767A solid;