Skip to content
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,8 +9,8 @@
* GitHub history for details.
*/

import { RedirectProps } from "react-router-dom";
import { convertLegacyNotebooksUrl } from "../helpers/legacy_route_helpers";
import { RedirectProps } from 'react-router-dom';
import { convertLegacyNotebooksUrl } from '../helpers/legacy_route_helpers';

describe('Test legacy route helpers', () => {
it('converts legacy notebooks url', () => {
Expand All @@ -32,19 +32,10 @@ describe('Test legacy route helpers', () => {
},
] as Location[];
const expected = [
{
pathname: '/app/observability',
hash: '#/notebooks/GQ5icXwBJCegTOBKO4Um'
},
{
pathname: '/app/observability',
hash: '#/notebooks/clPiPXwBEM7l9gC0xTpA?view=view_both'
},
{
pathname: '/testBasePath/app/observability',
hash: `#/notebooks/GQ5icXwBJCegTOBKO4Um?_g=(time:(from:'2021-10-15T20:25:09.556Z',to:'2021-10-15T20:55:09.556Z'))&view=output_only&security_tenant=global`
},
] as RedirectProps['to'][]
'/app/observability#/notebooks/GQ5icXwBJCegTOBKO4Um',
'/app/observability#/notebooks/clPiPXwBEM7l9gC0xTpA?view=view_both',
`/testBasePath/app/observability#/notebooks/GQ5icXwBJCegTOBKO4Um?_g=(time:(from:'2021-10-15T20:25:09.556Z',to:'2021-10-15T20:55:09.556Z'))&view=output_only&security_tenant=global`,
] as RedirectProps['to'][];
expect(locations.map((location) => convertLegacyNotebooksUrl(location))).toEqual(expected);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
* GitHub history for details.
*/

import { RedirectProps } from 'react-router-dom';

export const convertLegacyNotebooksUrl = (location: Location): RedirectProps['to'] => {
export const convertLegacyNotebooksUrl = (location: Location)=> {
const pathname = location.pathname.replace('notebooks-dashboards', 'observability');
const hash = `#/notebooks${location.hash.replace(/^#/, '')}${
location.hash.includes('?') ? location.search.replace(/^\?/, '&') : location.search
}`;
return { pathname, hash };
return pathname + hash;
};

This file was deleted.

15 changes: 5 additions & 10 deletions dashboards-observability/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ import DSLService from './services/requests/dsl';
import TimestampUtils from './services/timestamp/timestamp';
import SavedObjects from './services/saved_objects/event_analytics/saved_objects';
import { AppPluginStartDependencies, ObservabilitySetup, ObservabilityStart } from './types';
import { convertLegacyNotebooksUrl } from './components/notebooks/components/helpers/legacy_route_helpers';

export class ObservabilityPlugin implements Plugin<ObservabilitySetup, ObservabilityStart> {

public setup(core: CoreSetup): ObservabilitySetup {
// redirect legacy notebooks URL to current URL under observability
if (window.location.pathname.includes('notebooks-dashboards')) {
window.location.assign(convertLegacyNotebooksUrl(window.location));
}

core.application.register({
id: observabilityID,
Expand Down Expand Up @@ -53,16 +58,6 @@ export class ObservabilityPlugin implements Plugin<ObservabilitySetup, Observabi
},
});

// redirect legacy notebooks URL to current URL under observability
core.application.register({
id: "notebooks-dashboards",
title: "",
async mount(params: AppMountParameters) {
const { LegacyRoute } = await import('./components/notebooks/components/legacy_route');
return LegacyRoute(params)
}
});

// Return methods that should be available to other plugins
return {};
}
Expand Down