From 72d2b2a4e359be2e54520aecf986179ece2e8053 Mon Sep 17 00:00:00 2001 From: Lars Michelsen Date: Thu, 26 Sep 2024 14:19:50 +0200 Subject: [PATCH] Purge another edition condition By moving the code to the right place. The auto completer is reporting specific, so it should be part of the reporting feature. Change-Id: Ic9a4a7ee465d3d780eece3a85437b65f690627e8 --- cmk/gui/visuals/__init__.py | 7 +------ cmk/gui/visuals/_add_to_visual.py | 11 ++--------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/cmk/gui/visuals/__init__.py b/cmk/gui/visuals/__init__.py index d741e4c64d2..5c70d12c426 100644 --- a/cmk/gui/visuals/__init__.py +++ b/cmk/gui/visuals/__init__.py @@ -5,7 +5,6 @@ from collections.abc import Callable -import cmk.ccc.version as cmk_version from cmk.ccc import store from cmk.utils import paths @@ -18,10 +17,10 @@ from . import _filters, _site_filters, info from ._add_to_visual import ( add_to_dashboard_choices_autocompleter, - add_to_report_choices_autocompleter, ajax_add_visual, ajax_popup_add, ) +from ._add_to_visual import get_visual_choices as get_visual_choices from ._add_to_visual import page_menu_dropdown_add_to_visual as page_menu_dropdown_add_to_visual from ._add_to_visual import page_menu_topic_add_to as page_menu_topic_add_to from ._add_to_visual import set_page_context as set_page_context @@ -119,10 +118,6 @@ def register( autocompleter_registry.register_autocompleter( "add_to_dashboard_choices", add_to_dashboard_choices_autocompleter ) - if cmk_version.edition(paths.omd_root) is not cmk_version.Edition.CRE: - autocompleter_registry.register_autocompleter( - "add_to_report_choices", add_to_report_choices_autocompleter - ) hooks.register_builtin("snapshot-pushed", invalidate_all_caches) hooks.register_builtin( diff --git a/cmk/gui/visuals/_add_to_visual.py b/cmk/gui/visuals/_add_to_visual.py index 65f666a05ff..166170514e7 100644 --- a/cmk/gui/visuals/_add_to_visual.py +++ b/cmk/gui/visuals/_add_to_visual.py @@ -212,20 +212,13 @@ def page_menu_topic_add_to(visual_type: str, name: str, source_type: str) -> lis def add_to_dashboard_choices_autocompleter(value: str, params: dict) -> Choices: - return _get_visual_choices( + return get_visual_choices( visual_type="dashboards", value=value, ) -def add_to_report_choices_autocompleter(value: str, params: dict) -> Choices: - return _get_visual_choices( - visual_type="reports", - value=value, - ) - - -def _get_visual_choices(visual_type: str, value: str) -> Choices: +def get_visual_choices(visual_type: str, value: str) -> Choices: match_pattern = re.compile(value, re.IGNORECASE) matching_visuals = [] for name, content in sorted(visual_type_registry[f"{visual_type}"]().permitted_visuals.items()):