Skip to content

Commit

Permalink
using badge for severity in rules table
Browse files Browse the repository at this point in the history
Signed-off-by: Amardeepsingh Siglani <[email protected]>
  • Loading branch information
amsiglan committed Sep 5, 2023
1 parent 65af605 commit 754f1dd
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions public/pages/Rules/utils/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { EuiBasicTableColumn, EuiBreadcrumb, EuiLink } from '@elastic/eui';
import { EuiBasicTableColumn, EuiBreadcrumb, EuiLink, EuiBadge } from '@elastic/eui';
import React from 'react';
import { capitalizeFirstLetter, errorNotificationToast } from '../../../utils/helpers';
import { errorNotificationToast } from '../../../utils/helpers';
import { ruleSeverity, ruleSource, ruleTypes } from './constants';
import { Search } from '@opensearch-project/oui/src/eui_components/basic_table';
import { Rule } from '../../../../models/interfaces';
Expand All @@ -14,6 +14,7 @@ import { AUTHOR_REGEX, validateDescription, validateName } from '../../../utils/
import { dump, load } from 'js-yaml';
import { BREADCRUMBS, DEFAULT_EMPTY_DATA } from '../../../utils/constants';
import { RuleItemInfoBase, RulesTableColumnFields } from '../../../../types';
import { getSeverityColor, getSeverityLabel } from '../../Correlations/utils/constants';

export interface RuleTableItem {
title: string;
Expand Down Expand Up @@ -49,7 +50,14 @@ export const getRulesTableColumns = (
sortable: true,
width: '10%',
truncateText: true,
render: (level: string) => capitalizeFirstLetter(level),
render: (level: string) => {
const { text, background } = getSeverityColor(level);
return (
<EuiBadge style={{ color: text }} color={background}>
{getSeverityLabel(level)}
</EuiBadge>
);
},
},
category: {
field: 'category',
Expand Down

0 comments on commit 754f1dd

Please sign in to comment.