mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import React, { FC } from 'react';
|
|
import { useHistory } from 'react-router-dom';
|
|
|
|
import { Button, Tooltip } from '@grafana/ui';
|
|
|
|
import { createBridgeURL, usePluginBridge, SupportedPlugin } from '../PluginBridge';
|
|
|
|
interface Props {
|
|
title?: string;
|
|
severity?: 'minor' | 'major' | 'critical';
|
|
}
|
|
|
|
export const DeclareIncident: FC<Props> = ({ title = '', severity = '' }) => {
|
|
const history = useHistory();
|
|
const bridgeURL = createBridgeURL(SupportedPlugin.Incident, '/incidents/declare', { title, severity });
|
|
|
|
const { loading, installed, settings } = usePluginBridge(SupportedPlugin.Incident);
|
|
|
|
return (
|
|
<>
|
|
{loading === true && (
|
|
<Button 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>
|
|
Declare Incident
|
|
</Button>
|
|
</Tooltip>
|
|
)}
|
|
{settings && (
|
|
<Button size="sm" type="button" onClick={() => history.push(bridgeURL)}>
|
|
Declare Incident
|
|
</Button>
|
|
)}
|
|
</>
|
|
);
|
|
};
|