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

Revert "Uptime Monitor Management - Adjust monitor details page href for browser monitors" #124082

Merged
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 @@ -9,11 +9,11 @@ import React from 'react';
import { screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { render } from '../../../lib/helper/rtl_helpers';
import { ConfigKey, DataStream, HTTPFields, ScheduleUnit } from '../../../../common/runtime_types';
import { DataStream, HTTPFields, ScheduleUnit } from '../../../../common/runtime_types';
import { MonitorManagementList } from './monitor_list';
import { MonitorManagementList as MonitorManagementListState } from '../../../state/reducers/monitor_management';

describe('<MonitorManagementList />', () => {
describe('<ActionBar />', () => {
const setRefresh = jest.fn();
const setPageSize = jest.fn();
const setPageIndex = jest.fn();
Expand Down Expand Up @@ -110,64 +110,4 @@ describe('<MonitorManagementList />', () => {
expect(setPageIndex).toBeCalledWith(2);
expect(setRefresh).toBeCalledWith(true);
});

it.each([
[DataStream.BROWSER, ConfigKey.SOURCE_INLINE],
[DataStream.HTTP, ConfigKey.URLS],
[DataStream.TCP, ConfigKey.HOSTS],
[DataStream.ICMP, ConfigKey.HOSTS],
])(
'appends inline to the monitor id for browser monitors and omits for lightweight checks',
(type, configKey) => {
const id = '123456';
const name = 'sample monitor';
const browserState = {
monitorManagementList: {
...state.monitorManagementList,
list: {
...state.monitorManagementList.list,
monitors: [
{
id,
attributes: {
name,
schedule: {
unit: ScheduleUnit.MINUTES,
number: '1',
},
[configKey]: 'test',
type,
tags: [`tag-1`],
},
},
],
},
},
};

render(
<MonitorManagementList
setRefresh={setRefresh}
setPageSize={setPageSize}
setPageIndex={setPageIndex}
monitorList={browserState.monitorManagementList as unknown as MonitorManagementListState}
/>,
{ state: browserState }
);

const link = screen.getByText(name) as HTMLAnchorElement;

expect(link.href).toEqual(
expect.stringContaining(
`/app/uptime/monitor/${Buffer.from(
`${id}${type === DataStream.BROWSER ? `-inline` : ''}`,
'utf8'
).toString('base64')}`
)
);

expect(setPageIndex).toBeCalledWith(2);
expect(setRefresh).toBeCalledWith(true);
}
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { i18n } from '@kbn/i18n';
import { EuiBasicTable, EuiPanel, EuiSpacer, EuiLink } from '@elastic/eui';
import { SyntheticsMonitorSavedObject } from '../../../../common/types';
import { MonitorManagementList as MonitorManagementListState } from '../../../state/reducers/monitor_management';
import { DataStream, MonitorFields, SyntheticsMonitor } from '../../../../common/runtime_types';
import { MonitorFields, SyntheticsMonitor } from '../../../../common/runtime_types';
import { UptimeSettingsContext } from '../../../contexts';
import { Actions } from './actions';
import { MonitorLocations } from './monitor_locations';
Expand Down Expand Up @@ -66,19 +66,14 @@ export const MonitorManagementList = ({
defaultMessage: 'Monitor name',
}),
render: ({
attributes: { name, type },
attributes: { name },
id,
}: {
attributes: Partial<MonitorFields>;
id: string;
}) => (
<EuiLink
href={`${basePath}/app/uptime/monitor/${Buffer.from(
/* Monitor Management currently only supports inline browser monitors.
* Inline browser monitors append `inline` to the monitor id */
`${id}${type === DataStream.BROWSER ? `-inline` : ''}`,
'utf8'
).toString('base64')}`}
href={`${basePath}/app/uptime/monitor/${Buffer.from(id, 'utf8').toString('base64')}`}
>
{name}
</EuiLink>
Expand Down