Skip to content

Commit

Permalink
update naming
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 committed Aug 3, 2020
1 parent e8e68c1 commit c6822e1
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { EuiLink, EuiButton } from '@elastic/eui';

import '../../../lib/__mocks__/react_router_history.mock';

import { EuiReactRouterLink, EuiReactRouterButton } from './eui_link';
import { ReactRouterEuiLink, ReactRouterEuiButton } from './eui_link';
import { mockHistory } from '../../../lib/__mocks__';

describe('EUI & React Router Component Helpers', () => {
Expand All @@ -19,27 +19,27 @@ describe('EUI & React Router Component Helpers', () => {
});

it('renders', () => {
const wrapper = shallow(<EuiReactRouterLink to="/" />);
const wrapper = shallow(<ReactRouterEuiLink to="/" />);

expect(wrapper.find(EuiLink)).toHaveLength(1);
});

it('renders an EuiButton', () => {
const wrapper = shallow(<EuiReactRouterButton to="/" />);
const wrapper = shallow(<ReactRouterEuiButton to="/" />);

expect(wrapper.find(EuiButton)).toHaveLength(1);
});

it('passes down all ...rest props', () => {
const wrapper = shallow(<EuiReactRouterLink to="/" data-test-subj="foo" external={true} />);
const wrapper = shallow(<ReactRouterEuiLink to="/" data-test-subj="foo" external={true} />);
const link = wrapper.find(EuiLink);

expect(link.prop('external')).toEqual(true);
expect(link.prop('data-test-subj')).toEqual('foo');
});

it('renders with the correct href and onClick props', () => {
const wrapper = mount(<EuiReactRouterLink to="/foo/bar" />);
const wrapper = mount(<ReactRouterEuiLink to="/foo/bar" />);
const link = wrapper.find(EuiLink);

expect(link.prop('onClick')).toBeInstanceOf(Function);
Expand All @@ -49,7 +49,7 @@ describe('EUI & React Router Component Helpers', () => {

describe('onClick', () => {
it('prevents default navigation and uses React Router history', () => {
const wrapper = mount(<EuiReactRouterLink to="/bar/baz" />);
const wrapper = mount(<ReactRouterEuiLink to="/bar/baz" />);

const simulatedEvent = {
button: 0,
Expand All @@ -63,7 +63,7 @@ describe('EUI & React Router Component Helpers', () => {
});

it('does not prevent default browser behavior on new tab/window clicks', () => {
const wrapper = mount(<EuiReactRouterLink to="/bar/baz" />);
const wrapper = mount(<ReactRouterEuiLink to="/bar/baz" />);

const simulatedEvent = {
shiftKey: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ type TEuiReactRouterLinkProps = EuiLinkAnchorProps & IEuiReactRouterProps;
type TEuiReactRouterButtonProps = EuiButtonProps & IEuiReactRouterProps;
type TEuiReactRouterButtonEmptyProps = EuiButtonEmptyProps & IEuiReactRouterProps;

export const EuiReactRouterLink: React.FC<TEuiReactRouterLinkProps> = ({ to, ...rest }) => (
export const ReactRouterEuiLink: React.FC<TEuiReactRouterLinkProps> = ({ to, ...rest }) => (
<EuiReactRouterHelper to={to}>
<EuiLink {...rest} />
</EuiReactRouterHelper>
);

export const EuiReactRouterButton: React.FC<TEuiReactRouterButtonProps> = ({ to, ...rest }) => (
export const ReactRouterEuiButton: React.FC<TEuiReactRouterButtonProps> = ({ to, ...rest }) => (
<EuiReactRouterHelper to={to}>
<EuiButton {...rest} />
</EuiReactRouterHelper>
);

export const EuiReactRouterButtonEmpty: React.FC<TEuiReactRouterButtonEmptyProps> = ({
export const ReactRouterEuiButtonEmpty: React.FC<TEuiReactRouterButtonEmptyProps> = ({
to,
...rest
}) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
*/

export { letBrowserHandleEvent } from './link_events';
export { EuiReactRouterLink as EuiLink } from './eui_link';
export { EuiReactRouterButton as EuiButton } from './eui_link';
export { ReactRouterEuiLink as EuiLink } from './eui_link';
export { ReactRouterEuiButton as EuiButton } from './eui_link';
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ export const ManageMLJobComponent = ({ hasMLJob, onEnableJob, onJobDelete }: Pro
const deleteAnomalyAlert = () =>
dispatch(deleteAlertAction.get({ alertId: anomalyAlert?.id as string }));

const showLoading = isMLJobCreating || isMLJobLoading;

const btnText = hasMLJob ? labels.ANOMALY_DETECTION : labels.ENABLE_ANOMALY_DETECTION;

const button = (
<EuiButton
data-test-subj={hasMLJob ? 'uptimeManageMLJobBtn' : 'uptimeEnableAnomalyBtn'}
Expand All @@ -63,11 +67,7 @@ export const ManageMLJobComponent = ({ hasMLJob, onEnableJob, onJobDelete }: Pro
size="s"
aria-label={labels.ENABLE_MANAGE_JOB}
>
{isMLJobCreating || isMLJobLoading
? ''
: hasMLJob
? labels.ANOMALY_DETECTION
: labels.ENABLE_ANOMALY_DETECTION}
{showLoading ? '' : btnText}
</EuiButton>
);

Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/uptime/public/pages/certificates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { certificatesSelector, getCertificatesAction } from '../state/certificat
import { CertificateList, CertificateSearch, CertSort } from '../components/certificates';
import { ToggleAlertFlyoutButton } from '../components/overview/alerts/alerts_containers';
import { CLIENT_ALERT_TYPES } from '../../common/constants/alerts';
import { EuiReactRouterButtonEmpty } from '../components/common/react_router_helpers/eui_link';
import { ReactRouterEuiButtonEmpty } from '../components/common/react_router_helpers/eui_link';

const DEFAULT_PAGE_SIZE = 10;
const LOCAL_STORAGE_KEY = 'xpack.uptime.certList.pageSize';
Expand Down Expand Up @@ -80,7 +80,7 @@ export const CertificatesPage: React.FC = () => {
<>
<EuiFlexGroup responsive={false} gutterSize="s">
<EuiFlexItem grow={false} style={{ marginRight: 'auto', alignSelf: 'center' }}>
<EuiReactRouterButtonEmpty
<ReactRouterEuiButtonEmpty
color="primary"
data-test-subj="uptimeCertificatesToOverviewLink"
to={OVERVIEW_ROUTE}
Expand All @@ -89,7 +89,7 @@ export const CertificatesPage: React.FC = () => {
aria-label={labels.RETURN_TO_OVERVIEW}
>
{labels.RETURN_TO_OVERVIEW}
</EuiReactRouterButtonEmpty>
</ReactRouterEuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<ToggleAlertFlyoutButton alertOptions={[CLIENT_ALERT_TYPES.TLS]} />
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/uptime/public/pages/page_header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { UptimeDatePicker } from '../components/common/uptime_date_picker';
import { SETTINGS_ROUTE } from '../../common/constants';
import { ToggleAlertFlyoutButton } from '../components/overview/alerts/alerts_containers';
import { useKibana } from '../../../../../src/plugins/kibana_react/public';
import { EuiReactRouterButtonEmpty } from '../components/common/react_router_helpers/eui_link';
import { ReactRouterEuiButtonEmpty } from '../components/common/react_router_helpers/eui_link';

interface PageHeaderProps {
headingText: string | JSX.Element;
Expand Down Expand Up @@ -65,13 +65,13 @@ export const PageHeader = React.memo(
<ToggleAlertFlyoutButton />
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiReactRouterButtonEmpty
<ReactRouterEuiButtonEmpty
data-test-subj="settings-page-link"
iconType="gear"
to={SETTINGS_ROUTE}
>
{SETTINGS_LINK_TEXT}
</EuiReactRouterButtonEmpty>
</ReactRouterEuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonEmpty
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/uptime/public/pages/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
VALUE_MUST_BE_GREATER_THAN_ZERO,
VALUE_MUST_BE_AN_INTEGER,
} from '../../common/translations';
import { EuiReactRouterButtonEmpty } from '../components/common/react_router_helpers/eui_link';
import { ReactRouterEuiButtonEmpty } from '../components/common/react_router_helpers/eui_link';

interface SettingsPageFieldErrors {
heartbeatIndices: string | '';
Expand Down Expand Up @@ -145,15 +145,15 @@ export const SettingsPage: React.FC = () => {

return (
<>
<EuiReactRouterButtonEmpty
<ReactRouterEuiButtonEmpty
color="primary"
data-test-subj="uptimeSettingsToOverviewLink"
iconType="arrowLeft"
to={OVERVIEW_ROUTE}
size="s"
>
{Translations.settings.returnToOverviewLinkLabel}
</EuiReactRouterButtonEmpty>
</ReactRouterEuiButtonEmpty>
<EuiSpacer size="s" />
<EuiPanel>
<EuiFlexGroup>
Expand Down

0 comments on commit c6822e1

Please sign in to comment.