Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { css } from '@emotion/css';
import React from 'react';
import React, {useMemo} from 'react';

import { GrafanaTheme2 } from '@grafana/data';
import { LinkButton, useStyles2 } from '@grafana/ui';
Expand Down Expand Up @@ -27,6 +27,15 @@ export const AlertDetails = ({ alert, alertManagerSourceName }: AmNotificationsA
const isSeeSourceButtonEnabled = isGrafanaSource
? contextSrv.hasPermission(AccessControlAction.AlertingRuleRead)
: true;
// LOGZ.IO CHANGE :: DEV-46517 - fix "see source button"
const generatorURL = useMemo(() => {
if (alert.generatorURL) {
const url = new URL(alert.generatorURL);
return url.hash.replace(/^#.dashboard.metrics/, '/grafana-app');
}
return '';
}, [alert.generatorURL]);
// LOGZ.IO CHANGE :: DEV-46517 - fix "see source button" end

return (
<>
Expand Down Expand Up @@ -58,8 +67,8 @@ export const AlertDetails = ({ alert, alertManagerSourceName }: AmNotificationsA
</LinkButton>
</Authorize>
)}
{isSeeSourceButtonEnabled && alert.generatorURL && (
<LinkButton className={styles.button} href={alert.generatorURL} icon={'chart-line'} size={'sm'}>
{isSeeSourceButtonEnabled && generatorURL && ( /* LOGZ.IO CHANGE :: DEV-46517 - fix "see source button" */
<LinkButton className={styles.button} href={generatorURL} icon={'chart-line'} size={'sm'}>
See source
</LinkButton>
)}
Expand Down
16 changes: 8 additions & 8 deletions public/app/plugins/panel/alertGroups/AlertGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ export const AlertGroup = ({ alertManagerSourceName, group, expandAll }: Props)
start: new Date(alert.startsAt),
end: Date.now(),
});

// LOGZ.IO CHANGE :: DEV-46517 - fix "see source button"
if (alert.generatorURL) {
const generatorURL = alert.generatorURL ? (() => {
const url = new URL(alert.generatorURL);
alert.generatorURL = url.hash.replace(/^#/, '/grafana-app');
}
return url.hash.replace(/^#.dashboard.metrics/, '/grafana-app');
})() : null;
// LOGZ.IO CHANGE :: DEV-46517 - fix "see source button" end

return (
<div data-testid={'alert-group-alert'} className={styles.alert} key={`${alert.fingerprint}-${index}`}>
<div>
Expand Down Expand Up @@ -82,9 +82,9 @@ export const AlertGroup = ({ alertManagerSourceName, group, expandAll }: Props)
Silence
</LinkButton>
)}
{ /* LOGZ.IO CHANGE :: DEV-46517 - add link target to _top */ }
{alert.generatorURL && (
<LinkButton target="_top" className={styles.button} href={alert.generatorURL} icon={'chart-line'} size={'sm'}>
{ /* LOGZ.IO CHANGE :: DEV-46517 - patch the link url to work inside iframe */ }
{generatorURL && (
<LinkButton className={styles.button} href={generatorURL} icon={'chart-line'} size={'sm'}>
See source
</LinkButton>
)}
Expand Down