Alerting: Update tooltip message when routing preview is disabled (#113962)

* update tooltip message

* generate translations

* update translations
This commit is contained in:
Lauren
2025-11-14 16:37:08 +00:00
committed by GitHub
parent b70c6a726f
commit ef61b67e66
2 changed files with 22 additions and 15 deletions
@@ -36,7 +36,7 @@ export const NotificationPreview = ({
alertUid,
}: NotificationPreviewProps) => {
const styles = useStyles2(getStyles);
const disabled = !condition || !folder;
const previewRoutingDisabled = !condition || !folder;
const [trigger, { data = [], isLoading, isUninitialized: previewUninitialized }] = preview.useMutation();
@@ -51,7 +51,7 @@ export const NotificationPreview = ({
}, []);
const onPreview = () => {
if (!folder || !condition) {
if (previewRoutingDisabled) {
return;
}
@@ -67,7 +67,7 @@ export const NotificationPreview = ({
};
useEffectOnce(() => {
if (!disabled) {
if (!previewRoutingDisabled) {
onPreview();
}
});
@@ -76,6 +76,22 @@ export const NotificationPreview = ({
const alertManagerDataSources = useGetAlertManagerDataSourcesByPermissionAndConfig('notification');
const singleAlertManagerConfigured = alertManagerDataSources.length === 1;
const getTooltipContent = () => {
if (!folder) {
return (
<Trans i18nKey="alerting.notification-preview.select-folder-tooltip">Select a folder to preview routing</Trans>
);
}
if (previewRoutingDisabled) {
return (
<Trans i18nKey="alerting.notification-preview.disabled-tooltip">
You don&apos;t have sufficient permissions to preview
</Trans>
);
}
return '';
};
return (
<Stack direction="column">
<Stack direction="row" alignItems="flex-start" justifyContent="space-between">
@@ -104,18 +120,8 @@ export const NotificationPreview = ({
</Text>
)}
</Stack>
<Tooltip
content={
disabled ? (
<Trans i18nKey="alerting.notification-preview.disabled-tooltip">
You don&apos;t have sufficient permissions to preview
</Trans>
) : (
''
)
}
>
<Button icon="sync" variant="secondary" type="button" onClick={onPreview} disabled={disabled}>
<Tooltip content={getTooltipContent()}>
<Button icon="sync" variant="secondary" type="button" onClick={onPreview} disabled={previewRoutingDisabled}>
<Trans i18nKey="alerting.notification-preview.preview-routing">Preview routing</Trans>
</Button>
</Tooltip>
+1
View File
@@ -1986,6 +1986,7 @@
"error": "Could not load routing preview for {{alertmanager}}",
"initialized": "Based on the labels added, alert instances are routed to the following notification policies. Expand each notification policy below to view more details.",
"preview-routing": "Preview routing",
"select-folder-tooltip": "Select a folder to preview routing",
"text-loading-preview": "Loading preview...",
"title": "Alert instance routing preview",
"uninitialized": "When you have your folder selected and your query and labels are configured, click \"Preview routing\" to see the results here."