From 47bc23497b958a47ddd6b356950aeaa3019ee67a Mon Sep 17 00:00:00 2001 From: scottybollinger Date: Mon, 7 Dec 2020 17:57:57 -0600 Subject: [PATCH] Add EuiButtonEmptyTo components This PR adds another wrapper component for internal routing, the EuiButtonEmptyTo component. --- .../eui_components.test.tsx | 10 +++++++-- .../react_router_helpers/eui_components.tsx | 22 ++++++++++++++++++- .../shared/react_router_helpers/index.ts | 2 +- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/react_router_helpers/eui_components.test.tsx b/x-pack/plugins/enterprise_search/public/applications/shared/react_router_helpers/eui_components.test.tsx index 37784fbf4ffb5..712c3056b808e 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/react_router_helpers/eui_components.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/shared/react_router_helpers/eui_components.test.tsx @@ -8,11 +8,11 @@ import '../../__mocks__/kea.mock'; import React from 'react'; import { shallow, mount } from 'enzyme'; -import { EuiLink, EuiButton, EuiPanel } from '@elastic/eui'; +import { EuiLink, EuiButton, EuiButtonEmpty, EuiPanel } from '@elastic/eui'; import { mockKibanaValues, mockHistory } from '../../__mocks__'; -import { EuiLinkTo, EuiButtonTo, EuiPanelTo } from './eui_components'; +import { EuiLinkTo, EuiButtonTo, EuiButtonEmptyTo, EuiPanelTo } from './eui_components'; describe('EUI & React Router Component Helpers', () => { beforeEach(() => { @@ -31,6 +31,12 @@ describe('EUI & React Router Component Helpers', () => { expect(wrapper.find(EuiButton)).toHaveLength(1); }); + it('renders an EuiButtonEmpty', () => { + const wrapper = shallow(); + + expect(wrapper.find(EuiButtonEmpty)).toHaveLength(1); + }); + it('renders an EuiPanel', () => { const wrapper = shallow(); diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/react_router_helpers/eui_components.tsx b/x-pack/plugins/enterprise_search/public/applications/shared/react_router_helpers/eui_components.tsx index 56beed8780707..fea59acdb0cc2 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/react_router_helpers/eui_components.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/shared/react_router_helpers/eui_components.tsx @@ -6,7 +6,15 @@ import React from 'react'; import { useValues } from 'kea'; -import { EuiLink, EuiButton, EuiButtonProps, EuiLinkAnchorProps, EuiPanel } from '@elastic/eui'; +import { + EuiLink, + EuiButton, + EuiButtonEmpty, + EuiButtonEmptyProps, + EuiButtonProps, + EuiLinkAnchorProps, + EuiPanel, +} from '@elastic/eui'; import { EuiPanelProps } from '@elastic/eui/src/components/panel/panel'; import { KibanaLogic } from '../kibana'; @@ -83,6 +91,18 @@ export const EuiButtonTo: React.FC = ({ ); +type ReactRouterEuiButtonEmptyProps = ReactRouterProps & EuiButtonEmptyProps; +export const EuiButtonEmptyTo: React.FC = ({ + to, + onClick, + shouldNotCreateHref, + ...rest +}) => ( + + + +); + type ReactRouterEuiPanelProps = ReactRouterProps & EuiPanelProps; export const EuiPanelTo: React.FC = ({ to, diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/react_router_helpers/index.ts b/x-pack/plugins/enterprise_search/public/applications/shared/react_router_helpers/index.ts index 05a9450e4a348..2cf2ca3c2e816 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/react_router_helpers/index.ts +++ b/x-pack/plugins/enterprise_search/public/applications/shared/react_router_helpers/index.ts @@ -6,4 +6,4 @@ export { letBrowserHandleEvent } from './link_events'; export { createHref, CreateHrefOptions } from './create_href'; -export { EuiLinkTo, EuiButtonTo, EuiPanelTo } from './eui_components'; +export { EuiLinkTo, EuiButtonTo, EuiButtonEmptyTo, EuiPanelTo } from './eui_components';