mirror of
https://github.com/grafana/grafana.git
synced 2026-07-29 15:59:50 -05:00
Alerting: Improve incident button (#61372)
This commit is contained in:
@@ -1,39 +1,38 @@
|
||||
import React, { FC } from 'react';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
import { Button, Tooltip } from '@grafana/ui';
|
||||
import { Button, LinkButton, Tooltip } from '@grafana/ui';
|
||||
|
||||
import { createBridgeURL, usePluginBridge, SupportedPlugin } from '../PluginBridge';
|
||||
|
||||
interface Props {
|
||||
title?: string;
|
||||
severity?: 'minor' | 'major' | 'critical';
|
||||
url?: string;
|
||||
}
|
||||
|
||||
export const DeclareIncident: FC<Props> = ({ title = '', severity = '' }) => {
|
||||
const history = useHistory();
|
||||
const bridgeURL = createBridgeURL(SupportedPlugin.Incident, '/incidents/declare', { title, severity });
|
||||
export const DeclareIncident: FC<Props> = ({ title = '', severity = '', url = '' }) => {
|
||||
const bridgeURL = createBridgeURL(SupportedPlugin.Incident, '/incidents/declare', { title, severity, url });
|
||||
|
||||
const { loading, installed, settings } = usePluginBridge(SupportedPlugin.Incident);
|
||||
|
||||
return (
|
||||
<>
|
||||
{loading === true && (
|
||||
<Button size="sm" type="button" disabled>
|
||||
<Button icon="fire" size="sm" type="button" disabled>
|
||||
Declare Incident
|
||||
</Button>
|
||||
)}
|
||||
{installed === false && (
|
||||
<Tooltip content={'Grafana Incident is not installed or is not configured correctly'}>
|
||||
<Button size="sm" type="button" disabled>
|
||||
<Button icon="fire" size="sm" type="button" disabled>
|
||||
Declare Incident
|
||||
</Button>
|
||||
</Tooltip>
|
||||
)}
|
||||
{settings && (
|
||||
<Button size="sm" type="button" onClick={() => history.push(bridgeURL)}>
|
||||
<LinkButton icon="fire" size="sm" type="button" href={bridgeURL}>
|
||||
Declare Incident
|
||||
</Button>
|
||||
</LinkButton>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -172,7 +172,7 @@ export const RuleDetailsActionButtons: FC<Props> = ({ rule, rulesSource, isViewM
|
||||
if (isFiringRule) {
|
||||
buttons.push(
|
||||
<Fragment key="declare-incident">
|
||||
<DeclareIncident title={rule.name} />
|
||||
<DeclareIncident title={rule.name} url={buildShareUrl()} />
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user