mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* add FGAC actions for silences table * redirect users without permissions * add permissions checks to routes * add fgac to notifications and contact points * fgac for notification policies * fix mute timing authorization * use consistent naming for checking grafana alertmanager * tests for fgac in contact points and notification policies * bump up timeout on rule editor test * use new permissions util * break out route evaluation into util * Remove test timeout * Change permissions for the alert-notifiers endpoint * Use signed in handler for alert-notifiers when unified alerting enabled Co-authored-by: Konrad Lalik <konrad.lalik@grafana.com>
48 lines
1.9 KiB
TypeScript
48 lines
1.9 KiB
TypeScript
import { css } from '@emotion/css';
|
|
import { GrafanaTheme2 } from '@grafana/data';
|
|
import { Alert, LinkButton, useStyles2 } from '@grafana/ui';
|
|
import { AlertManagerCortexConfig } from 'app/plugins/datasource/alertmanager/types';
|
|
import { AccessControlAction } from 'app/types';
|
|
import React, { FC } from 'react';
|
|
import { GRAFANA_RULES_SOURCE_NAME, isVanillaPrometheusAlertManagerDataSource } from '../../utils/datasource';
|
|
import { makeAMLink } from '../../utils/misc';
|
|
import { Authorize } from '../Authorize';
|
|
import { ReceiversTable } from './ReceiversTable';
|
|
import { TemplatesTable } from './TemplatesTable';
|
|
|
|
interface Props {
|
|
config: AlertManagerCortexConfig;
|
|
alertManagerName: string;
|
|
}
|
|
|
|
export const ReceiversAndTemplatesView: FC<Props> = ({ config, alertManagerName }) => {
|
|
const isCloud = alertManagerName !== GRAFANA_RULES_SOURCE_NAME;
|
|
const styles = useStyles2(getStyles);
|
|
const isVanillaAM = isVanillaPrometheusAlertManagerDataSource(alertManagerName);
|
|
return (
|
|
<>
|
|
{!isVanillaAM && <TemplatesTable config={config} alertManagerName={alertManagerName} />}
|
|
<ReceiversTable config={config} alertManagerName={alertManagerName} />
|
|
{isCloud && (
|
|
<Authorize actions={[AccessControlAction.AlertingNotificationsExternalWrite]}>
|
|
<Alert className={styles.section} severity="info" title="Global config for contact points">
|
|
<p>
|
|
For each external Alertmanager you can define global settings, like server addresses, usernames and
|
|
password, for all the supported contact points.
|
|
</p>
|
|
<LinkButton href={makeAMLink('alerting/notifications/global-config', alertManagerName)} variant="secondary">
|
|
{isVanillaAM ? 'View global config' : 'Edit global config'}
|
|
</LinkButton>
|
|
</Alert>
|
|
</Authorize>
|
|
)}
|
|
</>
|
|
);
|
|
};
|
|
|
|
const getStyles = (theme: GrafanaTheme2) => ({
|
|
section: css`
|
|
margin-top: ${theme.spacing(4)};
|
|
`,
|
|
});
|