Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution][Exceptions] - Remove initial add exception item button in builder #72215

Merged
merged 2 commits into from
Jul 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,12 @@ addDecorator((storyFn) => (
));

storiesOf('Components|Exceptions|BuilderButtonOptions', module)
.add('init button', () => {
return (
<BuilderButtonOptions
isAndDisabled={false}
isOrDisabled={false}
showNestedButton={false}
displayInitButton
onOrClicked={action('onClick')}
onAndClicked={action('onClick')}
onNestedClicked={action('onClick')}
/>
);
})
.add('and/or buttons', () => {
return (
<BuilderButtonOptions
isAndDisabled={false}
isOrDisabled={false}
showNestedButton={false}
displayInitButton={false}
onOrClicked={action('onClick')}
onAndClicked={action('onClick')}
onNestedClicked={action('onClick')}
Expand All @@ -48,7 +34,6 @@ storiesOf('Components|Exceptions|BuilderButtonOptions', module)
isAndDisabled={false}
isOrDisabled={false}
showNestedButton
displayInitButton={false}
onOrClicked={action('onClick')}
onAndClicked={action('onClick')}
onNestedClicked={action('onClick')}
Expand All @@ -61,7 +46,6 @@ storiesOf('Components|Exceptions|BuilderButtonOptions', module)
isAndDisabled
isOrDisabled={false}
showNestedButton={false}
displayInitButton={false}
onOrClicked={action('onClick')}
onAndClicked={action('onClick')}
onNestedClicked={action('onClick')}
Expand All @@ -74,7 +58,6 @@ storiesOf('Components|Exceptions|BuilderButtonOptions', module)
isAndDisabled={false}
isOrDisabled
showNestedButton={false}
displayInitButton={false}
onOrClicked={action('onClick')}
onAndClicked={action('onClick')}
onNestedClicked={action('onClick')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ describe('BuilderButtonOptions', () => {
isAndDisabled={false}
isOrDisabled={false}
showNestedButton={false}
displayInitButton={false}
onOrClicked={jest.fn()}
onAndClicked={jest.fn()}
onNestedClicked={jest.fn()}
Expand All @@ -31,44 +30,6 @@ describe('BuilderButtonOptions', () => {
expect(wrapper.find('[data-test-subj="exceptionsNestedButton"] button')).toHaveLength(0);
});

test('it renders "add exception" button if "displayInitButton" is true', () => {
const wrapper = mount(
<BuilderButtonOptions
isAndDisabled={false}
isOrDisabled={false}
showNestedButton={false}
displayInitButton
onOrClicked={jest.fn()}
onAndClicked={jest.fn()}
onNestedClicked={jest.fn()}
/>
);

expect(wrapper.find('[data-test-subj="exceptionsAddNewExceptionButton"] button')).toHaveLength(
1
);
});

test('it invokes "onAddExceptionClicked" when "add exception" button is clicked', () => {
const onOrClicked = jest.fn();

const wrapper = mount(
<BuilderButtonOptions
isAndDisabled={false}
isOrDisabled={false}
showNestedButton={false}
displayInitButton
onOrClicked={onOrClicked}
onAndClicked={jest.fn()}
onNestedClicked={jest.fn()}
/>
);

wrapper.find('[data-test-subj="exceptionsAddNewExceptionButton"] button').simulate('click');

expect(onOrClicked).toHaveBeenCalledTimes(1);
});

test('it invokes "onOrClicked" when "or" button is clicked', () => {
const onOrClicked = jest.fn();

Expand All @@ -77,7 +38,6 @@ describe('BuilderButtonOptions', () => {
isAndDisabled={false}
isOrDisabled={false}
showNestedButton={false}
displayInitButton={false}
onOrClicked={onOrClicked}
onAndClicked={jest.fn()}
onNestedClicked={jest.fn()}
Expand All @@ -97,7 +57,6 @@ describe('BuilderButtonOptions', () => {
isAndDisabled={false}
isOrDisabled={false}
showNestedButton={false}
displayInitButton={false}
onOrClicked={jest.fn()}
onAndClicked={onAndClicked}
onNestedClicked={jest.fn()}
Expand All @@ -113,7 +72,6 @@ describe('BuilderButtonOptions', () => {
const wrapper = mount(
<BuilderButtonOptions
showNestedButton={false}
displayInitButton={false}
isOrDisabled={false}
isAndDisabled
onOrClicked={jest.fn()}
Expand All @@ -131,7 +89,6 @@ describe('BuilderButtonOptions', () => {
const wrapper = mount(
<BuilderButtonOptions
showNestedButton={false}
displayInitButton={false}
isOrDisabled
isAndDisabled={false}
onOrClicked={jest.fn()}
Expand All @@ -153,7 +110,6 @@ describe('BuilderButtonOptions', () => {
isAndDisabled={false}
isOrDisabled={false}
showNestedButton
displayInitButton={false}
onOrClicked={jest.fn()}
onAndClicked={jest.fn()}
onNestedClicked={onNestedClicked}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const MyEuiButton = styled(EuiButton)`
interface BuilderButtonOptionsProps {
isOrDisabled: boolean;
isAndDisabled: boolean;
displayInitButton: boolean;
showNestedButton: boolean;
onAndClicked: () => void;
onOrClicked: () => void;
Expand All @@ -26,64 +25,47 @@ interface BuilderButtonOptionsProps {
export const BuilderButtonOptions: React.FC<BuilderButtonOptionsProps> = ({
isOrDisabled = false,
isAndDisabled = false,
displayInitButton,
showNestedButton = false,
onAndClicked,
onOrClicked,
onNestedClicked,
}) => (
<EuiFlexGroup gutterSize="s" alignItems="center">
{displayInitButton ? (
<EuiFlexItem grow={false}>
<MyEuiButton
fill
size="s"
iconType="plusInCircle"
onClick={onAndClicked}
data-test-subj="exceptionsAndButton"
isDisabled={isAndDisabled}
>
{i18n.AND}
</MyEuiButton>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<MyEuiButton
fill
size="s"
iconType="plusInCircle"
onClick={onOrClicked}
isDisabled={isOrDisabled}
data-test-subj="exceptionsOrButton"
>
{i18n.OR}
</MyEuiButton>
</EuiFlexItem>
{showNestedButton && (
<EuiFlexItem grow={false}>
<EuiButton
fill
size="s"
iconType="plusInCircle"
onClick={onOrClicked}
data-test-subj="exceptionsAddNewExceptionButton"
iconType="nested"
onClick={onNestedClicked}
data-test-subj="exceptionsNestedButton"
>
{i18n.ADD_EXCEPTION_TITLE}
{i18n.ADD_NESTED_DESCRIPTION}
</EuiButton>
</EuiFlexItem>
) : (
<>
<EuiFlexItem grow={false}>
<MyEuiButton
fill
size="s"
iconType="plusInCircle"
onClick={onAndClicked}
data-test-subj="exceptionsAndButton"
isDisabled={isAndDisabled}
>
{i18n.AND}
</MyEuiButton>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<MyEuiButton
fill
size="s"
iconType="plusInCircle"
onClick={onOrClicked}
isDisabled={isOrDisabled}
data-test-subj="exceptionsOrButton"
>
{i18n.OR}
</MyEuiButton>
</EuiFlexItem>
{showNestedButton && (
<EuiFlexItem grow={false}>
<EuiButton
size="s"
iconType="nested"
onClick={onNestedClicked}
data-test-subj="exceptionsNestedButton"
>
{i18n.ADD_NESTED_DESCRIPTION}
</EuiButton>
</EuiFlexItem>
)}
</>
)}
</EuiFlexGroup>
);
Loading