Skip to content

Commit

Permalink
add url forwarding from old url setup
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkime committed May 16, 2020
1 parent 461069e commit e78faf7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/plugins/index_pattern_management/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"version": "kibana",
"server": false,
"ui": true,
"requiredPlugins": ["management", "data"]
"requiredPlugins": ["management", "data", "kibanaLegacy"]
}
17 changes: 15 additions & 2 deletions src/plugins/index_pattern_management/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import { i18n } from '@kbn/i18n';
import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from 'src/core/public';
import { DataPublicPluginStart } from 'src/plugins/data/public';
import { KibanaLegacySetup } from '../../kibana_legacy/public';
import {
IndexPatternManagementService,
IndexPatternManagementServiceSetup,
Expand All @@ -30,6 +31,7 @@ import { ManagementSetup, ManagementApp, ManagementSectionId } from '../../manag

export interface IndexPatternManagementSetupDependencies {
management: ManagementSetup;
kibanaLegacy: KibanaLegacySetup;
}

export interface IndexPatternManagementStartDependencies {
Expand All @@ -44,6 +46,8 @@ const sectionsHeader = i18n.translate('indexPatternManagement.indexPattern.secti
defaultMessage: 'Index Patterns',
});

const IPM_APP_ID = 'indexPatterns';

export class IndexPatternManagementPlugin
implements
Plugin<
Expand All @@ -59,16 +63,25 @@ export class IndexPatternManagementPlugin

public setup(
core: CoreSetup<IndexPatternManagementStartDependencies, IndexPatternManagementStart>,
{ management }: IndexPatternManagementSetupDependencies
{ management, kibanaLegacy }: IndexPatternManagementSetupDependencies
) {
const kibanaSection = management.sections.getSection(ManagementSectionId.Kibana);

if (!kibanaSection) {
throw new Error('`kibana` management section not found.');
}

const newAppPath = `kibana#/management/kibana/${IPM_APP_ID}`;
const legacyPatternsPath = 'management/kibana/index_patterns';

kibanaLegacy.forwardApp('management/kibana/index_pattern', newAppPath, path => '/create');
kibanaLegacy.forwardApp(legacyPatternsPath, newAppPath, path => {
const pathInApp = path.substr(legacyPatternsPath.length + 1);
return pathInApp && `/patterns${pathInApp}`;
});

this.managementApp = kibanaSection.registerApp({
id: 'indexPatterns',
id: IPM_APP_ID,
title: sectionsHeader,
order: 0,
mount: async params => {
Expand Down

0 comments on commit e78faf7

Please sign in to comment.