Skip to content

Commit

Permalink
Use rule type Id instead of rule category to show technical preview b…
Browse files Browse the repository at this point in the history
…adge (#159979)

Uses rule type Id instead of rule category to show technical preview
badge in alert detail pages of `Infra` rules.

Refactoring based on suggestion:
#159862 (comment)
  • Loading branch information
benakansara authored Jun 20, 2023
1 parent bd38b48 commit 45a9274
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
ALERT_DURATION,
ALERT_FLAPPING,
ALERT_RULE_CATEGORY,
ALERT_RULE_TYPE_ID,
ALERT_STATUS_ACTIVE,
ALERT_STATUS_RECOVERED,
TIMESTAMP,
Expand All @@ -45,15 +46,19 @@ export function pageTitleContent(ruleCategory: string) {
});
}

const LOG_DOCUMENT_COUNT_RULE_TYPE_ID = 'logs.alert.document.count';
const METRIC_THRESHOLD_ALERT_TYPE_ID = 'metrics.alert.threshold';
const METRIC_INVENTORY_THRESHOLD_ALERT_TYPE_ID = 'metrics.alert.inventory.threshold';

export function PageTitle({ alert }: PageTitleProps) {
const { euiTheme } = useEuiTheme();

if (!alert) return <EuiLoadingSpinner />;

const showExperimentalBadge =
alert.fields[ALERT_RULE_CATEGORY] === 'Log threshold' ||
alert.fields[ALERT_RULE_CATEGORY] === 'Metric threshold' ||
alert.fields[ALERT_RULE_CATEGORY] === 'Inventory';
alert.fields[ALERT_RULE_TYPE_ID] === LOG_DOCUMENT_COUNT_RULE_TYPE_ID ||
alert.fields[ALERT_RULE_TYPE_ID] === METRIC_THRESHOLD_ALERT_TYPE_ID ||
alert.fields[ALERT_RULE_TYPE_ID] === METRIC_INVENTORY_THRESHOLD_ALERT_TYPE_ID;

return (
<div data-test-subj="page-title-container">
Expand Down

0 comments on commit 45a9274

Please sign in to comment.