def _migrate_all_visuals_topics(self, topics: Dict):
        topic_created_for: Set[UserId] = set()

        # Views
        topic_created_for.update(
            self._migrate_visuals_topics(topics,
                                         visual_type="views",
                                         all_visuals=get_all_views()))

        # Dashboards
        topic_created_for.update(
            self._migrate_visuals_topics(topics,
                                         visual_type="dashboards",
                                         all_visuals=get_all_dashboards()))

        # Reports
        try:
            import cmk.gui.cee.reporting as reporting  # pylint: disable=cmk-module-layer-violation
        except ImportError:
            reporting = None  # type: ignore[assignment]

        if reporting:
            reporting.load_reports()
            topic_created_for.update(
                self._migrate_visuals_topics(topics,
                                             visual_type="reports",
                                             all_visuals=reporting.reports))

        return topic_created_for
Exemple #2
0
def get_view_menu_items(include_reports: bool) -> List[TopicMenuTopic]:
    # The page types that are implementing the PageRenderer API should also be
    # part of the menu. Bring them into a visual like structure to make it easy to
    # integrate them.
    page_type_items: List[Tuple[str, Tuple[str, Visual]]] = []
    for page_type in pagetypes.all_page_types().values():
        if not issubclass(page_type, pagetypes.PageRenderer):
            continue

        for page in page_type.pages():
            if page._show_in_sidebar():
                visual = page.internal_representation().copy()
                visual[
                    "hidden"] = False  # Is currently to configurable for pagetypes
                visual[
                    "icon"] = None  # Is currently to configurable for pagetypes

                page_type_items.append(
                    (page_type.type_name(), (page.name(), visual)))

    # Apply some view specific filters
    views_to_show = [
        (name, view) for name, view in views.get_permitted_views().items()
        if (not active_config.visible_views or name in active_config.
            visible_views) and (not active_config.hidden_views
                                or name not in active_config.hidden_views)
    ]

    network_topology_visual_spec = ParentChildTopologyPage.visual_spec()
    pages_to_show = [(network_topology_visual_spec["name"],
                      network_topology_visual_spec)]

    visuals_to_show = [("views", e) for e in views_to_show]
    visuals_to_show += [("dashboards", e)
                        for e in dashboard.get_permitted_dashboards().items()]
    visuals_to_show += [("pages", e) for e in pages_to_show]
    visuals_to_show += page_type_items

    if reporting and include_reports:
        reporting.load_reports()
        visuals_to_show += [("reports", e)
                            for e in reporting.permitted_reports().items()]

    return make_topic_menu(visuals_to_show)