Skip to content

Commit

Permalink
Add components for name, description and tags
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitaindik committed Sep 16, 2024
1 parent f029f80 commit 6483996
Show file tree
Hide file tree
Showing 8 changed files with 226 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ interface TagsProps {
tags: string[];
}

const Tags = ({ tags }: TagsProps) => (
export const Tags = ({ tags }: TagsProps) => (
<BadgeList badges={tags} data-test-subj="tagsPropertyValue" />
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import { ThreatReadOnly } from './fields/threat/threat';
import { ThreatIndexReadOnly } from './fields/threat_index/threat_index';
import { ThreatIndicatorPathReadOnly } from './fields/threat_indicator_path/threat_indicator_path';
import { ThreatQueryReadOnly } from './fields/threat_query/threat_query';
import { NameReadOnly } from './fields/name/name';
import { TagsReadOnly } from './fields/tags/tags';
import { DescriptionReadOnly } from './fields/description/description';

interface FieldReadOnlyProps {
fieldName: keyof DiffableAllFields;
Expand All @@ -31,6 +34,8 @@ export function FieldReadOnly({ fieldName, finalDiffableRule }: FieldReadOnlyPro
switch (fieldName) {
case 'data_source':
return <DataSourceReadOnly dataSource={finalDiffableRule.data_source} />;
case 'description':
return <DescriptionReadOnly description={finalDiffableRule.description} />;
case 'eql_query':
return (
<EqlQueryReadOnly
Expand All @@ -54,6 +59,8 @@ export function FieldReadOnly({ fieldName, finalDiffableRule }: FieldReadOnlyPro
machineLearningJobId={finalDiffableRule.machine_learning_job_id}
/>
);
case 'name':
return <NameReadOnly name={finalDiffableRule.name} />;
case 'related_integrations':
return (
<RelatedIntegrationsReadOnly relatedIntegrations={finalDiffableRule.related_integrations} />
Expand All @@ -64,6 +71,8 @@ export function FieldReadOnly({ fieldName, finalDiffableRule }: FieldReadOnlyPro
return <RiskScoreMappingReadOnly riskScoreMapping={finalDiffableRule.risk_score_mapping} />;
case 'severity_mapping':
return <SeverityMappingReadOnly severityMapping={finalDiffableRule.severity_mapping} />;
case 'tags':
return <TagsReadOnly tags={finalDiffableRule.tags} />;
case 'threat':
return <ThreatReadOnly threat={finalDiffableRule.threat} />;
case 'threat_index':
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import React from 'react';
import type { Story } from '@storybook/react';
import { DescriptionReadOnly } from './description';
import { FieldReadOnly } from '../../field_readonly';
import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine';

export default {
component: DescriptionReadOnly,
title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FieldReadOnly/description',
};

interface TemplateProps {
finalDiffableRule: Partial<DiffableAllFields>;
}

const Template: Story<TemplateProps> = (args) => {
return (
<FieldReadOnly
fieldName="description"
finalDiffableRule={args.finalDiffableRule as DiffableAllFields}
/>
);
};

export const Default = Template.bind({});

Default.args = {
finalDiffableRule: {
description:
"Identifies the occurrence of a security alert from the Google Workspace alerts center. Google Workspace's security alert center provides an overview of actionable alerts that may be affecting an organization's domain. An alert is a warning of a potential security issue that Google has detected.",
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import React from 'react';
import { EuiDescriptionList } from '@elastic/eui';
import * as ruleDetailsI18n from '../../../../translations';
import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine';

interface RuleDescriptionProps {
description: DiffableAllFields['name'];
}

function RuleDescription({ description }: RuleDescriptionProps) {
return <>{description}</>;
}

interface DescriptionReadOnlyProps {
description: DiffableAllFields['description'];
}

export function DescriptionReadOnly({ description }: DescriptionReadOnlyProps) {
return (
<EuiDescriptionList
listItems={[
{
title: ruleDetailsI18n.DESCRIPTION_FIELD_LABEL,
description: <RuleDescription description={description} />,
},
]}
/>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import React from 'react';
import type { Story } from '@storybook/react';
import { NameReadOnly } from './name';
import { FieldReadOnly } from '../../field_readonly';
import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine';

export default {
component: NameReadOnly,
title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FieldReadOnly/name',
};

interface TemplateProps {
finalDiffableRule: Partial<DiffableAllFields>;
}

const Template: Story<TemplateProps> = (args) => {
return (
<FieldReadOnly
fieldName="name"
finalDiffableRule={args.finalDiffableRule as DiffableAllFields}
/>
);
};

export const Default = Template.bind({});

Default.args = {
finalDiffableRule: {
name: 'Forwarded Google Workspace Security Alert',
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import React from 'react';
import { EuiDescriptionList } from '@elastic/eui';
import * as ruleDetailsI18n from '../../../../translations';
import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine';

interface RuleNameProps {
name: DiffableAllFields['name'];
}

function RuleName({ name }: RuleNameProps) {
return <>{name}</>;
}

interface NameReadOnlyProps {
name: DiffableAllFields['name'];
}

export function NameReadOnly({ name }: NameReadOnlyProps) {
return (
<EuiDescriptionList
listItems={[
{
title: ruleDetailsI18n.NAME_FIELD_LABEL,
description: <RuleName name={name} />,
},
]}
/>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import React from 'react';
import type { Story } from '@storybook/react';
import { TagsReadOnly } from './tags';
import { FieldReadOnly } from '../../field_readonly';
import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine';

export default {
component: TagsReadOnly,
title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FieldReadOnly/tags',
};

interface TemplateProps {
finalDiffableRule: Partial<DiffableAllFields>;
}

const Template: Story<TemplateProps> = (args) => {
return (
<FieldReadOnly
fieldName="tags"
finalDiffableRule={args.finalDiffableRule as DiffableAllFields}
/>
);
};

export const Default = Template.bind({});

Default.args = {
finalDiffableRule: {
tags: ['Elastic', 'Cloud', 'Google Workspace', 'Log Auditing', 'Threat Detection'],
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import React from 'react';
import { EuiDescriptionList } from '@elastic/eui';
import * as ruleDetailsI18n from '../../../../translations';
import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine';
import { Tags } from '../../../../rule_about_section';

interface TagsReadOnlyProps {
tags: DiffableAllFields['tags'];
}

export function TagsReadOnly({ tags }: TagsReadOnlyProps) {
return (
<EuiDescriptionList
listItems={[
{
title: ruleDetailsI18n.TAGS_FIELD_LABEL,
description: <Tags tags={tags} />,
},
]}
/>
);
}

0 comments on commit 6483996

Please sign in to comment.