The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
grafana/public/app/features/alerting/unified/components/silences/SilencedAlertsTable.tsx

73 lines
1.9 KiB

import { css, cx } from '@emotion/css';
import React from 'react';
import { GrafanaTheme2 } from '@grafana/data';
import { useStyles2 } from '@grafana/ui';
Alerting: Add RBAC logic for silences creation (#87322) * Remove role requirement for editing silence (instead handled by silence editor displaying error) * Send query params for metadata/access control silence logic * Add new access control types to enum * Add folder-specific checks for silences * Remove filtering in alert manager picker * fix flakey rule viewer test and update permissions helper * Use `returnTo` in rule viewer page * Fix incorrect display of duration * Clean up some mock server behaviour in rule details tests * Tweak styles for silences alerts table * Remove alertmanager picker from silences drawer * Add error if user cannot edit a silence * Show alert rule name in silences table and consume RBAC logic * Update mocks to include RBAC access control logic * Update silences tests * Update silences type to include access control info * Update comment for missing alertmanager * Update mock handlers and query param logic * Tweak query params again * Update access control mock * Revert AM picker fix as user may not have access to Grafana AM * Swap ternary order * Change text for no alert rule targeted * Don't show error alert from RTKQ query and remove alert instance preview in case of error * Add missing translations * Fix test adding missing mock for getting alert rule * Add missing translations in SilencesTable * Add translations autogenerated files * fix allowing edit silence in external alert manager --------- Co-authored-by: Sonia Aguilar <soniaaguilarpeiron@gmail.com> Co-authored-by: Yuri Tseretyan <yuriy.tseretyan@grafana.com>
12 months ago
import { Trans } from 'app/core/internationalization';
import { AlertmanagerAlert } from 'app/plugins/datasource/alertmanager/types';
import { getAlertTableStyles } from '../../styles/table';
import { SilencedAlertsTableRow } from './SilencedAlertsTableRow';
interface Props {
silencedAlerts: AlertmanagerAlert[];
}
const SilencedAlertsTable = ({ silencedAlerts }: Props) => {
const tableStyles = useStyles2(getAlertTableStyles);
const styles = useStyles2(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} />
</colgroup>
<thead>
<tr>
<th></th>
Alerting: Add RBAC logic for silences creation (#87322) * Remove role requirement for editing silence (instead handled by silence editor displaying error) * Send query params for metadata/access control silence logic * Add new access control types to enum * Add folder-specific checks for silences * Remove filtering in alert manager picker * fix flakey rule viewer test and update permissions helper * Use `returnTo` in rule viewer page * Fix incorrect display of duration * Clean up some mock server behaviour in rule details tests * Tweak styles for silences alerts table * Remove alertmanager picker from silences drawer * Add error if user cannot edit a silence * Show alert rule name in silences table and consume RBAC logic * Update mocks to include RBAC access control logic * Update silences tests * Update silences type to include access control info * Update comment for missing alertmanager * Update mock handlers and query param logic * Tweak query params again * Update access control mock * Revert AM picker fix as user may not have access to Grafana AM * Swap ternary order * Change text for no alert rule targeted * Don't show error alert from RTKQ query and remove alert instance preview in case of error * Add missing translations * Fix test adding missing mock for getting alert rule * Add missing translations in SilencesTable * Add translations autogenerated files * fix allowing edit silence in external alert manager --------- Co-authored-by: Sonia Aguilar <soniaaguilarpeiron@gmail.com> Co-authored-by: Yuri Tseretyan <yuriy.tseretyan@grafana.com>
12 months ago
<th>
<Trans i18nKey="silences-table.header.state">State</Trans>
</th>
<th></th>
Alerting: Add RBAC logic for silences creation (#87322) * Remove role requirement for editing silence (instead handled by silence editor displaying error) * Send query params for metadata/access control silence logic * Add new access control types to enum * Add folder-specific checks for silences * Remove filtering in alert manager picker * fix flakey rule viewer test and update permissions helper * Use `returnTo` in rule viewer page * Fix incorrect display of duration * Clean up some mock server behaviour in rule details tests * Tweak styles for silences alerts table * Remove alertmanager picker from silences drawer * Add error if user cannot edit a silence * Show alert rule name in silences table and consume RBAC logic * Update mocks to include RBAC access control logic * Update silences tests * Update silences type to include access control info * Update comment for missing alertmanager * Update mock handlers and query param logic * Tweak query params again * Update access control mock * Revert AM picker fix as user may not have access to Grafana AM * Swap ternary order * Change text for no alert rule targeted * Don't show error alert from RTKQ query and remove alert instance preview in case of error * Add missing translations * Fix test adding missing mock for getting alert rule * Add missing translations in SilencesTable * Add translations autogenerated files * fix allowing edit silence in external alert manager --------- Co-authored-by: Sonia Aguilar <soniaaguilarpeiron@gmail.com> Co-authored-by: Yuri Tseretyan <yuriy.tseretyan@grafana.com>
12 months ago
<th>
<Trans i18nKey="silences-table.header.alert-name">Alert name</Trans>
</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: GrafanaTheme2) => ({
tableMargin: css({
marginBottom: theme.spacing(1),
}),
colState: css({
width: '110px',
}),
colName: css({
width: '65%',
}),
});
export default SilencedAlertsTable;