mirror of
https://github.com/grafana/grafana.git
synced 2025-08-03 05:08:36 +08:00
Alerting: Hide labels section if we only have private labels (#105996)
This commit is contained in:
@ -24,6 +24,7 @@ import { grantPermissionsHelper } from '../../test/test-utils';
|
||||
import { setupDataSources } from '../../testSetup/datasources';
|
||||
import { Annotation } from '../../utils/constants';
|
||||
import { DataSourceType } from '../../utils/datasource';
|
||||
import { GRAFANA_ORIGIN_LABEL } from '../../utils/labels';
|
||||
import * as ruleId from '../../utils/rule-id';
|
||||
import { stringifyIdentifier } from '../../utils/rule-id';
|
||||
|
||||
@ -286,6 +287,19 @@ describe('RuleViewer', () => {
|
||||
expect(versionSummary).toHaveTextContent(/Version 5 updated by alerting/i);
|
||||
expect(versionSummary).toHaveTextContent(/Version 6 updated by provisioning/i);
|
||||
});
|
||||
|
||||
it('should not show any labels if we only have private labels', async () => {
|
||||
const ruleIdentifier = ruleId.fromCombinedRule('grafana', mockRule);
|
||||
const rule = getGrafanaRule({
|
||||
name: 'Test alert',
|
||||
labels: {
|
||||
[GRAFANA_ORIGIN_LABEL]: 'plugins/synthetic-monitoring-app',
|
||||
},
|
||||
});
|
||||
|
||||
await renderRuleViewer(rule, ruleIdentifier);
|
||||
expect(screen.queryByText('Labels')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { css } from '@emotion/css';
|
||||
import { chain, isEmpty, truncate } from 'lodash';
|
||||
import { chain, truncate } from 'lodash';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useMeasure } from 'react-use';
|
||||
|
||||
@ -40,6 +40,7 @@ import { useReturnTo } from '../../hooks/useReturnTo';
|
||||
import { PluginOriginBadge } from '../../plugins/PluginOriginBadge';
|
||||
import { Annotation } from '../../utils/constants';
|
||||
import { ruleIdentifierToRuleSourceIdentifier } from '../../utils/datasource';
|
||||
import { labelsSize } from '../../utils/labels';
|
||||
import { makeDashboardLink, makePanelLink, stringifyErrorLike } from '../../utils/misc';
|
||||
import { createListFilterLink } from '../../utils/navigation';
|
||||
import {
|
||||
@ -188,7 +189,7 @@ const createMetadata = (rule: CombinedRule): PageInfoItem[] => {
|
||||
|
||||
const hasDashboardAndPanel = dashboardUID && panelID;
|
||||
const hasDashboard = dashboardUID;
|
||||
const hasLabels = !isEmpty(labels);
|
||||
const hasLabels = labelsSize(labels) > 0;
|
||||
|
||||
const interval = group.interval;
|
||||
const styles = useStyles2(getStyles);
|
||||
|
Reference in New Issue
Block a user