Skip to content

Commit 41ce45b

Browse files
committed
Clean up complex/renamed instances of Eui*To
(hopefully much more straightforward now) - unfortunately side_nav requires an eslint disable
1 parent 8d0e730 commit 41ce45b

File tree

6 files changed

+27
-32
lines changed

6 files changed

+27
-32
lines changed

x-pack/plugins/enterprise_search/public/applications/shared/layout/side_nav.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import React from 'react';
1010
import { useLocation } from 'react-router-dom';
1111
import { shallow } from 'enzyme';
1212

13-
import { EuiLink as EuiLinkExternal } from '@elastic/eui';
14-
import { EuiLink } from '../react_router_helpers';
13+
import { EuiLink } from '@elastic/eui';
14+
import { EuiLinkTo } from '../react_router_helpers';
1515
import { ENTERPRISE_SEARCH_PLUGIN, APP_SEARCH_PLUGIN } from '../../../../common/constants';
1616

1717
import { SideNav, SideNavLink, SideNavItem } from './';
@@ -42,7 +42,7 @@ describe('SideNavLink', () => {
4242
const wrapper = shallow(<SideNavLink to="/">Link</SideNavLink>);
4343

4444
expect(wrapper.type()).toEqual('li');
45-
expect(wrapper.find(EuiLink)).toHaveLength(1);
45+
expect(wrapper.find(EuiLinkTo)).toHaveLength(1);
4646
expect(wrapper.find('.enterpriseSearchNavLinks__item')).toHaveLength(1);
4747
});
4848

@@ -52,7 +52,7 @@ describe('SideNavLink', () => {
5252
Link
5353
</SideNavLink>
5454
);
55-
const externalLink = wrapper.find(EuiLinkExternal);
55+
const externalLink = wrapper.find(EuiLink);
5656

5757
expect(externalLink).toHaveLength(1);
5858
expect(externalLink.prop('href')).toEqual('http://website.com');

x-pack/plugins/enterprise_search/public/applications/shared/layout/side_nav.tsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { useLocation } from 'react-router-dom';
99
import classNames from 'classnames';
1010

1111
import { i18n } from '@kbn/i18n';
12-
import { EuiIcon, EuiTitle, EuiText, EuiLink as EuiLinkExternal } from '@elastic/eui'; // TODO: Remove EuiLinkExternal after full Kibana transition
13-
import { EuiLink } from '../react_router_helpers';
12+
import { EuiIcon, EuiTitle, EuiText, EuiLink } from '@elastic/eui'; // TODO: Remove EuiLink after full Kibana transition
13+
import { EuiLinkTo } from '../react_router_helpers';
1414

1515
import { ENTERPRISE_SEARCH_PLUGIN } from '../../../../common/constants';
1616
import { stripTrailingSlash } from '../../../../common/strip_slashes';
@@ -96,19 +96,14 @@ export const SideNavLink: React.FC<SideNavLinkProps> = ({
9696
return (
9797
<li>
9898
{isExternal ? (
99-
<EuiLinkExternal
100-
{...rest}
101-
className={classes}
102-
href={to}
103-
target="_blank"
104-
onClick={closeNavigation}
105-
>
99+
// eslint-disable-next-line @elastic/eui/href-or-on-click
100+
<EuiLink {...rest} className={classes} href={to} target="_blank" onClick={closeNavigation}>
106101
{children}
107-
</EuiLinkExternal>
102+
</EuiLink>
108103
) : (
109-
<EuiLink {...rest} className={classes} to={to} onClick={closeNavigation}>
104+
<EuiLinkTo {...rest} className={classes} to={to} onClick={closeNavigation}>
110105
{children}
111-
</EuiLink>
106+
</EuiLinkTo>
112107
)}
113108
{subNav && <ul className="enterpriseSearchNavLinks__subNav">{subNav}</ul>}
114109
</li>

x-pack/plugins/enterprise_search/public/applications/shared/not_found/not_found.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
EuiTitle,
1414
EuiFlexGroup,
1515
EuiFlexItem,
16-
EuiButton as EuiButtonExternal,
16+
EuiButton,
1717
} from '@elastic/eui';
1818

1919
import {
@@ -22,7 +22,7 @@ import {
2222
LICENSED_SUPPORT_URL,
2323
} from '../../../../common/constants';
2424

25-
import { EuiButton } from '../react_router_helpers';
25+
import { EuiButtonTo } from '../react_router_helpers';
2626
import { SetAppSearchChrome, SetWorkplaceSearchChrome } from '../kibana_chrome';
2727
import { SendAppSearchTelemetry, SendWorkplaceSearchTelemetry } from '../telemetry';
2828
import { LicensingLogic } from '../licensing';
@@ -89,18 +89,18 @@ export const NotFound: React.FC<NotFoundProps> = ({ product = {} }) => {
8989
actions={
9090
<EuiFlexGroup>
9191
<EuiFlexItem>
92-
<EuiButton to="/" color="primary" fill>
92+
<EuiButtonTo to="/" color="primary" fill>
9393
{i18n.translate('xpack.enterpriseSearch.notFound.action1', {
9494
defaultMessage: 'Back to your dashboard',
9595
})}
96-
</EuiButton>
96+
</EuiButtonTo>
9797
</EuiFlexItem>
9898
<EuiFlexItem>
99-
<EuiButtonExternal href={supportUrl} target="_blank">
99+
<EuiButton href={supportUrl} target="_blank">
100100
{i18n.translate('xpack.enterpriseSearch.notFound.action2', {
101101
defaultMessage: 'Contact support',
102102
})}
103-
</EuiButtonExternal>
103+
</EuiButton>
104104
</EuiFlexItem>
105105
</EuiFlexGroup>
106106
}

x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_manager_modal.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
EuiSpacer,
2727
} from '@elastic/eui';
2828

29-
import { EuiButton as EuiLinkButton } from '../../../../shared/react_router_helpers';
29+
import { EuiButtonTo } from '../../../../shared/react_router_helpers';
3030

3131
import { Group } from '../../../types';
3232
import { ORG_SOURCES_PATH } from '../../../routes';
@@ -96,9 +96,9 @@ export const GroupManagerModal: React.FC<GroupManagerModalProps> = ({
9696
const handleSelectAll = () => selectAll(allSelected ? [] : allItems);
9797

9898
const sourcesButton = (
99-
<EuiLinkButton to={ORG_SOURCES_PATH} fill color="primary">
99+
<EuiButtonTo to={ORG_SOURCES_PATH} fill color="primary">
100100
{ADD_SOURCE_BUTTON_TEXT}
101-
</EuiLinkButton>
101+
</EuiButtonTo>
102102
);
103103

104104
const emptyState = (

x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { TableFilters } from './components/table_filters';
2727
import { DEFAULT_META } from '../../../shared/constants';
2828

2929
import { EuiFieldSearch, EuiLoadingSpinner } from '@elastic/eui';
30-
import { EuiButton as EuiLinkButton } from '../../../shared/react_router_helpers';
30+
import { EuiButtonTo } from '../../../shared/react_router_helpers';
3131

3232
const getSearchResults = jest.fn();
3333
const openNewGroupModal = jest.fn();
@@ -138,7 +138,7 @@ describe('GroupOverview', () => {
138138
const action = shallow(<Action />);
139139

140140
expect(action.find('[data-test-subj="InviteUsersButton"]')).toHaveLength(1);
141-
expect(action.find(EuiLinkButton)).toHaveLength(1);
141+
expect(action.find(EuiButtonTo)).toHaveLength(1);
142142
});
143143

144144
it('does not render inviteUsersButton when federated auth', () => {

x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { useActions, useValues } from 'kea';
1010
import { i18n } from '@kbn/i18n';
1111

1212
import { EuiButton, EuiFlexGroup, EuiFlexItem, EuiLoadingSpinner, EuiSpacer } from '@elastic/eui';
13-
import { EuiButton as EuiLinkButton } from '../../../shared/react_router_helpers';
13+
import { EuiButtonTo } from '../../../shared/react_router_helpers';
1414

1515
import { AppLogic } from '../../app_logic';
1616

@@ -61,25 +61,25 @@ export const Groups: React.FC = () => {
6161

6262
if (newGroup && hasMessages) {
6363
messages[0].description = (
64-
<EuiLinkButton
64+
<EuiButtonTo
6565
to={getGroupPath(newGroup.id)}
6666
color="primary"
6767
data-test-subj="NewGroupManageButton"
6868
>
6969
{i18n.translate('xpack.enterpriseSearch.workplaceSearch.groups.newGroup.action', {
7070
defaultMessage: 'Manage Group',
7171
})}
72-
</EuiLinkButton>
72+
</EuiButtonTo>
7373
);
7474
}
7575

7676
const clearFilters = hasFiltersSet && <ClearFiltersLink />;
7777
const inviteUsersButton = !isFederatedAuth ? (
78-
<EuiLinkButton to={USERS_PATH} data-test-subj="InviteUsersButton">
78+
<EuiButtonTo to={USERS_PATH} data-test-subj="InviteUsersButton">
7979
{i18n.translate('xpack.enterpriseSearch.workplaceSearch.groups.inviteUsers.action', {
8080
defaultMessage: 'Invite users',
8181
})}
82-
</EuiLinkButton>
82+
</EuiButtonTo>
8383
) : null;
8484

8585
const headerAction = (

0 commit comments

Comments
 (0)