Skip to content

Commit

Permalink
Add rule type to table
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathonherbert committed Nov 5, 2024
1 parent 6f475da commit 8456b2e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
8 changes: 6 additions & 2 deletions apps/rule-manager/client/src/ts/components/RuleContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@ export const ruleTypeOptions: RuleTypeOption[] = [
id: 'regex',
label: 'Regex',
},
{
id: 'dictionary',
label: 'Dictionary',
},
{
id: 'languageToolXML',
label: 'LanguageTool',
},
{
id: 'dictionary',
label: 'Dictionary',
id: 'languageToolCore',
label: 'LT built-in',
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export type BaseRule = {
updatedBy: string;
updatedAt: string;
id?: number;
externalId?: string;
isArchived: boolean;
isPublished: boolean;
hasUnpublishedChanges: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { TagsContext } from '../context/tags';
import { EuiDataGridToolBarVisibilityOptions } from '@elastic/eui/src/components/datagrid/data_grid_types';
import { useEuiFontSize } from '@elastic/eui/src/global_styling/mixins/_typography';
import { useNavigate } from 'react-router-dom';
import { ruleTypeOptions } from '../RuleContent';

type EditRuleButtonProps = {
editIsEnabled: boolean;
Expand Down Expand Up @@ -121,6 +122,12 @@ const TestRule = ({
};

const columns: EuiDataGridColumn[] = [
{
id: 'ruleType',
display: 'Rule type',
isSortable: true,
initialWidth: 120,
},
{
id: 'description',
display: 'Description',
Expand Down Expand Up @@ -338,7 +345,15 @@ export const PaginatedRulesTable = ({
if (!rule || isLoading) {
return <EuiSkeletonText />;
}
return getRuleAtRowIndex(rowIndex)[columnId as keyof BaseRule] || '';

const value =
getRuleAtRowIndex(rowIndex)[columnId as keyof BaseRule] || '';

if (columnId === 'ruleType') {
return ruleTypeOptions.find(({ id }) => id === value)?.label ?? '';
}

return value;
},
[ruleData, isLoading],
);
Expand Down

0 comments on commit 8456b2e

Please sign in to comment.