Skip to content

Commit

Permalink
redirect to default app if hash can not be forwarded (#70417) (#70590)
Browse files Browse the repository at this point in the history
  • Loading branch information
flash1293 authored Jul 3, 2020
1 parent 46ccf89 commit d235ddc
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/plugins/kibana_legacy/public/forward_app/forward_app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@
import { App, AppMountParameters, CoreSetup } from 'kibana/public';
import { AppNavLinkStatus } from '../../../../core/public';
import { navigateToLegacyKibanaUrl } from './navigate_to_legacy_kibana_url';
import { ForwardDefinition } from '../plugin';
import { ForwardDefinition, KibanaLegacyStart } from '../plugin';

export const createLegacyUrlForwardApp = (core: CoreSetup, forwards: ForwardDefinition[]): App => ({
export const createLegacyUrlForwardApp = (
core: CoreSetup<{}, KibanaLegacyStart>,
forwards: ForwardDefinition[]
): App => ({
id: 'kibana',
chromeless: true,
title: 'Legacy URL migration',
Expand All @@ -31,7 +34,8 @@ export const createLegacyUrlForwardApp = (core: CoreSetup, forwards: ForwardDefi
const hash = params.history.location.hash.substr(1);

if (!hash) {
core.fatalErrors.add('Could not forward URL');
const [, , kibanaLegacyStart] = await core.getStartServices();
kibanaLegacyStart.navigateToDefaultApp();
}

const [
Expand All @@ -44,7 +48,8 @@ export const createLegacyUrlForwardApp = (core: CoreSetup, forwards: ForwardDefi
const result = await navigateToLegacyKibanaUrl(hash, forwards, basePath, application);

if (!result.navigated) {
core.fatalErrors.add('Could not forward URL');
const [, , kibanaLegacyStart] = await core.getStartServices();
kibanaLegacyStart.navigateToDefaultApp();
}

return () => {};
Expand Down

0 comments on commit d235ddc

Please sign in to comment.