Skip to content

Commit 4afa2d6

Browse files
[Uptime] Modify router to use ScopedHistory (#76421)
* Remove hashbang and modify router to use ScopedHistory. * Update test to conform to refactored API. * Update test snapshots. * Fix broken type check. * Remove unneeded prop. * Prevent full page reload for breadcrumbs. * Fix outdated test. * Fix type errors. * Add default value for focusConnectorField url param. * Make stringify function support focusFieldConnector empty values. * Avoid unnecessary text in breadcrumb href. * Refresh test snapshot. Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent 728dfb4 commit 4afa2d6

File tree

15 files changed

+68
-40
lines changed

15 files changed

+68
-40
lines changed

x-pack/plugins/uptime/common/constants/client_defaults.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export const CLIENT_DEFAULTS = {
3131
* The end of the default date range is now.
3232
*/
3333
DATE_RANGE_END: 'now',
34+
FOCUS_CONNECTOR_FIELD: false,
3435
FILTERS: '',
3536
MONITOR_LIST_PAGE_INDEX: 0,
3637
MONITOR_LIST_PAGE_SIZE: 20,

x-pack/plugins/uptime/common/constants/plugin.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export const PLUGIN = {
1717
NAME: i18n.translate('xpack.uptime.featureRegistry.uptimeFeatureName', {
1818
defaultMessage: 'Uptime',
1919
}),
20-
ROUTER_BASE_NAME: '/app/uptime#',
2120
TITLE: i18n.translate('xpack.uptime.uptimeFeatureCatalogueTitle', {
2221
defaultMessage: 'Uptime',
2322
}),

x-pack/plugins/uptime/public/apps/plugin.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class UptimePlugin
5959
title: PLUGIN.TITLE,
6060
description: PLUGIN.DESCRIPTION,
6161
icon: 'uptimeApp',
62-
path: '/app/uptime#/',
62+
path: '/app/uptime',
6363
showOnHomePage: false,
6464
category: FeatureCatalogueCategory.DATA,
6565
});
@@ -84,7 +84,6 @@ export class UptimePlugin
8484
});
8585

8686
core.application.register({
87-
appRoute: '/app/uptime#/',
8887
id: PLUGIN.ID,
8988
euiIconType: 'uptimeApp',
9089
order: 8400,

x-pack/plugins/uptime/public/apps/render_app.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@ import {
1616
} from '../../common/constants';
1717
import { UptimeApp, UptimeAppProps } from './uptime_app';
1818
import { ClientPluginsSetup, ClientPluginsStart } from './plugin';
19-
import { PLUGIN } from '../../common/constants/plugin';
2019

2120
export function renderApp(
2221
core: CoreStart,
2322
plugins: ClientPluginsSetup,
2423
startPlugins: ClientPluginsStart,
25-
{ element }: AppMountParameters
24+
{ element, history }: AppMountParameters
2625
) {
2726
const {
2827
application: { capabilities },
@@ -48,6 +47,7 @@ export function renderApp(
4847
basePath: basePath.get(),
4948
darkMode: core.uiSettings.get(DEFAULT_DARK_MODE),
5049
commonlyUsedRanges: core.uiSettings.get(DEFAULT_TIMEPICKER_QUICK_RANGES),
50+
history,
5151
isApmAvailable: apm,
5252
isInfraAvailable: infrastructure,
5353
isLogsAvailable: logs,
@@ -67,7 +67,6 @@ export function renderApp(
6767
},
6868
],
6969
}),
70-
routerBasename: basePath.prepend(PLUGIN.ROUTER_BASE_NAME),
7170
setBadge,
7271
setBreadcrumbs: core.chrome.setBreadcrumbs,
7372
};

x-pack/plugins/uptime/public/apps/uptime_app.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { EuiPage, EuiErrorBoundary } from '@elastic/eui';
88
import { i18n } from '@kbn/i18n';
99
import React, { useEffect } from 'react';
1010
import { Provider as ReduxProvider } from 'react-redux';
11-
import { BrowserRouter as Router } from 'react-router-dom';
11+
import { Router } from 'react-router-dom';
1212
import { I18nStart, ChromeBreadcrumb, CoreStart } from 'kibana/public';
1313
import {
1414
KibanaContextProvider,
@@ -31,6 +31,7 @@ import {
3131
} from '../components/overview/alerts';
3232
import { store } from '../state';
3333
import { kibanaService } from '../state/kibana_service';
34+
import { ScopedHistory } from '../../../../../src/core/public';
3435

3536
export interface UptimeAppColors {
3637
danger: string;
@@ -46,13 +47,13 @@ export interface UptimeAppProps {
4647
canSave: boolean;
4748
core: CoreStart;
4849
darkMode: boolean;
50+
history: ScopedHistory;
4951
i18n: I18nStart;
5052
isApmAvailable: boolean;
5153
isInfraAvailable: boolean;
5254
isLogsAvailable: boolean;
5355
plugins: ClientPluginsSetup;
5456
startPlugins: ClientPluginsStart;
55-
routerBasename: string;
5657
setBadge: UMUpdateBadge;
5758
renderGlobalHelpControls(): void;
5859
commonlyUsedRanges: CommonlyUsedRange[];
@@ -68,7 +69,6 @@ const Application = (props: UptimeAppProps) => {
6869
i18n: i18nCore,
6970
plugins,
7071
renderGlobalHelpControls,
71-
routerBasename,
7272
setBadge,
7373
startPlugins,
7474
} = props;
@@ -99,7 +99,7 @@ const Application = (props: UptimeAppProps) => {
9999
<i18nCore.Context>
100100
<ReduxProvider store={store}>
101101
<KibanaContextProvider services={{ ...core, ...plugins }}>
102-
<Router basename={routerBasename}>
102+
<Router history={props.history}>
103103
<UptimeRefreshContextProvider>
104104
<UptimeSettingsContextProvider {...props}>
105105
<UptimeThemeContextProvider darkMode={darkMode}>

x-pack/plugins/uptime/public/apps/uptime_overview_fetcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async function fetchUptimeOverviewData({
2424
const pings = await fetchPingHistogram({ dateStart: start, dateEnd: end, bucketSize });
2525

2626
const response: UptimeFetchDataResponse = {
27-
appLink: `/app/uptime#/?dateRangeStart=${relativeTime.start}&dateRangeEnd=${relativeTime.end}`,
27+
appLink: `/app/uptime?dateRangeStart=${relativeTime.start}&dateRangeEnd=${relativeTime.end}`,
2828
stats: {
2929
monitors: {
3030
type: 'number',

x-pack/plugins/uptime/public/components/overview/empty_state/__tests__/__snapshots__/data_or_index_missing.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugins/uptime/public/components/overview/empty_state/__tests__/__snapshots__/empty_state.test.tsx.snap

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugins/uptime/public/components/overview/empty_state/data_or_index_missing.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export const DataOrIndexMissing = ({ headingMessage, settings }: DataMissingProp
6969
</EuiButton>
7070
</EuiFlexItem>
7171
<EuiFlexItem>
72-
<EuiButton color="primary" href={`${basePath}/app/uptime#/settings`}>
72+
<EuiButton color="primary" href={`${basePath}/app/uptime/settings`}>
7373
<FormattedMessage
7474
id="xpack.uptime.emptyState.updateIndexPattern"
7575
defaultMessage="Update index pattern settings"

x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/__snapshots__/most_recent_error.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)