Skip to content

Commit

Permalink
quick_setup: fix aws recap message
Browse files Browse the repository at this point in the history
Change-Id: Ia662d3e02f69903cf2cd7df6871d9323883ba6b8
JIRA-Ref: CMK-20967
  • Loading branch information
ottermata committed Jan 16, 2025
1 parent f9872d1 commit 3c8218f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 23 deletions.
51 changes: 34 additions & 17 deletions cmk/gui/quick_setup/config_setups/aws/stages.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# conditions defined in the file COPYING, which is part of this source code package.

from collections.abc import Mapping, Sequence
from typing import Callable

from cmk.ccc.i18n import _

Expand Down Expand Up @@ -46,7 +47,7 @@
Text,
Widget,
)
from cmk.gui.utils.urls import makeuri_contextless
from cmk.gui.utils.urls import doc_reference_url, DocReference, makeuri_contextless

from cmk.rulesets.v1 import Title
from cmk.rulesets.v1.form_specs import Dictionary
Expand Down Expand Up @@ -209,6 +210,34 @@ def configure_services_to_monitor() -> QuickSetupStage:
)


class _EC2RecapMessage:
@staticmethod
def _cre_message() -> str:
return _(
"Hosts for EC2 instances need to be created manually, please check the %s."
) % HTMLWriter.render_a(
_("documentation"),
href=doc_reference_url(DocReference.AWS_EC2),
)

message: Callable[[], str] = _cre_message


ec2_recap_message = _EC2RecapMessage()


def _save_and_activate_recap(title: str, parsed_data: ParsedFormData) -> Sequence[Widget]:
message = _("Save your progress and go to the Activate Changes page to enable it.")
if "ec2" in parsed_data.get(FormSpecId("configure_services_to_monitor"), {}).get(
"services", []
):
message += " " + ec2_recap_message.message()
return [
Text(text=title),
Text(text=message),
]


def recap_found_services(
_quick_setup_id: QuickSetupId,
_stage_index: StageIndex,
Expand All @@ -226,14 +255,7 @@ def recap_found_services(
service_discovery_result=service_discovery_result,
)
if len(filtered_groups_of_services[aws_service_interest]):
return [
Text(text=_("AWS services found!")),
Text(
text=_(
"Save your progress and go to the Activate Changes page to enable it. EC2 instances may take a few minutes to show up."
)
),
]
return _save_and_activate_recap(_("AWS services found!"), parsed_data)
return [
Text(text=_("No AWS services found.")),
Text(
Expand Down Expand Up @@ -264,14 +286,9 @@ def review_and_run_preview_service_discovery() -> QuickSetupStage:
id=ActionId("skip_configuration_test"),
custom_validators=[],
recap=[
lambda __, ___, ____: [
Text(text=_("Skipped the configuration test.")),
Text(
text=_(
"Save your progress and go to the Activate Changes page to enable it."
)
),
]
lambda __, ___, parsed_data: _save_and_activate_recap(
_("Skipped the configuration test."), parsed_data
)
],
next_button_label=_("Skip test"),
),
Expand Down
1 change: 1 addition & 0 deletions cmk/gui/utils/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ class DocReference(Enum):
ANALYZE_CONFIG = "analyze_configuration"
ANALYZE_NOTIFICATIONS = "notifications#_rule_evaluation_by_the_notification_module"
AWS = "monitoring_aws"
AWS_EC2 = "monitoring_aws#_manually_creating_hosts_for_ec2_instances"
AZURE = "monitoring_azure"
BACKUPS = "backup"
BI = "bi" # Business Intelligence
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ This file is part of Checkmk (https://checkmk.com). It is subject to the terms a
conditions defined in the file COPYING, which is part of this source code package.
-->
<script setup lang="ts">
import CmkHtml from '@/components/CmkHtml.vue'
import ToolTip from '@/quick-setup/components/ToolTip.vue'

import { type TextWidgetProps } from './widget_types'
Expand All @@ -12,16 +13,20 @@ defineProps<TextWidgetProps>()
</script>

<template>
<span class="qs-text-widget"
>{{ text }}
<ToolTip v-if="tooltip"
><p>{{ tooltip }}</p></ToolTip
></span
>
<span class="qs-text-widget">
<CmkHtml :html="text" />
<ToolTip v-if="tooltip">
<p>{{ tooltip }}</p>
</ToolTip>
</span>
</template>

<style scoped>
.qs-text-widget {
margin-bottom: var(--spacing);

::v-deep(a) {
pointer-events: all;
}
}
</style>

0 comments on commit 3c8218f

Please sign in to comment.