Files
grafana/public/app/features/alerting/unified/components/silences/SilencedAlertsTable.tsx
Nathan Rodman 1913d304a3 Alerting: Add silences table (#33138)
* Create table for silences

* Style table to figma designs

* Add rules table to silences

* Rebase with new rules table

* Remove redundant reducer

* fetch alertmanager alerts (#33142)

* fetch alertmanager alerts

* show the alerts json

* Use matching alerts from alertmanager api

* Add handle to expire silence

* Get silenced alerts closer to figma designs

* fix expire silence endpoint typo

* Style affected alerts table

* Add default empty string for alertmanager source

Co-authored-by: Domas <domasx2@gmail.com>
2021-04-27 13:46:34 -07:00

67 lines
1.7 KiB
TypeScript

import { AlertmanagerAlert } from 'app/plugins/datasource/alertmanager/types';
import React, { FC } from 'react';
import { getAlertTableStyles } from '../../styles/table';
import { useStyles } from '@grafana/ui';
import { SilencedAlertsTableRow } from './SilencedAlertsTableRow';
import { GrafanaTheme } from '@grafana/data';
import { css, cx } from '@emotion/css';
interface Props {
silencedAlerts: AlertmanagerAlert[];
}
const SilencedAlertsTable: FC<Props> = ({ silencedAlerts }) => {
const tableStyles = useStyles(getAlertTableStyles);
const styles = useStyles(getStyles);
if (!!silencedAlerts.length) {
return (
<table className={cx(tableStyles.table, styles.tableMargin)}>
<colgroup>
<col className={tableStyles.colExpand} />
<col className={styles.colState} />
<col />
<col className={styles.colName} />
<col />
</colgroup>
<thead>
<tr>
<th></th>
<th>State</th>
<th></th>
<th>Alert name</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{silencedAlerts.map((alert, index) => {
return (
<SilencedAlertsTableRow
key={alert.fingerprint}
alert={alert}
className={index % 2 === 0 ? tableStyles.evenRow : ''}
/>
);
})}
</tbody>
</table>
);
} else {
return null;
}
};
const getStyles = (theme: GrafanaTheme) => ({
tableMargin: css`
margin-bottom: ${theme.spacing.sm};
`,
colState: css`
width: 110px;
`,
colName: css`
width: 65%;
`,
});
export default SilencedAlertsTable;