forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SIEM][Detections Engine] - Exceptions viewer cleanup (elastic#68651) (…
…elastic#68755) ### Summary This PR is a follow up to elastic#68027 where some feedback didn't make it in. It cleans up the and_or_badge component, updates some css, and cleans up stories.
- Loading branch information
Showing
18 changed files
with
371 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...ck/plugins/security_solution/public/common/components/and_or_badge/rounded_badge.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { ThemeProvider } from 'styled-components'; | ||
import { mount } from 'enzyme'; | ||
import euiLightVars from '@elastic/eui/dist/eui_theme_light.json'; | ||
|
||
import { RoundedBadge } from './rounded_badge'; | ||
|
||
describe('RoundedBadge', () => { | ||
test('it renders "and" when "type" is "and"', () => { | ||
const wrapper = mount( | ||
<ThemeProvider theme={() => ({ eui: euiLightVars, darkMode: false })}> | ||
<RoundedBadge type="and" /> | ||
</ThemeProvider> | ||
); | ||
|
||
expect(wrapper.find('[data-test-subj="and-or-badge"]').at(0).text()).toEqual('AND'); | ||
}); | ||
|
||
test('it renders "or" when "type" is "or"', () => { | ||
const wrapper = mount( | ||
<ThemeProvider theme={() => ({ eui: euiLightVars, darkMode: false })}> | ||
<RoundedBadge type="or" /> | ||
</ThemeProvider> | ||
); | ||
|
||
expect(wrapper.find('[data-test-subj="and-or-badge"]').at(0).text()).toEqual('OR'); | ||
}); | ||
}); |
42 changes: 42 additions & 0 deletions
42
x-pack/plugins/security_solution/public/common/components/and_or_badge/rounded_badge.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { EuiBadge } from '@elastic/eui'; | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
import * as i18n from './translations'; | ||
import { AndOr } from '.'; | ||
|
||
const RoundBadge = (styled(EuiBadge)` | ||
align-items: center; | ||
border-radius: 100%; | ||
display: inline-flex; | ||
font-size: 9px; | ||
height: 34px; | ||
justify-content: center; | ||
margin: 0 5px 0 5px; | ||
padding: 7px 6px 4px 6px; | ||
user-select: none; | ||
width: 34px; | ||
.euiBadge__content { | ||
position: relative; | ||
top: -1px; | ||
} | ||
.euiBadge__text { | ||
text-overflow: clip; | ||
} | ||
` as unknown) as typeof EuiBadge; | ||
|
||
RoundBadge.displayName = 'RoundBadge'; | ||
|
||
export const RoundedBadge: React.FC<{ type: AndOr }> = ({ type }) => ( | ||
<RoundBadge data-test-subj="and-or-badge" color="hollow"> | ||
{type === 'and' ? i18n.AND : i18n.OR} | ||
</RoundBadge> | ||
); | ||
|
||
RoundedBadge.displayName = 'RoundedBadge'; |
46 changes: 46 additions & 0 deletions
46
...ns/security_solution/public/common/components/and_or_badge/rounded_badge_antenna.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { ThemeProvider } from 'styled-components'; | ||
import { mount } from 'enzyme'; | ||
import euiLightVars from '@elastic/eui/dist/eui_theme_light.json'; | ||
|
||
import { RoundedBadgeAntenna } from './rounded_badge_antenna'; | ||
|
||
describe('RoundedBadgeAntenna', () => { | ||
test('it renders top and bottom antenna bars', () => { | ||
const wrapper = mount( | ||
<ThemeProvider theme={() => ({ eui: euiLightVars, darkMode: false })}> | ||
<RoundedBadgeAntenna type="and" /> | ||
</ThemeProvider> | ||
); | ||
|
||
expect(wrapper.find('[data-test-subj="and-or-badge"]').at(0).text()).toEqual('AND'); | ||
expect(wrapper.find('[data-test-subj="andOrBadgeBarTop"]').exists()).toBeTruthy(); | ||
expect(wrapper.find('[data-test-subj="andOrBadgeBarBottom"]').exists()).toBeTruthy(); | ||
}); | ||
|
||
test('it renders "and" when "type" is "and"', () => { | ||
const wrapper = mount( | ||
<ThemeProvider theme={() => ({ eui: euiLightVars, darkMode: false })}> | ||
<RoundedBadgeAntenna type="and" /> | ||
</ThemeProvider> | ||
); | ||
|
||
expect(wrapper.find('[data-test-subj="and-or-badge"]').at(0).text()).toEqual('AND'); | ||
}); | ||
|
||
test('it renders "or" when "type" is "or"', () => { | ||
const wrapper = mount( | ||
<ThemeProvider theme={() => ({ eui: euiLightVars, darkMode: false })}> | ||
<RoundedBadgeAntenna type="or" /> | ||
</ThemeProvider> | ||
); | ||
|
||
expect(wrapper.find('[data-test-subj="and-or-badge"]').at(0).text()).toEqual('OR'); | ||
}); | ||
}); |
62 changes: 62 additions & 0 deletions
62
...plugins/security_solution/public/common/components/and_or_badge/rounded_badge_antenna.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; | ||
import React from 'react'; | ||
import styled, { css } from 'styled-components'; | ||
|
||
import { RoundedBadge } from './rounded_badge'; | ||
import { AndOr } from '.'; | ||
|
||
const antennaStyles = css` | ||
background: ${({ theme }) => theme.eui.euiColorLightShade}; | ||
position: relative; | ||
width: 2px; | ||
margin: 0 12px 0 0; | ||
&:after { | ||
background: ${({ theme }) => theme.eui.euiColorLightShade}; | ||
content: ''; | ||
height: 8px; | ||
right: -4px; | ||
position: absolute; | ||
width: 10px; | ||
clip-path: circle(); | ||
} | ||
`; | ||
|
||
const TopAntenna = styled(EuiFlexItem)` | ||
${antennaStyles} | ||
&:after { | ||
top: 0; | ||
} | ||
`; | ||
const BottomAntenna = styled(EuiFlexItem)` | ||
${antennaStyles} | ||
&:after { | ||
bottom: 0; | ||
} | ||
`; | ||
|
||
const EuiFlexItemWrapper = styled(EuiFlexItem)` | ||
margin: 0 12px 0 0; | ||
`; | ||
|
||
export const RoundedBadgeAntenna: React.FC<{ type: AndOr }> = ({ type }) => ( | ||
<EuiFlexGroup | ||
className="andBadgeContainer" | ||
gutterSize="none" | ||
direction="column" | ||
alignItems="center" | ||
> | ||
<TopAntenna data-test-subj="andOrBadgeBarTop" grow={1} /> | ||
<EuiFlexItemWrapper grow={false}> | ||
<RoundedBadge type={type} /> | ||
</EuiFlexItemWrapper> | ||
<BottomAntenna data-test-subj="andOrBadgeBarBottom" grow={1} /> | ||
</EuiFlexGroup> | ||
); | ||
|
||
RoundedBadgeAntenna.displayName = 'RoundedBadgeAntenna'; |
Oops, something went wrong.