Skip to content

Commit

Permalink
Purge another edition condition
Browse files Browse the repository at this point in the history
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
  • Loading branch information
LarsMichelsen committed Sep 26, 2024
1 parent 17f79be commit 72d2b2a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
7 changes: 1 addition & 6 deletions cmk/gui/visuals/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand Down
11 changes: 2 additions & 9 deletions cmk/gui/visuals/_add_to_visual.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()):
Expand Down

0 comments on commit 72d2b2a

Please sign in to comment.