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.
Add close button to expression popovers (elastic#61352)
* Add X to trigger expression popovers * Fix jest tests * PR feedback Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
bec4e33
commit d1214f8
Showing
13 changed files
with
138 additions
and
41 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
...gers_actions_ui/public/common/expression_items/components/closable_popover_title.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,30 @@ | ||
/* | ||
* 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 * as React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import { ClosablePopoverTitle } from './closable_popover_title'; | ||
|
||
describe('closable popover title', () => { | ||
it('renders with defined options', () => { | ||
const onClose = jest.fn(); | ||
const children = <div className="foo" />; | ||
const wrapper = mount( | ||
<ClosablePopoverTitle onClose={onClose}>{children}</ClosablePopoverTitle> | ||
); | ||
expect(wrapper.contains(<div className="foo" />)).toBeTruthy(); | ||
}); | ||
|
||
it('onClose function gets called', () => { | ||
const onClose = jest.fn(); | ||
const children = <div className="foo" />; | ||
const wrapper = mount( | ||
<ClosablePopoverTitle onClose={onClose}>{children}</ClosablePopoverTitle> | ||
); | ||
wrapper.find('EuiButtonIcon').simulate('click'); | ||
expect(onClose).toHaveBeenCalled(); | ||
}); | ||
}); |
37 changes: 37 additions & 0 deletions
37
.../triggers_actions_ui/public/common/expression_items/components/closable_popover_title.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,37 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
import { EuiPopoverTitle, EuiFlexGroup, EuiFlexItem, EuiButtonIcon } from '@elastic/eui'; | ||
|
||
interface ClosablePopoverTitleProps { | ||
children: JSX.Element; | ||
onClose: () => void; | ||
} | ||
|
||
export const ClosablePopoverTitle = ({ children, onClose }: ClosablePopoverTitleProps) => { | ||
return ( | ||
<EuiPopoverTitle> | ||
<EuiFlexGroup alignItems="center" gutterSize="s"> | ||
<EuiFlexItem>{children}</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiButtonIcon | ||
iconType="cross" | ||
color="danger" | ||
aria-label={i18n.translate( | ||
'xpack.triggersActionsUI.common.expressionItems.components.closablePopoverTitle.closeLabel', | ||
{ | ||
defaultMessage: 'Close', | ||
} | ||
)} | ||
onClick={() => onClose()} | ||
/> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiPopoverTitle> | ||
); | ||
}; |
7 changes: 7 additions & 0 deletions
7
x-pack/plugins/triggers_actions_ui/public/common/expression_items/components/index.ts
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,7 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export { ClosablePopoverTitle } from './closable_popover_title'; |
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
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
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
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