From 374070759967e3835e15b6372dd4ab07c290ccf4 Mon Sep 17 00:00:00 2001
From: Alexey Antonov
Date: Wed, 13 May 2020 13:25:29 +0300
Subject: [PATCH 01/93] [New Platform Migration]: Management - Implement NP API
Part of #47432
---
src/legacy/core_plugins/kibana/index.js | 17 +-
.../core_plugins/kibana/public/.eslintrc.js | 83 -----
.../core_plugins/kibana/public/_hacks.scss | 0
.../core_plugins/kibana/public/kibana.js | 2 +-
.../public/management/_management_app.scss | 69 -----
.../kibana/public/management/app.html | 4 -
.../kibana/public/management/index.js | 167 ----------
.../kibana/public/management/index.scss | 4 +-
.../kibana/public/management/landing.html | 3 -
.../index_pattern_table.tsx | 8 +-
.../management_app.test.tsx.snap | 11 -
src/plugins/management/public/application.tsx | 42 +++
.../management/public/components/_index.scss | 1 -
.../management/public/components/index.ts | 4 +-
.../{management_chrome => langing}/index.ts | 2 +-
.../public/components/langing/landing.tsx | 71 +++++
.../management_app/_management_app.scss | 19 ++
.../management_app/index.ts} | 3 +-
.../management_app/management_app.tsx | 110 +++++++
.../management_app_wrapper/index.tsx} | 6 +-
.../management_app_wrapper.tsx | 69 +++++
.../management_chrome/management_chrome.tsx | 59 ----
.../{ => components}/management_sections.tsx | 6 +-
.../management_sidebar_nav.test.ts.snap | 95 ------
.../management_sidebar_nav.test.ts | 98 ------
.../management_sidebar_nav.tsx | 242 +++++----------
src/plugins/management/public/index.ts | 13 +-
.../public/legacy/redirect_messages.tsx | 67 ----
.../management/public/legacy/section.js | 160 ----------
.../management/public/legacy/section.test.js | 285 ------------------
.../public/legacy/sections_register.js | 47 ---
.../management/public/management_app.test.tsx | 66 ----
.../management/public/management_app.tsx | 107 -------
.../public/management_section.test.ts | 66 ----
.../management/public/management_section.ts | 80 -----
.../management_sections_service.test.ts | 67 ++++
.../public/management_sections_service.ts | 68 +++++
.../public/management_service.test.ts | 40 ---
.../management/public/management_service.ts | 109 -------
src/plugins/management/public/mocks/index.ts | 18 +-
src/plugins/management/public/plugin.ts | 62 ++--
src/plugins/management/public/types.ts | 96 ++----
.../management/public/utils/index.ts} | 17 +-
.../management/public/utils/management_app.ts | 38 +++
.../public/utils/management_item.ts | 46 +++
.../public/utils/management_section.test.ts | 55 ++++
.../public/utils/management_section.ts | 58 ++++
.../management/management_service.test.ts | 46 +--
x-pack/plugins/spaces/public/plugin.test.ts | 16 +-
49 files changed, 842 insertions(+), 1980 deletions(-)
delete mode 100644 src/legacy/core_plugins/kibana/public/.eslintrc.js
delete mode 100644 src/legacy/core_plugins/kibana/public/_hacks.scss
delete mode 100644 src/legacy/core_plugins/kibana/public/management/_management_app.scss
delete mode 100644 src/legacy/core_plugins/kibana/public/management/app.html
delete mode 100644 src/legacy/core_plugins/kibana/public/management/index.js
delete mode 100644 src/legacy/core_plugins/kibana/public/management/landing.html
delete mode 100644 src/plugins/management/public/__snapshots__/management_app.test.tsx.snap
create mode 100644 src/plugins/management/public/application.tsx
delete mode 100644 src/plugins/management/public/components/_index.scss
rename src/plugins/management/public/components/{management_chrome => langing}/index.ts (93%)
create mode 100644 src/plugins/management/public/components/langing/landing.tsx
create mode 100644 src/plugins/management/public/components/management_app/_management_app.scss
rename src/plugins/management/public/{legacy/index.js => components/management_app/index.ts} (87%)
create mode 100644 src/plugins/management/public/components/management_app/management_app.tsx
rename src/{legacy/core_plugins/kibana/public/management/saved_object_registry.ts => plugins/management/public/components/management_app_wrapper/index.tsx} (82%)
create mode 100644 src/plugins/management/public/components/management_app_wrapper/management_app_wrapper.tsx
delete mode 100644 src/plugins/management/public/components/management_chrome/management_chrome.tsx
rename src/plugins/management/public/{ => components}/management_sections.tsx (93%)
delete mode 100644 src/plugins/management/public/components/management_sidebar_nav/__snapshots__/management_sidebar_nav.test.ts.snap
delete mode 100644 src/plugins/management/public/components/management_sidebar_nav/management_sidebar_nav.test.ts
delete mode 100644 src/plugins/management/public/legacy/redirect_messages.tsx
delete mode 100644 src/plugins/management/public/legacy/section.js
delete mode 100644 src/plugins/management/public/legacy/section.test.js
delete mode 100644 src/plugins/management/public/legacy/sections_register.js
delete mode 100644 src/plugins/management/public/management_app.test.tsx
delete mode 100644 src/plugins/management/public/management_app.tsx
delete mode 100644 src/plugins/management/public/management_section.test.ts
delete mode 100644 src/plugins/management/public/management_section.ts
create mode 100644 src/plugins/management/public/management_sections_service.test.ts
create mode 100644 src/plugins/management/public/management_sections_service.ts
delete mode 100644 src/plugins/management/public/management_service.test.ts
delete mode 100644 src/plugins/management/public/management_service.ts
rename src/{legacy/core_plugins/kibana/public/management/sections/index_patterns/types.ts => plugins/management/public/utils/index.ts} (75%)
create mode 100644 src/plugins/management/public/utils/management_app.ts
create mode 100644 src/plugins/management/public/utils/management_item.ts
create mode 100644 src/plugins/management/public/utils/management_section.test.ts
create mode 100644 src/plugins/management/public/utils/management_section.ts
diff --git a/src/legacy/core_plugins/kibana/index.js b/src/legacy/core_plugins/kibana/index.js
index 5807c439bd277..4d36f3260ca10 100644
--- a/src/legacy/core_plugins/kibana/index.js
+++ b/src/legacy/core_plugins/kibana/index.js
@@ -26,8 +26,7 @@ import { exportApi } from './server/routes/api/export';
import { getUiSettingDefaults } from './server/ui_setting_defaults';
import { registerCspCollector } from './server/lib/csp_usage_collector';
import { injectVars } from './inject_vars';
-import { i18n } from '@kbn/i18n';
-import { DEFAULT_APP_CATEGORIES } from '../../../../src/core/server';
+
import { kbnBaseUrl } from '../../../plugins/kibana_legacy/server';
const mkdirAsync = promisify(Fs.mkdir);
@@ -59,19 +58,7 @@ export default function(kibana) {
main: 'plugins/kibana/kibana',
},
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
- links: [
- {
- id: 'kibana:stack_management',
- title: i18n.translate('kbn.managementTitle', {
- defaultMessage: 'Stack Management',
- }),
- order: 9003,
- url: `${kbnBaseUrl}#/management`,
- euiIconType: 'managementApp',
- linkToLastSubUrl: false,
- category: DEFAULT_APP_CATEGORIES.management,
- },
- ],
+ links: [],
injectDefaultVars(server, options) {
const mapConfig = server.config().get('map');
diff --git a/src/legacy/core_plugins/kibana/public/.eslintrc.js b/src/legacy/core_plugins/kibana/public/.eslintrc.js
deleted file mode 100644
index 1153706eb8566..0000000000000
--- a/src/legacy/core_plugins/kibana/public/.eslintrc.js
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-const topLevelConfig = require('../../../../../.eslintrc.js');
-const path = require('path');
-
-const topLevelRestricedZones = topLevelConfig.overrides.find(
- override =>
- override.files[0] === '**/*.{js,ts,tsx}' &&
- Object.keys(override.rules)[0] === '@kbn/eslint/no-restricted-paths'
-).rules['@kbn/eslint/no-restricted-paths'][1].zones;
-
-/**
- * Builds custom restricted paths configuration for the shimmed plugins within the kibana plugin.
- * These custom rules extend the default checks in the top level `eslintrc.js` by also checking two other things:
- * * Making sure nothing within np_ready imports from the `ui` directory
- * * Making sure no other code is importing things deep from within the shimmed plugins
- * @param shimmedPlugins List of plugin names within the kibana plugin that are partially np ready
- * @returns zones configuration for the no-restricted-paths linter
- */
-function buildRestrictedPaths(shimmedPlugins) {
- return shimmedPlugins
- .map(shimmedPlugin => [
- {
- target: [`src/legacy/core_plugins/kibana/public/${shimmedPlugin}/np_ready/**/*`],
- from: [
- 'ui/**/*',
- 'src/legacy/ui/**/*',
- 'src/legacy/core_plugins/kibana/public/**/*',
- `!src/legacy/core_plugins/kibana/public/${shimmedPlugin}/**/*`,
- ],
- allowSameFolder: false,
- errorMessage: `${shimmedPlugin} is a shimmed plugin that is not allowed to import modules from the legacy platform. If you need legacy modules for the transition period, import them either in the legacy_imports, kibana_services or index module.`,
- },
- {
- target: [
- 'src/**/*',
- `!src/legacy/core_plugins/kibana/public/${shimmedPlugin}/**/*`,
- 'x-pack/**/*',
- ],
- from: [
- `src/legacy/core_plugins/kibana/public/${shimmedPlugin}/**/*`,
- `!src/legacy/core_plugins/kibana/public/${shimmedPlugin}/index.ts`,
- `!src/legacy/core_plugins/kibana/public/${shimmedPlugin}/legacy.ts`,
- ],
- allowSameFolder: false,
- errorMessage: `kibana/public/${shimmedPlugin} is behaving like a NP plugin and does not allow deep imports. If you need something from within ${shimmedPlugin} in another plugin, consider re-exporting it from the top level index module`,
- },
- ])
- .reduce((acc, part) => [...acc, ...part], []);
-}
-
-module.exports = {
- rules: {
- 'no-console': 2,
- 'import/no-default-export': 'error',
- '@kbn/eslint/no-restricted-paths': [
- 'error',
- {
- basePath: path.resolve(__dirname, '../../../../../'),
- zones: topLevelRestricedZones.concat(
- buildRestrictedPaths(['visualize', 'discover', 'dashboard', 'devTools'])
- ),
- },
- ],
- },
-};
diff --git a/src/legacy/core_plugins/kibana/public/_hacks.scss b/src/legacy/core_plugins/kibana/public/_hacks.scss
deleted file mode 100644
index e69de29bb2d1d..0000000000000
diff --git a/src/legacy/core_plugins/kibana/public/kibana.js b/src/legacy/core_plugins/kibana/public/kibana.js
index 0bf74edc77cb6..610ae4d452384 100644
--- a/src/legacy/core_plugins/kibana/public/kibana.js
+++ b/src/legacy/core_plugins/kibana/public/kibana.js
@@ -38,7 +38,7 @@ import 'uiExports/shareContextMenuExtensions';
import 'uiExports/interpreter';
import 'ui/autoload/all';
-import './management';
+
import { localApplicationService } from './local_application_service';
npSetup.plugins.kibanaLegacy.registerLegacyAppAlias('doc', 'discover', { keepPrefix: true });
diff --git a/src/legacy/core_plugins/kibana/public/management/_management_app.scss b/src/legacy/core_plugins/kibana/public/management/_management_app.scss
deleted file mode 100644
index bd3cabbc574d3..0000000000000
--- a/src/legacy/core_plugins/kibana/public/management/_management_app.scss
+++ /dev/null
@@ -1,69 +0,0 @@
-.mgtPanel {
- margin-bottom: $euiSize;
- background: $euiColorEmptyShade;
-}
-
-/**
- * 1. Override kuiPanelBody styles to accommodate padding of items within the panel body..
- */
-.mgtPanel__body {
- padding: 5px 10px; /* 1 */
-}
-
-/**
- * 1. Create vertical space between items when they wrap.
- */
-.mgtPanel__item {
- padding: 5px 15px; /* 1 */
-}
-
-// SASSTODO: Remove when this is replaced by the side nav
-.mgtPanel__link {
- @include euiFontSizeL;
-
- line-height: 1.5; // Make sure the space between wrapped lines is than the vertical space between items.
-
- &.mgtPanel__link--disabled {
- opacity: $euiColorDarkShade;
- cursor: default;
-
- &:hover, &:visited {
- color: $euiColorPrimary;
- }
- }
-}
-
-// SASSTODO: Remove when this form is replaced by EUI
-kbn-management-objects {
- form {
- margin-bottom: $euiSize;
- }
- .list-unstyled {
- li {
- border-bottom: $euiBorderThin;
- padding: $euiSizeS;
- }
- }
- .empty {
- color: $euiColorDarkShade;
- }
-
- .item {
- padding: $euiSizeM;
-
- .item-title {
- margin-left: $euiSizeL;
- }
-
- .actions {
- margin-top: $euiSizeXS;
- }
- }
-
- .header {
- .title, .controls {
- padding-right: 1em;
- display: inline-block;
- }
- }
-}
diff --git a/src/legacy/core_plugins/kibana/public/management/app.html b/src/legacy/core_plugins/kibana/public/management/app.html
deleted file mode 100644
index 11198c02960c7..0000000000000
--- a/src/legacy/core_plugins/kibana/public/management/app.html
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/src/legacy/core_plugins/kibana/public/management/index.js b/src/legacy/core_plugins/kibana/public/management/index.js
deleted file mode 100644
index 2cba9fab7be22..0000000000000
--- a/src/legacy/core_plugins/kibana/public/management/index.js
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import React from 'react';
-import { render, unmountComponentAtNode } from 'react-dom';
-import { FormattedMessage } from '@kbn/i18n/react';
-
-import './sections';
-import uiRoutes from 'ui/routes';
-import { I18nContext } from 'ui/i18n';
-import { uiModules } from 'ui/modules';
-import appTemplate from './app.html';
-import landingTemplate from './landing.html';
-import { management, MANAGEMENT_BREADCRUMB } from 'ui/management';
-import { ManagementSidebarNav } from '../../../../../plugins/management/public';
-import { timefilter } from 'ui/timefilter';
-import {
- EuiPageContent,
- EuiTitle,
- EuiText,
- EuiSpacer,
- EuiIcon,
- EuiHorizontalRule,
-} from '@elastic/eui';
-import { npStart } from 'ui/new_platform';
-
-const SIDENAV_ID = 'management-sidenav';
-const LANDING_ID = 'management-landing';
-
-uiRoutes.when('/management', {
- template: landingTemplate,
- k7Breadcrumbs: () => [MANAGEMENT_BREADCRUMB],
-});
-
-uiRoutes.when('/management/:section', {
- redirectTo: '/management',
-});
-
-export function updateLandingPage(version) {
- const node = document.getElementById(LANDING_ID);
- if (!node) {
- return;
- }
-
- render(
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ,
- node
- );
-}
-
-export function updateSidebar(legacySections, id) {
- const node = document.getElementById(SIDENAV_ID);
- if (!node) {
- return;
- }
-
- render(
-
-
- ,
- node
- );
-}
-
-export const destroyReact = id => {
- const node = document.getElementById(id);
- node && unmountComponentAtNode(node);
-};
-
-uiModules.get('apps/management').directive('kbnManagementApp', function($location) {
- return {
- restrict: 'E',
- template: appTemplate,
- transclude: true,
- scope: {
- sectionName: '@section',
- omitPages: '@omitBreadcrumbPages',
- pageTitle: '=',
- },
-
- link: function($scope) {
- timefilter.disableAutoRefreshSelector();
- timefilter.disableTimeRangeSelector();
- $scope.sections = management.visibleItems;
- $scope.section = management.getSection($scope.sectionName) || management;
-
- if ($scope.section) {
- $scope.section.items.forEach(item => {
- item.active = `#${$location.path()}`.indexOf(item.url) > -1;
- });
- }
-
- updateSidebar($scope.sections, $scope.section.id);
- $scope.$on('$destroy', () => destroyReact(SIDENAV_ID));
- management.addListener(() => updateSidebar(management.visibleItems, $scope.section.id));
-
- updateLandingPage($scope.$root.chrome.getKibanaVersion());
- $scope.$on('$destroy', () => destroyReact(LANDING_ID));
- },
- };
-});
-
-uiModules.get('apps/management').directive('kbnManagementLanding', function(kbnVersion) {
- return {
- restrict: 'E',
- link: function($scope) {
- $scope.sections = management.visibleItems;
- $scope.kbnVersion = kbnVersion;
- },
- };
-});
diff --git a/src/legacy/core_plugins/kibana/public/management/index.scss b/src/legacy/core_plugins/kibana/public/management/index.scss
index 123580c0b7907..fb267b714f1c9 100644
--- a/src/legacy/core_plugins/kibana/public/management/index.scss
+++ b/src/legacy/core_plugins/kibana/public/management/index.scss
@@ -7,9 +7,7 @@
// mgtChart__legend--small
// mgtChart__legend-isLoading
-@import 'hacks';
-
// Core
-@import 'management_app';
@import '../../../../../plugins/advanced_settings/public/index';
+
@import 'sections/index_patterns/index';
diff --git a/src/legacy/core_plugins/kibana/public/management/landing.html b/src/legacy/core_plugins/kibana/public/management/landing.html
deleted file mode 100644
index 39459b26f7415..0000000000000
--- a/src/legacy/core_plugins/kibana/public/management/landing.html
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/index_pattern_table/index_pattern_table.tsx b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/index_pattern_table/index_pattern_table.tsx
index f254a6bc22a0d..d8efcfecebcc1 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/index_pattern_table/index_pattern_table.tsx
+++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/index_pattern_table/index_pattern_table.tsx
@@ -33,9 +33,8 @@ import { FormattedMessage } from '@kbn/i18n/react';
import React from 'react';
import { CreateButton } from '../create_button';
import { CreateIndexPatternPrompt } from '../create_index_pattern_prompt';
-import { IndexPattern, IndexPatternCreationOption } from '../types';
-const columns = [
+const columns: any[] = [
{
field: 'title',
name: 'Pattern',
@@ -86,8 +85,9 @@ const search = {
};
interface Props {
- indexPatterns: IndexPattern[];
- indexPatternCreationOptions: IndexPatternCreationOption[];
+ // Todo: temporary. should be reverted before merge
+ indexPatterns: any[];
+ indexPatternCreationOptions: any[];
}
interface State {
diff --git a/src/plugins/management/public/__snapshots__/management_app.test.tsx.snap b/src/plugins/management/public/__snapshots__/management_app.test.tsx.snap
deleted file mode 100644
index 7f13472ee02ee..0000000000000
--- a/src/plugins/management/public/__snapshots__/management_app.test.tsx.snap
+++ /dev/null
@@ -1,11 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`Management app can mount and unmount 1`] = `
-
-
- Test App - Hello world!
-
-
-`;
-
-exports[`Management app can mount and unmount 2`] = ``;
diff --git a/src/plugins/management/public/application.tsx b/src/plugins/management/public/application.tsx
new file mode 100644
index 0000000000000..5d014504b8938
--- /dev/null
+++ b/src/plugins/management/public/application.tsx
@@ -0,0 +1,42 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import React from 'react';
+import ReactDOM from 'react-dom';
+
+import { AppMountContext, AppMountParameters } from 'kibana/public';
+import { ManagementApp, ManagementAppDependencies } from './components/management_app';
+
+export const renderApp = async (
+ context: AppMountContext,
+ { history, appBasePath, element }: AppMountParameters,
+ dependencies: ManagementAppDependencies
+) => {
+ ReactDOM.render(
+ ,
+ element
+ );
+
+ return () => ReactDOM.unmountComponentAtNode(element);
+};
diff --git a/src/plugins/management/public/components/_index.scss b/src/plugins/management/public/components/_index.scss
deleted file mode 100644
index df0ebb48803d9..0000000000000
--- a/src/plugins/management/public/components/_index.scss
+++ /dev/null
@@ -1 +0,0 @@
-@import './management_sidebar_nav/index';
diff --git a/src/plugins/management/public/components/index.ts b/src/plugins/management/public/components/index.ts
index 2650d23d3c25c..8979809c5245e 100644
--- a/src/plugins/management/public/components/index.ts
+++ b/src/plugins/management/public/components/index.ts
@@ -17,5 +17,5 @@
* under the License.
*/
-export { ManagementSidebarNav } from './management_sidebar_nav';
-export { ManagementChrome } from './management_chrome';
+export { ManagementApp } from './management_app';
+export { managementSections } from './management_sections';
diff --git a/src/plugins/management/public/components/management_chrome/index.ts b/src/plugins/management/public/components/langing/index.ts
similarity index 93%
rename from src/plugins/management/public/components/management_chrome/index.ts
rename to src/plugins/management/public/components/langing/index.ts
index b82c1af871be7..79a1c2b1145c2 100644
--- a/src/plugins/management/public/components/management_chrome/index.ts
+++ b/src/plugins/management/public/components/langing/index.ts
@@ -17,4 +17,4 @@
* under the License.
*/
-export { ManagementChrome } from './management_chrome';
+export { ManagementLandingPage } from './landing';
diff --git a/src/plugins/management/public/components/langing/landing.tsx b/src/plugins/management/public/components/langing/landing.tsx
new file mode 100644
index 0000000000000..a82044784bc95
--- /dev/null
+++ b/src/plugins/management/public/components/langing/landing.tsx
@@ -0,0 +1,71 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import React from 'react';
+import { FormattedMessage } from '@kbn/i18n/react';
+
+import {
+ EuiHorizontalRule,
+ EuiIcon,
+ EuiPageContent,
+ EuiSpacer,
+ EuiText,
+ EuiTitle,
+} from '@elastic/eui';
+
+interface ManagementLandingPageProps {
+ version: string;
+}
+
+export const ManagementLandingPage = ({ version }: ManagementLandingPageProps) => (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+);
diff --git a/src/plugins/management/public/components/management_app/_management_app.scss b/src/plugins/management/public/components/management_app/_management_app.scss
new file mode 100644
index 0000000000000..6eaf82ba8283d
--- /dev/null
+++ b/src/plugins/management/public/components/management_app/_management_app.scss
@@ -0,0 +1,19 @@
+.mgtPanel {
+ margin-bottom: $euiSize;
+ background: $euiColorEmptyShade;
+}
+
+/**
+ * 1. Override kuiPanelBody styles to accommodate padding of items within the panel body..
+ */
+.mgtPanel__body {
+ padding: 5px 10px; /* 1 */
+}
+
+/**
+ * 1. Create vertical space between items when they wrap.
+ */
+.mgtPanel__item {
+ padding: 5px 15px; /* 1 */
+}
+
diff --git a/src/plugins/management/public/legacy/index.js b/src/plugins/management/public/components/management_app/index.ts
similarity index 87%
rename from src/plugins/management/public/legacy/index.js
rename to src/plugins/management/public/components/management_app/index.ts
index f2e0ba89b7b59..83f8ae0159978 100644
--- a/src/plugins/management/public/legacy/index.js
+++ b/src/plugins/management/public/components/management_app/index.ts
@@ -17,5 +17,4 @@
* under the License.
*/
-export { LegacyManagementAdapter } from './sections_register';
-export { LegacyManagementSection } from './section';
+export { ManagementApp, ManagementAppDependencies } from './management_app';
diff --git a/src/plugins/management/public/components/management_app/management_app.tsx b/src/plugins/management/public/components/management_app/management_app.tsx
new file mode 100644
index 0000000000000..7dffc4f5942fb
--- /dev/null
+++ b/src/plugins/management/public/components/management_app/management_app.tsx
@@ -0,0 +1,110 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React, { useState, useEffect, useCallback } from 'react';
+import { Route, Router, Switch } from 'react-router-dom';
+import { AppMountContext, AppMountParameters, ChromeBreadcrumb } from 'kibana/public';
+import { I18nProvider } from '@kbn/i18n/src/react';
+import { EuiPage, EuiPageBody } from '@elastic/eui';
+import { ManagementStart } from '../../types';
+import { ManagementSection } from '../../utils';
+
+import { ManagementLandingPage } from '../langing';
+import { ManagementSidebarNav } from '../management_sidebar_nav';
+import { ManagementAppWrapper } from '../management_app_wrapper';
+
+import './_management_app.scss';
+
+interface ManagementAppProps {
+ appBasePath: string;
+ context: AppMountContext;
+ history: AppMountParameters['history'];
+ dependencies: ManagementAppDependencies;
+}
+
+export interface ManagementAppDependencies {
+ management: ManagementStart;
+ kibanaVersion: string;
+}
+
+export const ManagementApp = ({ context, dependencies, history }: ManagementAppProps) => {
+ const [selectedId, setSelectedId] = useState('');
+ const [sections, setSections] = useState();
+
+ const onManagementSectionSelected = useCallback(
+ (id: string, path: string) => {
+ history.push(path);
+ },
+ [history]
+ );
+
+ const onAppMounted = useCallback((id: string) => {
+ setSelectedId(id);
+ }, []);
+
+ const setBreadcrumbs = useCallback(
+ (crumbs: ChromeBreadcrumb[]) => {
+ context.core.chrome.setBreadcrumbs(crumbs);
+ },
+ [context.core.chrome]
+ );
+
+ useEffect(() => {
+ setSections(dependencies.management.sections.getSectionsEnabled());
+ }, [dependencies.management.sections]);
+
+ if (!sections) {
+ return null;
+ }
+
+ return (
+
+
+
+
+
+
+ {sections.map(section =>
+ section.apps.map(app => (
+ (
+
+ )}
+ />
+ ))
+ )}
+ }
+ />
+
+
+
+
+
+ );
+};
diff --git a/src/legacy/core_plugins/kibana/public/management/saved_object_registry.ts b/src/plugins/management/public/components/management_app_wrapper/index.tsx
similarity index 82%
rename from src/legacy/core_plugins/kibana/public/management/saved_object_registry.ts
rename to src/plugins/management/public/components/management_app_wrapper/index.tsx
index 587a372f91555..71546e7ca1342 100644
--- a/src/legacy/core_plugins/kibana/public/management/saved_object_registry.ts
+++ b/src/plugins/management/public/components/management_app_wrapper/index.tsx
@@ -17,8 +17,4 @@
* under the License.
*/
-import { npSetup } from 'ui/new_platform';
-
-const registry = npSetup.plugins.savedObjectsManagement?.serviceRegistry;
-
-export const savedObjectManagementRegistry = registry!;
+export { ManagementAppWrapper } from './management_app_wrapper';
diff --git a/src/plugins/management/public/components/management_app_wrapper/management_app_wrapper.tsx b/src/plugins/management/public/components/management_app_wrapper/management_app_wrapper.tsx
new file mode 100644
index 0000000000000..dac219823b7ca
--- /dev/null
+++ b/src/plugins/management/public/components/management_app_wrapper/management_app_wrapper.tsx
@@ -0,0 +1,69 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import React, { useEffect, createRef, useRef, RefObject } from 'react';
+
+import { ChromeBreadcrumb } from 'kibana/public';
+import { ManagementApp } from '../../utils';
+import { Unmount } from '../../types';
+
+interface ManagementSectionWrapperProps {
+ app: ManagementApp;
+ setBreadcrumbs: (crumbs: ChromeBreadcrumb[]) => void;
+ onAppMounted: (id: string) => void;
+}
+
+export const ManagementAppWrapper = ({
+ app,
+ setBreadcrumbs,
+ onAppMounted,
+}: ManagementSectionWrapperProps) => {
+ const mountElementRef = useRef>();
+ const { mount, basePath } = app;
+ const unmount = useRef();
+
+ mountElementRef.current = createRef();
+
+ useEffect(() => {
+ if (mount && basePath) {
+ const mountResult = mount({
+ basePath,
+ setBreadcrumbs,
+ element: mountElementRef.current!.current,
+ });
+
+ onAppMounted(app.id);
+
+ if (mountResult instanceof Promise) {
+ mountResult.then(um => {
+ unmount.current = um;
+ });
+ } else {
+ unmount.current = mountResult;
+ }
+ return () => {
+ if (unmount.current) {
+ unmount.current();
+ }
+ };
+ }
+ }, [app.id, basePath, mount, onAppMounted, setBreadcrumbs]);
+
+ return ;
+};
diff --git a/src/plugins/management/public/components/management_chrome/management_chrome.tsx b/src/plugins/management/public/components/management_chrome/management_chrome.tsx
deleted file mode 100644
index df844e2208936..0000000000000
--- a/src/plugins/management/public/components/management_chrome/management_chrome.tsx
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import * as React from 'react';
-import { EuiPage, EuiPageBody, EuiPageSideBar } from '@elastic/eui';
-import { I18nProvider } from '@kbn/i18n/react';
-import { ManagementSidebarNav } from '../management_sidebar_nav';
-import { LegacySection } from '../../types';
-import { ManagementSection } from '../../management_section';
-
-interface Props {
- getSections: () => ManagementSection[];
- legacySections: LegacySection[];
- selectedId: string;
- onMounted: (element: HTMLDivElement) => void;
-}
-
-export class ManagementChrome extends React.Component {
- private container = React.createRef();
- componentDidMount() {
- if (this.container.current) {
- this.props.onMounted(this.container.current);
- }
- }
- render() {
- return (
-
-
-
-
-
-
-
-
-
-
- );
- }
-}
diff --git a/src/plugins/management/public/management_sections.tsx b/src/plugins/management/public/components/management_sections.tsx
similarity index 93%
rename from src/plugins/management/public/management_sections.tsx
rename to src/plugins/management/public/components/management_sections.tsx
index 77e494626a00e..33c3526c4d23b 100644
--- a/src/plugins/management/public/management_sections.tsx
+++ b/src/plugins/management/public/components/management_sections.tsx
@@ -20,14 +20,14 @@
import React from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiToolTip, EuiIcon } from '@elastic/eui';
-import { ManagementSectionId } from './types';
+import { ManagementSectionId } from '../types';
-interface Props {
+interface ManagementSectionTitleProps {
text: string;
tip: string;
}
-const ManagementSectionTitle = ({ text, tip }: Props) => (
+const ManagementSectionTitle = ({ text, tip }: ManagementSectionTitleProps) => (
{text}
diff --git a/src/plugins/management/public/components/management_sidebar_nav/__snapshots__/management_sidebar_nav.test.ts.snap b/src/plugins/management/public/components/management_sidebar_nav/__snapshots__/management_sidebar_nav.test.ts.snap
deleted file mode 100644
index e7225b356ed68..0000000000000
--- a/src/plugins/management/public/components/management_sidebar_nav/__snapshots__/management_sidebar_nav.test.ts.snap
+++ /dev/null
@@ -1,95 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`Management adds legacy apps to existing SidebarNav sections 1`] = `
-Array [
- Object {
- "data-test-subj": "activeSection",
- "icon": null,
- "id": "activeSection",
- "items": Array [
- Object {
- "data-test-subj": "item",
- "href": undefined,
- "id": "item",
- "isSelected": false,
- "name": "item",
- "order": undefined,
- },
- ],
- "name": "activeSection",
- "order": 10,
- },
- Object {
- "data-test-subj": "no-active-items",
- "icon": null,
- "id": "no-active-items",
- "items": Array [
- Object {
- "data-test-subj": "disabled",
- "href": undefined,
- "id": "disabled",
- "isSelected": false,
- "name": "disabled",
- "order": undefined,
- },
- Object {
- "data-test-subj": "notVisible",
- "href": undefined,
- "id": "notVisible",
- "isSelected": false,
- "name": "notVisible",
- "order": undefined,
- },
- ],
- "name": "No active items",
- "order": 10,
- },
-]
-`;
-
-exports[`Management maps legacy sections and apps into SidebarNav items 1`] = `
-Array [
- Object {
- "data-test-subj": "no-active-items",
- "icon": null,
- "id": "no-active-items",
- "items": Array [
- Object {
- "data-test-subj": "disabled",
- "href": undefined,
- "id": "disabled",
- "isSelected": false,
- "name": "disabled",
- "order": undefined,
- },
- Object {
- "data-test-subj": "notVisible",
- "href": undefined,
- "id": "notVisible",
- "isSelected": false,
- "name": "notVisible",
- "order": undefined,
- },
- ],
- "name": "No active items",
- "order": 10,
- },
- Object {
- "data-test-subj": "activeSection",
- "icon": null,
- "id": "activeSection",
- "items": Array [
- Object {
- "data-test-subj": "item",
- "href": undefined,
- "id": "item",
- "isSelected": false,
- "name": "item",
- "order": undefined,
- },
- ],
- "name": "activeSection",
- "order": 10,
- },
-]
-`;
diff --git a/src/plugins/management/public/components/management_sidebar_nav/management_sidebar_nav.test.ts b/src/plugins/management/public/components/management_sidebar_nav/management_sidebar_nav.test.ts
deleted file mode 100644
index e04e0a7572612..0000000000000
--- a/src/plugins/management/public/components/management_sidebar_nav/management_sidebar_nav.test.ts
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import { IndexedArray } from '../../../../../legacy/ui/public/indexed_array';
-import { mergeLegacyItems } from './management_sidebar_nav';
-
-const toIndexedArray = (initialSet: any[]) =>
- new IndexedArray({
- index: ['id'],
- order: ['order'],
- initialSet,
- });
-
-const activeProps = { visible: true, disabled: false };
-const disabledProps = { visible: true, disabled: true };
-const notVisibleProps = { visible: false, disabled: false };
-const visibleItem = { display: 'item', id: 'item', ...activeProps };
-
-const notVisibleSection = {
- display: 'Not visible',
- id: 'not-visible',
- order: 10,
- visibleItems: toIndexedArray([visibleItem]),
- ...notVisibleProps,
-};
-const disabledSection = {
- display: 'Disabled',
- id: 'disabled',
- order: 10,
- visibleItems: toIndexedArray([visibleItem]),
- ...disabledProps,
-};
-const noItemsSection = {
- display: 'No items',
- id: 'no-items',
- order: 10,
- visibleItems: toIndexedArray([]),
- ...activeProps,
-};
-const noActiveItemsSection = {
- display: 'No active items',
- id: 'no-active-items',
- order: 10,
- visibleItems: toIndexedArray([
- { display: 'disabled', id: 'disabled', ...disabledProps },
- { display: 'notVisible', id: 'notVisible', ...notVisibleProps },
- ]),
- ...activeProps,
-};
-const activeSection = {
- display: 'activeSection',
- id: 'activeSection',
- order: 10,
- visibleItems: toIndexedArray([visibleItem]),
- ...activeProps,
-};
-
-const managementSections = [
- notVisibleSection,
- disabledSection,
- noItemsSection,
- noActiveItemsSection,
- activeSection,
-];
-
-describe('Management', () => {
- it('maps legacy sections and apps into SidebarNav items', () => {
- expect(mergeLegacyItems([], managementSections, 'active-item-id')).toMatchSnapshot();
- });
-
- it('adds legacy apps to existing SidebarNav sections', () => {
- const navSection = {
- 'data-test-subj': 'activeSection',
- icon: null,
- id: 'activeSection',
- items: [],
- name: 'activeSection',
- order: 10,
- };
- expect(mergeLegacyItems([navSection], managementSections, 'active-item-id')).toMatchSnapshot();
- });
-});
diff --git a/src/plugins/management/public/components/management_sidebar_nav/management_sidebar_nav.tsx b/src/plugins/management/public/components/management_sidebar_nav/management_sidebar_nav.tsx
index c58de6d8b0a81..0fa338710ae5a 100644
--- a/src/plugins/management/public/components/management_sidebar_nav/management_sidebar_nav.tsx
+++ b/src/plugins/management/public/components/management_sidebar_nav/management_sidebar_nav.tsx
@@ -17,184 +17,94 @@
* under the License.
*/
-import {
- EuiIcon,
- // @ts-ignore
- EuiSideNav,
- EuiScreenReaderOnly,
-} from '@elastic/eui';
-import { FormattedMessage } from '@kbn/i18n/react';
+import { EuiIcon, EuiSideNav, EuiSideNavItemType, EuiScreenReaderOnly } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
-import React, { ReactElement } from 'react';
-import { LegacySection, LegacyApp } from '../../types';
-import { ManagementApp } from '../../management_app';
-import { ManagementSection } from '../../management_section';
+import React, { useState } from 'react';
+import { ManagementApp, ManagementSection } from '../../utils';
-interface NavApp {
- id: string;
- name: ReactElement | string;
- [key: string]: unknown;
- order: number; // only needed while merging platform and legacy
-}
-
-interface NavSection extends NavApp {
- items: NavApp[];
-}
+import './_index.scss';
+import { ManagementItem } from '../../utils/management_item';
interface ManagementSidebarNavProps {
- getSections: () => ManagementSection[];
- legacySections: LegacySection[];
+ sections: ManagementSection[];
+ onManagementSectionSelected: (id: string, path: string) => void;
selectedId: string;
}
-interface ManagementSidebarNavState {
- isSideNavOpenOnMobile: boolean;
-}
-
-const managementSectionOrAppToNav = (appOrSection: ManagementApp | ManagementSection) => ({
- id: appOrSection.id,
- name: appOrSection.title,
- 'data-test-subj': appOrSection.id,
- order: appOrSection.order,
-});
-
-const managementSectionToNavSection = (section: ManagementSection) => {
- const iconType = section.euiIconType
- ? section.euiIconType
- : section.icon
- ? section.icon
- : 'empty';
-
- return {
- icon: ,
- ...managementSectionOrAppToNav(section),
- };
-};
-
-const managementAppToNavItem = (selectedId?: string, parentId?: string) => (
- app: ManagementApp
-) => ({
- isSelected: selectedId === app.id,
- href: `#/management/${parentId}/${app.id}`,
- ...managementSectionOrAppToNav(app),
-});
-
-const legacySectionToNavSection = (section: LegacySection) => ({
- name: section.display,
- id: section.id,
- icon: section.icon ? : null,
- items: [],
- 'data-test-subj': section.id,
- // @ts-ignore
- order: section.order,
+const headerLabel = i18n.translate('management.nav.label', {
+ defaultMessage: 'Management',
});
-const legacyAppToNavItem = (app: LegacyApp, selectedId: string) => ({
- isSelected: selectedId === app.id,
- name: app.display,
- id: app.id,
- href: app.url,
- 'data-test-subj': app.id,
- // @ts-ignore
- order: app.order,
+const navMenuLabel = i18n.translate('management.nav.menu', {
+ defaultMessage: 'Management menu',
});
-const sectionVisible = (section: LegacySection | LegacyApp) => !section.disabled && section.visible;
-
-const sideNavItems = (sections: ManagementSection[], selectedId: string) =>
- sections.map(section => ({
- items: section.getAppsEnabled().map(managementAppToNavItem(selectedId, section.id)),
- ...managementSectionToNavSection(section),
- }));
-
-const findOrAddSection = (navItems: NavSection[], legacySection: LegacySection): NavSection => {
- const foundSection = navItems.find(sec => sec.id === legacySection.id);
-
- if (foundSection) {
- return foundSection;
- } else {
- const newSection = legacySectionToNavSection(legacySection);
- navItems.push(newSection);
- navItems.sort((a: NavSection, b: NavSection) => a.order - b.order); // only needed while merging platform and legacy
- return newSection;
- }
-};
-
-export const mergeLegacyItems = (
- navItems: NavSection[],
- legacySections: LegacySection[],
- selectedId: string
-) => {
- const filteredLegacySections = legacySections
- .filter(sectionVisible)
- .filter(section => section.visibleItems.length);
-
- filteredLegacySections.forEach(legacySection => {
- const section = findOrAddSection(navItems, legacySection);
- legacySection.visibleItems.forEach(app => {
- section.items.push(legacyAppToNavItem(app, selectedId));
- return section.items.sort((a, b) => a.order - b.order);
- });
- });
-
- return navItems;
-};
+/** @internal **/
+export const ManagementSidebarNav = ({
+ selectedId,
+ sections,
+ onManagementSectionSelected,
+}: ManagementSidebarNavProps) => {
+ const HEADER_ID = 'stack-management-nav-header';
+ const [isSideNavOpenOnMobile, setIsSideNavOpenOnMobile] = useState(false);
+ const toggleOpenOnMobile = () => setIsSideNavOpenOnMobile(!isSideNavOpenOnMobile);
+
+ const sectionsToNavItems = (managementSections: ManagementSection[]) => {
+ if (!managementSections) {
+ return undefined;
+ }
+
+ return (managementSections || [])
+ .filter(section => section.getAppsEnabled())
+ .map(section => ({
+ ...createNavItem(section, {
+ items: appsToNavItems(section.apps),
+ }),
+ }));
+ };
-const sectionsToItems = (
- sections: ManagementSection[],
- legacySections: LegacySection[],
- selectedId: string
-) => {
- const navItems = sideNavItems(sections, selectedId);
- return mergeLegacyItems(navItems, legacySections, selectedId);
-};
+ const appsToNavItems = (managementApps: ManagementApp[]) => {
+ if (!managementApps) {
+ return undefined;
+ }
+
+ return (managementApps || [])
+ .filter(app => app.enabled)
+ .map(app => ({
+ ...createNavItem(app, {
+ onClick: () => onManagementSectionSelected(app.id, app.basePath),
+ }),
+ }));
+ };
-export class ManagementSidebarNav extends React.Component<
- ManagementSidebarNavProps,
- ManagementSidebarNavState
-> {
- constructor(props: ManagementSidebarNavProps) {
- super(props);
- this.state = {
- isSideNavOpenOnMobile: false,
+ const createNavItem = (
+ item: T,
+ customParams: Record = {}
+ ): EuiSideNavItemType => {
+ const iconType = item.euiIconType || item.icon;
+
+ return {
+ id: item.id,
+ name: item.title,
+ isSelected: item.id === selectedId,
+ icon: iconType ? : undefined,
+ ...customParams,
};
- }
-
- public render() {
- const HEADER_ID = 'stack-management-nav-header';
-
- return (
- <>
-
-
-
-
- >
- );
- }
-
- private renderMobileTitle() {
- return ;
- }
-
- private toggleOpenOnMobile = () => {
- this.setState({
- isSideNavOpenOnMobile: !this.state.isSideNavOpenOnMobile,
- });
};
-}
+
+ return (
+ <>
+
+
+
+
+ >
+ );
+};
diff --git a/src/plugins/management/public/index.ts b/src/plugins/management/public/index.ts
index f2cc6a00b93d8..3ba469c7831f6 100644
--- a/src/plugins/management/public/index.ts
+++ b/src/plugins/management/public/index.ts
@@ -21,17 +21,14 @@ import { PluginInitializerContext } from 'kibana/public';
import { ManagementPlugin } from './plugin';
export function plugin(initializerContext: PluginInitializerContext) {
- return new ManagementPlugin();
+ return new ManagementPlugin(initializerContext);
}
+export { RegisterManagementAppArgs, ManagementSection, ManagementApp } from './utils';
+
export {
- ManagementSetup,
- ManagementStart,
- RegisterManagementApp,
ManagementSectionId,
- RegisterManagementAppArgs,
ManagementAppMountParams,
+ ManagementSetup,
+ ManagementStart,
} from './types';
-export { ManagementApp } from './management_app';
-export { ManagementSection } from './management_section';
-export { ManagementSidebarNav } from './components'; // for use in legacy management apps
diff --git a/src/plugins/management/public/legacy/redirect_messages.tsx b/src/plugins/management/public/legacy/redirect_messages.tsx
deleted file mode 100644
index f8cb975e6fae5..0000000000000
--- a/src/plugins/management/public/legacy/redirect_messages.tsx
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import React from 'react';
-import { EuiCallOut } from '@elastic/eui';
-import { NotificationsStart, OverlayStart } from 'kibana/public';
-import { parse } from 'query-string';
-import { i18n } from '@kbn/i18n';
-import { toMountPoint } from '../../../kibana_react/public';
-import { MarkdownSimple } from '../../../kibana_react/public';
-
-/**
- * Show banners and toasts carried over from other applications. This is only necessary as long as
- * management is rendered in the legacy platform (which requires a full page reload to switch to).
- *
- * Once management is rendered using the core application service, this file and the places setting
- * bannerMessage and notFoundMessage URL params can be removed.
- * @param notifications Core notifications service
- * @param overlays Core overlays service
- */
-export function showLegacyRedirectMessages(
- notifications: NotificationsStart,
- overlays: OverlayStart
-) {
- const queryPosition = window.location.hash.indexOf('?');
- if (queryPosition === -1) {
- return;
- }
-
- const urlParams = parse(window.location.hash.substr(queryPosition)) as Record;
-
- if (urlParams.bannerMessage) {
- const bannerId = overlays.banners.add(
- toMountPoint(
-
- )
- );
- setTimeout(() => {
- overlays.banners.remove(bannerId);
- }, 15000);
- }
-
- if (urlParams.notFoundMessage) {
- notifications.toasts.addWarning({
- title: i18n.translate('management.history.savedObjectIsMissingNotificationMessage', {
- defaultMessage: 'Saved object is missing',
- }),
- text: toMountPoint({urlParams.notFoundMessage}),
- });
- }
-}
diff --git a/src/plugins/management/public/legacy/section.js b/src/plugins/management/public/legacy/section.js
deleted file mode 100644
index 7d733b7b3173b..0000000000000
--- a/src/plugins/management/public/legacy/section.js
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import { assign } from 'lodash';
-import { IndexedArray } from '../../../../legacy/ui/public/indexed_array';
-
-const listeners = [];
-
-export class LegacyManagementSection {
- /**
- * @param {string} id
- * @param {object} options
- * @param {number|null} options.order
- * @param {string|null} options.display - defaults to id
- * @param {string|null} options.url - defaults to ''
- * @param {boolean|null} options.visible - defaults to true
- * @param {boolean|null} options.disabled - defaults to false
- * @param {string|null} options.tooltip - defaults to ''
- * @param {string|null} options.icon - defaults to ''
- * @returns {ManagementSection}
- */
-
- constructor(id, options = {}, capabilities) {
- this.display = id;
- this.id = id;
- this.items = new IndexedArray({
- index: ['id'],
- order: ['order'],
- });
- this.visible = true;
- this.disabled = false;
- this.tooltip = '';
- this.icon = '';
- this.url = '';
- this.capabilities = capabilities;
-
- assign(this, options);
- }
-
- get visibleItems() {
- return this.items.inOrder.filter(item => {
- const capabilityManagementSection = this.capabilities.management[this.id];
- const itemCapability = capabilityManagementSection
- ? capabilityManagementSection[item.id]
- : null;
-
- return item.visible && itemCapability !== false;
- });
- }
-
- /**
- * Registers a callback that will be executed when management sections are updated
- * Globally bound to solve for sidebar nav needs
- *
- * @param {function} fn
- */
- addListener(fn) {
- listeners.push(fn);
- }
-
- /**
- * Registers a sub-section
- *
- * @param {string} id
- * @param {object} options
- * @returns {ManagementSection}
- */
-
- register(id, options = {}) {
- const item = new LegacyManagementSection(
- id,
- assign(options, { parent: this }),
- this.capabilities
- );
-
- if (this.hasItem(id)) {
- throw new Error(`'${id}' is already registered`);
- }
-
- this.items.push(item);
- listeners.forEach(fn => fn());
-
- return item;
- }
-
- /**
- * Deregisters a section
- *
- * @param {string} id
- */
- deregister(id) {
- this.items.remove(item => item.id === id);
- listeners.forEach(fn => fn(this.items));
- }
-
- /**
- * Determine if an id is already registered
- *
- * @param {string} id
- * @returns {boolean}
- */
-
- hasItem(id) {
- return this.items.byId.hasOwnProperty(id);
- }
-
- /**
- * Fetches a section by id
- *
- * @param {string} id
- * @returns {ManagementSection}
- */
-
- getSection(id) {
- if (!id) {
- return;
- }
-
- const sectionPath = id.split('/');
- return sectionPath.reduce((currentSection, nextSection) => {
- if (!currentSection) {
- return;
- }
-
- return currentSection.items.byId[nextSection];
- }, this);
- }
-
- hide() {
- this.visible = false;
- }
-
- show() {
- this.visible = true;
- }
-
- disable() {
- this.disabled = true;
- }
-
- enable() {
- this.disabled = false;
- }
-}
diff --git a/src/plugins/management/public/legacy/section.test.js b/src/plugins/management/public/legacy/section.test.js
deleted file mode 100644
index 45cc80ef80edd..0000000000000
--- a/src/plugins/management/public/legacy/section.test.js
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import { LegacyManagementSection } from './section';
-import { IndexedArray } from '../../../../legacy/ui/public/indexed_array';
-
-const capabilitiesMock = {
- management: {
- kibana: { sampleFeature2: false },
- },
-};
-
-describe('ManagementSection', () => {
- describe('constructor', () => {
- it('defaults display to id', () => {
- const section = new LegacyManagementSection('kibana', {}, capabilitiesMock);
- expect(section.display).toBe('kibana');
- });
-
- it('defaults visible to true', () => {
- const section = new LegacyManagementSection('kibana', {}, capabilitiesMock);
- expect(section.visible).toBe(true);
- });
-
- it('defaults disabled to false', () => {
- const section = new LegacyManagementSection('kibana', {}, capabilitiesMock);
- expect(section.disabled).toBe(false);
- });
-
- it('defaults tooltip to empty string', () => {
- const section = new LegacyManagementSection('kibana', {}, capabilitiesMock);
- expect(section.tooltip).toBe('');
- });
-
- it('defaults url to empty string', () => {
- const section = new LegacyManagementSection('kibana', {}, capabilitiesMock);
- expect(section.url).toBe('');
- });
-
- it('exposes items', () => {
- const section = new LegacyManagementSection('kibana', {}, capabilitiesMock);
- expect(section.items).toHaveLength(0);
- });
-
- it('exposes visibleItems', () => {
- const section = new LegacyManagementSection('kibana', {}, capabilitiesMock);
- expect(section.visibleItems).toHaveLength(0);
- });
-
- it('assigns all options', () => {
- const section = new LegacyManagementSection(
- 'kibana',
- { description: 'test', url: 'foobar' },
- capabilitiesMock
- );
- expect(section.description).toBe('test');
- expect(section.url).toBe('foobar');
- });
- });
-
- describe('register', () => {
- let section;
-
- beforeEach(() => {
- section = new LegacyManagementSection('kibana', {}, capabilitiesMock);
- });
-
- it('returns a ManagementSection', () => {
- expect(section.register('about')).toBeInstanceOf(LegacyManagementSection);
- });
-
- it('provides a reference to the parent', () => {
- expect(section.register('about').parent).toBe(section);
- });
-
- it('adds item', function() {
- section.register('about', { description: 'test' });
-
- expect(section.items).toHaveLength(1);
- expect(section.items[0]).toBeInstanceOf(LegacyManagementSection);
- expect(section.items[0].id).toBe('about');
- });
-
- it('can only register a section once', () => {
- let threwException = false;
- section.register('about');
-
- try {
- section.register('about');
- } catch (e) {
- threwException = e.message.indexOf('is already registered') > -1;
- }
-
- expect(threwException).toBe(true);
- });
-
- it('calls listener when item added', () => {
- let listerCalled = false;
- const listenerFn = () => {
- listerCalled = true;
- };
-
- section.addListener(listenerFn);
- section.register('about');
- expect(listerCalled).toBe(true);
- });
- });
-
- describe('deregister', () => {
- let section;
-
- beforeEach(() => {
- section = new LegacyManagementSection('kibana', {}, capabilitiesMock);
- section.register('about');
- });
-
- it('deregisters an existing section', () => {
- section.deregister('about');
- expect(section.items).toHaveLength(0);
- });
-
- it('allows deregistering a section more than once', () => {
- section.deregister('about');
- section.deregister('about');
- expect(section.items).toHaveLength(0);
- });
-
- it('calls listener when item added', () => {
- let listerCalled = false;
- const listenerFn = () => {
- listerCalled = true;
- };
-
- section.addListener(listenerFn);
- section.deregister('about');
- expect(listerCalled).toBe(true);
- });
- });
-
- describe('getSection', () => {
- let section;
-
- beforeEach(() => {
- section = new LegacyManagementSection('kibana', {}, capabilitiesMock);
- section.register('about');
- });
-
- it('returns registered section', () => {
- expect(section.getSection('about')).toBeInstanceOf(LegacyManagementSection);
- });
-
- it('returns undefined if un-registered', () => {
- expect(section.getSection('unknown')).not.toBeDefined();
- });
-
- it('returns sub-sections specified via a /-separated path', () => {
- section.getSection('about').register('time');
- expect(section.getSection('about/time')).toBeInstanceOf(LegacyManagementSection);
- expect(section.getSection('about/time')).toBe(section.getSection('about').getSection('time'));
- });
-
- it('returns undefined if a sub-section along a /-separated path does not exist', () => {
- expect(section.getSection('about/damn/time')).toBe(undefined);
- });
- });
-
- describe('items', () => {
- let section;
-
- beforeEach(() => {
- section = new LegacyManagementSection('kibana', {}, capabilitiesMock);
-
- section.register('three', { order: 3 });
- section.register('one', { order: 1 });
- section.register('two', { order: 2 });
- });
-
- it('is an indexed array', () => {
- expect(section.items).toBeInstanceOf(IndexedArray);
- });
-
- it('is indexed on id', () => {
- const keys = Object.keys(section.items.byId).sort();
- expect(section.items.byId).toBeInstanceOf(Object);
-
- expect(keys).toEqual(['one', 'three', 'two']);
- });
-
- it('can be ordered', () => {
- const ids = section.items.inOrder.map(i => {
- return i.id;
- });
- expect(ids).toEqual(['one', 'two', 'three']);
- });
- });
-
- describe('visible', () => {
- let section;
-
- beforeEach(() => {
- section = new LegacyManagementSection('kibana', {}, capabilitiesMock);
- });
-
- it('hide sets visible to false', () => {
- section.hide();
- expect(section.visible).toBe(false);
- });
-
- it('show sets visible to true', () => {
- section.hide();
- section.show();
- expect(section.visible).toBe(true);
- });
- });
-
- describe('disabled', () => {
- let section;
-
- beforeEach(() => {
- section = new LegacyManagementSection('kibana', {}, capabilitiesMock);
- });
-
- it('disable sets disabled to true', () => {
- section.disable();
- expect(section.disabled).toBe(true);
- });
-
- it('enable sets disabled to false', () => {
- section.enable();
- expect(section.disabled).toBe(false);
- });
- });
-
- describe('visibleItems', () => {
- let section;
-
- beforeEach(() => {
- section = new LegacyManagementSection('kibana', {}, capabilitiesMock);
-
- section.register('three', { order: 3 });
- section.register('one', { order: 1 });
- section.register('two', { order: 2 });
- });
-
- it('maintains the order', () => {
- const ids = section.visibleItems.map(i => {
- return i.id;
- });
- expect(ids).toEqual(['one', 'two', 'three']);
- });
-
- it('does not include hidden items', () => {
- section.getSection('two').hide();
-
- const ids = section.visibleItems.map(i => {
- return i.id;
- });
- expect(ids).toEqual(['one', 'three']);
- });
-
- it('does not include visible items hidden via uiCapabilities', () => {
- section.register('sampleFeature2', { order: 4, visible: true });
- const ids = section.visibleItems.map(i => {
- return i.id;
- });
- expect(ids).toEqual(['one', 'two', 'three']);
- });
- });
-});
diff --git a/src/plugins/management/public/legacy/sections_register.js b/src/plugins/management/public/legacy/sections_register.js
deleted file mode 100644
index 3fa1998c378f6..0000000000000
--- a/src/plugins/management/public/legacy/sections_register.js
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import { i18n } from '@kbn/i18n';
-import { LegacyManagementSection } from './section';
-import { managementSections } from '../management_sections';
-
-export class LegacyManagementAdapter {
- main = undefined;
- init = capabilities => {
- this.main = new LegacyManagementSection(
- 'management',
- {
- display: i18n.translate('management.displayName', {
- defaultMessage: 'Stack Management',
- }),
- },
- capabilities
- );
-
- managementSections.forEach(({ id, title }, idx) => {
- this.main.register(id, {
- display: title,
- order: idx,
- });
- });
-
- return this.main;
- };
- getManagement = () => this.main;
-}
diff --git a/src/plugins/management/public/management_app.test.tsx b/src/plugins/management/public/management_app.test.tsx
deleted file mode 100644
index a76b234d95ef5..0000000000000
--- a/src/plugins/management/public/management_app.test.tsx
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import * as React from 'react';
-import * as ReactDOM from 'react-dom';
-import { coreMock } from '../../../core/public/mocks';
-
-import { ManagementApp } from './management_app';
-// @ts-ignore
-import { LegacyManagementSection } from './legacy';
-
-function createTestApp() {
- const legacySection = new LegacyManagementSection('legacy');
- return new ManagementApp(
- {
- id: 'test-app',
- title: 'Test App',
- basePath: '',
- mount(params) {
- params.setBreadcrumbs([{ text: 'Test App' }]);
- ReactDOM.render(Test App - Hello world!
, params.element);
-
- return () => {
- ReactDOM.unmountComponentAtNode(params.element);
- };
- },
- },
- () => [],
- jest.fn(),
- () => legacySection,
- coreMock.createSetup().getStartServices
- );
-}
-
-test('Management app can mount and unmount', async () => {
- const testApp = createTestApp();
- const container = document.createElement('div');
- document.body.appendChild(container);
- const unmount = testApp.mount({ element: container, basePath: '', setBreadcrumbs: jest.fn() });
- expect(container).toMatchSnapshot();
- (await unmount)();
- expect(container).toMatchSnapshot();
-});
-
-test('Enabled by default, can disable', () => {
- const testApp = createTestApp();
- expect(testApp.enabled).toBe(true);
- testApp.disable();
- expect(testApp.enabled).toBe(false);
-});
diff --git a/src/plugins/management/public/management_app.tsx b/src/plugins/management/public/management_app.tsx
deleted file mode 100644
index 843bbfde654ee..0000000000000
--- a/src/plugins/management/public/management_app.tsx
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import * as React from 'react';
-import ReactDOM from 'react-dom';
-import { i18n } from '@kbn/i18n';
-import { CreateManagementApp, ManagementSectionMount, Unmount } from './types';
-import { KibanaLegacySetup } from '../../kibana_legacy/public';
-// @ts-ignore
-import { LegacyManagementSection } from './legacy';
-import { ManagementChrome } from './components';
-import { ManagementSection } from './management_section';
-import { ChromeBreadcrumb, StartServicesAccessor } from '../../../core/public/';
-
-export class ManagementApp {
- readonly id: string;
- readonly title: string;
- readonly basePath: string;
- readonly order: number;
- readonly mount: ManagementSectionMount;
- private enabledStatus = true;
-
- constructor(
- { id, title, basePath, order = 100, mount }: CreateManagementApp,
- getSections: () => ManagementSection[],
- registerLegacyApp: KibanaLegacySetup['registerLegacyApp'],
- getLegacyManagementSections: () => LegacyManagementSection,
- getStartServices: StartServicesAccessor
- ) {
- this.id = id;
- this.title = title;
- this.basePath = basePath;
- this.order = order;
- this.mount = mount;
-
- registerLegacyApp({
- id: basePath.substr(1), // get rid of initial slash
- title,
- mount: async ({}, params) => {
- let appUnmount: Unmount;
- if (!this.enabledStatus) {
- const [coreStart] = await getStartServices();
- coreStart.application.navigateToApp('kibana#/management');
- return () => {};
- }
- async function setBreadcrumbs(crumbs: ChromeBreadcrumb[]) {
- const [coreStart] = await getStartServices();
- coreStart.chrome.setBreadcrumbs([
- {
- text: i18n.translate('management.breadcrumb', {
- defaultMessage: 'Stack Management',
- }),
- href: '#/management',
- },
- ...crumbs,
- ]);
- }
-
- ReactDOM.render(
- {
- appUnmount = await mount({
- basePath,
- element,
- setBreadcrumbs,
- });
- }}
- />,
- params.element
- );
-
- return async () => {
- appUnmount();
- ReactDOM.unmountComponentAtNode(params.element);
- };
- },
- });
- }
- public enable() {
- this.enabledStatus = true;
- }
- public disable() {
- this.enabledStatus = false;
- }
- public get enabled() {
- return this.enabledStatus;
- }
-}
diff --git a/src/plugins/management/public/management_section.test.ts b/src/plugins/management/public/management_section.test.ts
deleted file mode 100644
index e1d047425ac18..0000000000000
--- a/src/plugins/management/public/management_section.test.ts
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import { ManagementSection } from './management_section';
-import { ManagementSectionId } from './types';
-// @ts-ignore
-import { LegacyManagementSection } from './legacy';
-import { coreMock } from '../../../core/public/mocks';
-
-function createSection(registerLegacyApp: () => void) {
- const legacySection = new LegacyManagementSection('legacy');
- const getLegacySection = () => legacySection;
- const getManagementSections: () => ManagementSection[] = () => [];
-
- const testSectionConfig = { id: ManagementSectionId.Data, title: 'Test Section' };
- return new ManagementSection(
- testSectionConfig,
- getManagementSections,
- registerLegacyApp,
- getLegacySection,
- coreMock.createSetup().getStartServices
- );
-}
-
-test('cannot register two apps with the same id', () => {
- const registerLegacyApp = jest.fn();
- const section = createSection(registerLegacyApp);
-
- const testAppConfig = { id: 'test-app', title: 'Test App', mount: () => () => {} };
-
- section.registerApp(testAppConfig);
- expect(registerLegacyApp).toHaveBeenCalled();
- expect(section.apps.length).toEqual(1);
-
- expect(() => {
- section.registerApp(testAppConfig);
- }).toThrow();
-});
-
-test('can enable and disable apps', () => {
- const registerLegacyApp = jest.fn();
- const section = createSection(registerLegacyApp);
-
- const testAppConfig = { id: 'test-app', title: 'Test App', mount: () => () => {} };
-
- const app = section.registerApp(testAppConfig);
- expect(section.getAppsEnabled().length).toEqual(1);
- app.disable();
- expect(section.getAppsEnabled().length).toEqual(0);
-});
diff --git a/src/plugins/management/public/management_section.ts b/src/plugins/management/public/management_section.ts
deleted file mode 100644
index ace8f87bec766..0000000000000
--- a/src/plugins/management/public/management_section.ts
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import { ReactElement } from 'react';
-
-import { CreateSection, RegisterManagementAppArgs, ManagementSectionId } from './types';
-import { KibanaLegacySetup } from '../../kibana_legacy/public';
-import { StartServicesAccessor } from '../../../core/public';
-// @ts-ignore
-import { LegacyManagementSection } from './legacy';
-import { ManagementApp } from './management_app';
-
-export class ManagementSection {
- public readonly id: ManagementSectionId;
- public readonly title: string | ReactElement = '';
- public readonly apps: ManagementApp[] = [];
- public readonly order: number;
- public readonly euiIconType?: string;
- public readonly icon?: string;
- private readonly getSections: () => ManagementSection[];
- private readonly registerLegacyApp: KibanaLegacySetup['registerLegacyApp'];
- private readonly getLegacyManagementSection: () => LegacyManagementSection;
- private readonly getStartServices: StartServicesAccessor;
-
- constructor(
- { id, title, order = 100, euiIconType, icon }: CreateSection,
- getSections: () => ManagementSection[],
- registerLegacyApp: KibanaLegacySetup['registerLegacyApp'],
- getLegacyManagementSection: () => ManagementSection,
- getStartServices: StartServicesAccessor
- ) {
- this.id = id;
- this.title = title;
- this.order = order;
- this.euiIconType = euiIconType;
- this.icon = icon;
- this.getSections = getSections;
- this.registerLegacyApp = registerLegacyApp;
- this.getLegacyManagementSection = getLegacyManagementSection;
- this.getStartServices = getStartServices;
- }
-
- registerApp({ id, title, order, mount }: RegisterManagementAppArgs) {
- if (this.getApp(id)) {
- throw new Error(`Management app already registered - id: ${id}, title: ${title}`);
- }
-
- const app = new ManagementApp(
- { id, title, order, mount, basePath: `/management/${this.id}/${id}` },
- this.getSections,
- this.registerLegacyApp,
- this.getLegacyManagementSection,
- this.getStartServices
- );
- this.apps.push(app);
- return app;
- }
- getApp(id: ManagementApp['id']) {
- return this.apps.find(app => app.id === id);
- }
- getAppsEnabled() {
- return this.apps.filter(app => app.enabled).sort((a, b) => a.order - b.order);
- }
-}
diff --git a/src/plugins/management/public/management_sections_service.test.ts b/src/plugins/management/public/management_sections_service.test.ts
new file mode 100644
index 0000000000000..27bff646117aa
--- /dev/null
+++ b/src/plugins/management/public/management_sections_service.test.ts
@@ -0,0 +1,67 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { ManagementSectionId } from './index';
+import { ManagementSectionsService } from './management_sections_service';
+
+describe('ManagementService', () => {
+ let managementService: ManagementSectionsService;
+
+ beforeEach(() => {
+ managementService = new ManagementSectionsService();
+ });
+
+ test('Provides default sections', () => {
+ managementService.setup();
+ const start = managementService.start();
+
+ expect(start.getAllSections().length).toEqual(6);
+ expect(start.getSection(ManagementSectionId.Ingest)).toBeDefined();
+ expect(start.getSection(ManagementSectionId.Data)).toBeDefined();
+ expect(start.getSection(ManagementSectionId.InsightsAndAlerting)).toBeDefined();
+ expect(start.getSection(ManagementSectionId.Security)).toBeDefined();
+ expect(start.getSection(ManagementSectionId.Kibana)).toBeDefined();
+ expect(start.getSection(ManagementSectionId.Stack)).toBeDefined();
+ });
+
+ test('Register section, enable and disable', () => {
+ // Setup phase:
+ const setup = managementService.setup();
+ const testSection = setup.register({ id: 'test-section', title: 'Test Section' });
+
+ expect(setup.getSection('test-section')).not.toBeUndefined();
+
+ const testApp = testSection.registerApp({
+ id: 'test-app',
+ title: 'Test App',
+ mount: () => () => {},
+ });
+
+ expect(testSection.getApp('test-app')).not.toBeUndefined();
+
+ // Start phase:
+ const start = managementService.start();
+
+ expect(start.getSectionsEnabled().length).toEqual(1);
+
+ testApp.disable();
+
+ expect(start.getSectionsEnabled().length).toEqual(0);
+ });
+});
diff --git a/src/plugins/management/public/management_sections_service.ts b/src/plugins/management/public/management_sections_service.ts
new file mode 100644
index 0000000000000..4fc041df340ce
--- /dev/null
+++ b/src/plugins/management/public/management_sections_service.ts
@@ -0,0 +1,68 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { ReactElement } from 'react';
+import { ManagementSection, RegisterManagementSectionArgs } from './utils';
+import { managementSections } from './components/management_sections';
+
+import { ManagementSectionId, SectionsServiceSetup, SectionsServiceStart } from './types';
+
+export class ManagementSectionsService {
+ private sections: Map = new Map();
+
+ private getSection = (sectionId: ManagementSectionId | string) =>
+ this.sections.get(sectionId) as ManagementSection;
+
+ private getAllSections = () => [...this.sections.values()];
+
+ private registerSection = (section: RegisterManagementSectionArgs) => {
+ if (this.sections.has(section.id)) {
+ throw Error(`ManagementSection '${section.id}' already registered`);
+ }
+
+ const newSection = new ManagementSection(section);
+
+ this.sections.set(section.id, newSection);
+ return newSection;
+ };
+
+ setup(): SectionsServiceSetup {
+ managementSections.forEach(
+ ({ id, title }: { id: ManagementSectionId; title: ReactElement }, idx: number) => {
+ this.registerSection({ id, title, order: idx });
+ }
+ );
+
+ return {
+ register: this.registerSection,
+ getSection: this.getSection,
+ };
+ }
+
+ start(): SectionsServiceStart {
+ return {
+ getSection: this.getSection,
+ getAllSections: this.getAllSections,
+ getSectionsEnabled: () =>
+ this.getAllSections()
+ .filter(section => section.enabled && section.apps.length)
+ .sort((a, b) => a.order - b.order),
+ };
+ }
+}
diff --git a/src/plugins/management/public/management_service.test.ts b/src/plugins/management/public/management_service.test.ts
deleted file mode 100644
index 1507d6f43619d..0000000000000
--- a/src/plugins/management/public/management_service.test.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import { ManagementService } from './management_service';
-import { ManagementSectionId } from './types';
-import { coreMock } from '../../../core/public/mocks';
-import { npSetup } from '../../../legacy/ui/public/new_platform/__mocks__';
-
-jest.mock('ui/new_platform');
-
-test('Provides default sections', () => {
- const service = new ManagementService().setup(
- npSetup.plugins.kibanaLegacy,
- () => {},
- coreMock.createSetup().getStartServices
- );
- expect(service.getAllSections().length).toEqual(6);
- expect(service.getSection(ManagementSectionId.Ingest)).toBeDefined();
- expect(service.getSection(ManagementSectionId.Data)).toBeDefined();
- expect(service.getSection(ManagementSectionId.InsightsAndAlerting)).toBeDefined();
- expect(service.getSection(ManagementSectionId.Security)).toBeDefined();
- expect(service.getSection(ManagementSectionId.Kibana)).toBeDefined();
- expect(service.getSection(ManagementSectionId.Stack)).toBeDefined();
-});
diff --git a/src/plugins/management/public/management_service.ts b/src/plugins/management/public/management_service.ts
deleted file mode 100644
index 85d27a526d402..0000000000000
--- a/src/plugins/management/public/management_service.ts
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import { ReactElement } from 'react';
-
-import { ManagementSection } from './management_section';
-import { managementSections } from './management_sections';
-import { KibanaLegacySetup } from '../../kibana_legacy/public';
-// @ts-ignore
-import { LegacyManagementSection, sections } from './legacy';
-import { CreateSection, ManagementSectionId } from './types';
-import { StartServicesAccessor, CoreStart } from '../../../core/public';
-
-export class ManagementService {
- private sections: ManagementSection[] = [];
-
- private register(
- registerLegacyApp: KibanaLegacySetup['registerLegacyApp'],
- getLegacyManagement: () => LegacyManagementSection,
- getStartServices: StartServicesAccessor
- ) {
- return (section: CreateSection) => {
- if (this.getSection(section.id)) {
- throw Error(`ManagementSection '${section.id}' already registered`);
- }
-
- const newSection = new ManagementSection(
- section,
- this.getSectionsEnabled.bind(this),
- registerLegacyApp,
- getLegacyManagement,
- getStartServices
- );
- this.sections.push(newSection);
- return newSection;
- };
- }
-
- private getSection(sectionId: ManagementSectionId) {
- return this.sections.find(section => section.id === sectionId);
- }
-
- private getAllSections() {
- return this.sections;
- }
-
- private getSectionsEnabled() {
- return this.sections
- .filter(section => section.getAppsEnabled().length > 0)
- .sort((a, b) => a.order - b.order);
- }
-
- private sharedInterface = {
- getSection: (sectionId: ManagementSectionId) => {
- const section = this.getSection(sectionId);
- if (!section) {
- throw new Error(`Management section with id ${sectionId} is undefined`);
- }
- return section;
- },
- getSectionsEnabled: this.getSectionsEnabled.bind(this),
- getAllSections: this.getAllSections.bind(this),
- };
-
- public setup(
- kibanaLegacy: KibanaLegacySetup,
- getLegacyManagement: () => LegacyManagementSection,
- getStartServices: StartServicesAccessor
- ) {
- const register = this.register.bind(this)(
- kibanaLegacy.registerLegacyApp,
- getLegacyManagement,
- getStartServices
- );
-
- managementSections.forEach(
- ({ id, title }: { id: ManagementSectionId; title: ReactElement }, idx: number) => {
- register({ id, title, order: idx });
- }
- );
-
- return {
- ...this.sharedInterface,
- };
- }
-
- public start(navigateToApp: CoreStart['application']['navigateToApp']) {
- return {
- navigateToApp, // apps are currently registered as top level apps but this may change in the future
- ...this.sharedInterface,
- };
- }
-}
diff --git a/src/plugins/management/public/mocks/index.ts b/src/plugins/management/public/mocks/index.ts
index 3e32ff4fe26b2..123e3f28877aa 100644
--- a/src/plugins/management/public/mocks/index.ts
+++ b/src/plugins/management/public/mocks/index.ts
@@ -18,29 +18,29 @@
*/
import { ManagementSetup, ManagementStart } from '../types';
-import { ManagementSection } from '../management_section';
+import { ManagementSection } from '../index';
-const createManagementSectionMock = (): jest.Mocked> => {
- return {
+const createManagementSectionMock = () =>
+ (({
+ disable: jest.fn(),
+ enable: jest.fn(),
registerApp: jest.fn(),
getApp: jest.fn(),
- getAppsEnabled: jest.fn().mockReturnValue([]),
- };
-};
+ getEnabledItems: jest.fn().mockReturnValue([]),
+ } as unknown) as ManagementSection);
const createSetupContract = (): DeeplyMockedKeys => ({
sections: {
+ register: jest.fn(),
getSection: jest.fn().mockReturnValue(createManagementSectionMock()),
- getAllSections: jest.fn().mockReturnValue([]),
},
});
const createStartContract = (): DeeplyMockedKeys => ({
- legacy: {},
sections: {
getSection: jest.fn(),
getAllSections: jest.fn(),
- navigateToApp: jest.fn(),
+ getSectionsEnabled: jest.fn(),
},
});
diff --git a/src/plugins/management/public/plugin.ts b/src/plugins/management/public/plugin.ts
index e7f86996a9a1b..71656d7c0b83b 100644
--- a/src/plugins/management/public/plugin.ts
+++ b/src/plugins/management/public/plugin.ts
@@ -18,23 +18,30 @@
*/
import { i18n } from '@kbn/i18n';
-import { CoreSetup, CoreStart, Plugin } from 'kibana/public';
import { ManagementSetup, ManagementStart } from './types';
-import { ManagementService } from './management_service';
-import { KibanaLegacySetup } from '../../kibana_legacy/public';
import { FeatureCatalogueCategory, HomePublicPluginSetup } from '../../home/public';
-// @ts-ignore
-import { LegacyManagementAdapter } from './legacy';
-import { showLegacyRedirectMessages } from './legacy/redirect_messages';
+import {
+ CoreSetup,
+ CoreStart,
+ Plugin,
+ DEFAULT_APP_CATEGORIES,
+ PluginInitializerContext,
+} from '../../../core/public';
+
+import { ManagementSectionsService } from './management_sections_service';
+
+interface ManagementSetupDependencies {
+ home: HomePublicPluginSetup;
+}
export class ManagementPlugin implements Plugin {
- private managementSections = new ManagementService();
- private legacyManagement = new LegacyManagementAdapter();
+ private readonly managementSections = new ManagementSectionsService();
+
+ constructor(private initializerContext: PluginInitializerContext) {}
+
+ public setup(core: CoreSetup, { home }: ManagementSetupDependencies) {
+ const kibanaVersion = this.initializerContext.env.packageInfo.version;
- public setup(
- core: CoreSetup,
- { kibanaLegacy, home }: { kibanaLegacy: KibanaLegacySetup; home: HomePublicPluginSetup }
- ) {
home.featureCatalogue.register({
id: 'stack-management',
title: i18n.translate('management.stackManagement.managementLabel', {
@@ -44,25 +51,38 @@ export class ManagementPlugin implements Plugin ManagementSection;
+ getSection: (sectionId: ManagementSectionId | string) => ManagementSection;
+}
+
+export interface SectionsServiceStart {
+ getSection: (sectionId: ManagementSectionId | string) => ManagementSection;
+ getAllSections: () => ManagementSection[];
+ getSectionsEnabled: () => ManagementSection[];
}
export enum ManagementSectionId {
@@ -60,37 +48,8 @@ export enum ManagementSectionId {
Stack = 'stack',
}
-interface SectionsServiceSetup {
- getSection: (sectionId: ManagementSectionId) => ManagementSection;
- getAllSections: () => ManagementSection[];
-}
-
-interface SectionsServiceStart {
- getSection: (sectionId: ManagementSectionId) => ManagementSection;
- getAllSections: () => ManagementSection[];
- navigateToApp: ApplicationStart['navigateToApp'];
-}
-
-export interface CreateSection {
- id: ManagementSectionId;
- title: string | ReactElement;
- order?: number;
- euiIconType?: string; // takes precedence over `icon` property.
- icon?: string; // URL to image file; fallback if no `euiIconType`
-}
-
-export type RegisterSection = (section: CreateSection) => ManagementSection;
-
-export interface RegisterManagementAppArgs {
- id: string;
- title: string;
- mount: ManagementSectionMount;
- order?: number;
-}
-
-export type RegisterManagementApp = (managementApp: RegisterManagementAppArgs) => ManagementApp;
-
export type Unmount = () => Promise | void;
+export type Mount = (params: ManagementAppMountParams) => Unmount | Promise;
export interface ManagementAppMountParams {
basePath: string; // base path for setting up your router
@@ -98,29 +57,10 @@ export interface ManagementAppMountParams {
setBreadcrumbs: (crumbs: ChromeBreadcrumb[]) => void;
}
-export type ManagementSectionMount = (
- params: ManagementAppMountParams
-) => Unmount | Promise;
-
-export interface CreateManagementApp {
+export interface CreateManagementItemArgs {
id: string;
- title: string;
- basePath: string;
+ title: string | ReactElement;
order?: number;
- mount: ManagementSectionMount;
-}
-
-export interface LegacySection extends LegacyApp {
- visibleItems: LegacyApp[];
-}
-
-export interface LegacyApp {
- disabled: boolean;
- visible: boolean;
- id: string;
- display: string;
- url?: string;
- euiIconType?: IconType;
- icon?: string;
- order: number;
+ euiIconType?: string; // takes precedence over `icon` property.
+ icon?: string; // URL to image file; fallback if no `euiIconType`
}
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/types.ts b/src/plugins/management/public/utils/index.ts
similarity index 75%
rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/types.ts
rename to src/plugins/management/public/utils/index.ts
index 81184d6fdd1a3..a1d759a3ec628 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/types.ts
+++ b/src/plugins/management/public/utils/index.ts
@@ -17,18 +17,5 @@
* under the License.
*/
-export interface IndexPatternCreationOption {
- text: string;
- description?: string;
- onClick: () => void;
-}
-
-export interface IndexPattern {
- id: string;
- title: string;
- url: string;
- active: boolean;
- default: boolean;
- tag?: string[];
- sort: string;
-}
+export { ManagementApp, RegisterManagementAppArgs } from './management_app';
+export { ManagementSection, RegisterManagementSectionArgs } from './management_section';
diff --git a/src/plugins/management/public/utils/management_app.ts b/src/plugins/management/public/utils/management_app.ts
new file mode 100644
index 0000000000000..a27db5522af82
--- /dev/null
+++ b/src/plugins/management/public/utils/management_app.ts
@@ -0,0 +1,38 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { CreateManagementItemArgs, Mount } from '../types';
+import { ManagementItem } from './management_item';
+
+export interface RegisterManagementAppArgs extends CreateManagementItemArgs {
+ mount: Mount;
+ basePath: string;
+}
+
+export class ManagementApp extends ManagementItem {
+ public readonly mount: Mount;
+ public readonly basePath: string;
+
+ constructor(args: RegisterManagementAppArgs) {
+ super(args);
+
+ this.mount = args.mount;
+ this.basePath = args.basePath;
+ }
+}
diff --git a/src/plugins/management/public/utils/management_item.ts b/src/plugins/management/public/utils/management_item.ts
new file mode 100644
index 0000000000000..ef0c8e4693895
--- /dev/null
+++ b/src/plugins/management/public/utils/management_item.ts
@@ -0,0 +1,46 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { ReactElement } from 'react';
+import { CreateManagementItemArgs } from '../types';
+
+export class ManagementItem {
+ public readonly id: string = '';
+ public readonly title: string | ReactElement = '';
+ public readonly order: number;
+ public readonly euiIconType?: string;
+ public readonly icon?: string;
+
+ public enabled: boolean = true;
+
+ constructor({ id, title, order = 100, euiIconType, icon }: CreateManagementItemArgs) {
+ this.id = id;
+ this.title = title;
+ this.order = order;
+ this.euiIconType = euiIconType;
+ this.icon = icon;
+ }
+
+ disable() {
+ this.enabled = false;
+ }
+
+ enable() {
+ this.enabled = true;
+ }
+}
diff --git a/src/plugins/management/public/utils/management_section.test.ts b/src/plugins/management/public/utils/management_section.test.ts
new file mode 100644
index 0000000000000..f5ce86f5dc963
--- /dev/null
+++ b/src/plugins/management/public/utils/management_section.test.ts
@@ -0,0 +1,55 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { ManagementSection, RegisterManagementSectionArgs } from './management_section';
+
+describe('ManagementSection', () => {
+ const createSection = (
+ config: RegisterManagementSectionArgs = {
+ id: 'test-section',
+ title: 'Test Section',
+ } as RegisterManagementSectionArgs
+ ) => new ManagementSection(config);
+
+ test('cannot register two apps with the same id', () => {
+ const section = createSection();
+ const testAppConfig = { id: 'test-app', title: 'Test App', mount: () => () => {} };
+
+ section.registerApp(testAppConfig);
+
+ expect(section.apps.length).toEqual(1);
+
+ expect(() => {
+ section.registerApp(testAppConfig);
+ }).toThrow();
+ });
+
+ test('can enable and disable apps', () => {
+ const section = createSection();
+ const testAppConfig = { id: 'test-app', title: 'Test App', mount: () => () => {} };
+
+ const app = section.registerApp(testAppConfig);
+
+ expect(section.getAppsEnabled().length).toEqual(1);
+
+ app.disable();
+
+ expect(section.getAppsEnabled().length).toEqual(0);
+ });
+});
diff --git a/src/plugins/management/public/utils/management_section.ts b/src/plugins/management/public/utils/management_section.ts
new file mode 100644
index 0000000000000..e00c2b942e0c4
--- /dev/null
+++ b/src/plugins/management/public/utils/management_section.ts
@@ -0,0 +1,58 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { Assign } from '@kbn/utility-types';
+import { CreateManagementItemArgs, ManagementSectionId } from '../types';
+import { ManagementItem } from './management_item';
+import { ManagementApp, RegisterManagementAppArgs } from './management_app';
+
+export type RegisterManagementSectionArgs = Assign<
+ CreateManagementItemArgs,
+ { id: ManagementSectionId | string }
+>;
+
+export class ManagementSection extends ManagementItem {
+ public readonly apps: ManagementApp[] = [];
+
+ constructor(args: RegisterManagementSectionArgs) {
+ super(args);
+ }
+
+ registerApp(args: Omit) {
+ if (this.getApp(args.id)) {
+ throw new Error(`Management app already registered - id: ${args.id}, title: ${args.title}`);
+ }
+
+ const app = new ManagementApp({
+ ...args,
+ basePath: `/${this.id}/${args.id}`,
+ });
+
+ this.apps.push(app);
+
+ return app;
+ }
+
+ getApp(id: ManagementApp['id']) {
+ return this.apps.find(app => app.id === id);
+ }
+
+ getAppsEnabled() {
+ return this.apps.filter(app => app.enabled).sort((a, b) => a.order - b.order);
+ }
+}
diff --git a/x-pack/plugins/security/public/management/management_service.test.ts b/x-pack/plugins/security/public/management/management_service.test.ts
index 466e1aa9b3c68..78d7f7ff118a6 100644
--- a/x-pack/plugins/security/public/management/management_service.test.ts
+++ b/x-pack/plugins/security/public/management/management_service.test.ts
@@ -5,7 +5,11 @@
*/
import { BehaviorSubject } from 'rxjs';
-import { ManagementApp } from '../../../../../src/plugins/management/public';
+import {
+ ManagementApp,
+ ManagementSetup,
+ ManagementStart,
+} from '../../../../../src/plugins/management/public';
import { SecurityLicenseFeatures } from '../../common/licensing/license_features';
import { ManagementService } from './management_service';
import { usersManagementApp } from './users';
@@ -25,10 +29,10 @@ describe('ManagementService', () => {
const license = licenseMock.create();
const mockSection = { registerApp: jest.fn() };
- const managementSetup = {
+ const managementSetup: ManagementSetup = {
sections: {
+ register: jest.fn(),
getSection: jest.fn().mockReturnValue(mockSection),
- getAllSections: jest.fn(),
},
};
@@ -80,17 +84,20 @@ describe('ManagementService', () => {
license.features$ = licenseSubject;
const service = new ManagementService();
+
+ const managementSetup: ManagementSetup = {
+ sections: {
+ register: jest.fn(),
+ getSection: jest.fn().mockReturnValue(mockSection),
+ },
+ };
+
service.setup({
getStartServices: getStartServices as any,
license,
fatalErrors,
authc: securityMock.createSetup().authc,
- management: {
- sections: {
- getSection: jest.fn().mockReturnValue({ registerApp: jest.fn() }),
- getAllSections: jest.fn(),
- },
- },
+ management: managementSetup,
});
const getMockedApp = () => {
@@ -115,17 +122,18 @@ describe('ManagementService', () => {
[roleMappingsManagementApp.id, getMockedApp()],
] as Array<[string, jest.Mocked]>);
- service.start({
- management: {
- sections: {
- getSection: jest
- .fn()
- .mockReturnValue({ getApp: jest.fn().mockImplementation(id => mockApps.get(id)) }),
- getAllSections: jest.fn(),
- navigateToApp: jest.fn(),
- },
- legacy: undefined,
+ const managementStart: ManagementStart = {
+ sections: {
+ getSection: jest
+ .fn()
+ .mockReturnValue({ getApp: jest.fn().mockImplementation(id => mockApps.get(id)) }),
+ getAllSections: jest.fn(),
+ getSectionsEnabled: jest.fn(),
},
+ };
+
+ service.start({
+ management: managementStart,
});
return {
diff --git a/x-pack/plugins/spaces/public/plugin.test.ts b/x-pack/plugins/spaces/public/plugin.test.ts
index a98f593f546a0..4a49cf20d3a4a 100644
--- a/x-pack/plugins/spaces/public/plugin.test.ts
+++ b/x-pack/plugins/spaces/public/plugin.test.ts
@@ -33,17 +33,11 @@ describe('Spaces plugin', () => {
it('should register the management and feature catalogue sections when the management and home plugins are both available', () => {
const coreSetup = coreMock.createSetup();
- const kibanaSection = new ManagementSection(
- {
- id: ManagementSectionId.Kibana,
- title: 'Mock Kibana Section',
- order: 1,
- },
- jest.fn(),
- jest.fn(),
- jest.fn(),
- coreSetup.getStartServices
- );
+ const kibanaSection = new ManagementSection({
+ id: ManagementSectionId.Kibana,
+ title: 'Mock Kibana Section',
+ order: 1,
+ });
const registerAppSpy = jest.spyOn(kibanaSection, 'registerApp');
From 0a3a79f3d62692f4e6a32e42e2a393b2c743cd35 Mon Sep 17 00:00:00 2001
From: Matt Kime
Date: Mon, 18 May 2020 23:37:11 -0500
Subject: [PATCH 02/93] partial progress on a number of management sections
---
.../mount_management_section.tsx | 6 ++---
.../edit_index_pattern/tabs/utils.ts | 2 +-
.../index_pattern_table.tsx | 8 ++++---
.../mount_management_section.tsx | 6 ++---
.../management_app/management_app.tsx | 1 +
.../management_app_wrapper.tsx | 7 ++++--
src/plugins/management/public/types.ts | 3 +++
.../management_section/mount_section.tsx | 8 +++----
.../beats_management/public/application.tsx | 16 ++++---------
.../public/app/index.tsx | 18 +++++++++-----
.../public/application/app.tsx | 17 ++++++-------
.../public/application/index.tsx | 10 +++++---
.../public/plugin.tsx | 4 ++--
.../public/application/app.js | 6 ++---
.../public/application/app_context.tsx | 2 ++
.../public/application/index.tsx | 12 ++++++----
.../license_management/public/plugin.ts | 3 ++-
.../logstash/public/application/index.tsx | 18 +++++++-------
.../role_mappings_management_app.tsx | 8 +++----
.../management/roles/roles_management_app.tsx | 8 +++----
.../users/users_grid/users_grid_page.tsx | 2 +-
.../management/users/users_management_app.tsx | 8 +++----
.../management/spaces_management_app.tsx | 8 +++----
x-pack/plugins/transform/public/app/app.tsx | 24 +++++++++----------
.../transform/public/app/app_dependencies.tsx | 2 ++
.../public/app/mount_management_section.ts | 3 ++-
.../watcher/public/application/app.tsx | 22 ++++++++---------
x-pack/plugins/watcher/public/plugin.ts | 3 ++-
28 files changed, 129 insertions(+), 106 deletions(-)
diff --git a/src/plugins/advanced_settings/public/management_app/mount_management_section.tsx b/src/plugins/advanced_settings/public/management_app/mount_management_section.tsx
index df44ea45e9d01..b4779d051ab02 100644
--- a/src/plugins/advanced_settings/public/management_app/mount_management_section.tsx
+++ b/src/plugins/advanced_settings/public/management_app/mount_management_section.tsx
@@ -19,7 +19,7 @@
import React from 'react';
import ReactDOM from 'react-dom';
-import { HashRouter, Switch, Route } from 'react-router-dom';
+import { Router, Switch, Route } from 'react-router-dom';
import { i18n } from '@kbn/i18n';
import { I18nProvider } from '@kbn/i18n/react';
@@ -60,7 +60,7 @@ export async function mountManagementSection(
ReactDOM.render(
-
+
-
+
,
params.element
);
diff --git a/src/plugins/index_pattern_management/public/components/edit_index_pattern/tabs/utils.ts b/src/plugins/index_pattern_management/public/components/edit_index_pattern/tabs/utils.ts
index b9b59142290dc..d544bd11a1480 100644
--- a/src/plugins/index_pattern_management/public/components/edit_index_pattern/tabs/utils.ts
+++ b/src/plugins/index_pattern_management/public/components/edit_index_pattern/tabs/utils.ts
@@ -117,7 +117,7 @@ export function getTabs(
}
export function getPath(field: IndexPatternField) {
- return `${field.indexPattern?.id}/field/${field.name}`;
+ return `/patterns/${field.indexPattern?.id}/field/${field.name}`;
}
const allTypesDropDown = i18n.translate(
diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx
index 599ed1fa04ee2..e2e71632a10f4 100644
--- a/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx
+++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx
@@ -28,6 +28,7 @@ import {
EuiSpacer,
EuiText,
} from '@elastic/eui';
+import { AppMountParameters } from 'kibana/public';
import { FormattedMessage } from '@kbn/i18n/react';
import { withRouter, RouteComponentProps } from 'react-router-dom';
import React, { useState, useEffect } from 'react';
@@ -45,7 +46,7 @@ import { IndexPatternManagementStart } from '../../plugin';
import { getIndexPatterns } from '../utils';
import { getListBreadcrumbs } from '../breadcrumbs';
-const columns = [
+const columns = (history: AppMountParameters['history']) => [
{
field: 'title',
name: 'Pattern',
@@ -59,7 +60,7 @@ const columns = [
}>;
}
) => (
-
+ history.push(`/patterns/${index.id}`)}>
{name}
{index.tags &&
index.tags.map(({ key: tagKey, name: tagName }) => (
@@ -106,6 +107,7 @@ const title = i18n.translate('indexPatternManagement.indexPatternTable.title', {
interface Props extends RouteComponentProps {
getIndexPatternCreationOptions: IndexPatternManagementStart['creation']['getIndexPatternCreationOptions'];
canSave: boolean;
+ history: AppMountParameters['history'];
services: {
savedObjectsClient: SavedObjectsClientContract;
uiSettings: IUiSettingsClient;
@@ -195,7 +197,7 @@ export const IndexPatternTable = ({
itemId="id"
isSelectable={false}
items={indexPatterns}
- columns={columns}
+ columns={columns(history)}
pagination={pagination}
sorting={sorting}
search={search}
diff --git a/src/plugins/index_pattern_management/public/management_app/mount_management_section.tsx b/src/plugins/index_pattern_management/public/management_app/mount_management_section.tsx
index b6b58d8f006c8..ea900f2d24039 100644
--- a/src/plugins/index_pattern_management/public/management_app/mount_management_section.tsx
+++ b/src/plugins/index_pattern_management/public/management_app/mount_management_section.tsx
@@ -19,7 +19,7 @@
import React from 'react';
import ReactDOM from 'react-dom';
-import { HashRouter, Switch, Route } from 'react-router-dom';
+import { Router, Switch, Route } from 'react-router-dom';
import { i18n } from '@kbn/i18n';
import { I18nProvider } from '@kbn/i18n/react';
@@ -61,7 +61,7 @@ export async function mountManagementSection(
ReactDOM.render(
-
+
-
+
,
params.element
);
diff --git a/src/plugins/management/public/components/management_app/management_app.tsx b/src/plugins/management/public/components/management_app/management_app.tsx
index 7dffc4f5942fb..e2ff105268abe 100644
--- a/src/plugins/management/public/components/management_app/management_app.tsx
+++ b/src/plugins/management/public/components/management_app/management_app.tsx
@@ -92,6 +92,7 @@ export const ManagementApp = ({ context, dependencies, history }: ManagementAppP
app={app}
setBreadcrumbs={setBreadcrumbs}
onAppMounted={onAppMounted}
+ history={history.createSubHistory(app.basePath)}
/>
)}
/>
diff --git a/src/plugins/management/public/components/management_app_wrapper/management_app_wrapper.tsx b/src/plugins/management/public/components/management_app_wrapper/management_app_wrapper.tsx
index dac219823b7ca..4341197173a82 100644
--- a/src/plugins/management/public/components/management_app_wrapper/management_app_wrapper.tsx
+++ b/src/plugins/management/public/components/management_app_wrapper/management_app_wrapper.tsx
@@ -19,7 +19,7 @@
import React, { useEffect, createRef, useRef, RefObject } from 'react';
-import { ChromeBreadcrumb } from 'kibana/public';
+import { ChromeBreadcrumb, AppMountParameters } from 'kibana/public';
import { ManagementApp } from '../../utils';
import { Unmount } from '../../types';
@@ -27,12 +27,14 @@ interface ManagementSectionWrapperProps {
app: ManagementApp;
setBreadcrumbs: (crumbs: ChromeBreadcrumb[]) => void;
onAppMounted: (id: string) => void;
+ history: AppMountParameters['history'];
}
export const ManagementAppWrapper = ({
app,
setBreadcrumbs,
onAppMounted,
+ history,
}: ManagementSectionWrapperProps) => {
const mountElementRef = useRef>();
const { mount, basePath } = app;
@@ -46,6 +48,7 @@ export const ManagementAppWrapper = ({
basePath,
setBreadcrumbs,
element: mountElementRef.current!.current,
+ history,
});
onAppMounted(app.id);
@@ -63,7 +66,7 @@ export const ManagementAppWrapper = ({
}
};
}
- }, [app.id, basePath, mount, onAppMounted, setBreadcrumbs]);
+ }, [app.id, basePath, history, mount, onAppMounted, setBreadcrumbs]);
return ;
};
diff --git a/src/plugins/management/public/types.ts b/src/plugins/management/public/types.ts
index 05992c9f1f5a2..2dbcacbffa169 100644
--- a/src/plugins/management/public/types.ts
+++ b/src/plugins/management/public/types.ts
@@ -16,7 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
+
import { ReactElement } from 'react';
+import { AppMountParameters } from 'kibana/public';
import { ManagementSection, RegisterManagementSectionArgs } from './utils';
import { ChromeBreadcrumb } from '../../../core/public/';
@@ -55,6 +57,7 @@ export interface ManagementAppMountParams {
basePath: string; // base path for setting up your router
element: HTMLElement; // element the section should render into
setBreadcrumbs: (crumbs: ChromeBreadcrumb[]) => void;
+ history: AppMountParameters['history'];
}
export interface CreateManagementItemArgs {
diff --git a/src/plugins/saved_objects_management/public/management_section/mount_section.tsx b/src/plugins/saved_objects_management/public/management_section/mount_section.tsx
index c1daf3445219f..3ca0c3772a243 100644
--- a/src/plugins/saved_objects_management/public/management_section/mount_section.tsx
+++ b/src/plugins/saved_objects_management/public/management_section/mount_section.tsx
@@ -19,7 +19,7 @@
import React, { lazy, Suspense } from 'react';
import ReactDOM from 'react-dom';
-import { HashRouter, Switch, Route } from 'react-router-dom';
+import { Router, Switch, Route } from 'react-router-dom';
import { I18nProvider } from '@kbn/i18n/react';
import { EuiLoadingSpinner } from '@elastic/eui';
import { CoreSetup, Capabilities } from 'src/core/public';
@@ -44,7 +44,7 @@ export const mountManagementSection = async ({
serviceRegistry,
}: MountParams) => {
const [coreStart, { data }, pluginStart] = await core.getStartServices();
- const { element, basePath, setBreadcrumbs } = mountParams;
+ const { element, history, setBreadcrumbs } = mountParams;
if (allowedObjectTypes === undefined) {
allowedObjectTypes = await getAllowedTypes(coreStart.http);
}
@@ -53,7 +53,7 @@ export const mountManagementSection = async ({
ReactDOM.render(
-
+
@@ -81,7 +81,7 @@ export const mountManagementSection = async ({
-
+
,
element
);
diff --git a/x-pack/plugins/beats_management/public/application.tsx b/x-pack/plugins/beats_management/public/application.tsx
index 6711e93895b62..0b8b0ad3dafc9 100644
--- a/x-pack/plugins/beats_management/public/application.tsx
+++ b/x-pack/plugins/beats_management/public/application.tsx
@@ -8,7 +8,7 @@ import * as euiVars from '@elastic/eui/dist/eui_theme_light.json';
import { i18n } from '@kbn/i18n';
import React from 'react';
import ReactDOM from 'react-dom';
-import { HashRouter } from 'react-router-dom';
+import { Router } from 'react-router-dom';
import { ThemeProvider } from 'styled-components';
import { Provider as UnstatedProvider, Subscribe } from 'unstated';
import { Background } from './components/layouts/background';
@@ -19,19 +19,13 @@ import { TagsContainer } from './containers/tags';
import { FrontendLibs } from './lib/types';
import { AppRouter } from './router';
import { services } from './kbn_services';
-import {
- ManagementAppMountParams,
- ManagementSectionId,
-} from '../../../../src/plugins/management/public';
+import { ManagementAppMountParams } from '../../../../src/plugins/management/public';
-export const renderApp = (
- { basePath, element, setBreadcrumbs }: ManagementAppMountParams,
- libs: FrontendLibs
-) => {
+export const renderApp = ({ element, history }: ManagementAppMountParams, libs: FrontendLibs) => {
ReactDOM.render(
-
+
@@ -48,7 +42,7 @@ export const renderApp = (
-
+
,
element
diff --git a/x-pack/plugins/cross_cluster_replication/public/app/index.tsx b/x-pack/plugins/cross_cluster_replication/public/app/index.tsx
index 79569b587f97f..d4a74aefb1571 100644
--- a/x-pack/plugins/cross_cluster_replication/public/app/index.tsx
+++ b/x-pack/plugins/cross_cluster_replication/public/app/index.tsx
@@ -6,8 +6,8 @@
import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import { Provider } from 'react-redux';
-import { HashRouter } from 'react-router-dom';
-import { I18nStart } from 'kibana/public';
+import { Router } from 'react-router-dom';
+import { I18nStart, AppMountParameters } from 'kibana/public';
import { UnmountCallback } from 'src/core/public';
import { init as initBreadcrumbs, SetBreadcrumbs } from './services/breadcrumbs';
@@ -15,13 +15,17 @@ import { init as initDocumentation } from './services/documentation_links';
import { App } from './app';
import { ccrStore } from './store';
-const renderApp = (element: Element, I18nContext: I18nStart['Context']): UnmountCallback => {
+const renderApp = (
+ element: Element,
+ I18nContext: I18nStart['Context'],
+ history: AppMountParameters['history']
+): UnmountCallback => {
render(
-
+
-
+
,
element
@@ -36,17 +40,19 @@ export async function mountApp({
I18nContext,
ELASTIC_WEBSITE_URL,
DOC_LINK_VERSION,
+ history,
}: {
element: Element;
setBreadcrumbs: SetBreadcrumbs;
I18nContext: I18nStart['Context'];
ELASTIC_WEBSITE_URL: string;
DOC_LINK_VERSION: string;
+ history: AppMountParameters['history'];
}): Promise {
// Import and initialize additional services here instead of in plugin.ts to reduce the size of the
// initial bundle as much as possible.
initBreadcrumbs(setBreadcrumbs);
initDocumentation(`${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/reference/${DOC_LINK_VERSION}/`);
- return renderApp(element, I18nContext);
+ return renderApp(element, I18nContext, history);
}
diff --git a/x-pack/plugins/index_lifecycle_management/public/application/app.tsx b/x-pack/plugins/index_lifecycle_management/public/application/app.tsx
index 993dced20bbe6..dff21fb6d796d 100644
--- a/x-pack/plugins/index_lifecycle_management/public/application/app.tsx
+++ b/x-pack/plugins/index_lifecycle_management/public/application/app.tsx
@@ -5,25 +5,26 @@
*/
import React, { useEffect } from 'react';
-import { HashRouter, Switch, Route, Redirect } from 'react-router-dom';
+import { Router, Switch, Route, Redirect } from 'react-router-dom';
+import { AppMountParameters } from 'kibana/public';
import { METRIC_TYPE } from '@kbn/analytics';
-import { BASE_PATH } from '../../common/constants';
import { UIM_APP_LOAD } from './constants';
import { EditPolicy } from './sections/edit_policy';
import { PolicyTable } from './sections/policy_table';
import { trackUiMetric } from './services/ui_metric';
-export const App = () => {
+export const App = ({ history }: { history: AppMountParameters['history'] }) => {
useEffect(() => trackUiMetric(METRIC_TYPE.LOADED, UIM_APP_LOAD), []);
return (
-
+
-
-
-
+
+
+
+
-
+
);
};
diff --git a/x-pack/plugins/index_lifecycle_management/public/application/index.tsx b/x-pack/plugins/index_lifecycle_management/public/application/index.tsx
index a7d88d31e58fc..9d9120398810b 100644
--- a/x-pack/plugins/index_lifecycle_management/public/application/index.tsx
+++ b/x-pack/plugins/index_lifecycle_management/public/application/index.tsx
@@ -7,17 +7,21 @@
import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import { Provider } from 'react-redux';
-import { I18nStart } from 'kibana/public';
+import { I18nStart, AppMountParameters } from 'kibana/public';
import { UnmountCallback } from 'src/core/public';
import { App } from './app';
import { indexLifecycleManagementStore } from './store';
-export const renderApp = (element: Element, I18nContext: I18nStart['Context']): UnmountCallback => {
+export const renderApp = (
+ element: Element,
+ I18nContext: I18nStart['Context'],
+ history: AppMountParameters['history']
+): UnmountCallback => {
render(
-
+
,
element
diff --git a/x-pack/plugins/index_lifecycle_management/public/plugin.tsx b/x-pack/plugins/index_lifecycle_management/public/plugin.tsx
index 8fce57b0e79b0..3f8d7d7f88487 100644
--- a/x-pack/plugins/index_lifecycle_management/public/plugin.tsx
+++ b/x-pack/plugins/index_lifecycle_management/public/plugin.tsx
@@ -42,7 +42,7 @@ export class IndexLifecycleManagementPlugin {
id: PLUGIN.ID,
title: PLUGIN.TITLE,
order: 2,
- mount: async ({ element }) => {
+ mount: async ({ element, history }) => {
const [coreStart] = await getStartServices();
const {
i18n: { Context: I18nContext },
@@ -55,7 +55,7 @@ export class IndexLifecycleManagementPlugin {
);
const { renderApp } = await import('./application');
- return renderApp(element, I18nContext);
+ return renderApp(element, I18nContext, history);
},
});
diff --git a/x-pack/plugins/license_management/public/application/app.js b/x-pack/plugins/license_management/public/application/app.js
index 1bc8e9cd563e2..222a6f879cbf8 100644
--- a/x-pack/plugins/license_management/public/application/app.js
+++ b/x-pack/plugins/license_management/public/application/app.js
@@ -8,7 +8,7 @@ import React, { Component } from 'react';
import { FormattedMessage } from '@kbn/i18n/react';
import { LicenseDashboard, UploadLicense } from './sections';
import { Switch, Route } from 'react-router-dom';
-import { APP_PERMISSION, BASE_PATH } from '../../common/constants';
+import { APP_PERMISSION } from '../../common/constants';
import { EuiPageBody, EuiEmptyPrompt, EuiText, EuiLoadingSpinner, EuiCallOut } from '@elastic/eui';
export class App extends Component {
@@ -89,8 +89,8 @@ export class App extends Component {
return (
-
-
+
+
);
diff --git a/x-pack/plugins/license_management/public/application/app_context.tsx b/x-pack/plugins/license_management/public/application/app_context.tsx
index 1e90f4c907b8c..28fa16641a369 100644
--- a/x-pack/plugins/license_management/public/application/app_context.tsx
+++ b/x-pack/plugins/license_management/public/application/app_context.tsx
@@ -5,6 +5,7 @@
*/
import React, { createContext, useContext } from 'react';
+import { AppMountParameters } from 'kibana/public';
import { CoreStart } from '../../../../../src/core/public';
import { LicensingPluginSetup, ILicense } from '../../../licensing/public';
@@ -18,6 +19,7 @@ export interface AppDependencies {
core: CoreStart;
services: {
breadcrumbService: BreadcrumbService;
+ history: AppMountParameters['history'];
};
plugins: {
licensing: LicensingPluginSetup;
diff --git a/x-pack/plugins/license_management/public/application/index.tsx b/x-pack/plugins/license_management/public/application/index.tsx
index 75f2f98f51e6e..84f3067a528ea 100644
--- a/x-pack/plugins/license_management/public/application/index.tsx
+++ b/x-pack/plugins/license_management/public/application/index.tsx
@@ -6,7 +6,8 @@
import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
-import { HashRouter } from 'react-router-dom';
+import { Router } from 'react-router-dom';
+import { AppMountParameters } from 'kibana/public';
import { AppDependencies } from './app_context';
import { AppProviders } from './app_providers';
@@ -14,15 +15,18 @@ import { AppProviders } from './app_providers';
import { App } from './app.container';
const AppWithRouter = (props: { [key: string]: any }) => (
-
+
-
+
);
export const renderApp = (element: Element, dependencies: AppDependencies) => {
render(
-
+
,
element
);
diff --git a/x-pack/plugins/license_management/public/plugin.ts b/x-pack/plugins/license_management/public/plugin.ts
index 927902945cd8c..e2e6437d12d2a 100644
--- a/x-pack/plugins/license_management/public/plugin.ts
+++ b/x-pack/plugins/license_management/public/plugin.ts
@@ -48,7 +48,7 @@ export class LicenseManagementUIPlugin
id: PLUGIN.id,
title: PLUGIN.title,
order: 0,
- mount: async ({ element, setBreadcrumbs }) => {
+ mount: async ({ element, setBreadcrumbs, history }) => {
const [core] = await getStartServices();
const initialLicense = await plugins.licensing.license$.pipe(first()).toPromise();
@@ -72,6 +72,7 @@ export class LicenseManagementUIPlugin
},
services: {
breadcrumbService: this.breadcrumbService,
+ history,
},
store: {
initialLicense,
diff --git a/x-pack/plugins/logstash/public/application/index.tsx b/x-pack/plugins/logstash/public/application/index.tsx
index 3588e1f6b2417..8d515ad6b3932 100644
--- a/x-pack/plugins/logstash/public/application/index.tsx
+++ b/x-pack/plugins/logstash/public/application/index.tsx
@@ -6,7 +6,7 @@
import React from 'react';
import ReactDOM from 'react-dom';
-import { HashRouter, Route, Switch, Redirect } from 'react-router-dom';
+import { Router, Route, Switch, Redirect } from 'react-router-dom';
import { Observable } from 'rxjs';
import { first } from 'rxjs/operators';
@@ -30,7 +30,7 @@ import * as Breadcrumbs from './breadcrumbs';
export const renderApp = async (
core: CoreStart,
- { basePath, element, setBreadcrumbs }: ManagementAppMountParams,
+ { history, element, setBreadcrumbs }: ManagementAppMountParams,
isMonitoringEnabled: boolean,
licenseService$: Observable
) => {
@@ -43,12 +43,12 @@ export const renderApp = async (
ReactDOM.render(
-
+
{
+ render={() => {
setBreadcrumbs(Breadcrumbs.getPipelineListBreadcrumbs());
return (
history.push(`/pipeline/${id}/edit`)}
clonePipeline={(id: string) => history.push(`/pipeline/${id}/edit?clone`)}
- createPipeline={() => history.push(`/pipeline/new-pipeline`)}
+ createPipeline={() => history.push(`pipeline/new-pipeline`)}
pipelinesService={pipelinesService}
toastNotifications={core.notifications.toasts}
/>
@@ -70,7 +70,7 @@ export const renderApp = async (
(
+ render={() => (
(
+ render={({ match }) => (
-
+
,
element
);
diff --git a/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.tsx b/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.tsx
index ffb6d6d98f180..4f0cb6d382470 100644
--- a/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.tsx
@@ -6,7 +6,7 @@
import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
-import { HashRouter as Router, Route, Switch, useParams } from 'react-router-dom';
+import { Router, Route, Switch, useParams } from 'react-router-dom';
import { i18n } from '@kbn/i18n';
import { StartServicesAccessor } from 'src/core/public';
import { RegisterManagementAppArgs } from '../../../../../../src/plugins/management/public';
@@ -26,7 +26,7 @@ export const roleMappingsManagementApp = Object.freeze({
title: i18n.translate('xpack.security.management.roleMappingsTitle', {
defaultMessage: 'Role Mappings',
}),
- async mount({ basePath, element, setBreadcrumbs }) {
+ async mount({ basePath, element, setBreadcrumbs, history }) {
const roleMappingsBreadcrumbs = [
{
text: i18n.translate('xpack.security.roleMapping.breadcrumb', {
@@ -91,9 +91,9 @@ export const roleMappingsManagementApp = Object.freeze({
render(
-
+
-
+
diff --git a/x-pack/plugins/security/public/management/roles/roles_management_app.tsx b/x-pack/plugins/security/public/management/roles/roles_management_app.tsx
index 9aaa3b47f3b19..860d07e400f65 100644
--- a/x-pack/plugins/security/public/management/roles/roles_management_app.tsx
+++ b/x-pack/plugins/security/public/management/roles/roles_management_app.tsx
@@ -6,7 +6,7 @@
import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
-import { HashRouter as Router, Route, Switch, useParams } from 'react-router-dom';
+import { Router, Route, Switch, useParams } from 'react-router-dom';
import { i18n } from '@kbn/i18n';
import { StartServicesAccessor, FatalErrorsSetup } from 'src/core/public';
import { RegisterManagementAppArgs } from '../../../../../../src/plugins/management/public';
@@ -27,7 +27,7 @@ export const rolesManagementApp = Object.freeze({
id: this.id,
order: 20,
title: i18n.translate('xpack.security.management.rolesTitle', { defaultMessage: 'Roles' }),
- async mount({ basePath, element, setBreadcrumbs }) {
+ async mount({ basePath, element, setBreadcrumbs, history }) {
const rolesBreadcrumbs = [
{
text: i18n.translate('xpack.security.roles.breadcrumb', { defaultMessage: 'Roles' }),
@@ -101,9 +101,9 @@ export const rolesManagementApp = Object.freeze({
render(
-
+
-
+
diff --git a/x-pack/plugins/security/public/management/users/users_grid/users_grid_page.tsx b/x-pack/plugins/security/public/management/users/users_grid/users_grid_page.tsx
index f8882129772f7..e63dc3682336c 100644
--- a/x-pack/plugins/security/public/management/users/users_grid/users_grid_page.tsx
+++ b/x-pack/plugins/security/public/management/users/users_grid/users_grid_page.tsx
@@ -97,7 +97,7 @@ export class UsersGridPage extends Component {
);
}
- const path = '#/management/security/';
+ const path = '/';
const columns: Array> = [
{
field: 'username',
diff --git a/x-pack/plugins/security/public/management/users/users_management_app.tsx b/x-pack/plugins/security/public/management/users/users_management_app.tsx
index 9d337c1508ad4..04fa8df24bec7 100644
--- a/x-pack/plugins/security/public/management/users/users_management_app.tsx
+++ b/x-pack/plugins/security/public/management/users/users_management_app.tsx
@@ -6,7 +6,7 @@
import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
-import { HashRouter as Router, Route, Switch, useParams } from 'react-router-dom';
+import { Router, Route, Switch, useParams } from 'react-router-dom';
import { i18n } from '@kbn/i18n';
import { StartServicesAccessor } from 'src/core/public';
import { RegisterManagementAppArgs } from '../../../../../../src/plugins/management/public';
@@ -25,7 +25,7 @@ export const usersManagementApp = Object.freeze({
id: this.id,
order: 10,
title: i18n.translate('xpack.security.management.usersTitle', { defaultMessage: 'Users' }),
- async mount({ basePath, element, setBreadcrumbs }) {
+ async mount({ basePath, element, setBreadcrumbs, history }) {
const usersBreadcrumbs = [
{
text: i18n.translate('xpack.security.users.breadcrumb', { defaultMessage: 'Users' }),
@@ -87,9 +87,9 @@ export const usersManagementApp = Object.freeze({
render(
-
+
-
+
diff --git a/x-pack/plugins/spaces/public/management/spaces_management_app.tsx b/x-pack/plugins/spaces/public/management/spaces_management_app.tsx
index 079cf2234b13b..9216cc31ee77c 100644
--- a/x-pack/plugins/spaces/public/management/spaces_management_app.tsx
+++ b/x-pack/plugins/spaces/public/management/spaces_management_app.tsx
@@ -6,7 +6,7 @@
import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
-import { HashRouter as Router, Route, Switch, useParams } from 'react-router-dom';
+import { Router, Route, Switch, useParams } from 'react-router-dom';
import { i18n } from '@kbn/i18n';
import { StartServicesAccessor } from 'src/core/public';
import { SecurityLicense } from '../../../security/public';
@@ -32,7 +32,7 @@ export const spacesManagementApp = Object.freeze({
title: i18n.translate('xpack.spaces.displayName', {
defaultMessage: 'Spaces',
}),
- async mount({ basePath, element, setBreadcrumbs }) {
+ async mount({ basePath, element, setBreadcrumbs, history }) {
const [
{ notifications, i18n: i18nStart, application },
{ features },
@@ -108,9 +108,9 @@ export const spacesManagementApp = Object.freeze({
render(
-
+
-
+
diff --git a/x-pack/plugins/transform/public/app/app.tsx b/x-pack/plugins/transform/public/app/app.tsx
index 01ff7f5bff27f..330fb7a17f5fa 100644
--- a/x-pack/plugins/transform/public/app/app.tsx
+++ b/x-pack/plugins/transform/public/app/app.tsx
@@ -6,7 +6,8 @@
import React, { useContext, FC } from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
-import { HashRouter, Redirect, Route, Switch } from 'react-router-dom';
+import { Router, Redirect, Route, Switch } from 'react-router-dom';
+import { AppMountParameters } from 'kibana/public';
import { FormattedMessage } from '@kbn/i18n/react';
@@ -23,7 +24,7 @@ import { CloneTransformSection } from './sections/clone_transform';
import { CreateTransformSection } from './sections/create_transform';
import { TransformManagementSection } from './sections/transform_management';
-export const App: FC = () => {
+export const App: FC<{ history: AppMountParameters['history'] }> = ({ history }) => {
const { apiError } = useContext(AuthorizationContext);
if (apiError !== null) {
return (
@@ -41,24 +42,21 @@ export const App: FC = () => {
return (
-
+
-
-
+
+
+
-
+
);
};
@@ -70,7 +68,7 @@ export const renderApp = (element: HTMLElement, appDependencies: AppDependencies
-
+
,
diff --git a/x-pack/plugins/transform/public/app/app_dependencies.tsx b/x-pack/plugins/transform/public/app/app_dependencies.tsx
index 87db02988adf0..586381fd3b2b5 100644
--- a/x-pack/plugins/transform/public/app/app_dependencies.tsx
+++ b/x-pack/plugins/transform/public/app/app_dependencies.tsx
@@ -6,6 +6,7 @@
import { CoreSetup, CoreStart } from 'src/core/public';
import { DataPublicPluginStart } from 'src/plugins/data/public';
+import { AppMountParameters } from 'kibana/public';
import { useKibana } from '../../../../../src/plugins/kibana_react/public';
import { Storage } from '../../../../../src/plugins/kibana_utils/public';
@@ -21,6 +22,7 @@ export interface AppDependencies {
savedObjects: CoreStart['savedObjects'];
storage: Storage;
overlays: CoreStart['overlays'];
+ history: AppMountParameters['history'];
}
export const useAppDependencies = () => {
diff --git a/x-pack/plugins/transform/public/app/mount_management_section.ts b/x-pack/plugins/transform/public/app/mount_management_section.ts
index f3a48975a68e6..454738f7a313a 100644
--- a/x-pack/plugins/transform/public/app/mount_management_section.ts
+++ b/x-pack/plugins/transform/public/app/mount_management_section.ts
@@ -21,7 +21,7 @@ export async function mountManagementSection(
coreSetup: CoreSetup,
params: ManagementAppMountParams
) {
- const { element, setBreadcrumbs } = params;
+ const { element, setBreadcrumbs, history } = params;
const { http, notifications, getStartServices } = coreSetup;
const startServices = await getStartServices();
const [core, plugins] = startServices;
@@ -46,6 +46,7 @@ export async function mountManagementSection(
savedObjects,
storage: localStorage,
uiSettings,
+ history,
};
return renderApp(element, appDependencies);
diff --git a/x-pack/plugins/watcher/public/application/app.tsx b/x-pack/plugins/watcher/public/application/app.tsx
index 8a6d2746237e9..5e75eff5ac949 100644
--- a/x-pack/plugins/watcher/public/application/app.tsx
+++ b/x-pack/plugins/watcher/public/application/app.tsx
@@ -6,16 +6,15 @@
import React, { useEffect, useState } from 'react';
import { Observable } from 'rxjs';
-import { DocLinksStart, HttpSetup, ToastsSetup, IUiSettingsClient } from 'kibana/public';
-
import {
- HashRouter,
- Switch,
- Route,
- Redirect,
- withRouter,
- RouteComponentProps,
-} from 'react-router-dom';
+ DocLinksStart,
+ HttpSetup,
+ ToastsSetup,
+ IUiSettingsClient,
+ AppMountParameters,
+} from 'kibana/public';
+
+import { Router, Switch, Route, Redirect, withRouter, RouteComponentProps } from 'react-router-dom';
import { EuiCallOut, EuiLink } from '@elastic/eui';
@@ -46,6 +45,7 @@ export interface AppDeps {
createTimeBuckets: () => any;
licenseStatus$: Observable;
setBreadcrumbs: Parameters[0]['setBreadcrumbs'];
+ history: AppMountParameters['history'];
}
export const App = (deps: AppDeps) => {
@@ -79,13 +79,13 @@ export const App = (deps: AppDeps) => {
);
}
return (
-
+
-
+
);
};
diff --git a/x-pack/plugins/watcher/public/plugin.ts b/x-pack/plugins/watcher/public/plugin.ts
index 6496c742fcb40..a772d26308dfd 100644
--- a/x-pack/plugins/watcher/public/plugin.ts
+++ b/x-pack/plugins/watcher/public/plugin.ts
@@ -38,7 +38,7 @@ export class WatcherUIPlugin implements Plugin {
{ defaultMessage: 'Watcher' }
),
order: 3,
- mount: async ({ element, setBreadcrumbs }) => {
+ mount: async ({ element, setBreadcrumbs, history }) => {
const [core] = await getStartServices();
const { i18n: i18nDep, docLinks, savedObjects } = core;
const { boot } = await import('./application/boot');
@@ -58,6 +58,7 @@ export class WatcherUIPlugin implements Plugin {
savedObjects: savedObjects.client,
I18nContext: i18nDep.Context,
createTimeBuckets: () => new TimeBuckets(uiSettings, data),
+ history,
});
},
});
From 0a96008b663f1c60de9d30d3bc54f6ee6b7319a0 Mon Sep 17 00:00:00 2001
From: Matt Kime
Date: Tue, 19 May 2020 09:22:02 -0500
Subject: [PATCH 03/93] fix passing history
---
x-pack/plugins/cross_cluster_replication/public/plugin.ts | 3 ++-
.../management/api_keys/api_keys_management_app.test.tsx | 2 ++
.../role_mappings/role_mappings_management_app.test.tsx | 3 ++-
.../public/management/roles/roles_management_app.test.tsx | 3 ++-
.../public/management/users/users_management_app.test.tsx | 3 ++-
.../spaces/public/management/spaces_management_app.test.tsx | 3 ++-
x-pack/plugins/transform/public/app/app.tsx | 2 +-
.../__jest__/client_integration/helpers/app_context.mock.tsx | 2 ++
x-pack/plugins/watcher/public/application/app.tsx | 2 +-
9 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/x-pack/plugins/cross_cluster_replication/public/plugin.ts b/x-pack/plugins/cross_cluster_replication/public/plugin.ts
index 561da838a4202..388185b38889f 100644
--- a/x-pack/plugins/cross_cluster_replication/public/plugin.ts
+++ b/x-pack/plugins/cross_cluster_replication/public/plugin.ts
@@ -41,7 +41,7 @@ export class CrossClusterReplicationPlugin implements Plugin {
id: MANAGEMENT_ID,
title: PLUGIN.TITLE,
order: 6,
- mount: async ({ element, setBreadcrumbs }) => {
+ mount: async ({ element, setBreadcrumbs, history }) => {
const { mountApp } = await import('./app');
const [coreStart] = await getStartServices();
@@ -56,6 +56,7 @@ export class CrossClusterReplicationPlugin implements Plugin {
I18nContext,
ELASTIC_WEBSITE_URL,
DOC_LINK_VERSION,
+ history,
});
},
});
diff --git a/x-pack/plugins/security/public/management/api_keys/api_keys_management_app.test.tsx b/x-pack/plugins/security/public/management/api_keys/api_keys_management_app.test.tsx
index 11e65f14e2708..16332b6df15e3 100644
--- a/x-pack/plugins/security/public/management/api_keys/api_keys_management_app.test.tsx
+++ b/x-pack/plugins/security/public/management/api_keys/api_keys_management_app.test.tsx
@@ -10,6 +10,7 @@ jest.mock('./api_keys_grid', () => ({
import { apiKeysManagementApp } from './api_keys_management_app';
import { coreMock } from '../../../../../../src/core/public/mocks';
+import { ScopedHistory } from 'kibana/public';
describe('apiKeysManagementApp', () => {
it('create() returns proper management app descriptor', () => {
@@ -37,6 +38,7 @@ describe('apiKeysManagementApp', () => {
basePath: '/some-base-path',
element: container,
setBreadcrumbs,
+ history: {} as ScopedHistory,
});
expect(setBreadcrumbs).toHaveBeenCalledTimes(1);
diff --git a/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.test.tsx b/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.test.tsx
index 5907413d7299e..2f59da91941b8 100644
--- a/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.test.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.test.tsx
@@ -12,6 +12,7 @@ jest.mock('./edit_role_mapping', () => ({
EditRoleMappingPage: (props: any) => `Role Mapping Edit Page: ${JSON.stringify(props)}`,
}));
+import { ScopedHistory } from 'kibana/public';
import { roleMappingsManagementApp } from './role_mappings_management_app';
import { coreMock } from '../../../../../../src/core/public/mocks';
@@ -22,7 +23,7 @@ async function mountApp(basePath: string) {
const unmount = await roleMappingsManagementApp
.create({ getStartServices: coreMock.createSetup().getStartServices as any })
- .mount({ basePath, element: container, setBreadcrumbs });
+ .mount({ basePath, element: container, setBreadcrumbs, history: {} as ScopedHistory });
return { unmount, container, setBreadcrumbs };
}
diff --git a/x-pack/plugins/security/public/management/roles/roles_management_app.test.tsx b/x-pack/plugins/security/public/management/roles/roles_management_app.test.tsx
index 96051dbd7fa56..0c6e9f87b6325 100644
--- a/x-pack/plugins/security/public/management/roles/roles_management_app.test.tsx
+++ b/x-pack/plugins/security/public/management/roles/roles_management_app.test.tsx
@@ -5,6 +5,7 @@
*/
import { licenseMock } from '../../../common/licensing/index.mock';
+import { ScopedHistory } from 'kibana/public';
jest.mock('./roles_grid', () => ({
RolesGridPage: (props: any) => `Roles Page: ${JSON.stringify(props)}`,
@@ -34,7 +35,7 @@ async function mountApp(basePath: string) {
.fn()
.mockResolvedValue([coreMock.createStart(), { data: {}, features: featuresStart }]),
})
- .mount({ basePath, element: container, setBreadcrumbs });
+ .mount({ basePath, element: container, setBreadcrumbs, history: {} as ScopedHistory });
return { unmount, container, setBreadcrumbs };
}
diff --git a/x-pack/plugins/security/public/management/users/users_management_app.test.tsx b/x-pack/plugins/security/public/management/users/users_management_app.test.tsx
index 05491d6f889b6..543904858f7f7 100644
--- a/x-pack/plugins/security/public/management/users/users_management_app.test.tsx
+++ b/x-pack/plugins/security/public/management/users/users_management_app.test.tsx
@@ -12,6 +12,7 @@ jest.mock('./edit_user', () => ({
EditUserPage: (props: any) => `User Edit Page: ${JSON.stringify(props)}`,
}));
+import { ScopedHistory } from 'kibana/public';
import { usersManagementApp } from './users_management_app';
import { coreMock } from '../../../../../../src/core/public/mocks';
@@ -26,7 +27,7 @@ async function mountApp(basePath: string) {
authc: securityMock.createSetup().authc,
getStartServices: coreMock.createSetup().getStartServices as any,
})
- .mount({ basePath, element: container, setBreadcrumbs });
+ .mount({ basePath, element: container, setBreadcrumbs, history: {} as ScopedHistory });
return { unmount, container, setBreadcrumbs };
}
diff --git a/x-pack/plugins/spaces/public/management/spaces_management_app.test.tsx b/x-pack/plugins/spaces/public/management/spaces_management_app.test.tsx
index 92c78d63d1b2e..6d4cb3a58c1b3 100644
--- a/x-pack/plugins/spaces/public/management/spaces_management_app.test.tsx
+++ b/x-pack/plugins/spaces/public/management/spaces_management_app.test.tsx
@@ -17,6 +17,7 @@ jest.mock('./edit_space', () => ({
},
}));
+import { ScopedHistory } from 'kibana/public';
import { spacesManagementApp } from './spaces_management_app';
import { coreMock } from '../../../../../src/core/public/mocks';
@@ -53,7 +54,7 @@ async function mountApp(basePath: string, spaceId?: string) {
securityLicense,
getStartServices: async () => [coreStart, pluginsStart as PluginsStart, {}],
})
- .mount({ basePath, element: container, setBreadcrumbs });
+ .mount({ basePath, element: container, setBreadcrumbs, history: {} as ScopedHistory });
return { unmount, container, setBreadcrumbs };
}
diff --git a/x-pack/plugins/transform/public/app/app.tsx b/x-pack/plugins/transform/public/app/app.tsx
index 330fb7a17f5fa..7b0c49c7a49b7 100644
--- a/x-pack/plugins/transform/public/app/app.tsx
+++ b/x-pack/plugins/transform/public/app/app.tsx
@@ -16,7 +16,7 @@ import { KibanaContextProvider } from '../../../../../src/plugins/kibana_react/p
import { API_BASE_PATH } from '../../common/constants';
import { SectionError } from './components';
-import { CLIENT_BASE_PATH, SECTION_SLUG } from './constants';
+import { SECTION_SLUG } from './constants';
import { AuthorizationContext, AuthorizationProvider } from './lib/authorization';
import { AppDependencies } from './app_dependencies';
diff --git a/x-pack/plugins/watcher/__jest__/client_integration/helpers/app_context.mock.tsx b/x-pack/plugins/watcher/__jest__/client_integration/helpers/app_context.mock.tsx
index 27aa3ba93684e..2b1b333638c95 100644
--- a/x-pack/plugins/watcher/__jest__/client_integration/helpers/app_context.mock.tsx
+++ b/x-pack/plugins/watcher/__jest__/client_integration/helpers/app_context.mock.tsx
@@ -7,6 +7,7 @@
import React from 'react';
import { of } from 'rxjs';
import { ComponentType } from 'enzyme';
+import { ScopedHistory } from 'kibana/public';
import {
docLinksServiceMock,
uiSettingsServiceMock,
@@ -39,6 +40,7 @@ export const mockContextValue = {
} as any,
// For our test harness, we don't use this mocked out http service
http: httpServiceMock.createSetupContract(),
+ history: {} as ScopedHistory,
};
export const withAppContext = (Component: ComponentType) => (props: any) => {
diff --git a/x-pack/plugins/watcher/public/application/app.tsx b/x-pack/plugins/watcher/public/application/app.tsx
index 5e75eff5ac949..af8e84146a16f 100644
--- a/x-pack/plugins/watcher/public/application/app.tsx
+++ b/x-pack/plugins/watcher/public/application/app.tsx
@@ -79,7 +79,7 @@ export const App = (deps: AppDeps) => {
);
}
return (
-
+
From 3f0f2e46c6830acbc0803fc30bd735c0af6467cf Mon Sep 17 00:00:00 2001
From: Uladzislau Lasitsa
Date: Tue, 19 May 2020 17:59:29 +0300
Subject: [PATCH 04/93] Fixed types
---
.../management_app/management_app.tsx | 2 +-
src/plugins/management/public/types.ts | 4 ++--
.../cross_cluster_replication/public/plugin.ts | 3 ++-
.../api_keys/api_keys_management_app.test.tsx | 5 +++--
.../management/management_service.test.ts | 3 ++-
.../role_mappings_management_app.test.tsx | 11 +++++++++--
.../roles/roles_management_app.test.tsx | 11 +++++++++--
.../users/users_management_app.test.tsx | 11 +++++++++--
.../management/spaces_management_app.test.tsx | 11 +++++++++--
x-pack/plugins/transform/public/app/app.tsx | 2 +-
.../helpers/app_context.mock.tsx | 3 +++
.../plugins/watcher/public/application/app.tsx | 17 +++++++----------
12 files changed, 57 insertions(+), 26 deletions(-)
diff --git a/src/plugins/management/public/components/management_app/management_app.tsx b/src/plugins/management/public/components/management_app/management_app.tsx
index e2ff105268abe..3586882bcf808 100644
--- a/src/plugins/management/public/components/management_app/management_app.tsx
+++ b/src/plugins/management/public/components/management_app/management_app.tsx
@@ -19,7 +19,7 @@
import React, { useState, useEffect, useCallback } from 'react';
import { Route, Router, Switch } from 'react-router-dom';
import { AppMountContext, AppMountParameters, ChromeBreadcrumb } from 'kibana/public';
-import { I18nProvider } from '@kbn/i18n/src/react';
+import { I18nProvider } from '@kbn/i18n/react';
import { EuiPage, EuiPageBody } from '@elastic/eui';
import { ManagementStart } from '../../types';
import { ManagementSection } from '../../utils';
diff --git a/src/plugins/management/public/types.ts b/src/plugins/management/public/types.ts
index 2dbcacbffa169..54ed598ae57d9 100644
--- a/src/plugins/management/public/types.ts
+++ b/src/plugins/management/public/types.ts
@@ -18,7 +18,7 @@
*/
import { ReactElement } from 'react';
-import { AppMountParameters } from 'kibana/public';
+import { ScopedHistory } from 'kibana/public';
import { ManagementSection, RegisterManagementSectionArgs } from './utils';
import { ChromeBreadcrumb } from '../../../core/public/';
@@ -57,7 +57,7 @@ export interface ManagementAppMountParams {
basePath: string; // base path for setting up your router
element: HTMLElement; // element the section should render into
setBreadcrumbs: (crumbs: ChromeBreadcrumb[]) => void;
- history: AppMountParameters['history'];
+ history: ScopedHistory;
}
export interface CreateManagementItemArgs {
diff --git a/x-pack/plugins/cross_cluster_replication/public/plugin.ts b/x-pack/plugins/cross_cluster_replication/public/plugin.ts
index 561da838a4202..388185b38889f 100644
--- a/x-pack/plugins/cross_cluster_replication/public/plugin.ts
+++ b/x-pack/plugins/cross_cluster_replication/public/plugin.ts
@@ -41,7 +41,7 @@ export class CrossClusterReplicationPlugin implements Plugin {
id: MANAGEMENT_ID,
title: PLUGIN.TITLE,
order: 6,
- mount: async ({ element, setBreadcrumbs }) => {
+ mount: async ({ element, setBreadcrumbs, history }) => {
const { mountApp } = await import('./app');
const [coreStart] = await getStartServices();
@@ -56,6 +56,7 @@ export class CrossClusterReplicationPlugin implements Plugin {
I18nContext,
ELASTIC_WEBSITE_URL,
DOC_LINK_VERSION,
+ history,
});
},
});
diff --git a/x-pack/plugins/security/public/management/api_keys/api_keys_management_app.test.tsx b/x-pack/plugins/security/public/management/api_keys/api_keys_management_app.test.tsx
index 11e65f14e2708..725698e767bec 100644
--- a/x-pack/plugins/security/public/management/api_keys/api_keys_management_app.test.tsx
+++ b/x-pack/plugins/security/public/management/api_keys/api_keys_management_app.test.tsx
@@ -7,9 +7,9 @@
jest.mock('./api_keys_grid', () => ({
APIKeysGridPage: (props: any) => `Page: ${JSON.stringify(props)}`,
}));
-
+import { ScopedHistory } from 'src/core/public';
import { apiKeysManagementApp } from './api_keys_management_app';
-import { coreMock } from '../../../../../../src/core/public/mocks';
+import { coreMock, scopedHistoryMock } from '../../../../../../src/core/public/mocks';
describe('apiKeysManagementApp', () => {
it('create() returns proper management app descriptor', () => {
@@ -37,6 +37,7 @@ describe('apiKeysManagementApp', () => {
basePath: '/some-base-path',
element: container,
setBreadcrumbs,
+ history: (scopedHistoryMock.create() as unknown) as ScopedHistory,
});
expect(setBreadcrumbs).toHaveBeenCalledTimes(1);
diff --git a/x-pack/plugins/security/public/management/management_service.test.ts b/x-pack/plugins/security/public/management/management_service.test.ts
index 78d7f7ff118a6..78dcda411191a 100644
--- a/x-pack/plugins/security/public/management/management_service.test.ts
+++ b/x-pack/plugins/security/public/management/management_service.test.ts
@@ -21,6 +21,8 @@ import { rolesManagementApp } from './roles';
import { apiKeysManagementApp } from './api_keys';
import { roleMappingsManagementApp } from './role_mappings';
+const mockSection = { registerApp: jest.fn() };
+
describe('ManagementService', () => {
describe('setup()', () => {
it('properly registers security section and its applications', () => {
@@ -28,7 +30,6 @@ describe('ManagementService', () => {
const { authc } = securityMock.createSetup();
const license = licenseMock.create();
- const mockSection = { registerApp: jest.fn() };
const managementSetup: ManagementSetup = {
sections: {
register: jest.fn(),
diff --git a/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.test.tsx b/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.test.tsx
index 5907413d7299e..9e0b7b028bb2b 100644
--- a/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.test.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.test.tsx
@@ -12,9 +12,11 @@ jest.mock('./edit_role_mapping', () => ({
EditRoleMappingPage: (props: any) => `Role Mapping Edit Page: ${JSON.stringify(props)}`,
}));
+import { ScopedHistory } from 'src/core/public';
+
import { roleMappingsManagementApp } from './role_mappings_management_app';
-import { coreMock } from '../../../../../../src/core/public/mocks';
+import { coreMock, scopedHistoryMock } from '../../../../../../src/core/public/mocks';
async function mountApp(basePath: string) {
const container = document.createElement('div');
@@ -22,7 +24,12 @@ async function mountApp(basePath: string) {
const unmount = await roleMappingsManagementApp
.create({ getStartServices: coreMock.createSetup().getStartServices as any })
- .mount({ basePath, element: container, setBreadcrumbs });
+ .mount({
+ basePath,
+ element: container,
+ setBreadcrumbs,
+ history: (scopedHistoryMock.create() as unknown) as ScopedHistory,
+ });
return { unmount, container, setBreadcrumbs };
}
diff --git a/x-pack/plugins/security/public/management/roles/roles_management_app.test.tsx b/x-pack/plugins/security/public/management/roles/roles_management_app.test.tsx
index 96051dbd7fa56..850dcce278185 100644
--- a/x-pack/plugins/security/public/management/roles/roles_management_app.test.tsx
+++ b/x-pack/plugins/security/public/management/roles/roles_management_app.test.tsx
@@ -14,9 +14,11 @@ jest.mock('./edit_role', () => ({
EditRolePage: (props: any) => `Role Edit Page: ${JSON.stringify(props)}`,
}));
+import { ScopedHistory } from 'src/core/public';
+
import { rolesManagementApp } from './roles_management_app';
-import { coreMock } from '../../../../../../src/core/public/mocks';
+import { coreMock, scopedHistoryMock } from '../../../../../../src/core/public/mocks';
import { featuresPluginMock } from '../../../../features/public/mocks';
async function mountApp(basePath: string) {
@@ -34,7 +36,12 @@ async function mountApp(basePath: string) {
.fn()
.mockResolvedValue([coreMock.createStart(), { data: {}, features: featuresStart }]),
})
- .mount({ basePath, element: container, setBreadcrumbs });
+ .mount({
+ basePath,
+ element: container,
+ setBreadcrumbs,
+ history: (scopedHistoryMock.create() as unknown) as ScopedHistory,
+ });
return { unmount, container, setBreadcrumbs };
}
diff --git a/x-pack/plugins/security/public/management/users/users_management_app.test.tsx b/x-pack/plugins/security/public/management/users/users_management_app.test.tsx
index 05491d6f889b6..e05dff81a0524 100644
--- a/x-pack/plugins/security/public/management/users/users_management_app.test.tsx
+++ b/x-pack/plugins/security/public/management/users/users_management_app.test.tsx
@@ -12,9 +12,11 @@ jest.mock('./edit_user', () => ({
EditUserPage: (props: any) => `User Edit Page: ${JSON.stringify(props)}`,
}));
+import { ScopedHistory } from 'src/core/public';
+
import { usersManagementApp } from './users_management_app';
-import { coreMock } from '../../../../../../src/core/public/mocks';
+import { coreMock, scopedHistoryMock } from '../../../../../../src/core/public/mocks';
import { securityMock } from '../../mocks';
async function mountApp(basePath: string) {
@@ -26,7 +28,12 @@ async function mountApp(basePath: string) {
authc: securityMock.createSetup().authc,
getStartServices: coreMock.createSetup().getStartServices as any,
})
- .mount({ basePath, element: container, setBreadcrumbs });
+ .mount({
+ basePath,
+ element: container,
+ setBreadcrumbs,
+ history: (scopedHistoryMock.create() as unknown) as ScopedHistory,
+ });
return { unmount, container, setBreadcrumbs };
}
diff --git a/x-pack/plugins/spaces/public/management/spaces_management_app.test.tsx b/x-pack/plugins/spaces/public/management/spaces_management_app.test.tsx
index 92c78d63d1b2e..d35e31093800c 100644
--- a/x-pack/plugins/spaces/public/management/spaces_management_app.test.tsx
+++ b/x-pack/plugins/spaces/public/management/spaces_management_app.test.tsx
@@ -17,9 +17,11 @@ jest.mock('./edit_space', () => ({
},
}));
+import { ScopedHistory } from 'src/core/public';
+
import { spacesManagementApp } from './spaces_management_app';
-import { coreMock } from '../../../../../src/core/public/mocks';
+import { coreMock, scopedHistoryMock } from '../../../../../src/core/public/mocks';
import { securityMock } from '../../../security/public/mocks';
import { spacesManagerMock } from '../spaces_manager/mocks';
import { SecurityLicenseFeatures } from '../../../security/public';
@@ -53,7 +55,12 @@ async function mountApp(basePath: string, spaceId?: string) {
securityLicense,
getStartServices: async () => [coreStart, pluginsStart as PluginsStart, {}],
})
- .mount({ basePath, element: container, setBreadcrumbs });
+ .mount({
+ basePath,
+ element: container,
+ setBreadcrumbs,
+ history: (scopedHistoryMock.create() as unknown) as ScopedHistory,
+ });
return { unmount, container, setBreadcrumbs };
}
diff --git a/x-pack/plugins/transform/public/app/app.tsx b/x-pack/plugins/transform/public/app/app.tsx
index 330fb7a17f5fa..7b0c49c7a49b7 100644
--- a/x-pack/plugins/transform/public/app/app.tsx
+++ b/x-pack/plugins/transform/public/app/app.tsx
@@ -16,7 +16,7 @@ import { KibanaContextProvider } from '../../../../../src/plugins/kibana_react/p
import { API_BASE_PATH } from '../../common/constants';
import { SectionError } from './components';
-import { CLIENT_BASE_PATH, SECTION_SLUG } from './constants';
+import { SECTION_SLUG } from './constants';
import { AuthorizationContext, AuthorizationProvider } from './lib/authorization';
import { AppDependencies } from './app_dependencies';
diff --git a/x-pack/plugins/watcher/__jest__/client_integration/helpers/app_context.mock.tsx b/x-pack/plugins/watcher/__jest__/client_integration/helpers/app_context.mock.tsx
index 27aa3ba93684e..e381d2717e54a 100644
--- a/x-pack/plugins/watcher/__jest__/client_integration/helpers/app_context.mock.tsx
+++ b/x-pack/plugins/watcher/__jest__/client_integration/helpers/app_context.mock.tsx
@@ -7,11 +7,13 @@
import React from 'react';
import { of } from 'rxjs';
import { ComponentType } from 'enzyme';
+import { ScopedHistory } from 'src/core/public';
import {
docLinksServiceMock,
uiSettingsServiceMock,
notificationServiceMock,
httpServiceMock,
+ scopedHistoryMock,
} from '../../../../../../src/core/public/mocks';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { AppContextProvider } from '../../../public/application/app_context';
@@ -39,6 +41,7 @@ export const mockContextValue = {
} as any,
// For our test harness, we don't use this mocked out http service
http: httpServiceMock.createSetupContract(),
+ history: (scopedHistoryMock.create() as unknown) as ScopedHistory,
};
export const withAppContext = (Component: ComponentType) => (props: any) => {
diff --git a/x-pack/plugins/watcher/public/application/app.tsx b/x-pack/plugins/watcher/public/application/app.tsx
index 5e75eff5ac949..da7ca45dd58ca 100644
--- a/x-pack/plugins/watcher/public/application/app.tsx
+++ b/x-pack/plugins/watcher/public/application/app.tsx
@@ -6,13 +6,7 @@
import React, { useEffect, useState } from 'react';
import { Observable } from 'rxjs';
-import {
- DocLinksStart,
- HttpSetup,
- ToastsSetup,
- IUiSettingsClient,
- AppMountParameters,
-} from 'kibana/public';
+import { DocLinksStart, HttpSetup, ToastsSetup, IUiSettingsClient } from 'kibana/public';
import { Router, Switch, Route, Redirect, withRouter, RouteComponentProps } from 'react-router-dom';
@@ -20,7 +14,10 @@ import { EuiCallOut, EuiLink } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
-import { RegisterManagementAppArgs } from '../../../../../src/plugins/management/public';
+import {
+ RegisterManagementAppArgs,
+ ManagementAppMountParams,
+} from '../../../../../src/plugins/management/public';
import { LicenseStatus } from '../../common/types/license_status';
import { WatchStatus } from './sections/watch_status/components/watch_status';
@@ -45,7 +42,7 @@ export interface AppDeps {
createTimeBuckets: () => any;
licenseStatus$: Observable;
setBreadcrumbs: Parameters[0]['setBreadcrumbs'];
- history: AppMountParameters['history'];
+ history: ManagementAppMountParams['history'];
}
export const App = (deps: AppDeps) => {
@@ -79,7 +76,7 @@ export const App = (deps: AppDeps) => {
);
}
return (
-
+
From 12d6ac2bd0420950f3621ac60cdf926771622954 Mon Sep 17 00:00:00 2001
From: Uladzislau Lasitsa
Date: Tue, 19 May 2020 18:34:40 +0300
Subject: [PATCH 05/93] Fixed routing for Ingest Node Pipelines
---
.../public/application/app.tsx | 19 +++++++++++--------
.../public/application/index.tsx | 2 ++
.../application/mount_management_section.ts | 3 ++-
.../sections/pipelines_list/empty_list.tsx | 2 +-
.../sections/pipelines_list/table.tsx | 10 +++++++---
.../application/services/breadcrumbs.ts | 4 ++--
6 files changed, 25 insertions(+), 15 deletions(-)
diff --git a/x-pack/plugins/ingest_pipelines/public/application/app.tsx b/x-pack/plugins/ingest_pipelines/public/application/app.tsx
index 98b49bafd6ed6..4b3f6d27ae8ef 100644
--- a/x-pack/plugins/ingest_pipelines/public/application/app.tsx
+++ b/x-pack/plugins/ingest_pipelines/public/application/app.tsx
@@ -6,9 +6,11 @@
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiPageContent } from '@elastic/eui';
import React, { FunctionComponent } from 'react';
-import { HashRouter, Switch, Route } from 'react-router-dom';
+import { Router, Switch, Route } from 'react-router-dom';
-import { BASE_PATH, APP_CLUSTER_REQUIRED_PRIVILEGES } from '../../common/constants';
+import { useKibana } from '../shared_imports';
+
+import { APP_CLUSTER_REQUIRED_PRIVILEGES } from '../../common/constants';
import {
SectionError,
@@ -22,10 +24,10 @@ import { PipelinesList, PipelinesCreate, PipelinesEdit, PipelinesClone } from '.
export const AppWithoutRouter = () => (
-
-
-
-
+
+
+
+
{/* Catch all */}
@@ -33,6 +35,7 @@ export const AppWithoutRouter = () => (
export const App: FunctionComponent = () => {
const { apiError } = useAuthorizationContext();
+ const { history } = useKibana().services;
if (apiError) {
return (
@@ -91,9 +94,9 @@ export const App: FunctionComponent = () => {
}
return (
-
+
-
+
);
}}
diff --git a/x-pack/plugins/ingest_pipelines/public/application/index.tsx b/x-pack/plugins/ingest_pipelines/public/application/index.tsx
index e43dba4689b44..a8e6febeb2e59 100644
--- a/x-pack/plugins/ingest_pipelines/public/application/index.tsx
+++ b/x-pack/plugins/ingest_pipelines/public/application/index.tsx
@@ -8,6 +8,7 @@ import { HttpSetup } from 'kibana/public';
import React, { ReactNode } from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import { NotificationsSetup } from 'kibana/public';
+import { ManagementAppMountParams } from 'src/plugins/management/public';
import { KibanaContextProvider } from '../../../../../src/plugins/kibana_react/public';
import { API_BASE_PATH } from '../../common/constants';
@@ -23,6 +24,7 @@ export interface AppServices {
documentation: DocumentationService;
api: ApiService;
notifications: NotificationsSetup;
+ history: ManagementAppMountParams['history'];
}
export interface CoreServices {
diff --git a/x-pack/plugins/ingest_pipelines/public/application/mount_management_section.ts b/x-pack/plugins/ingest_pipelines/public/application/mount_management_section.ts
index e36f27cbf5f62..49c8f5a7b2e1e 100644
--- a/x-pack/plugins/ingest_pipelines/public/application/mount_management_section.ts
+++ b/x-pack/plugins/ingest_pipelines/public/application/mount_management_section.ts
@@ -13,7 +13,7 @@ export async function mountManagementSection(
{ http, getStartServices, notifications }: CoreSetup,
params: ManagementAppMountParams
) {
- const { element, setBreadcrumbs } = params;
+ const { element, setBreadcrumbs, history } = params;
const [coreStart] = await getStartServices();
const {
docLinks,
@@ -29,6 +29,7 @@ export async function mountManagementSection(
documentation: documentationService,
api: apiService,
notifications,
+ history,
};
return renderApp(element, I18nContext, services, { http });
diff --git a/x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/empty_list.tsx b/x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/empty_list.tsx
index f6fe2f0cf65fa..b8d4a8006a1d0 100644
--- a/x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/empty_list.tsx
+++ b/x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/empty_list.tsx
@@ -41,7 +41,7 @@ export const EmptyList: FunctionComponent = () => {
}
actions={
-
+
{i18n.translate('xpack.ingestPipelines.list.table.emptyPrompt.createButtonLabel', {
defaultMessage: 'Create a pipeline',
})}
diff --git a/x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/table.tsx b/x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/table.tsx
index e5c708b5c0e53..47c505dd38d24 100644
--- a/x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/table.tsx
+++ b/x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/table.tsx
@@ -14,8 +14,8 @@ import {
EuiTableFieldDataColumnType,
} from '@elastic/eui';
-import { BASE_PATH } from '../../../../common/constants';
import { Pipeline } from '../../../../common/types';
+import { useKibana } from '../../../shared_imports';
export interface Props {
pipelines: Pipeline[];
@@ -32,6 +32,7 @@ export const PipelineTable: FunctionComponent = ({
onClonePipelineClick,
onDeletePipelineClick,
}) => {
+ const { history } = useKibana().services;
const [selection, setSelection] = useState([]);
const tableProps: EuiInMemoryTableProps = {
@@ -82,7 +83,7 @@ export const PipelineTable: FunctionComponent = ({
})}
,
= ({
}),
sortable: true,
render: (name: string) => (
-
+
{name}
),
diff --git a/x-pack/plugins/ingest_pipelines/public/application/services/breadcrumbs.ts b/x-pack/plugins/ingest_pipelines/public/application/services/breadcrumbs.ts
index 1ccdbbad9b1bb..9b974fdea283a 100644
--- a/x-pack/plugins/ingest_pipelines/public/application/services/breadcrumbs.ts
+++ b/x-pack/plugins/ingest_pipelines/public/application/services/breadcrumbs.ts
@@ -28,7 +28,7 @@ export class BreadcrumbService {
create: [
{
text: homeBreadcrumbText,
- href: `#${BASE_PATH}`,
+ href: `/`,
},
{
text: i18n.translate('xpack.ingestPipelines.breadcrumb.createPipelineLabel', {
@@ -39,7 +39,7 @@ export class BreadcrumbService {
edit: [
{
text: homeBreadcrumbText,
- href: `#${BASE_PATH}`,
+ href: `/`,
},
{
text: i18n.translate('xpack.ingestPipelines.breadcrumb.editPipelineLabel', {
From 8890dc8a367478b530eada920c6ba12c6a64dae1 Mon Sep 17 00:00:00 2001
From: Matt Kime
Date: Tue, 19 May 2020 14:13:53 -0500
Subject: [PATCH 06/93] introduce and use react router wrapped eui components
---
.../index_pattern_table.tsx | 10 +--
.../eui_button_empty_react_router.tsx | 56 +++++++++++++++++
.../eui_button_react_router.tsx | 56 +++++++++++++++++
.../eui_link_react_router.tsx | 57 +++++++++++++++++
.../public/eui_link_react_router/index.ts | 22 +++++++
.../react_router_element_wrapper.tsx | 63 +++++++++++++++++++
src/plugins/kibana_react/public/index.ts | 1 +
.../management_app/management_app.tsx | 1 +
.../sections/pipelines_list/empty_list.tsx | 8 +--
.../sections/pipelines_list/table.tsx | 18 +++---
10 files changed, 276 insertions(+), 16 deletions(-)
create mode 100644 src/plugins/kibana_react/public/eui_link_react_router/eui_button_empty_react_router.tsx
create mode 100644 src/plugins/kibana_react/public/eui_link_react_router/eui_button_react_router.tsx
create mode 100644 src/plugins/kibana_react/public/eui_link_react_router/eui_link_react_router.tsx
create mode 100644 src/plugins/kibana_react/public/eui_link_react_router/index.ts
create mode 100644 src/plugins/kibana_react/public/eui_link_react_router/react_router_element_wrapper.tsx
diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx
index e2e71632a10f4..13a037aa1c492 100644
--- a/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx
+++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx
@@ -19,7 +19,6 @@
import {
EuiBadge,
- EuiButtonEmpty,
EuiButtonIcon,
EuiFlexGroup,
EuiFlexItem,
@@ -33,6 +32,7 @@ import { FormattedMessage } from '@kbn/i18n/react';
import { withRouter, RouteComponentProps } from 'react-router-dom';
import React, { useState, useEffect } from 'react';
import { i18n } from '@kbn/i18n';
+import { EuiButtonEmptyReactRouter } from '../../../../kibana_react/public';
import {
SavedObjectsClientContract,
IUiSettingsClient,
@@ -46,7 +46,7 @@ import { IndexPatternManagementStart } from '../../plugin';
import { getIndexPatterns } from '../utils';
import { getListBreadcrumbs } from '../breadcrumbs';
-const columns = (history: AppMountParameters['history']) => [
+const columns = [
{
field: 'title',
name: 'Pattern',
@@ -60,7 +60,7 @@ const columns = (history: AppMountParameters['history']) => [
}>;
}
) => (
- history.push(`/patterns/${index.id}`)}>
+
{name}
{index.tags &&
index.tags.map(({ key: tagKey, name: tagName }) => (
@@ -68,7 +68,7 @@ const columns = (history: AppMountParameters['history']) => [
{tagName}
))}
-
+
),
dataType: 'string' as const,
sortable: ({ sort }: { sort: string }) => sort,
@@ -197,7 +197,7 @@ export const IndexPatternTable = ({
itemId="id"
isSelectable={false}
items={indexPatterns}
- columns={columns(history)}
+ columns={columns}
pagination={pagination}
sorting={sorting}
search={search}
diff --git a/src/plugins/kibana_react/public/eui_link_react_router/eui_button_empty_react_router.tsx b/src/plugins/kibana_react/public/eui_link_react_router/eui_button_empty_react_router.tsx
new file mode 100644
index 0000000000000..5985a93f2821a
--- /dev/null
+++ b/src/plugins/kibana_react/public/eui_link_react_router/eui_button_empty_react_router.tsx
@@ -0,0 +1,56 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import React from 'react';
+import { EuiButtonEmpty, EuiButtonEmptyProps } from '@elastic/eui';
+import { useHistory } from 'react-router-dom';
+
+type EuiButtonReactRouterProps = EuiButtonEmptyProps & {
+ to: string;
+ children: React.ReactNode;
+};
+
+const isModifiedEvent = (event: any) =>
+ !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
+
+const isLeftClickEvent = (event: any) => event.button === 0;
+
+export function EuiButtonEmptyReactRouter({ to, ...props }: EuiButtonReactRouterProps) {
+ const history = useHistory();
+
+ function onClick(event: any) {
+ if (event.defaultPrevented) {
+ return;
+ }
+
+ if (event.target.getAttribute('target')) {
+ return;
+ }
+
+ if (isModifiedEvent(event) || !isLeftClickEvent(event)) {
+ return;
+ }
+
+ // prevents page reload
+ event.preventDefault();
+ history.push(to);
+ }
+
+ return ; // eslint-disable-line
+}
diff --git a/src/plugins/kibana_react/public/eui_link_react_router/eui_button_react_router.tsx b/src/plugins/kibana_react/public/eui_link_react_router/eui_button_react_router.tsx
new file mode 100644
index 0000000000000..000a4e2877956
--- /dev/null
+++ b/src/plugins/kibana_react/public/eui_link_react_router/eui_button_react_router.tsx
@@ -0,0 +1,56 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import React from 'react';
+import { EuiButton, EuiButtonProps } from '@elastic/eui';
+import { useHistory } from 'react-router-dom';
+
+type EuiButtonReactRouterProps = EuiButtonProps & {
+ to: string;
+ children: React.ReactNode;
+};
+
+const isModifiedEvent = (event: any) =>
+ !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
+
+const isLeftClickEvent = (event: any) => event.button === 0;
+
+export function EuiButtonReactRouter({ to, ...props }: EuiButtonReactRouterProps) {
+ const history = useHistory();
+
+ function onClick(event: any) {
+ if (event.defaultPrevented) {
+ return;
+ }
+
+ if (event.target.getAttribute('target')) {
+ return;
+ }
+
+ if (isModifiedEvent(event) || !isLeftClickEvent(event)) {
+ return;
+ }
+
+ // prevents page reload
+ event.preventDefault();
+ history.push(to);
+ }
+
+ return ; // eslint-disable-line
+}
diff --git a/src/plugins/kibana_react/public/eui_link_react_router/eui_link_react_router.tsx b/src/plugins/kibana_react/public/eui_link_react_router/eui_link_react_router.tsx
new file mode 100644
index 0000000000000..fd569892e9243
--- /dev/null
+++ b/src/plugins/kibana_react/public/eui_link_react_router/eui_link_react_router.tsx
@@ -0,0 +1,57 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import React from 'react';
+import { EuiLink, EuiLinkAnchorProps } from '@elastic/eui';
+import { useHistory } from 'react-router-dom';
+
+type EuiLinkReactRouterProps = EuiLinkAnchorProps & {
+ to: string | { pathname?: string; search?: string; hash?: string };
+};
+
+const isModifiedEvent = (event: any) =>
+ !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
+
+const isLeftClickEvent = (event: any) => event.button === 0;
+
+export function EuiLinkReactRouter({ to, ...props }: EuiLinkReactRouterProps) {
+ const toAsObject = typeof to === 'string' ? { pathname: to } : to;
+ const history = useHistory();
+
+ function onClick(event: any) {
+ if (event.defaultPrevented) {
+ return;
+ }
+
+ if (event.target.getAttribute('target')) {
+ return;
+ }
+
+ if (isModifiedEvent(event) || !isLeftClickEvent(event)) {
+ return;
+ }
+
+ // prevents page reload
+ event.preventDefault();
+
+ history.push(toAsObject);
+ }
+
+ return ; // eslint-disable-line
+}
diff --git a/src/plugins/kibana_react/public/eui_link_react_router/index.ts b/src/plugins/kibana_react/public/eui_link_react_router/index.ts
new file mode 100644
index 0000000000000..a8e11a82f387e
--- /dev/null
+++ b/src/plugins/kibana_react/public/eui_link_react_router/index.ts
@@ -0,0 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+export { EuiLinkReactRouter } from './eui_link_react_router';
+export { EuiButtonReactRouter } from './eui_button_react_router';
+export { EuiButtonEmptyReactRouter } from './eui_button_empty_react_router';
diff --git a/src/plugins/kibana_react/public/eui_link_react_router/react_router_element_wrapper.tsx b/src/plugins/kibana_react/public/eui_link_react_router/react_router_element_wrapper.tsx
new file mode 100644
index 0000000000000..f221e7fbf2cab
--- /dev/null
+++ b/src/plugins/kibana_react/public/eui_link_react_router/react_router_element_wrapper.tsx
@@ -0,0 +1,63 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import React from 'react';
+import { useHistory } from 'react-router-dom';
+
+const isModifiedEvent = (event: any) =>
+ !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
+
+const isLeftClickEvent = (event: any) => event.button === 0;
+
+/*
+ * Attempt at abstracting react router wrapped eui components
+ */
+
+export function reactRouterElementWrapper({
+ Component,
+ to,
+ props,
+}: {
+ Component: React.ComponentClass;
+ to: string | { pathname?: string; search?: string; hash?: string };
+ props: { [key: string]: any };
+}) {
+ const toAsObject = typeof to === 'string' ? { pathname: to } : to;
+ const history = useHistory();
+
+ function onClick(event: any) {
+ if (event.defaultPrevented) {
+ return;
+ }
+
+ if (event.target.getAttribute('target')) {
+ return;
+ }
+
+ if (isModifiedEvent(event) || !isLeftClickEvent(event)) {
+ return;
+ }
+
+ // prevents page reload
+ event.preventDefault();
+ history.push(toAsObject);
+ }
+
+ return ;
+}
diff --git a/src/plugins/kibana_react/public/index.ts b/src/plugins/kibana_react/public/index.ts
index 9bec91b859ab7..b9b32988642b2 100644
--- a/src/plugins/kibana_react/public/index.ts
+++ b/src/plugins/kibana_react/public/index.ts
@@ -25,6 +25,7 @@ export * from './ui_settings';
export * from './field_icon';
export * from './table_list_view';
export * from './split_panel';
+export * from './eui_link_react_router';
export { ValidatedDualRange, Value } from './validated_range';
export * from './notifications';
export { Markdown, MarkdownSimple } from './markdown';
diff --git a/src/plugins/management/public/components/management_app/management_app.tsx b/src/plugins/management/public/components/management_app/management_app.tsx
index 3586882bcf808..8483b95486ea3 100644
--- a/src/plugins/management/public/components/management_app/management_app.tsx
+++ b/src/plugins/management/public/components/management_app/management_app.tsx
@@ -49,6 +49,7 @@ export const ManagementApp = ({ context, dependencies, history }: ManagementAppP
const onManagementSectionSelected = useCallback(
(id: string, path: string) => {
history.push(path);
+ window.scrollTo(0, 0);
},
[history]
);
diff --git a/x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/empty_list.tsx b/x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/empty_list.tsx
index b8d4a8006a1d0..f6bb5edc1ce9f 100644
--- a/x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/empty_list.tsx
+++ b/x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/empty_list.tsx
@@ -6,8 +6,8 @@
import React, { FunctionComponent } from 'react';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
-import { EuiButton, EuiEmptyPrompt, EuiLink, EuiPageBody, EuiPageContent } from '@elastic/eui';
-import { BASE_PATH } from '../../../../common/constants';
+import { EuiEmptyPrompt, EuiLink, EuiPageBody, EuiPageContent } from '@elastic/eui';
+import { EuiButtonReactRouter } from '../../../../../../../src/plugins/kibana_react/public';
import { useKibana } from '../../../shared_imports';
export const EmptyList: FunctionComponent = () => {
@@ -41,11 +41,11 @@ export const EmptyList: FunctionComponent = () => {
}
actions={
-
+
{i18n.translate('xpack.ingestPipelines.list.table.emptyPrompt.createButtonLabel', {
defaultMessage: 'Create a pipeline',
})}
-
+
}
/>
diff --git a/x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/table.tsx b/x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/table.tsx
index 47c505dd38d24..948496332ffd5 100644
--- a/x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/table.tsx
+++ b/x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/table.tsx
@@ -13,6 +13,10 @@ import {
EuiInMemoryTableProps,
EuiTableFieldDataColumnType,
} from '@elastic/eui';
+import {
+ EuiButtonReactRouter,
+ EuiLinkReactRouter,
+} from '../../../../../../../src/plugins/kibana_react/public';
import { Pipeline } from '../../../../common/types';
import { useKibana } from '../../../shared_imports';
@@ -82,17 +86,17 @@ export const PipelineTable: FunctionComponent = ({
defaultMessage: 'Reload',
})}
,
-
{i18n.translate('xpack.ingestPipelines.list.table.createPipelineButtonLabel', {
- defaultMessage: 'Create a pipeline',
+ defaultMessage: 'Create a pipeline here',
})}
- ,
+ ,
],
box: {
incremental: true,
@@ -110,12 +114,12 @@ export const PipelineTable: FunctionComponent = ({
}),
sortable: true,
render: (name: string) => (
-
{name}
-
+
),
},
{
From dbfe0e4f6f02e0605670c07ad67f5b535450e950 Mon Sep 17 00:00:00 2001
From: Matt Kime
Date: Tue, 19 May 2020 14:34:47 -0500
Subject: [PATCH 07/93] react router utils
---
.../react_router_element_wrapper.tsx | 63 ++++++++++++-------
1 file changed, 40 insertions(+), 23 deletions(-)
diff --git a/src/plugins/kibana_react/public/eui_link_react_router/react_router_element_wrapper.tsx b/src/plugins/kibana_react/public/eui_link_react_router/react_router_element_wrapper.tsx
index f221e7fbf2cab..8a23d836ef3ef 100644
--- a/src/plugins/kibana_react/public/eui_link_react_router/react_router_element_wrapper.tsx
+++ b/src/plugins/kibana_react/public/eui_link_react_router/react_router_element_wrapper.tsx
@@ -19,45 +19,62 @@
import React from 'react';
import { useHistory } from 'react-router-dom';
+import { ScopedHistory } from 'kibana/public';
const isModifiedEvent = (event: any) =>
!!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
const isLeftClickEvent = (event: any) => event.button === 0;
+export const reactRouterHrefOnClick = (to: string | LocationObject) => {
+ const toAsObject = typeof to === 'string' ? { pathname: to } : to;
+ const history = useHistory() as ScopedHistory;
+
+ return {
+ href: history.createHref(toAsObject),
+ onClick: reactRouterOnClickHandler(history, toAsObject),
+ };
+};
+
+export const reactRouterOnClickHandler = (
+ history: ScopedHistory,
+ locationObject: LocationObject
+) => (event: any) => {
+ if (event.defaultPrevented) {
+ return;
+ }
+
+ if (event.target.getAttribute('target')) {
+ return;
+ }
+
+ if (isModifiedEvent(event) || !isLeftClickEvent(event)) {
+ return;
+ }
+
+ // prevents page reload
+ event.preventDefault();
+ history.push(locationObject);
+};
+
/*
* Attempt at abstracting react router wrapped eui components
*/
+interface LocationObject {
+ pathname?: string;
+ search?: string;
+ hash?: string;
+}
+
export function reactRouterElementWrapper({
Component,
to,
props,
}: {
Component: React.ComponentClass;
- to: string | { pathname?: string; search?: string; hash?: string };
+ to: string | LocationObject;
props: { [key: string]: any };
}) {
- const toAsObject = typeof to === 'string' ? { pathname: to } : to;
- const history = useHistory();
-
- function onClick(event: any) {
- if (event.defaultPrevented) {
- return;
- }
-
- if (event.target.getAttribute('target')) {
- return;
- }
-
- if (isModifiedEvent(event) || !isLeftClickEvent(event)) {
- return;
- }
-
- // prevents page reload
- event.preventDefault();
- history.push(toAsObject);
- }
-
- return ;
+ return ;
}
From 13bf37c16b228b1c4f1e6fde2382f9ccac2693fd Mon Sep 17 00:00:00 2001
From: Matt Kime
Date: Tue, 19 May 2020 21:12:23 -0500
Subject: [PATCH 08/93] work in progress => hashRouter to router
---
.../index_pattern_table.tsx | 15 ++---
.../eui_button_empty_react_router.tsx | 56 ------------------
.../eui_button_react_router.tsx | 56 ------------------
.../eui_link_react_router.tsx | 57 -------------------
src/plugins/kibana_react/public/index.ts | 2 +-
.../index.ts | 4 +-
.../react_router_navigate.tsx} | 34 +++--------
.../plugins/apm/public/application/index.tsx | 9 +--
.../app/Main/route_config/index.tsx | 7 +++
.../public/app/app.tsx | 25 +++-----
.../public/app/index.tsx | 6 +-
.../public/application/app.tsx | 4 +-
.../public/application/index.tsx | 4 +-
.../public/application/app.tsx | 22 +++----
.../public/application/app_context.tsx | 2 +
.../public/application/index.tsx | 6 +-
.../application/mount_management_section.ts | 5 +-
.../sections/pipelines_list/empty_list.tsx | 11 ++--
.../sections/pipelines_list/table.tsx | 17 +++---
.../public/application/app_context.tsx | 4 +-
.../public/application/index.tsx | 3 +-
.../ml/public/application/routing/router.tsx | 6 +-
.../public/application/index.d.ts | 4 +-
.../public/application/index.js | 8 +--
.../plugins/remote_clusters/public/plugin.ts | 4 +-
x-pack/plugins/rollup/public/crud_app/app.js | 13 ++---
.../public/application/app.tsx | 31 ++++------
.../public/application/index.tsx | 13 +++--
.../application/mount_management_section.ts | 4 +-
x-pack/plugins/transform/public/app/app.tsx | 4 +-
.../transform/public/app/app_dependencies.tsx | 4 +-
.../watcher/public/application/app.tsx | 16 ++----
32 files changed, 127 insertions(+), 329 deletions(-)
delete mode 100644 src/plugins/kibana_react/public/eui_link_react_router/eui_button_empty_react_router.tsx
delete mode 100644 src/plugins/kibana_react/public/eui_link_react_router/eui_button_react_router.tsx
delete mode 100644 src/plugins/kibana_react/public/eui_link_react_router/eui_link_react_router.tsx
rename src/plugins/kibana_react/public/{eui_link_react_router => react_router_navigate}/index.ts (79%)
rename src/plugins/kibana_react/public/{eui_link_react_router/react_router_element_wrapper.tsx => react_router_navigate/react_router_navigate.tsx} (76%)
diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx
index 13a037aa1c492..3aaa1571994d5 100644
--- a/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx
+++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx
@@ -19,6 +19,7 @@
import {
EuiBadge,
+ EuiButtonEmpty,
EuiButtonIcon,
EuiFlexGroup,
EuiFlexItem,
@@ -27,12 +28,12 @@ import {
EuiSpacer,
EuiText,
} from '@elastic/eui';
-import { AppMountParameters } from 'kibana/public';
+import { AppMountParameters, ScopedHistory } from 'kibana/public';
import { FormattedMessage } from '@kbn/i18n/react';
import { withRouter, RouteComponentProps } from 'react-router-dom';
import React, { useState, useEffect } from 'react';
import { i18n } from '@kbn/i18n';
-import { EuiButtonEmptyReactRouter } from '../../../../kibana_react/public';
+import { reactRouterNavigate } from '../../../../kibana_react/public';
import {
SavedObjectsClientContract,
IUiSettingsClient,
@@ -46,7 +47,7 @@ import { IndexPatternManagementStart } from '../../plugin';
import { getIndexPatterns } from '../utils';
import { getListBreadcrumbs } from '../breadcrumbs';
-const columns = [
+const columns = (history: ScopedHistory) => [
{
field: 'title',
name: 'Pattern',
@@ -60,7 +61,7 @@ const columns = [
}>;
}
) => (
-
+
{name}
{index.tags &&
index.tags.map(({ key: tagKey, name: tagName }) => (
@@ -68,7 +69,7 @@ const columns = [
{tagName}
))}
-
+
),
dataType: 'string' as const,
sortable: ({ sort }: { sort: string }) => sort,
@@ -107,7 +108,7 @@ const title = i18n.translate('indexPatternManagement.indexPatternTable.title', {
interface Props extends RouteComponentProps {
getIndexPatternCreationOptions: IndexPatternManagementStart['creation']['getIndexPatternCreationOptions'];
canSave: boolean;
- history: AppMountParameters['history'];
+ history: ScopedHistory;
services: {
savedObjectsClient: SavedObjectsClientContract;
uiSettings: IUiSettingsClient;
@@ -197,7 +198,7 @@ export const IndexPatternTable = ({
itemId="id"
isSelectable={false}
items={indexPatterns}
- columns={columns}
+ columns={columns(history)}
pagination={pagination}
sorting={sorting}
search={search}
diff --git a/src/plugins/kibana_react/public/eui_link_react_router/eui_button_empty_react_router.tsx b/src/plugins/kibana_react/public/eui_link_react_router/eui_button_empty_react_router.tsx
deleted file mode 100644
index 5985a93f2821a..0000000000000
--- a/src/plugins/kibana_react/public/eui_link_react_router/eui_button_empty_react_router.tsx
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import React from 'react';
-import { EuiButtonEmpty, EuiButtonEmptyProps } from '@elastic/eui';
-import { useHistory } from 'react-router-dom';
-
-type EuiButtonReactRouterProps = EuiButtonEmptyProps & {
- to: string;
- children: React.ReactNode;
-};
-
-const isModifiedEvent = (event: any) =>
- !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
-
-const isLeftClickEvent = (event: any) => event.button === 0;
-
-export function EuiButtonEmptyReactRouter({ to, ...props }: EuiButtonReactRouterProps) {
- const history = useHistory();
-
- function onClick(event: any) {
- if (event.defaultPrevented) {
- return;
- }
-
- if (event.target.getAttribute('target')) {
- return;
- }
-
- if (isModifiedEvent(event) || !isLeftClickEvent(event)) {
- return;
- }
-
- // prevents page reload
- event.preventDefault();
- history.push(to);
- }
-
- return ; // eslint-disable-line
-}
diff --git a/src/plugins/kibana_react/public/eui_link_react_router/eui_button_react_router.tsx b/src/plugins/kibana_react/public/eui_link_react_router/eui_button_react_router.tsx
deleted file mode 100644
index 000a4e2877956..0000000000000
--- a/src/plugins/kibana_react/public/eui_link_react_router/eui_button_react_router.tsx
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import React from 'react';
-import { EuiButton, EuiButtonProps } from '@elastic/eui';
-import { useHistory } from 'react-router-dom';
-
-type EuiButtonReactRouterProps = EuiButtonProps & {
- to: string;
- children: React.ReactNode;
-};
-
-const isModifiedEvent = (event: any) =>
- !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
-
-const isLeftClickEvent = (event: any) => event.button === 0;
-
-export function EuiButtonReactRouter({ to, ...props }: EuiButtonReactRouterProps) {
- const history = useHistory();
-
- function onClick(event: any) {
- if (event.defaultPrevented) {
- return;
- }
-
- if (event.target.getAttribute('target')) {
- return;
- }
-
- if (isModifiedEvent(event) || !isLeftClickEvent(event)) {
- return;
- }
-
- // prevents page reload
- event.preventDefault();
- history.push(to);
- }
-
- return ; // eslint-disable-line
-}
diff --git a/src/plugins/kibana_react/public/eui_link_react_router/eui_link_react_router.tsx b/src/plugins/kibana_react/public/eui_link_react_router/eui_link_react_router.tsx
deleted file mode 100644
index fd569892e9243..0000000000000
--- a/src/plugins/kibana_react/public/eui_link_react_router/eui_link_react_router.tsx
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import React from 'react';
-import { EuiLink, EuiLinkAnchorProps } from '@elastic/eui';
-import { useHistory } from 'react-router-dom';
-
-type EuiLinkReactRouterProps = EuiLinkAnchorProps & {
- to: string | { pathname?: string; search?: string; hash?: string };
-};
-
-const isModifiedEvent = (event: any) =>
- !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
-
-const isLeftClickEvent = (event: any) => event.button === 0;
-
-export function EuiLinkReactRouter({ to, ...props }: EuiLinkReactRouterProps) {
- const toAsObject = typeof to === 'string' ? { pathname: to } : to;
- const history = useHistory();
-
- function onClick(event: any) {
- if (event.defaultPrevented) {
- return;
- }
-
- if (event.target.getAttribute('target')) {
- return;
- }
-
- if (isModifiedEvent(event) || !isLeftClickEvent(event)) {
- return;
- }
-
- // prevents page reload
- event.preventDefault();
-
- history.push(toAsObject);
- }
-
- return ; // eslint-disable-line
-}
diff --git a/src/plugins/kibana_react/public/index.ts b/src/plugins/kibana_react/public/index.ts
index b9b32988642b2..c7fd734a56cec 100644
--- a/src/plugins/kibana_react/public/index.ts
+++ b/src/plugins/kibana_react/public/index.ts
@@ -25,7 +25,7 @@ export * from './ui_settings';
export * from './field_icon';
export * from './table_list_view';
export * from './split_panel';
-export * from './eui_link_react_router';
+export * from './react_router_navigate';
export { ValidatedDualRange, Value } from './validated_range';
export * from './notifications';
export { Markdown, MarkdownSimple } from './markdown';
diff --git a/src/plugins/kibana_react/public/eui_link_react_router/index.ts b/src/plugins/kibana_react/public/react_router_navigate/index.ts
similarity index 79%
rename from src/plugins/kibana_react/public/eui_link_react_router/index.ts
rename to src/plugins/kibana_react/public/react_router_navigate/index.ts
index a8e11a82f387e..b00cc30ab031f 100644
--- a/src/plugins/kibana_react/public/eui_link_react_router/index.ts
+++ b/src/plugins/kibana_react/public/react_router_navigate/index.ts
@@ -17,6 +17,4 @@
* under the License.
*/
-export { EuiLinkReactRouter } from './eui_link_react_router';
-export { EuiButtonReactRouter } from './eui_button_react_router';
-export { EuiButtonEmptyReactRouter } from './eui_button_empty_react_router';
+export { reactRouterNavigate, reactRouterOnClickHandler } from './react_router_navigate';
diff --git a/src/plugins/kibana_react/public/eui_link_react_router/react_router_element_wrapper.tsx b/src/plugins/kibana_react/public/react_router_navigate/react_router_navigate.tsx
similarity index 76%
rename from src/plugins/kibana_react/public/eui_link_react_router/react_router_element_wrapper.tsx
rename to src/plugins/kibana_react/public/react_router_navigate/react_router_navigate.tsx
index 8a23d836ef3ef..448f3ebb74299 100644
--- a/src/plugins/kibana_react/public/eui_link_react_router/react_router_element_wrapper.tsx
+++ b/src/plugins/kibana_react/public/react_router_navigate/react_router_navigate.tsx
@@ -17,19 +17,21 @@
* under the License.
*/
-import React from 'react';
-import { useHistory } from 'react-router-dom';
import { ScopedHistory } from 'kibana/public';
+interface LocationObject {
+ pathname?: string;
+ search?: string;
+ hash?: string;
+}
+
const isModifiedEvent = (event: any) =>
!!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
const isLeftClickEvent = (event: any) => event.button === 0;
-export const reactRouterHrefOnClick = (to: string | LocationObject) => {
+export const reactRouterNavigate = (history: ScopedHistory, to: string | LocationObject) => {
const toAsObject = typeof to === 'string' ? { pathname: to } : to;
- const history = useHistory() as ScopedHistory;
-
return {
href: history.createHref(toAsObject),
onClick: reactRouterOnClickHandler(history, toAsObject),
@@ -56,25 +58,3 @@ export const reactRouterOnClickHandler = (
event.preventDefault();
history.push(locationObject);
};
-
-/*
- * Attempt at abstracting react router wrapped eui components
- */
-
-interface LocationObject {
- pathname?: string;
- search?: string;
- hash?: string;
-}
-
-export function reactRouterElementWrapper({
- Component,
- to,
- props,
-}: {
- Component: React.ComponentClass;
- to: string | LocationObject;
- props: { [key: string]: any };
-}) {
- return ;
-}
diff --git a/x-pack/plugins/apm/public/application/index.tsx b/x-pack/plugins/apm/public/application/index.tsx
index 6c1c3d3262a0e..4bca2c9140f91 100644
--- a/x-pack/plugins/apm/public/application/index.tsx
+++ b/x-pack/plugins/apm/public/application/index.tsx
@@ -9,6 +9,7 @@ import React from 'react';
import ReactDOM from 'react-dom';
import { Route, Router, Switch } from 'react-router-dom';
import styled from 'styled-components';
+import { ScopedHistory } from 'kibana/public';
import { CoreStart, AppMountParameters } from '../../../../../src/core/public';
import { ApmPluginSetupDeps } from '../plugin';
import { ApmPluginContext } from '../context/ApmPluginContext';
@@ -24,7 +25,7 @@ import { UpdateBreadcrumbs } from '../components/app/Main/UpdateBreadcrumbs';
import { APMIndicesPermission } from '../components/app/APMIndicesPermission';
import { ScrollToTopOnPathChange } from '../components/app/Main/ScrollToTopOnPathChange';
import { routes } from '../components/app/Main/route_config';
-import { history, resetHistory } from '../utils/history';
+// import { history, resetHistory } from '../utils/history';
import { ConfigSchema } from '..';
import 'react-vis/dist/style.css';
@@ -58,7 +59,7 @@ const ApmAppRoot = ({
}: {
core: CoreStart;
deps: ApmPluginSetupDeps;
- routerHistory: typeof history;
+ routerHistory: ScopedHistory;
config: ConfigSchema;
}) => {
const i18nCore = core.i18n;
@@ -108,10 +109,10 @@ const ApmAppRoot = ({
export const renderApp = (
core: CoreStart,
deps: ApmPluginSetupDeps,
- { element }: AppMountParameters,
+ { element, history }: AppMountParameters,
config: ConfigSchema
) => {
- resetHistory();
+ // resetHistory();
ReactDOM.render(
{
};
export const routes: BreadcrumbRoute[] = [
+ {
+ exact: true,
+ path: '',
+ render: renderAsRedirectTo('/services'),
+ breadcrumb: 'APM',
+ name: RouteName.HOME
+ },
{
exact: true,
path: '/',
diff --git a/x-pack/plugins/cross_cluster_replication/public/app/app.tsx b/x-pack/plugins/cross_cluster_replication/public/app/app.tsx
index ec349ccd6f2c7..48531e212b2f5 100644
--- a/x-pack/plugins/cross_cluster_replication/public/app/app.tsx
+++ b/x-pack/plugins/cross_cluster_replication/public/app/app.tsx
@@ -191,24 +191,13 @@ class AppComponent extends Component {
return (
-
-
-
-
-
-
+
+
+
+
+
+
+
);
diff --git a/x-pack/plugins/cross_cluster_replication/public/app/index.tsx b/x-pack/plugins/cross_cluster_replication/public/app/index.tsx
index d4a74aefb1571..79bef6d7aeaea 100644
--- a/x-pack/plugins/cross_cluster_replication/public/app/index.tsx
+++ b/x-pack/plugins/cross_cluster_replication/public/app/index.tsx
@@ -7,7 +7,7 @@ import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import { Provider } from 'react-redux';
import { Router } from 'react-router-dom';
-import { I18nStart, AppMountParameters } from 'kibana/public';
+import { I18nStart, ScopedHistory } from 'kibana/public';
import { UnmountCallback } from 'src/core/public';
import { init as initBreadcrumbs, SetBreadcrumbs } from './services/breadcrumbs';
@@ -18,7 +18,7 @@ import { ccrStore } from './store';
const renderApp = (
element: Element,
I18nContext: I18nStart['Context'],
- history: AppMountParameters['history']
+ history: ScopedHistory
): UnmountCallback => {
render(
@@ -47,7 +47,7 @@ export async function mountApp({
I18nContext: I18nStart['Context'];
ELASTIC_WEBSITE_URL: string;
DOC_LINK_VERSION: string;
- history: AppMountParameters['history'];
+ history: ScopedHistory;
}): Promise {
// Import and initialize additional services here instead of in plugin.ts to reduce the size of the
// initial bundle as much as possible.
diff --git a/x-pack/plugins/index_lifecycle_management/public/application/app.tsx b/x-pack/plugins/index_lifecycle_management/public/application/app.tsx
index dff21fb6d796d..0358a5f67cd8b 100644
--- a/x-pack/plugins/index_lifecycle_management/public/application/app.tsx
+++ b/x-pack/plugins/index_lifecycle_management/public/application/app.tsx
@@ -6,7 +6,7 @@
import React, { useEffect } from 'react';
import { Router, Switch, Route, Redirect } from 'react-router-dom';
-import { AppMountParameters } from 'kibana/public';
+import { ScopedHistory } from 'kibana/public';
import { METRIC_TYPE } from '@kbn/analytics';
import { UIM_APP_LOAD } from './constants';
@@ -14,7 +14,7 @@ import { EditPolicy } from './sections/edit_policy';
import { PolicyTable } from './sections/policy_table';
import { trackUiMetric } from './services/ui_metric';
-export const App = ({ history }: { history: AppMountParameters['history'] }) => {
+export const App = ({ history }: { history: ScopedHistory }) => {
useEffect(() => trackUiMetric(METRIC_TYPE.LOADED, UIM_APP_LOAD), []);
return (
diff --git a/x-pack/plugins/index_lifecycle_management/public/application/index.tsx b/x-pack/plugins/index_lifecycle_management/public/application/index.tsx
index 9d9120398810b..b0a7101a236db 100644
--- a/x-pack/plugins/index_lifecycle_management/public/application/index.tsx
+++ b/x-pack/plugins/index_lifecycle_management/public/application/index.tsx
@@ -7,7 +7,7 @@
import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import { Provider } from 'react-redux';
-import { I18nStart, AppMountParameters } from 'kibana/public';
+import { I18nStart, ScopedHistory } from 'kibana/public';
import { UnmountCallback } from 'src/core/public';
import { App } from './app';
@@ -16,7 +16,7 @@ import { indexLifecycleManagementStore } from './store';
export const renderApp = (
element: Element,
I18nContext: I18nStart['Context'],
- history: AppMountParameters['history']
+ history: ScopedHistory
): UnmountCallback => {
render(
diff --git a/x-pack/plugins/index_management/public/application/app.tsx b/x-pack/plugins/index_management/public/application/app.tsx
index 83997dd6ece18..9cccedd7f50b3 100644
--- a/x-pack/plugins/index_management/public/application/app.tsx
+++ b/x-pack/plugins/index_management/public/application/app.tsx
@@ -5,8 +5,9 @@
*/
import React, { useEffect } from 'react';
-import { HashRouter, Switch, Route, Redirect } from 'react-router-dom';
-import { BASE_PATH, UIM_APP_LOAD } from '../../common/constants';
+import { Router, Switch, Route, Redirect } from 'react-router-dom';
+import { ScopedHistory } from 'kibana/public';
+import { UIM_APP_LOAD } from '../../common/constants';
import { IndexManagementHome } from './sections/home';
import { TemplateCreate } from './sections/template_create';
import { TemplateClone } from './sections/template_clone';
@@ -14,24 +15,25 @@ import { TemplateEdit } from './sections/template_edit';
import { useServices } from './app_context';
-export const App = () => {
+export const App = ({ history }: { history: ScopedHistory }) => {
const { uiMetricService } = useServices();
useEffect(() => uiMetricService.trackMetric('loaded', UIM_APP_LOAD), [uiMetricService]);
+ console.log('3 - app');
return (
-
+
-
+
);
};
// Export this so we can test it with a different router.
export const AppWithoutRouter = () => (
-
-
-
-
-
+
+
+
+
+
);
diff --git a/x-pack/plugins/index_management/public/application/app_context.tsx b/x-pack/plugins/index_management/public/application/app_context.tsx
index 2bb618ad8efce..ad934c18c18e3 100644
--- a/x-pack/plugins/index_management/public/application/app_context.tsx
+++ b/x-pack/plugins/index_management/public/application/app_context.tsx
@@ -5,6 +5,7 @@
*/
import React, { createContext, useContext } from 'react';
+import { ScopedHistory } from 'kibana/public';
import { CoreStart } from '../../../../../src/core/public';
import { UsageCollectionSetup } from '../../../../../src/plugins/usage_collection/public';
@@ -27,6 +28,7 @@ export interface AppDependencies {
httpService: HttpService;
notificationService: NotificationService;
};
+ history: ScopedHistory;
}
export const AppContextProvider = ({
diff --git a/x-pack/plugins/index_management/public/application/index.tsx b/x-pack/plugins/index_management/public/application/index.tsx
index 5850cb8d42f1a..a9343552759b7 100644
--- a/x-pack/plugins/index_management/public/application/index.tsx
+++ b/x-pack/plugins/index_management/public/application/index.tsx
@@ -24,13 +24,13 @@ export const renderApp = (
const { i18n } = core;
const { Context: I18nContext } = i18n;
- const { services } = dependencies;
-
+ const { services, history } = dependencies;
+ console.log('2 before render', history);
render(
-
+
,
diff --git a/x-pack/plugins/index_management/public/application/mount_management_section.ts b/x-pack/plugins/index_management/public/application/mount_management_section.ts
index c47b0603dc1c8..a432ccc190400 100644
--- a/x-pack/plugins/index_management/public/application/mount_management_section.ts
+++ b/x-pack/plugins/index_management/public/application/mount_management_section.ts
@@ -30,13 +30,13 @@ export async function mountManagementSection(
services: InternalServices,
params: ManagementAppMountParams
) {
- const { element, setBreadcrumbs } = params;
+ const { element, setBreadcrumbs, history } = params;
const [core] = await coreSetup.getStartServices();
const { docLinks, fatalErrors } = core;
breadcrumbService.setup(setBreadcrumbs);
documentationService.setup(docLinks);
-
+ console.log('1 before render app', history);
const appDependencies: AppDependencies = {
core: {
fatalErrors,
@@ -45,6 +45,7 @@ export async function mountManagementSection(
usageCollection,
},
services,
+ history,
};
return renderApp(element, { core, dependencies: appDependencies });
diff --git a/x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/empty_list.tsx b/x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/empty_list.tsx
index f6bb5edc1ce9f..eba69ff454911 100644
--- a/x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/empty_list.tsx
+++ b/x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/empty_list.tsx
@@ -6,12 +6,15 @@
import React, { FunctionComponent } from 'react';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
-import { EuiEmptyPrompt, EuiLink, EuiPageBody, EuiPageContent } from '@elastic/eui';
-import { EuiButtonReactRouter } from '../../../../../../../src/plugins/kibana_react/public';
+import { EuiEmptyPrompt, EuiLink, EuiPageBody, EuiPageContent, EuiButton } from '@elastic/eui';
+import { useHistory } from 'react-router-dom';
+import { ScopedHistory } from 'kibana/public';
+import { reactRouterNavigate } from '../../../../../../../src/plugins/kibana_react/public';
import { useKibana } from '../../../shared_imports';
export const EmptyList: FunctionComponent = () => {
const { services } = useKibana();
+ const history = useHistory() as ScopedHistory;
return (
@@ -41,11 +44,11 @@ export const EmptyList: FunctionComponent = () => {
}
actions={
-
+
{i18n.translate('xpack.ingestPipelines.list.table.emptyPrompt.createButtonLabel', {
defaultMessage: 'Create a pipeline',
})}
-
+
}
/>
diff --git a/x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/table.tsx b/x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/table.tsx
index 948496332ffd5..5b426f17e0e8c 100644
--- a/x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/table.tsx
+++ b/x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_list/table.tsx
@@ -13,10 +13,7 @@ import {
EuiInMemoryTableProps,
EuiTableFieldDataColumnType,
} from '@elastic/eui';
-import {
- EuiButtonReactRouter,
- EuiLinkReactRouter,
-} from '../../../../../../../src/plugins/kibana_react/public';
+import { reactRouterNavigate } from '../../../../../../../src/plugins/kibana_react/public';
import { Pipeline } from '../../../../common/types';
import { useKibana } from '../../../shared_imports';
@@ -86,17 +83,17 @@ export const PipelineTable: FunctionComponent = ({
defaultMessage: 'Reload',
})}
,
-
{i18n.translate('xpack.ingestPipelines.list.table.createPipelineButtonLabel', {
defaultMessage: 'Create a pipeline here',
})}
- ,
+ ,
],
box: {
incremental: true,
@@ -114,12 +111,12 @@ export const PipelineTable: FunctionComponent = ({
}),
sortable: true,
render: (name: string) => (
-
{name}
-
+
),
},
{
diff --git a/x-pack/plugins/license_management/public/application/app_context.tsx b/x-pack/plugins/license_management/public/application/app_context.tsx
index 28fa16641a369..39e7ef5f16e79 100644
--- a/x-pack/plugins/license_management/public/application/app_context.tsx
+++ b/x-pack/plugins/license_management/public/application/app_context.tsx
@@ -5,7 +5,7 @@
*/
import React, { createContext, useContext } from 'react';
-import { AppMountParameters } from 'kibana/public';
+import { ScopedHistory } from 'kibana/public';
import { CoreStart } from '../../../../../src/core/public';
import { LicensingPluginSetup, ILicense } from '../../../licensing/public';
@@ -19,7 +19,7 @@ export interface AppDependencies {
core: CoreStart;
services: {
breadcrumbService: BreadcrumbService;
- history: AppMountParameters['history'];
+ history: ScopedHistory;
};
plugins: {
licensing: LicensingPluginSetup;
diff --git a/x-pack/plugins/license_management/public/application/index.tsx b/x-pack/plugins/license_management/public/application/index.tsx
index 84f3067a528ea..cca164b14b8b8 100644
--- a/x-pack/plugins/license_management/public/application/index.tsx
+++ b/x-pack/plugins/license_management/public/application/index.tsx
@@ -7,7 +7,6 @@
import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import { Router } from 'react-router-dom';
-import { AppMountParameters } from 'kibana/public';
import { AppDependencies } from './app_context';
import { AppProviders } from './app_providers';
@@ -15,7 +14,7 @@ import { AppProviders } from './app_providers';
import { App } from './app.container';
const AppWithRouter = (props: { [key: string]: any }) => (
-
+
);
diff --git a/x-pack/plugins/ml/public/application/routing/router.tsx b/x-pack/plugins/ml/public/application/routing/router.tsx
index f4d6fec5e6ee3..540265c1a0a05 100644
--- a/x-pack/plugins/ml/public/application/routing/router.tsx
+++ b/x-pack/plugins/ml/public/application/routing/router.tsx
@@ -5,7 +5,7 @@
*/
import React, { FC } from 'react';
-import { HashRouter, Route, RouteProps } from 'react-router-dom';
+import { Router, Route, RouteProps } from 'react-router-dom';
import { Location } from 'history';
import { IUiSettingsClient, ChromeStart } from 'kibana/public';
@@ -47,7 +47,7 @@ export const MlRouter: FC<{ pageDeps: PageDependencies }> = ({ pageDeps }) => {
const setBreadcrumbs = pageDeps.setBreadcrumbs;
return (
-
+
{Object.entries(routes).map(([name, route]) => (
= ({ pageDeps }) => {
/>
))}
-
+
);
};
diff --git a/x-pack/plugins/remote_clusters/public/application/index.d.ts b/x-pack/plugins/remote_clusters/public/application/index.d.ts
index b021dca51bacd..8b2af65e4fff7 100644
--- a/x-pack/plugins/remote_clusters/public/application/index.d.ts
+++ b/x-pack/plugins/remote_clusters/public/application/index.d.ts
@@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
+import { ScopedHistory } from 'kibana/public';
import { RegisterManagementAppArgs, I18nStart } from '../types';
export declare const renderApp: (
@@ -11,5 +12,6 @@ export declare const renderApp: (
I18nContext: I18nStart['Context'],
appDependencies: {
isCloudEnabled?: boolean;
- }
+ },
+ history: ScopedHistory
) => ReturnType;
diff --git a/x-pack/plugins/remote_clusters/public/application/index.js b/x-pack/plugins/remote_clusters/public/application/index.js
index cf6e855ba58df..5881e886c7384 100644
--- a/x-pack/plugins/remote_clusters/public/application/index.js
+++ b/x-pack/plugins/remote_clusters/public/application/index.js
@@ -6,7 +6,7 @@
import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
-import { HashRouter } from 'react-router-dom';
+import { Router } from 'react-router-dom';
import { Provider } from 'react-redux';
import { App } from './app';
@@ -15,14 +15,14 @@ import { AppContextProvider } from './app_context';
import './_hacks.scss';
-export const renderApp = (elem, I18nContext, appDependencies) => {
+export const renderApp = (elem, I18nContext, appDependencies, history) => {
render(
-
+
-
+
,
diff --git a/x-pack/plugins/remote_clusters/public/plugin.ts b/x-pack/plugins/remote_clusters/public/plugin.ts
index fde8ffa511319..8881db0f9196e 100644
--- a/x-pack/plugins/remote_clusters/public/plugin.ts
+++ b/x-pack/plugins/remote_clusters/public/plugin.ts
@@ -41,7 +41,7 @@ export class RemoteClustersUIPlugin
defaultMessage: 'Remote Clusters',
}),
order: 7,
- mount: async ({ element, setBreadcrumbs }) => {
+ mount: async ({ element, setBreadcrumbs, history }) => {
const [core] = await getStartServices();
const {
i18n: { Context: i18nContext },
@@ -59,7 +59,7 @@ export class RemoteClustersUIPlugin
const isCloudEnabled = Boolean(cloud?.isCloudEnabled);
const { renderApp } = await import('./application');
- return renderApp(element, i18nContext, { isCloudEnabled });
+ return renderApp(element, i18nContext, { isCloudEnabled }, history);
},
});
}
diff --git a/x-pack/plugins/rollup/public/crud_app/app.js b/x-pack/plugins/rollup/public/crud_app/app.js
index 0ef3253eeb94e..4eff849776aef 100644
--- a/x-pack/plugins/rollup/public/crud_app/app.js
+++ b/x-pack/plugins/rollup/public/crud_app/app.js
@@ -6,10 +6,9 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
-import { HashRouter, Switch, Route, Redirect, withRouter } from 'react-router-dom';
+import { Router, Switch, Route, Redirect, withRouter } from 'react-router-dom';
import { UIM_APP_LOAD } from '../../common';
-import { CRUD_APP_BASE_PATH } from './constants';
import { registerRouter, setUserHasLeftApp, METRIC_TYPE } from './services';
import { trackUiMetric } from '../kibana_services';
import { JobList, JobCreate } from './sections';
@@ -53,15 +52,15 @@ export class App extends Component {
render() {
return (
-
+
-
-
-
+
+
+
-
+
);
}
}
diff --git a/x-pack/plugins/snapshot_restore/public/application/app.tsx b/x-pack/plugins/snapshot_restore/public/application/app.tsx
index 350d8aec711ed..04f5b1a3c78aa 100644
--- a/x-pack/plugins/snapshot_restore/public/application/app.tsx
+++ b/x-pack/plugins/snapshot_restore/public/application/app.tsx
@@ -17,7 +17,7 @@ import {
NotAuthorizedSection,
} from '../shared_imports';
import { SectionLoading } from './components';
-import { BASE_PATH, DEFAULT_SECTION, Section } from './constants';
+import { DEFAULT_SECTION, Section } from './constants';
import {
RepositoryAdd,
RepositoryEdit,
@@ -63,34 +63,23 @@ export const App: React.FunctionComponent = () => {
) : hasPrivileges ? (
-
+
+
-
-
+
- {slmUi.enabled && (
-
- )}
- {slmUi.enabled && (
-
- )}
-
+ {slmUi.enabled && }
+ {slmUi.enabled && }
+
+
) : (
diff --git a/x-pack/plugins/snapshot_restore/public/application/index.tsx b/x-pack/plugins/snapshot_restore/public/application/index.tsx
index 220efd82859d2..49881ee4f3259 100644
--- a/x-pack/plugins/snapshot_restore/public/application/index.tsx
+++ b/x-pack/plugins/snapshot_restore/public/application/index.tsx
@@ -6,22 +6,23 @@
import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
-import { HashRouter } from 'react-router-dom';
+import { Router } from 'react-router-dom';
+import { ScopedHistory } from 'kibana/public';
import { App } from './app';
import { AppProviders } from './app_providers';
import { AppDependencies } from './app_context';
-const AppWithRouter = () => (
-
+const AppWithRouter = ({ history }: { history: ScopedHistory }) => (
+
-
+
);
-export const renderApp = (elem: Element, dependencies: AppDependencies) => {
+export const renderApp = (elem: Element, dependencies: AppDependencies, history: ScopedHistory) => {
render(
-
+
,
elem
);
diff --git a/x-pack/plugins/snapshot_restore/public/application/mount_management_section.ts b/x-pack/plugins/snapshot_restore/public/application/mount_management_section.ts
index 9697e24a7147e..87a9170307ea6 100644
--- a/x-pack/plugins/snapshot_restore/public/application/mount_management_section.ts
+++ b/x-pack/plugins/snapshot_restore/public/application/mount_management_section.ts
@@ -23,7 +23,7 @@ export async function mountManagementSection(
config: ClientConfigType,
params: ManagementAppMountParams
) {
- const { element, setBreadcrumbs } = params;
+ const { element, setBreadcrumbs, history } = params;
const [core] = await coreSetup.getStartServices();
const {
docLinks,
@@ -44,5 +44,5 @@ export async function mountManagementSection(
},
};
- return renderApp(element, appDependencies);
+ return renderApp(element, appDependencies, history);
}
diff --git a/x-pack/plugins/transform/public/app/app.tsx b/x-pack/plugins/transform/public/app/app.tsx
index 7b0c49c7a49b7..c9a8cb3f8539c 100644
--- a/x-pack/plugins/transform/public/app/app.tsx
+++ b/x-pack/plugins/transform/public/app/app.tsx
@@ -7,7 +7,7 @@
import React, { useContext, FC } from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import { Router, Redirect, Route, Switch } from 'react-router-dom';
-import { AppMountParameters } from 'kibana/public';
+import { ScopedHistory } from 'kibana/public';
import { FormattedMessage } from '@kbn/i18n/react';
@@ -24,7 +24,7 @@ import { CloneTransformSection } from './sections/clone_transform';
import { CreateTransformSection } from './sections/create_transform';
import { TransformManagementSection } from './sections/transform_management';
-export const App: FC<{ history: AppMountParameters['history'] }> = ({ history }) => {
+export const App: FC<{ history: ScopedHistory }> = ({ history }) => {
const { apiError } = useContext(AuthorizationContext);
if (apiError !== null) {
return (
diff --git a/x-pack/plugins/transform/public/app/app_dependencies.tsx b/x-pack/plugins/transform/public/app/app_dependencies.tsx
index 586381fd3b2b5..704875330fdd2 100644
--- a/x-pack/plugins/transform/public/app/app_dependencies.tsx
+++ b/x-pack/plugins/transform/public/app/app_dependencies.tsx
@@ -6,7 +6,7 @@
import { CoreSetup, CoreStart } from 'src/core/public';
import { DataPublicPluginStart } from 'src/plugins/data/public';
-import { AppMountParameters } from 'kibana/public';
+import { ScopedHistory } from 'kibana/public';
import { useKibana } from '../../../../../src/plugins/kibana_react/public';
import { Storage } from '../../../../../src/plugins/kibana_utils/public';
@@ -22,7 +22,7 @@ export interface AppDependencies {
savedObjects: CoreStart['savedObjects'];
storage: Storage;
overlays: CoreStart['overlays'];
- history: AppMountParameters['history'];
+ history: ScopedHistory;
}
export const useAppDependencies = () => {
diff --git a/x-pack/plugins/watcher/public/application/app.tsx b/x-pack/plugins/watcher/public/application/app.tsx
index da7ca45dd58ca..ca4371045c45d 100644
--- a/x-pack/plugins/watcher/public/application/app.tsx
+++ b/x-pack/plugins/watcher/public/application/app.tsx
@@ -24,7 +24,6 @@ import { WatchStatus } from './sections/watch_status/components/watch_status';
import { WatchEdit } from './sections/watch_edit/components/watch_edit';
import { WatchList } from './sections/watch_list/components/watch_list';
import { registerRouter } from './lib/navigation';
-import { BASE_PATH } from './constants';
import { AppContextProvider } from './app_context';
import { ChartsPluginSetup } from '../../../../../src/plugins/charts/public';
@@ -89,14 +88,11 @@ export const App = (deps: AppDeps) => {
// Export this so we can test it with a different router.
export const AppWithoutRouter = () => (
-
-
-
-
-
+
+
+
+
+
+
);
From beaaa70d0f92e6ae41a070da8943562e0b62b5b1 Mon Sep 17 00:00:00 2001
From: Matt Kime
Date: Tue, 19 May 2020 22:37:17 -0500
Subject: [PATCH 09/93] more partial progress
---
.../index_pattern_table.tsx | 2 +-
.../react_router_navigate.tsx | 23 +++++++++----------
.../plugins/apm/public/application/index.tsx | 1 -
.../public/app/app.tsx | 1 -
.../public/application/app.tsx | 1 -
.../public/application/sections/home/home.tsx | 9 ++++----
.../home/template_list/template_list.tsx | 2 ++
.../template_table/template_table.tsx | 8 +++++--
.../public/application/services/navigation.ts | 9 +++-----
.../public/application/services/routing.ts | 11 ++++-----
.../application/services/breadcrumbs.ts | 1 -
x-pack/plugins/ml/public/application/app.tsx | 11 ++++++---
.../ml/public/application/routing/router.tsx | 3 ++-
.../remote_clusters/public/application/app.js | 13 ++++++-----
14 files changed, 48 insertions(+), 47 deletions(-)
diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx
index 3aaa1571994d5..baf9e32ba85db 100644
--- a/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx
+++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx
@@ -28,7 +28,7 @@ import {
EuiSpacer,
EuiText,
} from '@elastic/eui';
-import { AppMountParameters, ScopedHistory } from 'kibana/public';
+import { ScopedHistory } from 'kibana/public';
import { FormattedMessage } from '@kbn/i18n/react';
import { withRouter, RouteComponentProps } from 'react-router-dom';
import React, { useState, useEffect } from 'react';
diff --git a/src/plugins/kibana_react/public/react_router_navigate/react_router_navigate.tsx b/src/plugins/kibana_react/public/react_router_navigate/react_router_navigate.tsx
index 448f3ebb74299..2de3c569dd6cd 100644
--- a/src/plugins/kibana_react/public/react_router_navigate/react_router_navigate.tsx
+++ b/src/plugins/kibana_react/public/react_router_navigate/react_router_navigate.tsx
@@ -30,18 +30,17 @@ const isModifiedEvent = (event: any) =>
const isLeftClickEvent = (event: any) => event.button === 0;
-export const reactRouterNavigate = (history: ScopedHistory, to: string | LocationObject) => {
- const toAsObject = typeof to === 'string' ? { pathname: to } : to;
- return {
- href: history.createHref(toAsObject),
- onClick: reactRouterOnClickHandler(history, toAsObject),
- };
-};
+export const toLocationObject = (to: string | LocationObject) =>
+ typeof to === 'string' ? { pathname: to } : to;
+
+export const reactRouterNavigate = (history: ScopedHistory, to: string | LocationObject) => ({
+ href: history.createHref(toLocationObject(to)),
+ onClick: reactRouterOnClickHandler(history, toLocationObject(to)),
+});
-export const reactRouterOnClickHandler = (
- history: ScopedHistory,
- locationObject: LocationObject
-) => (event: any) => {
+export const reactRouterOnClickHandler = (history: ScopedHistory, to: string | LocationObject) => (
+ event: any
+) => {
if (event.defaultPrevented) {
return;
}
@@ -56,5 +55,5 @@ export const reactRouterOnClickHandler = (
// prevents page reload
event.preventDefault();
- history.push(locationObject);
+ history.push(toLocationObject(to));
};
diff --git a/x-pack/plugins/apm/public/application/index.tsx b/x-pack/plugins/apm/public/application/index.tsx
index 4bca2c9140f91..0361d4eea27f3 100644
--- a/x-pack/plugins/apm/public/application/index.tsx
+++ b/x-pack/plugins/apm/public/application/index.tsx
@@ -112,7 +112,6 @@ export const renderApp = (
{ element, history }: AppMountParameters,
config: ConfigSchema
) => {
- // resetHistory();
ReactDOM.render(
{
const { uiMetricService } = useServices();
useEffect(() => uiMetricService.trackMetric('loaded', UIM_APP_LOAD), [uiMetricService]);
- console.log('3 - app');
return (
diff --git a/x-pack/plugins/index_management/public/application/sections/home/home.tsx b/x-pack/plugins/index_management/public/application/sections/home/home.tsx
index 5d8e32031ea10..3310b4a4291d4 100644
--- a/x-pack/plugins/index_management/public/application/sections/home/home.tsx
+++ b/x-pack/plugins/index_management/public/application/sections/home/home.tsx
@@ -18,7 +18,6 @@ import {
EuiTabs,
EuiTitle,
} from '@elastic/eui';
-import { BASE_PATH } from '../../../../common/constants';
import { documentationService } from '../../services/documentation';
import { IndexList } from './index_list';
import { TemplateList } from './template_list';
@@ -53,7 +52,7 @@ export const IndexManagementHome: React.FunctionComponent {
- history.push(`${BASE_PATH}${newSection}`);
+ history.push(`/${newSection}`);
};
useEffect(() => {
@@ -107,9 +106,9 @@ export const IndexManagementHome: React.FunctionComponent
-
-
-
+
+
+
diff --git a/x-pack/plugins/index_management/public/application/sections/home/template_list/template_list.tsx b/x-pack/plugins/index_management/public/application/sections/home/template_list/template_list.tsx
index 1e84202639ee8..0d75defa674d0 100644
--- a/x-pack/plugins/index_management/public/application/sections/home/template_list/template_list.tsx
+++ b/x-pack/plugins/index_management/public/application/sections/home/template_list/template_list.tsx
@@ -7,6 +7,7 @@
import React, { Fragment, useState, useEffect, useMemo } from 'react';
import { RouteComponentProps } from 'react-router-dom';
import { FormattedMessage } from '@kbn/i18n/react';
+import { ScopedHistory } from 'kibana/public';
import {
EuiEmptyPrompt,
EuiSpacer,
@@ -144,6 +145,7 @@ export const TemplateList: React.FunctionComponent
);
diff --git a/x-pack/plugins/index_management/public/application/sections/home/template_list/template_table/template_table.tsx b/x-pack/plugins/index_management/public/application/sections/home/template_list/template_table/template_table.tsx
index ef583a5a1fdf2..a1f89f957656c 100644
--- a/x-pack/plugins/index_management/public/application/sections/home/template_list/template_table/template_table.tsx
+++ b/x-pack/plugins/index_management/public/application/sections/home/template_list/template_table/template_table.tsx
@@ -8,18 +8,21 @@ import React, { useState, Fragment } from 'react';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiInMemoryTable, EuiIcon, EuiButton, EuiLink, EuiBasicTableColumn } from '@elastic/eui';
+import { ScopedHistory } from 'kibana/public';
import { TemplateListItem, IndexTemplateFormatVersion } from '../../../../../../common';
-import { BASE_PATH, UIM_TEMPLATE_SHOW_DETAILS_CLICK } from '../../../../../../common/constants';
+import { UIM_TEMPLATE_SHOW_DETAILS_CLICK } from '../../../../../../common/constants';
import { TemplateDeleteModal } from '../../../../components';
import { useServices } from '../../../../app_context';
import { getTemplateDetailsLink } from '../../../../services/routing';
import { SendRequestResponse } from '../../../../../shared_imports';
+import { reactRouterNavigate } from '../../../../../../../../../src/plugins/kibana_react/public';
interface Props {
templates: TemplateListItem[];
reload: () => Promise;
editTemplate: (name: string, formatVersion: IndexTemplateFormatVersion) => void;
cloneTemplate: (name: string, formatVersion: IndexTemplateFormatVersion) => void;
+ history: ScopedHistory;
}
export const TemplateTable: React.FunctionComponent = ({
@@ -27,6 +30,7 @@ export const TemplateTable: React.FunctionComponent = ({
reload,
editTemplate,
cloneTemplate,
+ history,
}) => {
const { uiMetricService } = useServices();
const [selection, setSelection] = useState([]);
@@ -239,11 +243,11 @@ export const TemplateTable: React.FunctionComponent = ({
/>
,
{
if (filter) {
// React router tries to decode url params but it can't because the browser partially
// decodes them. So we have to encode both the URL and the filter to get it all to
// work correctly for filters with URL unsafe characters in them.
- return encodeURI(`#${BASE_PATH}indices/filter/${encodeURIComponent(filter)}`);
+ return encodeURI(`/indices/filter/${encodeURIComponent(filter)}`);
}
// If no filter, URI is already safe so no need to encode.
- return `#${BASE_PATH}indices`;
+ return '/indices';
};
export const getILMPolicyPath = (policyName: string) => {
- return encodeURI(
- `#/management/data/index_lifecycle_management/policies/edit/${encodeURIComponent(policyName)}`
- );
+ return encodeURI(`/policies/edit/${encodeURIComponent(policyName)}`);
};
diff --git a/x-pack/plugins/index_management/public/application/services/routing.ts b/x-pack/plugins/index_management/public/application/services/routing.ts
index a6d8f67751cd1..fe118b1181082 100644
--- a/x-pack/plugins/index_management/public/application/services/routing.ts
+++ b/x-pack/plugins/index_management/public/application/services/routing.ts
@@ -3,11 +3,10 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
-import { BASE_PATH } from '../../../common/constants';
import { IndexTemplateFormatVersion } from '../../../common';
export const getTemplateListLink = () => {
- return `${BASE_PATH}templates`;
+ return `/templates`;
};
// Need to add some additonal encoding/decoding logic to work with React Router
@@ -17,22 +16,20 @@ export const getTemplateDetailsLink = (
formatVersion: IndexTemplateFormatVersion,
withHash = false
) => {
- const baseUrl = `${BASE_PATH}templates/${encodeURIComponent(
- encodeURIComponent(name)
- )}?v=${formatVersion}`;
+ const baseUrl = `/templates/${encodeURIComponent(encodeURIComponent(name))}?v=${formatVersion}`;
const url = withHash ? `#${baseUrl}` : baseUrl;
return encodeURI(url);
};
export const getTemplateEditLink = (name: string, formatVersion: IndexTemplateFormatVersion) => {
return encodeURI(
- `${BASE_PATH}edit_template/${encodeURIComponent(encodeURIComponent(name))}?v=${formatVersion}`
+ `/edit_template/${encodeURIComponent(encodeURIComponent(name))}?v=${formatVersion}`
);
};
export const getTemplateCloneLink = (name: string, formatVersion: IndexTemplateFormatVersion) => {
return encodeURI(
- `${BASE_PATH}clone_template/${encodeURIComponent(encodeURIComponent(name))}?v=${formatVersion}`
+ `/clone_template/${encodeURIComponent(encodeURIComponent(name))}?v=${formatVersion}`
);
};
diff --git a/x-pack/plugins/ingest_pipelines/public/application/services/breadcrumbs.ts b/x-pack/plugins/ingest_pipelines/public/application/services/breadcrumbs.ts
index 9b974fdea283a..5fc8e13e3dcad 100644
--- a/x-pack/plugins/ingest_pipelines/public/application/services/breadcrumbs.ts
+++ b/x-pack/plugins/ingest_pipelines/public/application/services/breadcrumbs.ts
@@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { i18n } from '@kbn/i18n';
-import { BASE_PATH } from '../../../common/constants';
import { ManagementAppMountParams } from '../../../../../../src/plugins/management/public';
type SetBreadcrumbs = ManagementAppMountParams['setBreadcrumbs'];
diff --git a/x-pack/plugins/ml/public/application/app.tsx b/x-pack/plugins/ml/public/application/app.tsx
index e9796fcbb0fe4..b10b7395c6d7f 100644
--- a/x-pack/plugins/ml/public/application/app.tsx
+++ b/x-pack/plugins/ml/public/application/app.tsx
@@ -7,7 +7,7 @@
import React, { FC } from 'react';
import ReactDOM from 'react-dom';
-import { AppMountParameters, CoreStart } from 'kibana/public';
+import { AppMountParameters, CoreStart, ScopedHistory } from 'kibana/public';
import { Storage } from '../../../../../src/plugins/kibana_utils/public';
@@ -23,15 +23,17 @@ type MlDependencies = MlSetupDependencies & MlStartDependencies;
interface AppProps {
coreStart: CoreStart;
deps: MlDependencies;
+ history: ScopedHistory;
}
const localStorage = new Storage(window.localStorage);
-const App: FC = ({ coreStart, deps }) => {
+const App: FC = ({ coreStart, deps, history }) => {
const pageDeps = {
indexPatterns: deps.data.indexPatterns,
config: coreStart.uiSettings!,
setBreadcrumbs: coreStart.chrome!.setBreadcrumbs,
+ history,
};
const services = {
appName: 'ML',
@@ -80,7 +82,10 @@ export const renderApp = (
appMountParams.onAppLeave(actions => actions.default());
- ReactDOM.render(, appMountParams.element);
+ ReactDOM.render(
+ ,
+ appMountParams.element
+ );
return () => {
mlLicense.unsubscribe();
diff --git a/x-pack/plugins/ml/public/application/routing/router.tsx b/x-pack/plugins/ml/public/application/routing/router.tsx
index 540265c1a0a05..cb35afd40090d 100644
--- a/x-pack/plugins/ml/public/application/routing/router.tsx
+++ b/x-pack/plugins/ml/public/application/routing/router.tsx
@@ -8,7 +8,7 @@ import React, { FC } from 'react';
import { Router, Route, RouteProps } from 'react-router-dom';
import { Location } from 'history';
-import { IUiSettingsClient, ChromeStart } from 'kibana/public';
+import { IUiSettingsClient, ChromeStart, ScopedHistory } from 'kibana/public';
import { ChromeBreadcrumb } from 'kibana/public';
import { IndexPatternsContract } from 'src/plugins/data/public';
import { MlContext, MlContextValue } from '../contexts/ml';
@@ -35,6 +35,7 @@ interface PageDependencies {
setBreadcrumbs: ChromeStart['setBreadcrumbs'];
indexPatterns: IndexPatternsContract;
config: IUiSettingsClient;
+ history: ScopedHistory;
}
export const PageLoader: FC<{ context: MlContextValue }> = ({ context, children }) => {
diff --git a/x-pack/plugins/remote_clusters/public/application/app.js b/x-pack/plugins/remote_clusters/public/application/app.js
index 483b2f5b97e27..dca9568eaee6c 100644
--- a/x-pack/plugins/remote_clusters/public/application/app.js
+++ b/x-pack/plugins/remote_clusters/public/application/app.js
@@ -8,7 +8,7 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Switch, Route, Redirect, withRouter } from 'react-router-dom';
-import { CRUD_APP_BASE_PATH, UIM_APP_LOAD } from './constants';
+import { UIM_APP_LOAD } from './constants';
import { registerRouter, setUserHasLeftApp, trackUiMetric, METRIC_TYPE } from './services';
import { RemoteClusterList, RemoteClusterAdd, RemoteClusterEdit } from './sections';
@@ -47,11 +47,12 @@ class AppComponent extends Component {
return (
-
-
-
-
-
+
+
+
+
+
+
);
From a729bcef490385e816b9437fe0f9158aa4c991ca Mon Sep 17 00:00:00 2001
From: Matt Kime
Date: Tue, 19 May 2020 23:21:02 -0500
Subject: [PATCH 10/93] remove console.log
---
x-pack/plugins/index_management/public/application/index.tsx | 2 +-
.../public/application/mount_management_section.ts | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/x-pack/plugins/index_management/public/application/index.tsx b/x-pack/plugins/index_management/public/application/index.tsx
index a9343552759b7..8da556cc81fcc 100644
--- a/x-pack/plugins/index_management/public/application/index.tsx
+++ b/x-pack/plugins/index_management/public/application/index.tsx
@@ -25,7 +25,7 @@ export const renderApp = (
const { i18n } = core;
const { Context: I18nContext } = i18n;
const { services, history } = dependencies;
- console.log('2 before render', history);
+
render(
diff --git a/x-pack/plugins/index_management/public/application/mount_management_section.ts b/x-pack/plugins/index_management/public/application/mount_management_section.ts
index a432ccc190400..5e8282fcdcdf8 100644
--- a/x-pack/plugins/index_management/public/application/mount_management_section.ts
+++ b/x-pack/plugins/index_management/public/application/mount_management_section.ts
@@ -36,7 +36,7 @@ export async function mountManagementSection(
breadcrumbService.setup(setBreadcrumbs);
documentationService.setup(docLinks);
- console.log('1 before render app', history);
+
const appDependencies: AppDependencies = {
core: {
fatalErrors,
From 0bacead3b33e721da770ccf1e324ba344fa34ffb Mon Sep 17 00:00:00 2001
From: Alexey Antonov
Date: Wed, 20 May 2020 12:04:07 +0300
Subject: [PATCH 11/93] use reactRouterNavigate for management_sidebar
---
.../components/management_app/management_app.tsx | 15 ++-------------
.../management_app_wrapper.tsx | 4 ++--
.../management_sidebar_nav.tsx | 9 ++++++---
3 files changed, 10 insertions(+), 18 deletions(-)
diff --git a/src/plugins/management/public/components/management_app/management_app.tsx b/src/plugins/management/public/components/management_app/management_app.tsx
index 8483b95486ea3..dd5e7c45ec1c3 100644
--- a/src/plugins/management/public/components/management_app/management_app.tsx
+++ b/src/plugins/management/public/components/management_app/management_app.tsx
@@ -46,16 +46,9 @@ export const ManagementApp = ({ context, dependencies, history }: ManagementAppP
const [selectedId, setSelectedId] = useState('');
const [sections, setSections] = useState();
- const onManagementSectionSelected = useCallback(
- (id: string, path: string) => {
- history.push(path);
- window.scrollTo(0, 0);
- },
- [history]
- );
-
const onAppMounted = useCallback((id: string) => {
setSelectedId(id);
+ window.scrollTo(0, 0);
}, []);
const setBreadcrumbs = useCallback(
@@ -77,11 +70,7 @@ export const ManagementApp = ({ context, dependencies, history }: ManagementAppP
-
+
{sections.map(section =>
diff --git a/src/plugins/management/public/components/management_app_wrapper/management_app_wrapper.tsx b/src/plugins/management/public/components/management_app_wrapper/management_app_wrapper.tsx
index 4341197173a82..63ef777dfe41c 100644
--- a/src/plugins/management/public/components/management_app_wrapper/management_app_wrapper.tsx
+++ b/src/plugins/management/public/components/management_app_wrapper/management_app_wrapper.tsx
@@ -40,7 +40,7 @@ export const ManagementAppWrapper = ({
const { mount, basePath } = app;
const unmount = useRef();
- mountElementRef.current = createRef();
+ mountElementRef.current = createRef();
useEffect(() => {
if (mount && basePath) {
@@ -68,5 +68,5 @@ export const ManagementAppWrapper = ({
}
}, [app.id, basePath, history, mount, onAppMounted, setBreadcrumbs]);
- return ;
+ return ;
};
diff --git a/src/plugins/management/public/components/management_sidebar_nav/management_sidebar_nav.tsx b/src/plugins/management/public/components/management_sidebar_nav/management_sidebar_nav.tsx
index 0fa338710ae5a..4e5addf0e7137 100644
--- a/src/plugins/management/public/components/management_sidebar_nav/management_sidebar_nav.tsx
+++ b/src/plugins/management/public/components/management_sidebar_nav/management_sidebar_nav.tsx
@@ -20,14 +20,17 @@
import { EuiIcon, EuiSideNav, EuiSideNavItemType, EuiScreenReaderOnly } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React, { useState } from 'react';
+import { AppMountParameters } from 'kibana/public';
import { ManagementApp, ManagementSection } from '../../utils';
import './_index.scss';
+
import { ManagementItem } from '../../utils/management_item';
+import { reactRouterNavigate } from '../../../../kibana_react/public';
interface ManagementSidebarNavProps {
sections: ManagementSection[];
- onManagementSectionSelected: (id: string, path: string) => void;
+ history: AppMountParameters['history'];
selectedId: string;
}
@@ -43,7 +46,7 @@ const navMenuLabel = i18n.translate('management.nav.menu', {
export const ManagementSidebarNav = ({
selectedId,
sections,
- onManagementSectionSelected,
+ history,
}: ManagementSidebarNavProps) => {
const HEADER_ID = 'stack-management-nav-header';
const [isSideNavOpenOnMobile, setIsSideNavOpenOnMobile] = useState(false);
@@ -72,7 +75,7 @@ export const ManagementSidebarNav = ({
.filter(app => app.enabled)
.map(app => ({
...createNavItem(app, {
- onClick: () => onManagementSectionSelected(app.id, app.basePath),
+ ...reactRouterNavigate(history, app.basePath),
}),
}));
};
From e570f0f70c5f047138ca94459e7e141e9e375a93 Mon Sep 17 00:00:00 2001
From: Alexey Antonov
Date: Wed, 20 May 2020 12:14:41 +0300
Subject: [PATCH 12/93] Breadcrumbs will need to make use of the
reactRouterNavigate function
---
.../management_app/management_app.tsx | 18 +++++++++++++++---
.../management_app_wrapper.tsx | 6 +++---
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/src/plugins/management/public/components/management_app/management_app.tsx b/src/plugins/management/public/components/management_app/management_app.tsx
index dd5e7c45ec1c3..7f3e61aa9b2f0 100644
--- a/src/plugins/management/public/components/management_app/management_app.tsx
+++ b/src/plugins/management/public/components/management_app/management_app.tsx
@@ -18,7 +18,12 @@
*/
import React, { useState, useEffect, useCallback } from 'react';
import { Route, Router, Switch } from 'react-router-dom';
-import { AppMountContext, AppMountParameters, ChromeBreadcrumb } from 'kibana/public';
+import {
+ AppMountContext,
+ AppMountParameters,
+ ChromeBreadcrumb,
+ ScopedHistory,
+} from 'kibana/public';
import { I18nProvider } from '@kbn/i18n/react';
import { EuiPage, EuiPageBody } from '@elastic/eui';
import { ManagementStart } from '../../types';
@@ -28,6 +33,8 @@ import { ManagementLandingPage } from '../langing';
import { ManagementSidebarNav } from '../management_sidebar_nav';
import { ManagementAppWrapper } from '../management_app_wrapper';
+import { reactRouterNavigate } from '../../../../kibana_react/public';
+
import './_management_app.scss';
interface ManagementAppProps {
@@ -52,8 +59,13 @@ export const ManagementApp = ({ context, dependencies, history }: ManagementAppP
}, []);
const setBreadcrumbs = useCallback(
- (crumbs: ChromeBreadcrumb[]) => {
- context.core.chrome.setBreadcrumbs(crumbs);
+ (crumbs: ChromeBreadcrumb[] = [], appHistory: ScopedHistory) => {
+ context.core.chrome.setBreadcrumbs(
+ crumbs.map(item => ({
+ ...item,
+ ...(item.href ? reactRouterNavigate(appHistory, item.href) : {}),
+ }))
+ );
},
[context.core.chrome]
);
diff --git a/src/plugins/management/public/components/management_app_wrapper/management_app_wrapper.tsx b/src/plugins/management/public/components/management_app_wrapper/management_app_wrapper.tsx
index 63ef777dfe41c..1e15a0eabfbf3 100644
--- a/src/plugins/management/public/components/management_app_wrapper/management_app_wrapper.tsx
+++ b/src/plugins/management/public/components/management_app_wrapper/management_app_wrapper.tsx
@@ -19,13 +19,13 @@
import React, { useEffect, createRef, useRef, RefObject } from 'react';
-import { ChromeBreadcrumb, AppMountParameters } from 'kibana/public';
+import { ChromeBreadcrumb, AppMountParameters, ScopedHistory } from 'kibana/public';
import { ManagementApp } from '../../utils';
import { Unmount } from '../../types';
interface ManagementSectionWrapperProps {
app: ManagementApp;
- setBreadcrumbs: (crumbs: ChromeBreadcrumb[]) => void;
+ setBreadcrumbs: (crumbs: ChromeBreadcrumb[], history: ScopedHistory) => void;
onAppMounted: (id: string) => void;
history: AppMountParameters['history'];
}
@@ -46,7 +46,7 @@ export const ManagementAppWrapper = ({
if (mount && basePath) {
const mountResult = mount({
basePath,
- setBreadcrumbs,
+ setBreadcrumbs: (crumbs: ChromeBreadcrumb[]) => setBreadcrumbs(crumbs, history),
element: mountElementRef.current!.current,
history,
});
From b95a10ae3b8fa8ac1fbcd3be05c25d60d1dd0ea7 Mon Sep 17 00:00:00 2001
From: Alexey Antonov
Date: Wed, 20 May 2020 13:47:31 +0300
Subject: [PATCH 13/93] [triggersActions] app. Hash Router -> Router
---
.../app/ServiceDetails/AlertIntegrations/index.tsx | 2 +-
.../metric_threshold/components/alert_dropdown.tsx | 2 +-
.../alerting/inventory/alert_dropdown.tsx | 2 +-
.../components/alerting/logs/alert_dropdown.tsx | 4 ++--
.../triggers_actions_ui/public/application/app.tsx | 14 ++++++++------
.../public/application/constants/index.ts | 10 ++++------
.../public/application/home.tsx | 4 ++--
.../public/application/lib/breadcrumb.test.ts | 6 +++---
.../public/application/lib/breadcrumb.ts | 6 +++---
.../connector_add_flyout.test.tsx | 2 +-
.../action_connector_form/connector_add_flyout.tsx | 2 +-
.../components/actions_connectors_list.test.tsx | 9 ++++++++-
.../alerts_list/components/alerts_list.test.tsx | 8 +++++++-
.../plugins/triggers_actions_ui/public/plugin.ts | 1 +
.../overview/alerts/toggle_alert_flyout_button.tsx | 2 +-
x-pack/test/functional_with_es_ssl/config.ts | 3 +--
16 files changed, 45 insertions(+), 32 deletions(-)
diff --git a/x-pack/plugins/apm/public/components/app/ServiceDetails/AlertIntegrations/index.tsx b/x-pack/plugins/apm/public/components/app/ServiceDetails/AlertIntegrations/index.tsx
index 9001eb6992a96..c1de9c2af8f8c 100644
--- a/x-pack/plugins/apm/public/components/app/ServiceDetails/AlertIntegrations/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/ServiceDetails/AlertIntegrations/index.tsx
@@ -82,7 +82,7 @@ export function AlertIntegrations(props: Props) {
}
),
href: plugin.core.http.basePath.prepend(
- '/app/kibana#/management/insightsAndAlerting/triggersActions/alerts'
+ '/app/management/insightsAndAlerting/triggersActions/alerts'
),
icon: 'tableOfContents'
}
diff --git a/x-pack/plugins/infra/public/alerting/metric_threshold/components/alert_dropdown.tsx b/x-pack/plugins/infra/public/alerting/metric_threshold/components/alert_dropdown.tsx
index bafb38459b17b..52033a00327c0 100644
--- a/x-pack/plugins/infra/public/alerting/metric_threshold/components/alert_dropdown.tsx
+++ b/x-pack/plugins/infra/public/alerting/metric_threshold/components/alert_dropdown.tsx
@@ -35,7 +35,7 @@ export const MetricsAlertDropdown = () => {
icon="tableOfContents"
key="manageLink"
href={kibana.services?.application?.getUrlForApp(
- 'kibana#/management/insightsAndAlerting/triggersActions/alerts'
+ 'management/insightsAndAlerting/triggersActions/alerts'
)}
>
diff --git a/x-pack/plugins/infra/public/components/alerting/inventory/alert_dropdown.tsx b/x-pack/plugins/infra/public/components/alerting/inventory/alert_dropdown.tsx
index a3cebcf33f386..c48b5b9a2cc58 100644
--- a/x-pack/plugins/infra/public/components/alerting/inventory/alert_dropdown.tsx
+++ b/x-pack/plugins/infra/public/components/alerting/inventory/alert_dropdown.tsx
@@ -35,7 +35,7 @@ export const InventoryAlertDropdown = () => {
icon="tableOfContents"
key="manageLink"
href={kibana.services?.application?.getUrlForApp(
- 'kibana#/management/insightsAndAlerting/triggersActions/alerts'
+ 'management/insightsAndAlerting/triggersActions/alerts'
)}
>
diff --git a/x-pack/plugins/infra/public/components/alerting/logs/alert_dropdown.tsx b/x-pack/plugins/infra/public/components/alerting/logs/alert_dropdown.tsx
index d808b4f3b64aa..b8eb73b99f45e 100644
--- a/x-pack/plugins/infra/public/components/alerting/logs/alert_dropdown.tsx
+++ b/x-pack/plugins/infra/public/components/alerting/logs/alert_dropdown.tsx
@@ -15,8 +15,8 @@ export const AlertDropdown = () => {
const [flyoutVisible, setFlyoutVisible] = useState(false);
const manageAlertsLinkProps = useLinkProps(
{
- app: 'kibana',
- hash: 'management/insightsAndAlerting/triggersActions/alerts',
+ app: 'management',
+ pathname: '/insightsAndAlerting/triggersActions/alerts',
},
{
hrefOnly: true,
diff --git a/x-pack/plugins/triggers_actions_ui/public/application/app.tsx b/x-pack/plugins/triggers_actions_ui/public/application/app.tsx
index ebd9294ce1e6d..d0d3b65b17a9d 100644
--- a/x-pack/plugins/triggers_actions_ui/public/application/app.tsx
+++ b/x-pack/plugins/triggers_actions_ui/public/application/app.tsx
@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import React, { lazy } from 'react';
-import { Switch, Route, Redirect, HashRouter } from 'react-router-dom';
+import { Switch, Route, Redirect, Router } from 'react-router-dom';
import {
ChromeStart,
DocLinksStart,
@@ -14,8 +14,9 @@ import {
ApplicationStart,
ChromeBreadcrumb,
CoreStart,
+ ScopedHistory,
} from 'kibana/public';
-import { BASE_PATH, Section, routeToAlertDetails } from './constants';
+import { Section, routeToAlertDetails } from './constants';
import { AppContextProvider, useAppDependencies } from './app_context';
import { hasShowAlertsCapability } from './lib/capabilities';
import { ActionTypeModel, AlertTypeModel } from '../types';
@@ -44,6 +45,7 @@ export interface AppDeps {
capabilities: ApplicationStart['capabilities'];
actionTypeRegistry: TypeRegistry;
alertTypeRegistry: TypeRegistry;
+ history: ScopedHistory;
}
export const App = (appDeps: AppDeps) => {
@@ -52,11 +54,11 @@ export const App = (appDeps: AppDeps) => {
const sectionsRegex = sections.join('|');
return (
-
+
-
+
);
};
@@ -67,7 +69,7 @@ export const AppWithoutRouter = ({ sectionsRegex }: { sectionsRegex: string }) =
return (
{canShowAlerts && (
@@ -76,7 +78,7 @@ export const AppWithoutRouter = ({ sectionsRegex }: { sectionsRegex: string }) =
component={suspendedComponentWithProps(AlertDetailsRoute, 'xl')}
/>
)}
-
+
);
};
diff --git a/x-pack/plugins/triggers_actions_ui/public/application/constants/index.ts b/x-pack/plugins/triggers_actions_ui/public/application/constants/index.ts
index 265cfddab4c06..7623f010c21fb 100644
--- a/x-pack/plugins/triggers_actions_ui/public/application/constants/index.ts
+++ b/x-pack/plugins/triggers_actions_ui/public/application/constants/index.ts
@@ -7,14 +7,12 @@
export { BASE_ALERT_API_PATH } from '../../../../alerting/common';
export { BASE_ACTION_API_PATH } from '../../../../actions/common';
-export const BASE_PATH = '/management/insightsAndAlerting/triggersActions';
-
export type Section = 'connectors' | 'alerts';
-export const routeToHome = `${BASE_PATH}`;
-export const routeToConnectors = `${BASE_PATH}/connectors`;
-export const routeToAlerts = `${BASE_PATH}/alerts`;
-export const routeToAlertDetails = `${BASE_PATH}/alert/:alertId`;
+export const routeToHome = `/`;
+export const routeToConnectors = `/connectors`;
+export const routeToAlerts = `/alerts`;
+export const routeToAlertDetails = `/alert/:alertId`;
export { TIME_UNITS } from './time_units';
export enum SORT_ORDERS {
diff --git a/x-pack/plugins/triggers_actions_ui/public/application/home.tsx b/x-pack/plugins/triggers_actions_ui/public/application/home.tsx
index b5f3b63c58a93..00571dd9348f5 100644
--- a/x-pack/plugins/triggers_actions_ui/public/application/home.tsx
+++ b/x-pack/plugins/triggers_actions_ui/public/application/home.tsx
@@ -21,7 +21,7 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
-import { BASE_PATH, Section, routeToConnectors, routeToAlerts } from './constants';
+import { Section, routeToConnectors, routeToAlerts } from './constants';
import { getCurrentBreadcrumb } from './lib/breadcrumb';
import { getCurrentDocTitle } from './lib/doc_title';
import { useAppDependencies } from './app_context';
@@ -76,7 +76,7 @@ export const TriggersActionsUIHome: React.FunctionComponent {
- history.push(`${BASE_PATH}/${newSection}`);
+ history.push(`/${newSection}`);
};
// Set breadcrumb and page title
diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/breadcrumb.test.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/breadcrumb.test.ts
index b75e014640d72..8ba909beff2a8 100644
--- a/x-pack/plugins/triggers_actions_ui/public/application/lib/breadcrumb.test.ts
+++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/breadcrumb.test.ts
@@ -13,19 +13,19 @@ describe('getCurrentBreadcrumb', () => {
text: i18n.translate('xpack.triggersActionsUI.connectors.breadcrumbTitle', {
defaultMessage: 'Connectors',
}),
- href: `#${routeToConnectors}`,
+ href: `${routeToConnectors}`,
});
expect(getCurrentBreadcrumb('alerts')).toMatchObject({
text: i18n.translate('xpack.triggersActionsUI.alerts.breadcrumbTitle', {
defaultMessage: 'Alerts',
}),
- href: `#${routeToAlerts}`,
+ href: `${routeToAlerts}`,
});
expect(getCurrentBreadcrumb('home')).toMatchObject({
text: i18n.translate('xpack.triggersActionsUI.home.breadcrumbTitle', {
defaultMessage: 'Alerts and Actions',
}),
- href: `#${routeToHome}`,
+ href: `${routeToHome}`,
});
});
});
diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/breadcrumb.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/breadcrumb.ts
index f833ae9eb39ac..3735942ff97af 100644
--- a/x-pack/plugins/triggers_actions_ui/public/application/lib/breadcrumb.ts
+++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/breadcrumb.ts
@@ -15,21 +15,21 @@ export const getCurrentBreadcrumb = (type: string): { text: string; href: string
text: i18n.translate('xpack.triggersActionsUI.connectors.breadcrumbTitle', {
defaultMessage: 'Connectors',
}),
- href: `#${routeToConnectors}`,
+ href: `${routeToConnectors}`,
};
case 'alerts':
return {
text: i18n.translate('xpack.triggersActionsUI.alerts.breadcrumbTitle', {
defaultMessage: 'Alerts',
}),
- href: `#${routeToAlerts}`,
+ href: `${routeToAlerts}`,
};
default:
return {
text: i18n.translate('xpack.triggersActionsUI.home.breadcrumbTitle', {
defaultMessage: 'Alerts and Actions',
}),
- href: `#${routeToHome}`,
+ href: `${routeToHome}`,
};
}
};
diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_flyout.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_flyout.test.tsx
index 1da9abea40dba..a96abfe312663 100644
--- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_flyout.test.tsx
+++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_flyout.test.tsx
@@ -127,7 +127,7 @@ describe('connector_add_flyout', () => {
const manageLink = callout.find('EuiButton');
expect(manageLink).toHaveLength(1);
expect(manageLink.getElements()[0].props.href).toMatchInlineSnapshot(
- `"/app/kibana#/management/stack/license_management/"`
+ `"/app//management/stack/license_management/"`
);
const subscriptionLink = callout.find('EuiButtonEmpty');
diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_flyout.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_flyout.tsx
index adee2e09a56fd..19de36b4f09ac 100644
--- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_flyout.tsx
+++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_flyout.tsx
@@ -293,7 +293,7 @@ const UpgradeYourLicenseCallOut = ({ http }: { http: HttpSetup }) => (
diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_list.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_list.test.tsx
index 12b6f99319596..b9ec083ed68e8 100644
--- a/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_list.test.tsx
+++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_list.test.tsx
@@ -4,9 +4,11 @@
* you may not use this file except in compliance with the Elastic License.
*/
import * as React from 'react';
+import { ScopedHistory } from 'kibana/public';
+
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { ActionsConnectorsList } from './actions_connectors_list';
-import { coreMock } from '../../../../../../../../src/core/public/mocks';
+import { coreMock, scopedHistoryMock } from '../../../../../../../../src/core/public/mocks';
import { ReactWrapper } from 'enzyme';
import { act } from 'react-dom/test-utils';
import { actionTypeRegistryMock } from '../../../action_type_registry.mock';
@@ -66,6 +68,7 @@ describe('actions_connectors_list component empty', () => {
'actions:delete': true,
},
},
+ history: (scopedHistoryMock.create() as unknown) as ScopedHistory,
setBreadcrumbs: jest.fn(),
actionTypeRegistry: actionTypeRegistry as any,
alertTypeRegistry: {} as any,
@@ -171,6 +174,7 @@ describe('actions_connectors_list component with items', () => {
'actions:delete': true,
},
},
+ history: (scopedHistoryMock.create() as unknown) as ScopedHistory,
setBreadcrumbs: jest.fn(),
actionTypeRegistry: {
get() {
@@ -256,6 +260,7 @@ describe('actions_connectors_list component empty with show only capability', ()
'actions:delete': false,
},
},
+ history: (scopedHistoryMock.create() as unknown) as ScopedHistory,
setBreadcrumbs: jest.fn(),
actionTypeRegistry: {
get() {
@@ -341,6 +346,7 @@ describe('actions_connectors_list with show only capability', () => {
'actions:delete': false,
},
},
+ history: (scopedHistoryMock.create() as unknown) as ScopedHistory,
setBreadcrumbs: jest.fn(),
actionTypeRegistry: {
get() {
@@ -438,6 +444,7 @@ describe('actions_connectors_list component with disabled items', () => {
'actions:delete': true,
},
},
+ history: (scopedHistoryMock.create() as unknown) as ScopedHistory,
setBreadcrumbs: jest.fn(),
actionTypeRegistry: {
get() {
diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.test.tsx
index cf1524094b41d..a28f638914cf2 100644
--- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.test.tsx
+++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.test.tsx
@@ -4,8 +4,10 @@
* you may not use this file except in compliance with the Elastic License.
*/
import * as React from 'react';
+import { ScopedHistory } from 'kibana/public';
+
import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers';
-import { coreMock } from '../../../../../../../../src/core/public/mocks';
+import { coreMock, scopedHistoryMock } from '../../../../../../../../src/core/public/mocks';
import { ReactWrapper } from 'enzyme';
import { act } from 'react-dom/test-utils';
import { actionTypeRegistryMock } from '../../../action_type_registry.mock';
@@ -101,6 +103,7 @@ describe('alerts_list component empty', () => {
'alerting:delete': true,
},
},
+ history: (scopedHistoryMock.create() as unknown) as ScopedHistory,
setBreadcrumbs: jest.fn(),
actionTypeRegistry: actionTypeRegistry as any,
alertTypeRegistry: alertTypeRegistry as any,
@@ -219,6 +222,7 @@ describe('alerts_list component with items', () => {
'alerting:delete': true,
},
},
+ history: (scopedHistoryMock.create() as unknown) as ScopedHistory,
setBreadcrumbs: jest.fn(),
actionTypeRegistry: actionTypeRegistry as any,
alertTypeRegistry: alertTypeRegistry as any,
@@ -300,6 +304,7 @@ describe('alerts_list component empty with show only capability', () => {
'alerting:delete': false,
},
},
+ history: (scopedHistoryMock.create() as unknown) as ScopedHistory,
setBreadcrumbs: jest.fn(),
actionTypeRegistry: {
get() {
@@ -414,6 +419,7 @@ describe('alerts_list with show only capability', () => {
'alerting:delete': false,
},
},
+ history: (scopedHistoryMock.create() as unknown) as ScopedHistory,
setBreadcrumbs: jest.fn(),
actionTypeRegistry: actionTypeRegistry as any,
alertTypeRegistry: alertTypeRegistry as any,
diff --git a/x-pack/plugins/triggers_actions_ui/public/plugin.ts b/x-pack/plugins/triggers_actions_ui/public/plugin.ts
index 016b564c47d00..f6505573dfb8f 100644
--- a/x-pack/plugins/triggers_actions_ui/public/plugin.ts
+++ b/x-pack/plugins/triggers_actions_ui/public/plugin.ts
@@ -95,6 +95,7 @@ export class Plugin
capabilities: core.application.capabilities,
navigateToApp: core.application.navigateToApp,
setBreadcrumbs: params.setBreadcrumbs,
+ history: params.history,
actionTypeRegistry: this.actionTypeRegistry,
alertTypeRegistry: this.alertTypeRegistry,
});
diff --git a/x-pack/plugins/uptime/public/components/overview/alerts/toggle_alert_flyout_button.tsx b/x-pack/plugins/uptime/public/components/overview/alerts/toggle_alert_flyout_button.tsx
index 0cdb3c0feb71f..c683d6afd278e 100644
--- a/x-pack/plugins/uptime/public/components/overview/alerts/toggle_alert_flyout_button.tsx
+++ b/x-pack/plugins/uptime/public/components/overview/alerts/toggle_alert_flyout_button.tsx
@@ -61,7 +61,7 @@ export const ToggleAlertFlyoutButtonComponent: React.FC = ({
Date: Wed, 20 May 2020 14:49:40 +0300
Subject: [PATCH 14/93] Replace /app/kibana#/management urls to /app/management
---
.../ui_settings/saved_objects/ui_settings.ts | 2 +-
.../server/lib/__tests__/relationships.js | 6 ++--
.../ensure_default_index_pattern.tsx | 2 +-
.../public/search/long_query_notification.tsx | 2 +-
.../server/saved_objects/index_patterns.ts | 2 +-
.../index_pattern_management/public/plugin.ts | 2 +-
.../url/kbn_url_storage.test.ts | 28 +++++++++----------
.../components/relationships.test.tsx | 2 +-
.../saved_objects_management/public/plugin.ts | 2 +-
src/plugins/telemetry/common/constants.ts | 2 +-
.../apis/saved_objects_management/find.ts | 2 +-
.../saved_objects_management/relationships.ts | 4 +--
.../ServiceIntegrations/index.tsx | 2 +-
.../InvalidLicenseNotification.tsx | 2 +-
.../plugins/licensing/public/plugin.test.ts | 2 +-
x-pack/plugins/licensing/public/plugin.ts | 2 +-
x-pack/plugins/logstash/public/plugin.ts | 2 +-
.../components/no_index_pattern_callout.js | 2 +-
.../datavisualizer_selector.tsx | 5 +---
.../results_links/results_links.tsx | 4 +--
.../create_watch_service.js | 2 +-
.../overview/components/sidebar.tsx | 2 +-
.../components/cluster/listing/listing.js | 2 +-
.../public/components/license/index.js | 2 +-
x-pack/plugins/reporting/constants.ts | 2 +-
.../public/components/report_listing.tsx | 2 +-
x-pack/plugins/reporting/public/plugin.tsx | 2 +-
x-pack/plugins/security/public/plugin.tsx | 2 +-
.../ml_popover/upgrade_contents.tsx | 2 +-
.../components/news_feed/no_news/index.tsx | 2 +-
.../public/create_feature_catalogue_entry.ts | 2 +-
.../transform/public/register_feature.ts | 2 +-
.../components/monitor/ml/license_info.tsx | 2 +-
x-pack/plugins/watcher/public/plugin.ts | 2 +-
34 files changed, 51 insertions(+), 54 deletions(-)
diff --git a/src/core/server/ui_settings/saved_objects/ui_settings.ts b/src/core/server/ui_settings/saved_objects/ui_settings.ts
index 1bea65ddee924..0eab40a7b3a5d 100644
--- a/src/core/server/ui_settings/saved_objects/ui_settings.ts
+++ b/src/core/server/ui_settings/saved_objects/ui_settings.ts
@@ -38,7 +38,7 @@ export const uiSettingsType: SavedObjectsType = {
importableAndExportable: true,
getInAppUrl() {
return {
- path: `/app/kibana#/management/kibana/settings`,
+ path: `/app/management/kibana/settings`,
uiCapabilitiesPath: 'advancedSettings.show',
};
},
diff --git a/src/legacy/core_plugins/kibana/server/lib/__tests__/relationships.js b/src/legacy/core_plugins/kibana/server/lib/__tests__/relationships.js
index 64676b1bce75c..4df0e7a140205 100644
--- a/src/legacy/core_plugins/kibana/server/lib/__tests__/relationships.js
+++ b/src/legacy/core_plugins/kibana/server/lib/__tests__/relationships.js
@@ -69,7 +69,7 @@ const savedObjectsManagement = getManagementaMock({
},
getInAppUrl(obj) {
return {
- path: `/app/kibana#/management/kibana/indexPatterns/patterns/${encodeURIComponent(obj.id)}`,
+ path: `/app/management/kibana/indexPatterns/patterns/${encodeURIComponent(obj.id)}`,
uiCapabilitiesPath: 'management.kibana.index_patterns',
};
},
@@ -325,7 +325,7 @@ describe('findRelationships', () => {
title: 'My Index Pattern',
editUrl: '/management/kibana/indexPatterns/patterns/1',
inAppUrl: {
- path: '/app/kibana#/management/kibana/indexPatterns/patterns/1',
+ path: '/app/management/kibana/indexPatterns/patterns/1',
uiCapabilitiesPath: 'management.kibana.index_patterns',
},
},
@@ -439,7 +439,7 @@ describe('findRelationships', () => {
title: 'My Index Pattern',
editUrl: '/management/kibana/indexPatterns/patterns/1',
inAppUrl: {
- path: '/app/kibana#/management/kibana/indexPatterns/patterns/1',
+ path: '/app/management/kibana/indexPatterns/patterns/1',
uiCapabilitiesPath: 'management.kibana.index_patterns',
},
},
diff --git a/src/plugins/data/public/index_patterns/index_patterns/ensure_default_index_pattern.tsx b/src/plugins/data/public/index_patterns/index_patterns/ensure_default_index_pattern.tsx
index 9115e523f5302..2ee6965bb4125 100644
--- a/src/plugins/data/public/index_patterns/index_patterns/ensure_default_index_pattern.tsx
+++ b/src/plugins/data/public/index_patterns/index_patterns/ensure_default_index_pattern.tsx
@@ -92,7 +92,7 @@ export const createEnsureDefaultIndexPattern = (core: CoreStart) => {
core.application.navigateToApp('home');
} else {
window.location.href = core.http.basePath.prepend(
- `/app/kibana#/management/kibana/indexPatterns?bannerMessage=${bannerMessage}`
+ `/app/management/kibana/indexPatterns?bannerMessage=${bannerMessage}`
);
}
diff --git a/src/plugins/data/public/search/long_query_notification.tsx b/src/plugins/data/public/search/long_query_notification.tsx
index 0bdf8ab7c66f8..1db298618fae8 100644
--- a/src/plugins/data/public/search/long_query_notification.tsx
+++ b/src/plugins/data/public/search/long_query_notification.tsx
@@ -44,7 +44,7 @@ export function LongQueryNotification(props: Props) {
{
- await props.application.navigateToApp('kibana#/management/stack/license_management');
+ await props.application.navigateToApp('management/stack/license_management');
}}
>
'/create');
diff --git a/src/plugins/kibana_utils/public/state_management/url/kbn_url_storage.test.ts b/src/plugins/kibana_utils/public/state_management/url/kbn_url_storage.test.ts
index 8db1d60f09d72..b8c06c8479926 100644
--- a/src/plugins/kibana_utils/public/state_management/url/kbn_url_storage.test.ts
+++ b/src/plugins/kibana_utils/public/state_management/url/kbn_url_storage.test.ts
@@ -35,7 +35,7 @@ import { ScopedHistory } from '../../../../../core/public';
describe('kbn_url_storage', () => {
describe('getStateFromUrl & setStateToUrl', () => {
- const url = 'http://localhost:5601/oxf/app/kibana#/management/kibana/indexPatterns/patterns/id';
+ const url = 'http://localhost:5601/oxf/app/management/kibana/indexPatterns/patterns/id';
const state1 = {
testStr: '123',
testNumber: 0,
@@ -50,14 +50,14 @@ describe('kbn_url_storage', () => {
it('should set expanded state to url', () => {
let newUrl = setStateToKbnUrl('_s', state1, { useHash: false }, url);
expect(newUrl).toMatchInlineSnapshot(
- `"http://localhost:5601/oxf/app/kibana#/management/kibana/indexPatterns/patterns/id?_s=(testArray:!(1,2,()),testNull:!n,testNumber:0,testObj:(test:'123'),testStr:'123')"`
+ `"http://localhost:5601/oxf/app/management/kibana/indexPatterns/patterns/id?_s=(testArray:!(1,2,()),testNull:!n,testNumber:0,testObj:(test:'123'),testStr:'123')"`
);
const retrievedState1 = getStateFromKbnUrl('_s', newUrl);
expect(retrievedState1).toEqual(state1);
newUrl = setStateToKbnUrl('_s', state2, { useHash: false }, newUrl);
expect(newUrl).toMatchInlineSnapshot(
- `"http://localhost:5601/oxf/app/kibana#/management/kibana/indexPatterns/patterns/id?_s=(test:'123')"`
+ `"http://localhost:5601/oxf/app/management/kibana/indexPatterns/patterns/id?_s=(test:'123')"`
);
const retrievedState2 = getStateFromKbnUrl('_s', newUrl);
expect(retrievedState2).toEqual(state2);
@@ -66,14 +66,14 @@ describe('kbn_url_storage', () => {
it('should set hashed state to url', () => {
let newUrl = setStateToKbnUrl('_s', state1, { useHash: true }, url);
expect(newUrl).toMatchInlineSnapshot(
- `"http://localhost:5601/oxf/app/kibana#/management/kibana/indexPatterns/patterns/id?_s=h@a897fac"`
+ `"http://localhost:5601/oxf/app/management/kibana/indexPatterns/patterns/id?_s=h@a897fac"`
);
const retrievedState1 = getStateFromKbnUrl('_s', newUrl);
expect(retrievedState1).toEqual(state1);
newUrl = setStateToKbnUrl('_s', state2, { useHash: true }, newUrl);
expect(newUrl).toMatchInlineSnapshot(
- `"http://localhost:5601/oxf/app/kibana#/management/kibana/indexPatterns/patterns/id?_s=h@40f94d5"`
+ `"http://localhost:5601/oxf/app/management/kibana/indexPatterns/patterns/id?_s=h@40f94d5"`
);
const retrievedState2 = getStateFromKbnUrl('_s', newUrl);
expect(retrievedState2).toEqual(state2);
@@ -244,20 +244,20 @@ describe('kbn_url_storage', () => {
it('should extract path relative to browser history without basename', () => {
const history = createBrowserHistory();
const url =
- "http://localhost:5601/oxf/app/kibana#/management/kibana/indexPatterns/patterns/id?_a=(tab:indexedFields)&_b=(f:test,i:'',l:'')";
+ "http://localhost:5601/oxf/app/management/kibana/indexPatterns/patterns/id?_a=(tab:indexedFields)&_b=(f:test,i:'',l:'')";
const relativePath = getRelativeToHistoryPath(url, history);
expect(relativePath).toEqual(
- "/oxf/app/kibana#/management/kibana/indexPatterns/patterns/id?_a=(tab:indexedFields)&_b=(f:test,i:'',l:'')"
+ "/oxf/app/management/kibana/indexPatterns/patterns/id?_a=(tab:indexedFields)&_b=(f:test,i:'',l:'')"
);
});
it('should extract path relative to browser history with basename', () => {
const url =
- "http://localhost:5601/oxf/app/kibana#/management/kibana/indexPatterns/patterns/id?_a=(tab:indexedFields)&_b=(f:test,i:'',l:'')";
+ "http://localhost:5601/oxf/app/management/kibana/indexPatterns/patterns/id?_a=(tab:indexedFields)&_b=(f:test,i:'',l:'')";
const history1 = createBrowserHistory({ basename: '/oxf/app/' });
const relativePath1 = getRelativeToHistoryPath(url, history1);
expect(relativePath1).toEqual(
- "/kibana#/management/kibana/indexPatterns/patterns/id?_a=(tab:indexedFields)&_b=(f:test,i:'',l:'')"
+ "/management/kibana/indexPatterns/patterns/id?_a=(tab:indexedFields)&_b=(f:test,i:'',l:'')"
);
const history2 = createBrowserHistory({ basename: '/oxf/app/kibana/' });
@@ -270,17 +270,17 @@ describe('kbn_url_storage', () => {
it('should extract path relative to browser history with basename from relative url', () => {
const history = createBrowserHistory({ basename: '/oxf/app/' });
const url =
- "/oxf/app/kibana#/management/kibana/indexPatterns/patterns/id?_a=(tab:indexedFields)&_b=(f:test,i:'',l:'')";
+ "/oxf/app/management/kibana/indexPatterns/patterns/id?_a=(tab:indexedFields)&_b=(f:test,i:'',l:'')";
const relativePath = getRelativeToHistoryPath(url, history);
expect(relativePath).toEqual(
- "/kibana#/management/kibana/indexPatterns/patterns/id?_a=(tab:indexedFields)&_b=(f:test,i:'',l:'')"
+ "/management/kibana/indexPatterns/patterns/id?_a=(tab:indexedFields)&_b=(f:test,i:'',l:'')"
);
});
it('should extract path relative to hash history without basename', () => {
const history = createHashHistory();
const url =
- "http://localhost:5601/oxf/app/kibana#/management/kibana/indexPatterns/patterns/id?_a=(tab:indexedFields)&_b=(f:test,i:'',l:'')";
+ "http://localhost:5601/oxf/app/management/kibana/indexPatterns/patterns/id?_a=(tab:indexedFields)&_b=(f:test,i:'',l:'')";
const relativePath = getRelativeToHistoryPath(url, history);
expect(relativePath).toEqual(
"/management/kibana/indexPatterns/patterns/id?_a=(tab:indexedFields)&_b=(f:test,i:'',l:'')"
@@ -290,7 +290,7 @@ describe('kbn_url_storage', () => {
it('should extract path relative to hash history with basename', () => {
const history = createHashHistory({ basename: 'management' });
const url =
- "http://localhost:5601/oxf/app/kibana#/management/kibana/indexPatterns/patterns/id?_a=(tab:indexedFields)&_b=(f:test,i:'',l:'')";
+ "http://localhost:5601/oxf/app/management/kibana/indexPatterns/patterns/id?_a=(tab:indexedFields)&_b=(f:test,i:'',l:'')";
const relativePath = getRelativeToHistoryPath(url, history);
expect(relativePath).toEqual(
"/kibana/indexPatterns/patterns/id?_a=(tab:indexedFields)&_b=(f:test,i:'',l:'')"
@@ -300,7 +300,7 @@ describe('kbn_url_storage', () => {
it('should extract path relative to hash history with basename from relative url', () => {
const history = createHashHistory({ basename: 'management' });
const url =
- "/oxf/app/kibana#/management/kibana/indexPatterns/patterns/id?_a=(tab:indexedFields)&_b=(f:test,i:'',l:'')";
+ "/oxf/app/management/kibana/indexPatterns/patterns/id?_a=(tab:indexedFields)&_b=(f:test,i:'',l:'')";
const relativePath = getRelativeToHistoryPath(url, history);
expect(relativePath).toEqual(
"/kibana/indexPatterns/patterns/id?_a=(tab:indexedFields)&_b=(f:test,i:'',l:'')"
diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/components/relationships.test.tsx b/src/plugins/saved_objects_management/public/management_section/objects_table/components/relationships.test.tsx
index b3372ccb6fda5..8d8453c227bfa 100644
--- a/src/plugins/saved_objects_management/public/management_section/objects_table/components/relationships.test.tsx
+++ b/src/plugins/saved_objects_management/public/management_section/objects_table/components/relationships.test.tsx
@@ -112,7 +112,7 @@ describe('Relationships', () => {
editUrl: '/management/kibana/indexPatterns/patterns/1',
icon: 'indexPatternApp',
inAppUrl: {
- path: '/app/kibana#/management/kibana/indexPatterns/patterns/1',
+ path: '/app/management/kibana/indexPatterns/patterns/1',
uiCapabilitiesPath: 'management.kibana.index_patterns',
},
title: 'My Index Pattern',
diff --git a/src/plugins/saved_objects_management/public/plugin.ts b/src/plugins/saved_objects_management/public/plugin.ts
index b0c6b1952a2a5..fc83c061aabd4 100644
--- a/src/plugins/saved_objects_management/public/plugin.ts
+++ b/src/plugins/saved_objects_management/public/plugin.ts
@@ -82,7 +82,7 @@ export class SavedObjectsManagementPlugin
'Import, export, and manage your saved searches, visualizations, and dashboards.',
}),
icon: 'savedObjectsApp',
- path: '/app/kibana#/management/kibana/objects',
+ path: '/app/management/kibana/objects',
showOnHomePage: true,
category: FeatureCatalogueCategory.ADMIN,
});
diff --git a/src/plugins/telemetry/common/constants.ts b/src/plugins/telemetry/common/constants.ts
index 2e058fdc13e4a..53c79b738f750 100644
--- a/src/plugins/telemetry/common/constants.ts
+++ b/src/plugins/telemetry/common/constants.ts
@@ -49,7 +49,7 @@ export const LOCALSTORAGE_KEY = 'telemetry.data';
/**
* Link to Advanced Settings.
*/
-export const PATH_TO_ADVANCED_SETTINGS = 'kibana#/management/kibana/settings';
+export const PATH_TO_ADVANCED_SETTINGS = 'management/kibana/settings';
/**
* Link to the Elastic Telemetry privacy statement.
diff --git a/test/api_integration/apis/saved_objects_management/find.ts b/test/api_integration/apis/saved_objects_management/find.ts
index ef7c5ab22ee66..797c5d34af3b9 100644
--- a/test/api_integration/apis/saved_objects_management/find.ts
+++ b/test/api_integration/apis/saved_objects_management/find.ts
@@ -285,7 +285,7 @@ export default function({ getService }: FtrProviderContext) {
'/management/kibana/indexPatterns/patterns/8963ca30-3224-11e8-a572-ffca06da1357',
inAppUrl: {
path:
- '/app/kibana#/management/kibana/indexPatterns/patterns/8963ca30-3224-11e8-a572-ffca06da1357',
+ '/app/management/kibana/indexPatterns/patterns/8963ca30-3224-11e8-a572-ffca06da1357',
uiCapabilitiesPath: 'management.kibana.index_patterns',
},
});
diff --git a/test/api_integration/apis/saved_objects_management/relationships.ts b/test/api_integration/apis/saved_objects_management/relationships.ts
index 00972a97f41e8..d78ac42a156f0 100644
--- a/test/api_integration/apis/saved_objects_management/relationships.ts
+++ b/test/api_integration/apis/saved_objects_management/relationships.ts
@@ -86,7 +86,7 @@ export default function({ getService }: FtrProviderContext) {
'/management/kibana/indexPatterns/patterns/8963ca30-3224-11e8-a572-ffca06da1357',
inAppUrl: {
path:
- '/app/kibana#/management/kibana/indexPatterns/patterns/8963ca30-3224-11e8-a572-ffca06da1357',
+ '/app/management/kibana/indexPatterns/patterns/8963ca30-3224-11e8-a572-ffca06da1357',
uiCapabilitiesPath: 'management.kibana.index_patterns',
},
},
@@ -127,7 +127,7 @@ export default function({ getService }: FtrProviderContext) {
'/management/kibana/indexPatterns/patterns/8963ca30-3224-11e8-a572-ffca06da1357',
inAppUrl: {
path:
- '/app/kibana#/management/kibana/indexPatterns/patterns/8963ca30-3224-11e8-a572-ffca06da1357',
+ '/app/management/kibana/indexPatterns/patterns/8963ca30-3224-11e8-a572-ffca06da1357',
uiCapabilitiesPath: 'management.kibana.index_patterns',
},
},
diff --git a/x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/index.tsx b/x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/index.tsx
index e1f58b7b35210..d6769ccf0ca5f 100644
--- a/x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/index.tsx
@@ -92,7 +92,7 @@ export class ServiceIntegrations extends React.Component {
),
icon: 'watchesApp',
href: core.http.basePath.prepend(
- '/app/kibana#/management/insightsAndAlerting/watcher'
+ '/app/management/insightsAndAlerting/watcher'
),
target: '_blank',
onClick: () => this.closePopover()
diff --git a/x-pack/plugins/apm/public/context/LicenseContext/InvalidLicenseNotification.tsx b/x-pack/plugins/apm/public/context/LicenseContext/InvalidLicenseNotification.tsx
index 8ed02f039289e..13ba123914fcb 100644
--- a/x-pack/plugins/apm/public/context/LicenseContext/InvalidLicenseNotification.tsx
+++ b/x-pack/plugins/apm/public/context/LicenseContext/InvalidLicenseNotification.tsx
@@ -11,7 +11,7 @@ import { useApmPluginContext } from '../../hooks/useApmPluginContext';
export function InvalidLicenseNotification() {
const { core } = useApmPluginContext();
const manageLicenseURL = core.http.basePath.prepend(
- '/app/kibana#/management/stack/license_management'
+ '/app/management/stack/license_management'
);
return (
diff --git a/x-pack/plugins/licensing/public/plugin.test.ts b/x-pack/plugins/licensing/public/plugin.test.ts
index 9f0019680d14b..846eb193258c7 100644
--- a/x-pack/plugins/licensing/public/plugin.test.ts
+++ b/x-pack/plugins/licensing/public/plugin.test.ts
@@ -367,7 +367,7 @@ describe('licensing plugin', () => {
expect(coreStart.overlays.banners.add).toHaveBeenCalledTimes(1);
expect(mountExpiredBannerMock).toHaveBeenCalledWith({
type: 'gold',
- uploadUrl: '/app/kibana#/management/stack/license_management/upload_license',
+ uploadUrl: '/app/management/stack/license_management/upload_license',
});
});
});
diff --git a/x-pack/plugins/licensing/public/plugin.ts b/x-pack/plugins/licensing/public/plugin.ts
index 31910d81b3434..3f16f14744179 100644
--- a/x-pack/plugins/licensing/public/plugin.ts
+++ b/x-pack/plugins/licensing/public/plugin.ts
@@ -148,7 +148,7 @@ export class LicensingPlugin implements Plugin {
private showExpiredBanner(license: ILicense) {
const uploadUrl = this.coreStart!.http.basePath.prepend(
- '/app/kibana#/management/stack/license_management/upload_license'
+ '/app/management/stack/license_management/upload_license'
);
this.coreStart!.overlays.banners.add(
mountExpiredBanner({
diff --git a/x-pack/plugins/logstash/public/plugin.ts b/x-pack/plugins/logstash/public/plugin.ts
index 7d4afc0a4ea13..cbfe8fe1ff4e5 100644
--- a/x-pack/plugins/logstash/public/plugin.ts
+++ b/x-pack/plugins/logstash/public/plugin.ts
@@ -71,7 +71,7 @@ export class LogstashPlugin implements Plugin {
defaultMessage: 'Create, delete, update, and clone data ingestion pipelines.',
}),
icon: 'pipelineApp',
- path: '/app/kibana#/management/ingest/pipelines',
+ path: '/app/management/ingest/pipelines',
showOnHomePage: true,
category: FeatureCatalogueCategory.ADMIN,
});
diff --git a/x-pack/plugins/maps/public/components/no_index_pattern_callout.js b/x-pack/plugins/maps/public/components/no_index_pattern_callout.js
index 89cd884a6dd32..2daab8c6322dd 100644
--- a/x-pack/plugins/maps/public/components/no_index_pattern_callout.js
+++ b/x-pack/plugins/maps/public/components/no_index_pattern_callout.js
@@ -24,7 +24,7 @@ export function NoIndexPatternCallout() {
id="xpack.maps.noIndexPattern.doThisPrefixDescription"
defaultMessage="You'll need to "
/>
-
+
{
}
description={startTrialDescription()}
footer={
-
+
= ({
/>
}
description=""
- href={`${basePath.get()}/app/kibana#/management/data/index_management/indices/filter/${index}`}
+ href={`${basePath.get()}/app/management/data/index_management/indices/filter/${index}`}
/>
@@ -153,7 +153,7 @@ export const ResultsLinks: FC = ({
/>
}
description=""
- href={`${basePath.get()}/app/kibana#/management/kibana/indexPatterns${
+ href={`${basePath.get()}/app/management/kibana/indexPatterns${
createIndexPattern ? `/patterns/${indexPatternId}` : ''
}`}
/>
diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/create_watch_flyout/create_watch_service.js b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/create_watch_flyout/create_watch_service.js
index 307fa79f5dea2..4f8cccdbb335e 100644
--- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/create_watch_flyout/create_watch_service.js
+++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/create_watch_flyout/create_watch_service.js
@@ -167,7 +167,7 @@ class CreateWatchService {
saveWatch(watchModel)
.then(() => {
this.status.watch = this.STATUS.SAVED;
- this.config.watcherEditURL = `${basePath.get()}/app/kibana#/management/insightsAndAlerting/watcher/watches/watch/${id}/edit?_g=()`;
+ this.config.watcherEditURL = `${basePath.get()}/app/management/insightsAndAlerting/watcher/watches/watch/${id}/edit?_g=()`;
resolve({
id,
url: this.config.watcherEditURL,
diff --git a/x-pack/plugins/ml/public/application/overview/components/sidebar.tsx b/x-pack/plugins/ml/public/application/overview/components/sidebar.tsx
index 87a7156b6f52e..119346ec8035a 100644
--- a/x-pack/plugins/ml/public/application/overview/components/sidebar.tsx
+++ b/x-pack/plugins/ml/public/application/overview/components/sidebar.tsx
@@ -42,7 +42,7 @@ export const OverviewSideBar: FC = ({ createAnomalyDetectionJobDisabled }
const { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } = docLinks;
const docsLink = `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/xpack-ml.html`;
- const transformsLink = `${basePath.get()}/app/kibana#/management/data/transform`;
+ const transformsLink = `${basePath.get()}/app/management/data/transform`;
return (
diff --git a/x-pack/plugins/monitoring/public/components/cluster/listing/listing.js b/x-pack/plugins/monitoring/public/components/cluster/listing/listing.js
index 69d7727f9a20a..cf403005df0bf 100644
--- a/x-pack/plugins/monitoring/public/components/cluster/listing/listing.js
+++ b/x-pack/plugins/monitoring/public/components/cluster/listing/listing.js
@@ -288,7 +288,7 @@ const handleClickIncompatibleLicense = (scope, clusterName) => {
};
const handleClickInvalidLicense = (scope, clusterName) => {
- const licensingPath = `${Legacy.shims.getBasePath()}/app/kibana#/management/stack/license_management/home`;
+ const licensingPath = `${Legacy.shims.getBasePath()}/app/management/stack/license_management/home`;
licenseWarning(scope, {
title: toMountPoint(
diff --git a/x-pack/plugins/monitoring/public/components/license/index.js b/x-pack/plugins/monitoring/public/components/license/index.js
index e8ea1f8df227a..076b8e6d543e6 100644
--- a/x-pack/plugins/monitoring/public/components/license/index.js
+++ b/x-pack/plugins/monitoring/public/components/license/index.js
@@ -169,7 +169,7 @@ const LicenseUpdateInfoForRemote = ({ isPrimaryCluster }) => {
export function License(props) {
const { status, type, isExpired, expiryDate } = props;
- const licenseManagement = `${Legacy.shims.getBasePath()}/app/kibana#/management/stack/license_management`;
+ const licenseManagement = `${Legacy.shims.getBasePath()}/app/management/stack/license_management`;
return (
diff --git a/x-pack/plugins/reporting/constants.ts b/x-pack/plugins/reporting/constants.ts
index 8079c5b1d9887..a610ff0bb16a9 100644
--- a/x-pack/plugins/reporting/constants.ts
+++ b/x-pack/plugins/reporting/constants.ts
@@ -12,7 +12,7 @@ export const API_BASE_URL = '/api/reporting';
export const API_LIST_URL = `${API_BASE_URL}/jobs`;
export const API_BASE_GENERATE = `${API_BASE_URL}/generate`;
export const API_GENERATE_IMMEDIATE = `${API_BASE_URL}/v1/generate/immediate/csv/saved-object`;
-export const REPORTING_MANAGEMENT_HOME = '/app/kibana#/management/kibana/reporting';
+export const REPORTING_MANAGEMENT_HOME = '/app/management/kibana/reporting';
// Statuses
export const JOB_STATUS_FAILED = 'failed';
diff --git a/x-pack/plugins/reporting/public/components/report_listing.tsx b/x-pack/plugins/reporting/public/components/report_listing.tsx
index d8f9b7d37cfbf..ca97692c650e8 100644
--- a/x-pack/plugins/reporting/public/components/report_listing.tsx
+++ b/x-pack/plugins/reporting/public/components/report_listing.tsx
@@ -266,7 +266,7 @@ class ReportListingUi extends Component {
} catch (fetchError) {
if (!this.licenseAllowsToShowThisPage()) {
this.props.toasts.addDanger(this.state.badLicenseMessage);
- this.props.redirect('kibana#/management');
+ this.props.redirect('management');
return;
}
diff --git a/x-pack/plugins/reporting/public/plugin.tsx b/x-pack/plugins/reporting/public/plugin.tsx
index ac8ea661a21ab..c5fed538e3b01 100644
--- a/x-pack/plugins/reporting/public/plugin.tsx
+++ b/x-pack/plugins/reporting/public/plugin.tsx
@@ -111,7 +111,7 @@ export class ReportingPublicPlugin implements Plugin {
defaultMessage: 'Manage your reports generated from Discover, Visualize, and Dashboard.',
}),
icon: 'reportingApp',
- path: '/app/kibana#/management/kibana/reporting',
+ path: '/app/management/kibana/reporting',
showOnHomePage: false,
category: FeatureCatalogueCategory.ADMIN,
});
diff --git a/x-pack/plugins/security/public/plugin.tsx b/x-pack/plugins/security/public/plugin.tsx
index 38ef552e75a9e..da69dd051c11d 100644
--- a/x-pack/plugins/security/public/plugin.tsx
+++ b/x-pack/plugins/security/public/plugin.tsx
@@ -122,7 +122,7 @@ export class SecurityPlugin
'Protect your data and easily manage who has access to what with users and roles.',
}),
icon: 'securityApp',
- path: '/app/kibana#/management/security/users',
+ path: '/app/management/security/users',
showOnHomePage: true,
category: FeatureCatalogueCategory.ADMIN,
});
diff --git a/x-pack/plugins/siem/public/common/components/ml_popover/upgrade_contents.tsx b/x-pack/plugins/siem/public/common/components/ml_popover/upgrade_contents.tsx
index eda6b0f28499c..e9efd7df23903 100644
--- a/x-pack/plugins/siem/public/common/components/ml_popover/upgrade_contents.tsx
+++ b/x-pack/plugins/siem/public/common/components/ml_popover/upgrade_contents.tsx
@@ -59,7 +59,7 @@ export const UpgradeContentsComponent = () => (
diff --git a/x-pack/plugins/siem/public/common/components/news_feed/no_news/index.tsx b/x-pack/plugins/siem/public/common/components/news_feed/no_news/index.tsx
index c4e0482c6b30a..8061a8f9799e3 100644
--- a/x-pack/plugins/siem/public/common/components/news_feed/no_news/index.tsx
+++ b/x-pack/plugins/siem/public/common/components/news_feed/no_news/index.tsx
@@ -13,7 +13,7 @@ export const NoNews = React.memo(() => (
<>
{i18n.NO_NEWS_MESSAGE}{' '}
-
+
{i18n.ADVANCED_SETTINGS_LINK_TITLE}
{'.'}
diff --git a/x-pack/plugins/spaces/public/create_feature_catalogue_entry.ts b/x-pack/plugins/spaces/public/create_feature_catalogue_entry.ts
index 2cf34e842ce33..15d141ccc328e 100644
--- a/x-pack/plugins/spaces/public/create_feature_catalogue_entry.ts
+++ b/x-pack/plugins/spaces/public/create_feature_catalogue_entry.ts
@@ -19,7 +19,7 @@ export const createSpacesFeatureCatalogueEntry = (): FeatureCatalogueEntry => {
}),
description: getSpacesFeatureDescription(),
icon: 'spacesApp',
- path: '/app/kibana#/management/kibana/spaces',
+ path: '/app/management/kibana/spaces',
showOnHomePage: true,
category: FeatureCatalogueCategory.ADMIN,
};
diff --git a/x-pack/plugins/transform/public/register_feature.ts b/x-pack/plugins/transform/public/register_feature.ts
index c81a18a3def87..796fa370dab25 100644
--- a/x-pack/plugins/transform/public/register_feature.ts
+++ b/x-pack/plugins/transform/public/register_feature.ts
@@ -22,7 +22,7 @@ export const registerFeature = (home: HomePublicPluginSetup) => {
'Use transforms to pivot existing Elasticsearch indices into summarized or entity-centric indices.',
}),
icon: 'managementApp', // there is currently no Transforms icon, so using the general management app icon
- path: '/app/kibana#/management/data/transform',
+ path: '/app/management/data/transform',
showOnHomePage: true,
category: FeatureCatalogueCategory.ADMIN,
});
diff --git a/x-pack/plugins/uptime/public/components/monitor/ml/license_info.tsx b/x-pack/plugins/uptime/public/components/monitor/ml/license_info.tsx
index 33fbbb117a11a..e37ec4cc4715d 100644
--- a/x-pack/plugins/uptime/public/components/monitor/ml/license_info.tsx
+++ b/x-pack/plugins/uptime/public/components/monitor/ml/license_info.tsx
@@ -22,7 +22,7 @@ export const ShowLicenseInfo = () => {
{labels.START_TRAIL_DESC}
{labels.START_TRAIL}
diff --git a/x-pack/plugins/watcher/public/plugin.ts b/x-pack/plugins/watcher/public/plugin.ts
index a772d26308dfd..a8df9d6dbce29 100644
--- a/x-pack/plugins/watcher/public/plugin.ts
+++ b/x-pack/plugins/watcher/public/plugin.ts
@@ -77,7 +77,7 @@ export class WatcherUIPlugin implements Plugin {
defaultMessage: 'Detect changes in your data by creating, managing, and monitoring alerts.',
}),
icon: 'watchesApp',
- path: '/app/kibana#/management/insightsAndAlerting/watcher/watches',
+ path: '/app/management/insightsAndAlerting/watcher/watches',
showOnHomePage: false,
};
From a1c51d7536cc881581403147361deae7cd952146 Mon Sep 17 00:00:00 2001
From: Alexey Antonov
Date: Wed, 20 May 2020 16:36:49 +0300
Subject: [PATCH 15/93] remove ui/public/management
---
src/legacy/ui/public/management/index.d.ts | 27 --------
src/legacy/ui/public/management/index.js | 22 ------
.../public/components/breadcrumbs.ts | 6 +-
.../public/components/langing/landing.tsx | 69 ++++++++++---------
.../management_app/management_app.tsx | 28 +++++---
.../management_app_wrapper.tsx | 2 +-
.../management/public/utils}/breadcrumbs.ts | 8 +--
src/plugins/management/public/utils/index.ts | 1 +
.../public/application/index.tsx | 2 +-
.../application/mount_management_section.ts | 2 +-
10 files changed, 66 insertions(+), 101 deletions(-)
delete mode 100644 src/legacy/ui/public/management/index.d.ts
delete mode 100644 src/legacy/ui/public/management/index.js
rename src/{legacy/ui/public/management => plugins/management/public/utils}/breadcrumbs.ts (85%)
diff --git a/src/legacy/ui/public/management/index.d.ts b/src/legacy/ui/public/management/index.d.ts
deleted file mode 100644
index 529efd36623a3..0000000000000
--- a/src/legacy/ui/public/management/index.d.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-declare module 'ui/management' {
- export const SidebarNav: React.FC;
- export const management: any; // TODO - properly provide types
- export const MANAGEMENT_BREADCRUMB: {
- text: string;
- href: string;
- };
-}
diff --git a/src/legacy/ui/public/management/index.js b/src/legacy/ui/public/management/index.js
deleted file mode 100644
index 25d3678c5dbba..0000000000000
--- a/src/legacy/ui/public/management/index.js
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-export { MANAGEMENT_BREADCRUMB } from './breadcrumbs';
-import { npStart } from 'ui/new_platform';
-export const management = npStart.plugins.management.legacy;
diff --git a/src/plugins/index_pattern_management/public/components/breadcrumbs.ts b/src/plugins/index_pattern_management/public/components/breadcrumbs.ts
index 6ffb929150b82..e62c46baa2c22 100644
--- a/src/plugins/index_pattern_management/public/components/breadcrumbs.ts
+++ b/src/plugins/index_pattern_management/public/components/breadcrumbs.ts
@@ -26,7 +26,7 @@ export function getListBreadcrumbs() {
text: i18n.translate('indexPatternManagement.indexPatterns.listBreadcrumb', {
defaultMessage: 'Index patterns',
}),
- href: `#/management/kibana/indexPatterns/`,
+ href: `/`,
},
];
}
@@ -38,7 +38,7 @@ export function getCreateBreadcrumbs() {
text: i18n.translate('indexPatternManagement.indexPatterns.createBreadcrumb', {
defaultMessage: 'Create index pattern',
}),
- href: `#/management/kibana/indexPatterns/create`,
+ href: `/create`,
},
];
}
@@ -48,7 +48,7 @@ export function getEditBreadcrumbs(indexPattern: IndexPattern) {
...getListBreadcrumbs(),
{
text: indexPattern.title,
- href: `#/management/kibana/indexPatterns/patterns/${indexPattern.id}`,
+ href: `/patterns/${indexPattern.id}`,
},
];
}
diff --git a/src/plugins/management/public/components/langing/landing.tsx b/src/plugins/management/public/components/langing/landing.tsx
index a82044784bc95..c35f8b10b8163 100644
--- a/src/plugins/management/public/components/langing/landing.tsx
+++ b/src/plugins/management/public/components/langing/landing.tsx
@@ -31,41 +31,46 @@ import {
interface ManagementLandingPageProps {
version: string;
+ setBreadcrumbs: () => void;
}
-export const ManagementLandingPage = ({ version }: ManagementLandingPageProps) => (
-
-
-
-
-
-
-
+export const ManagementLandingPage = ({ version, setBreadcrumbs }: ManagementLandingPageProps) => {
+ setBreadcrumbs();
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
-
+
-
-
-
-
-
-
-
-);
+
+
+
+
+
+
+
+ );
+};
diff --git a/src/plugins/management/public/components/management_app/management_app.tsx b/src/plugins/management/public/components/management_app/management_app.tsx
index 7f3e61aa9b2f0..0e85333af3546 100644
--- a/src/plugins/management/public/components/management_app/management_app.tsx
+++ b/src/plugins/management/public/components/management_app/management_app.tsx
@@ -27,7 +27,7 @@ import {
import { I18nProvider } from '@kbn/i18n/react';
import { EuiPage, EuiPageBody } from '@elastic/eui';
import { ManagementStart } from '../../types';
-import { ManagementSection } from '../../utils';
+import { ManagementSection, MANAGEMENT_BREADCRUMB } from '../../utils';
import { ManagementLandingPage } from '../langing';
import { ManagementSidebarNav } from '../management_sidebar_nav';
@@ -59,15 +59,18 @@ export const ManagementApp = ({ context, dependencies, history }: ManagementAppP
}, []);
const setBreadcrumbs = useCallback(
- (crumbs: ChromeBreadcrumb[] = [], appHistory: ScopedHistory) => {
- context.core.chrome.setBreadcrumbs(
- crumbs.map(item => ({
- ...item,
- ...(item.href ? reactRouterNavigate(appHistory, item.href) : {}),
- }))
- );
+ (crumbs: ChromeBreadcrumb[] = [], appHistory?: ScopedHistory) => {
+ const wrapBreadcrumb = (item: ChromeBreadcrumb, scopedHistory: ScopedHistory) => ({
+ ...item,
+ ...(item.href ? reactRouterNavigate(scopedHistory, item.href) : {}),
+ });
+
+ context.core.chrome.setBreadcrumbs([
+ wrapBreadcrumb(MANAGEMENT_BREADCRUMB, history),
+ ...crumbs.map(item => wrapBreadcrumb(item, appHistory || history)),
+ ]);
},
- [context.core.chrome]
+ [context.core.chrome, history]
);
useEffect(() => {
@@ -102,7 +105,12 @@ export const ManagementApp = ({ context, dependencies, history }: ManagementAppP
)}
}
+ component={() => (
+
+ )}
/>
diff --git a/src/plugins/management/public/components/management_app_wrapper/management_app_wrapper.tsx b/src/plugins/management/public/components/management_app_wrapper/management_app_wrapper.tsx
index 1e15a0eabfbf3..41546651e2684 100644
--- a/src/plugins/management/public/components/management_app_wrapper/management_app_wrapper.tsx
+++ b/src/plugins/management/public/components/management_app_wrapper/management_app_wrapper.tsx
@@ -25,7 +25,7 @@ import { Unmount } from '../../types';
interface ManagementSectionWrapperProps {
app: ManagementApp;
- setBreadcrumbs: (crumbs: ChromeBreadcrumb[], history: ScopedHistory) => void;
+ setBreadcrumbs: (crumbs?: ChromeBreadcrumb[], history?: ScopedHistory) => void;
onAppMounted: (id: string) => void;
history: AppMountParameters['history'];
}
diff --git a/src/legacy/ui/public/management/breadcrumbs.ts b/src/plugins/management/public/utils/breadcrumbs.ts
similarity index 85%
rename from src/legacy/ui/public/management/breadcrumbs.ts
rename to src/plugins/management/public/utils/breadcrumbs.ts
index 936e99caff565..147d157d29d7f 100644
--- a/src/legacy/ui/public/management/breadcrumbs.ts
+++ b/src/plugins/management/public/utils/breadcrumbs.ts
@@ -19,9 +19,9 @@
import { i18n } from '@kbn/i18n';
-export const MANAGEMENT_BREADCRUMB = Object.freeze({
- text: i18n.translate('common.ui.stackManagement.breadcrumb', {
+export const MANAGEMENT_BREADCRUMB = {
+ text: i18n.translate('management.breadcrumb', {
defaultMessage: 'Stack Management',
}),
- href: '#/management',
-});
+ href: '/',
+};
diff --git a/src/plugins/management/public/utils/index.ts b/src/plugins/management/public/utils/index.ts
index a1d759a3ec628..04c0c4c6811c7 100644
--- a/src/plugins/management/public/utils/index.ts
+++ b/src/plugins/management/public/utils/index.ts
@@ -17,5 +17,6 @@
* under the License.
*/
+export { MANAGEMENT_BREADCRUMB } from './breadcrumbs';
export { ManagementApp, RegisterManagementAppArgs } from './management_app';
export { ManagementSection, RegisterManagementSectionArgs } from './management_section';
diff --git a/x-pack/plugins/index_management/public/application/index.tsx b/x-pack/plugins/index_management/public/application/index.tsx
index a9343552759b7..8da556cc81fcc 100644
--- a/x-pack/plugins/index_management/public/application/index.tsx
+++ b/x-pack/plugins/index_management/public/application/index.tsx
@@ -25,7 +25,7 @@ export const renderApp = (
const { i18n } = core;
const { Context: I18nContext } = i18n;
const { services, history } = dependencies;
- console.log('2 before render', history);
+
render(
diff --git a/x-pack/plugins/index_management/public/application/mount_management_section.ts b/x-pack/plugins/index_management/public/application/mount_management_section.ts
index a432ccc190400..5e8282fcdcdf8 100644
--- a/x-pack/plugins/index_management/public/application/mount_management_section.ts
+++ b/x-pack/plugins/index_management/public/application/mount_management_section.ts
@@ -36,7 +36,7 @@ export async function mountManagementSection(
breadcrumbService.setup(setBreadcrumbs);
documentationService.setup(docLinks);
- console.log('1 before render app', history);
+
const appDependencies: AppDependencies = {
core: {
fatalErrors,
From ec4cde3e9e05cae80d40e61763f00483e40a8d40 Mon Sep 17 00:00:00 2001
From: Alexey Antonov
Date: Wed, 20 May 2020 18:00:47 +0300
Subject: [PATCH 16/93] fix some links to management apps
---
.../public/application/angular/discover.js | 4 ++--
.../components/top_nav/open_search_panel.js | 5 ++++-
.../public/application/components/add_data.js | 3 ++-
.../public/application/components/welcome.tsx | 4 ++--
.../public/angular/angular_config.tsx | 6 +++++-
.../visualize/public/application/legacy_app.js | 18 ++++++------------
6 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/src/plugins/discover/public/application/angular/discover.js b/src/plugins/discover/public/application/angular/discover.js
index 84b4b2254e703..fefad01f55c59 100644
--- a/src/plugins/discover/public/application/angular/discover.js
+++ b/src/plugins/discover/public/application/angular/discover.js
@@ -162,8 +162,8 @@ app.config($routeProvider => {
mapping: {
search: '/',
'index-pattern': {
- app: 'kibana',
- path: `#/management/kibana/objects/savedSearches/${$route.current.params.id}`,
+ app: 'management',
+ path: `kibana/objects/savedSearches/${$route.current.params.id}`,
},
},
toastNotifications,
diff --git a/src/plugins/discover/public/application/components/top_nav/open_search_panel.js b/src/plugins/discover/public/application/components/top_nav/open_search_panel.js
index 06267407dcb21..74154d41a6951 100644
--- a/src/plugins/discover/public/application/components/top_nav/open_search_panel.js
+++ b/src/plugins/discover/public/application/components/top_nav/open_search_panel.js
@@ -40,6 +40,7 @@ const SEARCH_OBJECT_TYPE = 'search';
export function OpenSearchPanel(props) {
const {
core: { uiSettings, savedObjects },
+ addBasePath,
} = getServices();
return (
@@ -86,7 +87,9 @@ export function OpenSearchPanel(props) {
{
const basePath = getServices().getBasePath();
+
const renderCards = () => {
const apmData = {
title: intl.formatMessage({
@@ -296,7 +297,7 @@ const AddDataUi = ({ apmUiEnabled, isNewKibanaInstance, intl, mlEnabled }) => {
{
id="home.dataManagementDisableCollection"
defaultMessage=" To stop collection, "
/>
-
+
{
id="home.dataManagementEnableCollection"
defaultMessage=" To start collection, "
/>
-
+
state:storeInSessionStorage,
advancedSettingsLink: (
-
+
Date: Wed, 20 May 2020 19:01:37 +0300
Subject: [PATCH 17/93] fix management url for functional tests
---
test/functional/config.js | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/test/functional/config.js b/test/functional/config.js
index fee7a6f249f53..90bb372334742 100644
--- a/test/functional/config.js
+++ b/test/functional/config.js
@@ -84,8 +84,7 @@ export default async function({ readConfigFile }) {
hash: '/list',
},
settings: {
- pathname: '/app/kibana',
- hash: '/management',
+ pathname: '/app/management',
},
timelion: {
pathname: '/app/timelion',
From 817f458430a30b087cde6488cef0c735c1e884a8 Mon Sep 17 00:00:00 2001
From: Alexey Antonov
Date: Wed, 20 May 2020 19:48:43 +0300
Subject: [PATCH 18/93] add data-test-subj for EuiSideNavItem
---
.../management_sidebar_nav/management_sidebar_nav.tsx | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/plugins/management/public/components/management_sidebar_nav/management_sidebar_nav.tsx b/src/plugins/management/public/components/management_sidebar_nav/management_sidebar_nav.tsx
index 4e5addf0e7137..fe9126fd9e623 100644
--- a/src/plugins/management/public/components/management_sidebar_nav/management_sidebar_nav.tsx
+++ b/src/plugins/management/public/components/management_sidebar_nav/management_sidebar_nav.tsx
@@ -17,7 +17,7 @@
* under the License.
*/
-import { EuiIcon, EuiSideNav, EuiSideNavItemType, EuiScreenReaderOnly } from '@elastic/eui';
+import { EuiIcon, EuiSideNav, EuiScreenReaderOnly } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React, { useState } from 'react';
import { AppMountParameters } from 'kibana/public';
@@ -83,7 +83,7 @@ export const ManagementSidebarNav = ({
const createNavItem = (
item: T,
customParams: Record = {}
- ): EuiSideNavItemType => {
+ ) => {
const iconType = item.euiIconType || item.icon;
return {
@@ -91,6 +91,7 @@ export const ManagementSidebarNav = ({
name: item.title,
isSelected: item.id === selectedId,
icon: iconType ? : undefined,
+ 'data-test-subj': item.id,
...customParams,
};
};
From edc75a0cab8ec1708159e66a57aad5c205473ad4 Mon Sep 17 00:00:00 2001
From: Matt Kime
Date: Wed, 20 May 2020 16:29:28 -0500
Subject: [PATCH 19/93] partial progress
---
.../ingest_pipelines/common/constants.ts | 2 +-
.../public/management/management_urls.ts | 21 ++++++++--------
.../role_mappings_grid_page.test.tsx | 4 +--
.../role_mappings_management_app.tsx | 2 +-
.../roles/edit_role/edit_role_page.tsx | 8 ++++--
.../roles/roles_grid/roles_grid_page.tsx | 25 +++++++++++++++----
.../management/roles/roles_management_app.tsx | 9 ++++++-
7 files changed, 48 insertions(+), 23 deletions(-)
diff --git a/x-pack/plugins/ingest_pipelines/common/constants.ts b/x-pack/plugins/ingest_pipelines/common/constants.ts
index de291e364e02f..4c6c6fefaad83 100644
--- a/x-pack/plugins/ingest_pipelines/common/constants.ts
+++ b/x-pack/plugins/ingest_pipelines/common/constants.ts
@@ -11,7 +11,7 @@ export const PLUGIN_ID = 'ingest_pipelines';
export const PLUGIN_MIN_LICENSE_TYPE = basicLicense;
-export const BASE_PATH = '/management/ingest/ingest_pipelines';
+export const BASE_PATH = '/';
export const API_BASE_PATH = '/api/ingest_pipelines';
diff --git a/x-pack/plugins/security/public/management/management_urls.ts b/x-pack/plugins/security/public/management/management_urls.ts
index 0d4e3fc920bdb..c7d325fd1d2d9 100644
--- a/x-pack/plugins/security/public/management/management_urls.ts
+++ b/x-pack/plugins/security/public/management/management_urls.ts
@@ -4,20 +4,19 @@
* you may not use this file except in compliance with the Elastic License.
*/
-const MANAGEMENT_PATH = '/management';
-const SECURITY_PATH = `${MANAGEMENT_PATH}/security`;
-export const ROLES_PATH = `${SECURITY_PATH}/roles`;
-export const EDIT_ROLES_PATH = `${ROLES_PATH}/edit`;
-export const CLONE_ROLES_PATH = `${ROLES_PATH}/clone`;
-export const USERS_PATH = `${SECURITY_PATH}/users`;
+// const MANAGEMENT_PATH = '/management';
+// const SECURITY_PATH = `${MANAGEMENT_PATH}/security`;
+// export const ROLES_PATH = `/roles`;
+export const EDIT_ROLES_PATH = `/edit`;
+export const CLONE_ROLES_PATH = `/clone`;
+export const USERS_PATH = `../users`;
export const EDIT_USERS_PATH = `${USERS_PATH}/edit`;
-export const ROLE_MAPPINGS_PATH = `${SECURITY_PATH}/role_mappings`;
+export const ROLE_MAPPINGS_PATH = `../role_mappings`;
const CREATE_ROLE_MAPPING_PATH = `${ROLE_MAPPINGS_PATH}/edit`;
-export const getEditRoleHref = (roleName: string) =>
- `#${ROLES_PATH}/edit/${encodeURIComponent(roleName)}`;
+export const getEditRoleHref = (roleName: string) => `/edit/${encodeURIComponent(roleName)}`;
-export const getCreateRoleMappingHref = () => `#${CREATE_ROLE_MAPPING_PATH}`;
+export const getCreateRoleMappingHref = () => `${CREATE_ROLE_MAPPING_PATH}`;
export const getEditRoleMappingHref = (roleMappingName: string) =>
- `#${CREATE_ROLE_MAPPING_PATH}/${encodeURIComponent(roleMappingName)}`;
+ `${CREATE_ROLE_MAPPING_PATH}/${encodeURIComponent(roleMappingName)}`;
diff --git a/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.test.tsx b/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.test.tsx
index 0d343ad33d78e..2318384650e78 100644
--- a/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.test.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.test.tsx
@@ -138,7 +138,7 @@ describe('RoleMappingsGridPage', () => {
const links = findTestSubject(wrapper, 'roleMappingRoles').find(EuiLink);
expect(links).toHaveLength(1);
expect(links.at(0).props()).toMatchObject({
- href: '#/management/security/roles/edit/superuser',
+ href: '/edit/superuser',
});
});
@@ -274,7 +274,7 @@ describe('RoleMappingsGridPage', () => {
Object {
"children":
kibana_user
-
+
= ({
docLinks,
uiCapabilities,
notifications,
+ history,
}) => {
// We should keep the same mutable instance of Validator for every re-render since we'll
// eventually enable validation after the first time user tries to save a role.
@@ -462,7 +466,7 @@ export const EditRolePage: FunctionComponent = ({
const getReturnToRoleListButton = () => {
return (
-
+
= ({
- {getFormButtons()}
+ {getFormButtons(history)}
);
diff --git a/x-pack/plugins/security/public/management/roles/roles_grid/roles_grid_page.tsx b/x-pack/plugins/security/public/management/roles/roles_grid/roles_grid_page.tsx
index 04a74a1a9b99a..4ecfffb8e0212 100644
--- a/x-pack/plugins/security/public/management/roles/roles_grid/roles_grid_page.tsx
+++ b/x-pack/plugins/security/public/management/roles/roles_grid/roles_grid_page.tsx
@@ -26,6 +26,7 @@ import {
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { NotificationsStart } from 'src/core/public';
+import { ScopedHistory } from 'kibana/public';
import {
Role,
isRoleEnabled,
@@ -38,10 +39,12 @@ import { RolesAPIClient } from '../roles_api_client';
import { ConfirmDelete } from './confirm_delete';
import { PermissionDenied } from './permission_denied';
import { DisabledBadge, DeprecatedBadge, ReservedBadge } from '../../badges';
+import { reactRouterNavigate } from '../../../../../../../src/plugins/kibana_react/public';
interface Props {
notifications: NotificationsStart;
rolesAPIClient: PublicMethodsOf;
+ history: ScopedHistory;
}
interface State {
@@ -55,7 +58,7 @@ interface State {
}
const getRoleManagementHref = (action: 'edit' | 'clone', roleName?: string) => {
- return `#/management/security/roles/${action}${roleName ? `/${roleName}` : ''}`;
+ return `/${action}${roleName ? `/${roleName}` : ''}`;
};
export class RolesGridPage extends Component {
@@ -106,7 +109,10 @@ export class RolesGridPage extends Component {
-
+
{
render: (name: string, record: Role) => {
return (
-
+
{name}
@@ -228,7 +237,10 @@ export class RolesGridPage extends Component {
title={title}
color={'primary'}
iconType={'pencil'}
- href={getRoleManagementHref('edit', role.name)}
+ {...reactRouterNavigate(
+ this.props.history,
+ getRoleManagementHref('edit', role.name)
+ )}
/>
);
},
@@ -248,7 +260,10 @@ export class RolesGridPage extends Component {
title={title}
color={'primary'}
iconType={'copy'}
- href={getRoleManagementHref('clone', role.name)}
+ {...reactRouterNavigate(
+ this.props.history,
+ getRoleManagementHref('edit', role.name)
+ )}
/>
);
},
diff --git a/x-pack/plugins/security/public/management/roles/roles_management_app.tsx b/x-pack/plugins/security/public/management/roles/roles_management_app.tsx
index 860d07e400f65..1e6f720c7ce71 100644
--- a/x-pack/plugins/security/public/management/roles/roles_management_app.tsx
+++ b/x-pack/plugins/security/public/management/roles/roles_management_app.tsx
@@ -59,7 +59,13 @@ export const rolesManagementApp = Object.freeze({
const rolesAPIClient = new RolesAPIClient(http);
const RolesGridPageWithBreadcrumbs = () => {
setBreadcrumbs(rolesBreadcrumbs);
- return ;
+ return (
+
+ );
};
const EditRolePageWithBreadcrumbs = ({ action }: { action: 'edit' | 'clone' }) => {
@@ -95,6 +101,7 @@ export const rolesManagementApp = Object.freeze({
docLinks={new DocumentationLinksService(docLinks)}
uiCapabilities={application.capabilities}
indexPatterns={data.indexPatterns}
+ history={history}
/>
);
};
From 9cccf1cd7cc0757423973bb14988f56dcf5df8f7 Mon Sep 17 00:00:00 2001
From: Alexey Antonov
Date: Thu, 21 May 2020 12:45:17 +0300
Subject: [PATCH 20/93] fix some of ts issues
---
.../roles/edit_role/edit_role_page.test.tsx | 5 +++--
.../roles/edit_role/edit_role_page.tsx | 16 +++-------------
.../roles/roles_grid/roles_grid_page.test.tsx | 11 ++++++++++-
3 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.test.tsx b/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.test.tsx
index f1ee681331005..afb8b6ec5dbe0 100644
--- a/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.test.tsx
+++ b/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.test.tsx
@@ -8,7 +8,7 @@ import { ReactWrapper } from 'enzyme';
import React from 'react';
import { act } from '@testing-library/react';
import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers';
-import { Capabilities } from 'src/core/public';
+import { Capabilities, ScopedHistory } from 'src/core/public';
import { Feature } from '../../../../../features/public';
import { Role } from '../../../../common/model';
import { DocumentationLinksService } from '../documentation_links';
@@ -16,7 +16,7 @@ import { EditRolePage } from './edit_role_page';
import { SimplePrivilegeSection } from './privileges/kibana/simple_privilege_section';
import { TransformErrorSection } from './privileges/kibana/transform_error_section';
-import { coreMock } from '../../../../../../../src/core/public/mocks';
+import { coreMock, scopedHistoryMock } from '../../../../../../../src/core/public/mocks';
import { dataPluginMock } from '../../../../../../../src/plugins/data/public/mocks';
import { licenseMock } from '../../../../common/licensing/index.mock';
import { userAPIClientMock } from '../../users/index.mock';
@@ -183,6 +183,7 @@ function getProps({
fatalErrors,
spacesEnabled,
uiCapabilities: buildUICapabilities(canManageSpaces),
+ history: (scopedHistoryMock.create() as unknown) as ScopedHistory,
};
}
diff --git a/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.tsx b/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.tsx
index b5c083c6a6110..760a869f12ef9 100644
--- a/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.tsx
+++ b/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.tsx
@@ -54,7 +54,6 @@ import {
RoleIndexPrivilege,
getExtendedRoleDeprecationNotice,
} from '../../../../common/model';
-import { ROLES_PATH } from '../../management_urls';
import { RoleValidationResult, RoleValidator } from './validate_role';
import { DeleteRoleButton } from './delete_role_button';
import { ElasticsearchPrivileges, KibanaPrivilegesRegion } from './privileges';
@@ -267,7 +266,8 @@ function useFeatures(
}
function backToRoleList() {
- window.location.hash = ROLES_PATH;
+ // todo: window.location.hash = ROLES_PATH;
+ // window.location.hash = '';
}
export const EditRolePage: FunctionComponent = ({
@@ -572,11 +572,8 @@ export const EditRolePage: FunctionComponent = ({
{getFormTitle()}
-
-
{description}
-
{isRoleReserved && (
@@ -590,7 +587,6 @@ export const EditRolePage: FunctionComponent = ({
)}
-
{isDeprecatedRole && (
@@ -601,18 +597,12 @@ export const EditRolePage: FunctionComponent = ({
/>
)}
-
-
{getRoleName()}
-
{getElasticsearchPrivileges()}
-
{getKibanaPrivileges()}
-
-
- {getFormButtons(history)}
+ {getFormButtons()}
);
diff --git a/x-pack/plugins/security/public/management/roles/roles_grid/roles_grid_page.test.tsx b/x-pack/plugins/security/public/management/roles/roles_grid/roles_grid_page.test.tsx
index 410d5bc9f7643..2976bde141b76 100644
--- a/x-pack/plugins/security/public/management/roles/roles_grid/roles_grid_page.test.tsx
+++ b/x-pack/plugins/security/public/management/roles/roles_grid/roles_grid_page.test.tsx
@@ -12,10 +12,11 @@ import { RolesAPIClient } from '../roles_api_client';
import { PermissionDenied } from './permission_denied';
import { RolesGridPage } from './roles_grid_page';
-import { coreMock } from '../../../../../../../src/core/public/mocks';
+import { coreMock, scopedHistoryMock } from '../../../../../../../src/core/public/mocks';
import { rolesAPIClientMock } from '../index.mock';
import { ReservedBadge, DisabledBadge } from '../../badges';
import { findTestSubject } from 'test_utils/find_test_subject';
+import { ScopedHistory } from 'kibana/public';
const mock403 = () => ({ body: { statusCode: 403 } });
@@ -41,7 +42,10 @@ const waitForRender = async (
describe('', () => {
let apiClientMock: jest.Mocked>;
+ let history: ScopedHistory;
+
beforeEach(() => {
+ history = (scopedHistoryMock.create() as unknown) as ScopedHistory;
apiClientMock = rolesAPIClientMock.create();
apiClientMock.getRoles.mockResolvedValue([
{
@@ -68,6 +72,7 @@ describe('', () => {
const wrapper = mountWithIntl(
);
@@ -85,6 +90,7 @@ describe('', () => {
const wrapper = mountWithIntl(
);
@@ -104,6 +110,7 @@ describe('', () => {
const wrapper = mountWithIntl(
);
@@ -117,6 +124,7 @@ describe('', () => {
const wrapper = mountWithIntl(
);
@@ -146,6 +154,7 @@ describe('', () => {
const wrapper = mountWithIntl(
);
From 5cff1a8778c2b5b26918100e34388d0b375199ff Mon Sep 17 00:00:00 2001
From: Uladzislau Lasitsa
Date: Thu, 21 May 2020 13:15:02 +0300
Subject: [PATCH 21/93] Fixed breadcrumbs for data index management
---
.../public/application/services/breadcrumbs.ts | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/x-pack/plugins/index_management/public/application/services/breadcrumbs.ts b/x-pack/plugins/index_management/public/application/services/breadcrumbs.ts
index 8128ccd545dce..e3d0058b2b9b0 100644
--- a/x-pack/plugins/index_management/public/application/services/breadcrumbs.ts
+++ b/x-pack/plugins/index_management/public/application/services/breadcrumbs.ts
@@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { i18n } from '@kbn/i18n';
-import { BASE_PATH } from '../../../common/constants';
import { ManagementAppMountParams } from '../../../../../../src/plugins/management/public';
type SetBreadcrumbs = ManagementAppMountParams['setBreadcrumbs'];
@@ -28,7 +27,7 @@ class BreadcrumbService {
text: i18n.translate('xpack.idxMgmt.breadcrumb.homeLabel', {
defaultMessage: 'Index Management',
}),
- href: `#${BASE_PATH}`,
+ href: `/`,
},
];
@@ -38,7 +37,7 @@ class BreadcrumbService {
text: i18n.translate('xpack.idxMgmt.breadcrumb.templatesLabel', {
defaultMessage: 'Templates',
}),
- href: `#${BASE_PATH}templates`,
+ href: `/templates`,
},
];
From bda4b31e1d938244c2ccd40ed3e68bffc9b78f31 Mon Sep 17 00:00:00 2001
From: Alexey Antonov
Date: Thu, 21 May 2020 14:33:11 +0300
Subject: [PATCH 22/93] [kibana/spaces] section
---
.../management_sidebar_nav.tsx | 12 ++--------
.../secure_space_message.tsx | 12 ++++++++--
.../enabled_features.test.tsx.snap | 2 +-
.../enabled_features.test.tsx | 5 ++++
.../enabled_features/enabled_features.tsx | 6 ++++-
.../edit_space/manage_space_page.test.tsx | 17 +++++++++++++-
.../edit_space/manage_space_page.tsx | 15 +++++++-----
.../spaces_grid_pages.test.tsx.snap | 6 +++--
.../spaces_grid/spaces_grid_page.tsx | 23 +++++++++++--------
.../spaces_grid/spaces_grid_pages.test.tsx | 14 ++++++++++-
.../management/spaces_management_app.tsx | 10 ++++++--
.../components/manage_spaces_button.tsx | 2 +-
12 files changed, 88 insertions(+), 36 deletions(-)
diff --git a/src/plugins/management/public/components/management_sidebar_nav/management_sidebar_nav.tsx b/src/plugins/management/public/components/management_sidebar_nav/management_sidebar_nav.tsx
index fe9126fd9e623..b880fd465a885 100644
--- a/src/plugins/management/public/components/management_sidebar_nav/management_sidebar_nav.tsx
+++ b/src/plugins/management/public/components/management_sidebar_nav/management_sidebar_nav.tsx
@@ -53,11 +53,7 @@ export const ManagementSidebarNav = ({
const toggleOpenOnMobile = () => setIsSideNavOpenOnMobile(!isSideNavOpenOnMobile);
const sectionsToNavItems = (managementSections: ManagementSection[]) => {
- if (!managementSections) {
- return undefined;
- }
-
- return (managementSections || [])
+ return managementSections
.filter(section => section.getAppsEnabled())
.map(section => ({
...createNavItem(section, {
@@ -67,11 +63,7 @@ export const ManagementSidebarNav = ({
};
const appsToNavItems = (managementApps: ManagementApp[]) => {
- if (!managementApps) {
- return undefined;
- }
-
- return (managementApps || [])
+ return managementApps
.filter(app => app.enabled)
.map(app => ({
...createNavItem(app, {
diff --git a/x-pack/plugins/spaces/public/management/components/secure_space_message/secure_space_message.tsx b/x-pack/plugins/spaces/public/management/components/secure_space_message/secure_space_message.tsx
index 38d8451b658a8..3ce24f35ec8de 100644
--- a/x-pack/plugins/spaces/public/management/components/secure_space_message/secure_space_message.tsx
+++ b/x-pack/plugins/spaces/public/management/components/secure_space_message/secure_space_message.tsx
@@ -8,8 +8,13 @@ import { EuiHorizontalRule, EuiLink, EuiText } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
import React, { Fragment } from 'react';
+import { ApplicationStart } from 'kibana/public';
-export const SecureSpaceMessage = () => {
+interface SecureSpaceMessageProps {
+ getUrlForApp: ApplicationStart['getUrlForApp'];
+}
+
+export const SecureSpaceMessage = (props: SecureSpaceMessageProps) => {
const rolesLinkTextAriaLabel = i18n.translate(
'xpack.spaces.management.secureSpaceMessage.rolesLinkTextAriaLabel',
{ defaultMessage: 'Roles management page' }
@@ -24,7 +29,10 @@ export const SecureSpaceMessage = () => {
defaultMessage="Want to assign a role to a space? Go to {rolesLink}."
values={{
rolesLink: (
-
+
{
+ const getUrlForApp = (appId: string) => appId;
+
it(`renders as expected`, () => {
expect(
shallowWithIntl(
@@ -44,6 +46,7 @@ describe('EnabledFeatures', () => {
space={space}
securityEnabled={true}
onChange={jest.fn()}
+ getUrlForApp={getUrlForApp}
/>
)
).toMatchSnapshot();
@@ -58,6 +61,7 @@ describe('EnabledFeatures', () => {
space={space}
securityEnabled={true}
onChange={changeHandler}
+ getUrlForApp={getUrlForApp}
/>
);
@@ -92,6 +96,7 @@ describe('EnabledFeatures', () => {
space={space}
securityEnabled={true}
onChange={changeHandler}
+ getUrlForApp={getUrlForApp}
/>
);
diff --git a/x-pack/plugins/spaces/public/management/edit_space/enabled_features/enabled_features.tsx b/x-pack/plugins/spaces/public/management/edit_space/enabled_features/enabled_features.tsx
index 6f0462a6ddcc2..9fe3bac73eeb1 100644
--- a/x-pack/plugins/spaces/public/management/edit_space/enabled_features/enabled_features.tsx
+++ b/x-pack/plugins/spaces/public/management/edit_space/enabled_features/enabled_features.tsx
@@ -8,6 +8,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiLink, EuiSpacer, EuiText, EuiTitle } from
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import React, { Component, Fragment, ReactNode } from 'react';
+import { ApplicationStart } from 'kibana/public';
import { FeatureConfig } from '../../../../../../plugins/features/public';
import { Space } from '../../../../common/model/space';
import { getEnabledFeatures } from '../../lib/feature_utils';
@@ -19,6 +20,7 @@ interface Props {
features: FeatureConfig[];
securityEnabled: boolean;
onChange: (space: Partial) => void;
+ getUrlForApp: ApplicationStart['getUrlForApp'];
}
export class EnabledFeatures extends Component {
@@ -136,7 +138,9 @@ export class EnabledFeatures extends Component {
defaultMessage="Want to secure access? Go to {rolesLink}."
values={{
rolesLink: (
-
+
{
+ const getUrlForApp = (appId: string) => appId;
+ const history = (scopedHistoryMock.create() as unknown) as ScopedHistory;
+
it('allows a space to be created', async () => {
const spacesManager = spacesManagerMock.create();
spacesManager.createSpace = jest.fn(spacesManager.createSpace);
@@ -46,6 +51,8 @@ describe('ManageSpacePage', () => {
getFeatures={featuresStart.getFeatures}
notifications={notificationServiceMock.createStartContract()}
securityEnabled={true}
+ getUrlForApp={getUrlForApp}
+ history={history}
capabilities={{
navLinks: {},
management: {},
@@ -103,6 +110,8 @@ describe('ManageSpacePage', () => {
getFeatures={featuresStart.getFeatures}
notifications={notificationServiceMock.createStartContract()}
securityEnabled={true}
+ getUrlForApp={getUrlForApp}
+ history={history}
capabilities={{
navLinks: {},
management: {},
@@ -152,6 +161,8 @@ describe('ManageSpacePage', () => {
getFeatures={() => Promise.reject(error)}
notifications={notifications}
securityEnabled={true}
+ getUrlForApp={getUrlForApp}
+ history={history}
capabilities={{
navLinks: {},
management: {},
@@ -187,6 +198,8 @@ describe('ManageSpacePage', () => {
getFeatures={featuresStart.getFeatures}
notifications={notificationServiceMock.createStartContract()}
securityEnabled={true}
+ getUrlForApp={getUrlForApp}
+ history={history}
capabilities={{
navLinks: {},
management: {},
@@ -246,6 +259,8 @@ describe('ManageSpacePage', () => {
getFeatures={featuresStart.getFeatures}
notifications={notificationServiceMock.createStartContract()}
securityEnabled={true}
+ getUrlForApp={getUrlForApp}
+ history={history}
capabilities={{
navLinks: {},
management: {},
diff --git a/x-pack/plugins/spaces/public/management/edit_space/manage_space_page.tsx b/x-pack/plugins/spaces/public/management/edit_space/manage_space_page.tsx
index 0cb471854f815..9733e6c84f99e 100644
--- a/x-pack/plugins/spaces/public/management/edit_space/manage_space_page.tsx
+++ b/x-pack/plugins/spaces/public/management/edit_space/manage_space_page.tsx
@@ -18,7 +18,7 @@ import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
import _ from 'lodash';
import React, { Component, Fragment } from 'react';
-import { Capabilities, NotificationsStart } from 'src/core/public';
+import { ApplicationStart, Capabilities, NotificationsStart, ScopedHistory } from 'src/core/public';
import { Feature, FeaturesPluginStart } from '../../../../features/public';
import { isReservedSpace } from '../../../common';
import { Space } from '../../../common/model/space';
@@ -40,6 +40,8 @@ interface Props {
onLoadSpace?: (space: Space) => void;
capabilities: Capabilities;
securityEnabled: boolean;
+ history: ScopedHistory;
+ getUrlForApp: ApplicationStart['getUrlForApp'];
}
interface State {
@@ -154,6 +156,7 @@ export class ManageSpacePage extends Component {
space={this.state.space}
features={this.state.features}
onChange={this.onSpaceChange}
+ getUrlForApp={this.props.getUrlForApp}
securityEnabled={this.props.securityEnabled}
/>
@@ -195,7 +198,7 @@ export class ManageSpacePage extends Component {
public maybeGetSecureSpacesMessage = () => {
if (this.editingExistingSpace() && this.props.securityEnabled) {
- return ;
+ return ;
}
return null;
};
@@ -387,7 +390,9 @@ export class ManageSpacePage extends Component {
}
)
);
- window.location.hash = `#/management/kibana/spaces`;
+
+ this.backToSpacesList();
+
if (requireRefresh) {
setTimeout(() => {
window.location.reload();
@@ -408,9 +413,7 @@ export class ManageSpacePage extends Component {
});
};
- private backToSpacesList = () => {
- window.location.hash = `#/management/kibana/spaces`;
- };
+ private backToSpacesList = () => this.props.history.push('/');
private editingExistingSpace = () => !!this.props.spaceId;
}
diff --git a/x-pack/plugins/spaces/public/management/spaces_grid/__snapshots__/spaces_grid_pages.test.tsx.snap b/x-pack/plugins/spaces/public/management/spaces_grid/__snapshots__/spaces_grid_pages.test.tsx.snap
index aa6db7e22fd5d..200c9c55a4f7c 100644
--- a/x-pack/plugins/spaces/public/management/spaces_grid/__snapshots__/spaces_grid_pages.test.tsx.snap
+++ b/x-pack/plugins/spaces/public/management/spaces_grid/__snapshots__/spaces_grid_pages.test.tsx.snap
@@ -39,7 +39,7 @@ exports[`SpacesGridPage renders as expected 1`] = `
>
-
+
`;
diff --git a/x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_page.tsx b/x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_page.tsx
index df5e6a2ca34af..014684704710a 100644
--- a/x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_page.tsx
+++ b/x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_page.tsx
@@ -20,7 +20,7 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
-import { Capabilities, NotificationsStart } from 'src/core/public';
+import { ApplicationStart, Capabilities, NotificationsStart, ScopedHistory } from 'src/core/public';
import { Feature, FeaturesPluginStart } from '../../../../features/public';
import { isReservedSpace } from '../../../common';
import { DEFAULT_SPACE_ID } from '../../../common/constants';
@@ -32,6 +32,7 @@ import { ConfirmDeleteModal } from '../components/confirm_delete_modal';
import { SecureSpaceMessage } from '../components/secure_space_message';
import { UnauthorizedPrompt } from '../components/unauthorized_prompt';
import { getEnabledFeatures } from '../lib/feature_utils';
+import { reactRouterNavigate } from '../../../../../../src/plugins/kibana_react/public';
interface Props {
spacesManager: SpacesManager;
@@ -39,6 +40,8 @@ interface Props {
getFeatures: FeaturesPluginStart['getFeatures'];
capabilities: Capabilities;
securityEnabled: boolean;
+ history: ScopedHistory;
+ getUrlForApp: ApplicationStart['getUrlForApp'];
}
interface State {
@@ -71,7 +74,9 @@ export class SpacesGridPage extends Component {
return (
{this.getPageContent()}
- {this.props.securityEnabled && }
+ {this.props.securityEnabled && (
+
+ )}
{this.getConfirmDeleteModal()}
);
@@ -137,7 +142,7 @@ export class SpacesGridPage extends Component {
public getPrimaryActionButton() {
return (
-
+
{
name: '',
width: '50px',
render: (value: string, record: Space) => (
-
+
),
@@ -258,7 +263,9 @@ export class SpacesGridPage extends Component {
}),
sortable: true,
render: (value: string, record: Space) => (
- {value}
+
+ {value}
+
),
},
{
@@ -338,7 +345,7 @@ export class SpacesGridPage extends Component {
)}
color={'primary'}
iconType={'pencil'}
- href={this.getEditSpacePath(record)}
+ {...reactRouterNavigate(this.props.history, this.getEditSpacePath(record))}
/>
),
},
@@ -364,9 +371,7 @@ export class SpacesGridPage extends Component {
];
}
- private getEditSpacePath = (space: Space) => {
- return `#/management/kibana/spaces/edit/${encodeURIComponent(space.id)}`;
- };
+ private getEditSpacePath = (space: Space) => `edit/${encodeURIComponent(space.id)}`;
private onDeleteSpaceClick = (space: Space) => {
this.setState({
diff --git a/x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_pages.test.tsx b/x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_pages.test.tsx
index 9b7dc921b9a25..1868823823a1a 100644
--- a/x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_pages.test.tsx
+++ b/x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_pages.test.tsx
@@ -5,12 +5,13 @@
*/
import React from 'react';
+import { ScopedHistory } from 'kibana/public';
import { mountWithIntl, shallowWithIntl, nextTick } from 'test_utils/enzyme_helpers';
import { SpaceAvatar } from '../../space_avatar';
import { spacesManagerMock } from '../../spaces_manager/mocks';
import { SpacesManager } from '../../spaces_manager';
import { SpacesGridPage } from './spaces_grid_page';
-import { httpServiceMock } from 'src/core/public/mocks';
+import { httpServiceMock, scopedHistoryMock } from 'src/core/public/mocks';
import { notificationServiceMock } from 'src/core/public/mocks';
import { featuresPluginMock } from '../../../../features/public/mocks';
import { Feature } from '../../../../features/public';
@@ -52,6 +53,9 @@ featuresStart.getFeatures.mockResolvedValue([
]);
describe('SpacesGridPage', () => {
+ const getUrlForApp = (appId: string) => appId;
+ const history = (scopedHistoryMock.create() as unknown) as ScopedHistory;
+
it('renders as expected', () => {
const httpStart = httpServiceMock.createStartContract();
httpStart.get.mockResolvedValue([]);
@@ -63,6 +67,8 @@ describe('SpacesGridPage', () => {
getFeatures={featuresStart.getFeatures}
notifications={notificationServiceMock.createStartContract()}
securityEnabled={true}
+ getUrlForApp={getUrlForApp}
+ history={history}
capabilities={{
navLinks: {},
management: {},
@@ -84,6 +90,8 @@ describe('SpacesGridPage', () => {
getFeatures={featuresStart.getFeatures}
notifications={notificationServiceMock.createStartContract()}
securityEnabled={true}
+ getUrlForApp={getUrlForApp}
+ history={history}
capabilities={{
navLinks: {},
management: {},
@@ -116,6 +124,8 @@ describe('SpacesGridPage', () => {
getFeatures={featuresStart.getFeatures}
notifications={notifications}
securityEnabled={true}
+ getUrlForApp={getUrlForApp}
+ history={history}
capabilities={{
navLinks: {},
management: {},
@@ -149,6 +159,8 @@ describe('SpacesGridPage', () => {
getFeatures={() => Promise.reject(error)}
notifications={notifications}
securityEnabled={true}
+ getUrlForApp={getUrlForApp}
+ history={history}
capabilities={{
navLinks: {},
management: {},
diff --git a/x-pack/plugins/spaces/public/management/spaces_management_app.tsx b/x-pack/plugins/spaces/public/management/spaces_management_app.tsx
index 9216cc31ee77c..050babdbc7b19 100644
--- a/x-pack/plugins/spaces/public/management/spaces_management_app.tsx
+++ b/x-pack/plugins/spaces/public/management/spaces_management_app.tsx
@@ -42,7 +42,7 @@ export const spacesManagementApp = Object.freeze({
text: i18n.translate('xpack.spaces.management.breadcrumb', {
defaultMessage: 'Spaces',
}),
- href: `#${basePath}`,
+ href: `/`,
},
];
@@ -54,6 +54,8 @@ export const spacesManagementApp = Object.freeze({
getFeatures={features.getFeatures}
notifications={notifications}
spacesManager={spacesManager}
+ history={history}
+ getUrlForApp={application.getUrlForApp}
securityEnabled={securityLicense?.getFeatures().showLinks ?? false}
/>
);
@@ -75,6 +77,8 @@ export const spacesManagementApp = Object.freeze({
getFeatures={features.getFeatures}
notifications={notifications}
spacesManager={spacesManager}
+ history={history}
+ getUrlForApp={application.getUrlForApp}
securityEnabled={securityLicense?.getFeatures().showLinks ?? false}
/>
);
@@ -88,7 +92,7 @@ export const spacesManagementApp = Object.freeze({
...spacesBreadcrumbs,
{
text: space.name,
- href: `#${basePath}/edit/${encodeURIComponent(space.id)}`,
+ href: `/edit/${encodeURIComponent(space.id)}`,
},
]);
};
@@ -101,6 +105,8 @@ export const spacesManagementApp = Object.freeze({
spacesManager={spacesManager}
spaceId={spaceId}
onLoadSpace={onLoadSpace}
+ history={history}
+ getUrlForApp={application.getUrlForApp}
securityEnabled={securityLicense?.getFeatures().showLinks ?? false}
/>
);
diff --git a/x-pack/plugins/spaces/public/nav_control/components/manage_spaces_button.tsx b/x-pack/plugins/spaces/public/nav_control/components/manage_spaces_button.tsx
index 456b7b0189a75..98467ebdb790b 100644
--- a/x-pack/plugins/spaces/public/nav_control/components/manage_spaces_button.tsx
+++ b/x-pack/plugins/spaces/public/nav_control/components/manage_spaces_button.tsx
@@ -46,6 +46,6 @@ export class ManageSpacesButton extends Component {
this.props.onClick();
}
- this.props.navigateToApp('kibana', { path: '#/management/kibana/spaces' });
+ this.props.navigateToApp('management', { path: 'kibana/spaces' });
};
}
From d49c9f9b2193417f3db6b21b888c441afce03e40 Mon Sep 17 00:00:00 2001
From: Alexey Antonov
Date: Thu, 21 May 2020 15:56:27 +0300
Subject: [PATCH 23/93] fix functional test
---
.../scripted_fields_table/components/header/header.tsx | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/plugins/index_pattern_management/public/components/edit_index_pattern/scripted_fields_table/components/header/header.tsx b/src/plugins/index_pattern_management/public/components/edit_index_pattern/scripted_fields_table/components/header/header.tsx
index dc48f61d1aa65..e432b9b466367 100644
--- a/src/plugins/index_pattern_management/public/components/edit_index_pattern/scripted_fields_table/components/header/header.tsx
+++ b/src/plugins/index_pattern_management/public/components/edit_index_pattern/scripted_fields_table/components/header/header.tsx
@@ -22,9 +22,13 @@ import { withRouter, RouteComponentProps } from 'react-router-dom';
import { EuiButton, EuiFlexGroup, EuiFlexItem, EuiText, EuiTitle } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
+import { ScopedHistory } from 'kibana/public';
+
+import { reactRouterNavigate } from '../../../../../../../kibana_react/public';
interface HeaderProps extends RouteComponentProps {
indexPatternId: string;
+ history: ScopedHistory;
}
export const Header = withRouter(({ indexPatternId, history }: HeaderProps) => (
@@ -52,9 +56,7 @@ export const Header = withRouter(({ indexPatternId, history }: HeaderProps) => (
{
- history.push(`${indexPatternId}/create-field/`);
- }}
+ {...reactRouterNavigate(history, `patterns/${indexPatternId}/create-field/`)}
>
Date: Thu, 21 May 2020 16:23:18 +0300
Subject: [PATCH 24/93] [role_management] fix Breadcrumbs
---
.../security/public/management/roles/roles_management_app.tsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/x-pack/plugins/security/public/management/roles/roles_management_app.tsx b/x-pack/plugins/security/public/management/roles/roles_management_app.tsx
index 1e6f720c7ce71..596f95a78bdfd 100644
--- a/x-pack/plugins/security/public/management/roles/roles_management_app.tsx
+++ b/x-pack/plugins/security/public/management/roles/roles_management_app.tsx
@@ -31,7 +31,7 @@ export const rolesManagementApp = Object.freeze({
const rolesBreadcrumbs = [
{
text: i18n.translate('xpack.security.roles.breadcrumb', { defaultMessage: 'Roles' }),
- href: `#${basePath}`,
+ href: `/`,
},
];
@@ -74,7 +74,7 @@ export const rolesManagementApp = Object.freeze({
setBreadcrumbs([
...rolesBreadcrumbs,
action === 'edit' && roleName
- ? { text: roleName, href: `#${basePath}/edit/${encodeURIComponent(roleName)}` }
+ ? { text: roleName, href: `/edit/${encodeURIComponent(roleName)}` }
: {
text: i18n.translate('xpack.security.roles.createBreadcrumb', {
defaultMessage: 'Create',
From 57cfa836586b8fb543639e99b147fff342dd78bc Mon Sep 17 00:00:00 2001
From: Alexey Antonov
Date: Thu, 21 May 2020 18:01:13 +0300
Subject: [PATCH 25/93] [api_keys] fix Breadcrumbs and Navigation
---
.../components/header/header.test.tsx | 3 ++-
.../api_keys_grid/api_keys_grid_page.test.tsx | 1 +
.../api_keys/api_keys_grid/api_keys_grid_page.tsx | 9 +++++++--
.../api_keys_grid/empty_prompt/empty_prompt.tsx | 11 +++++++++--
.../api_keys/api_keys_management_app.test.tsx | 2 +-
.../management/api_keys/api_keys_management_app.tsx | 7 ++++---
6 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/src/plugins/index_pattern_management/public/components/edit_index_pattern/scripted_fields_table/components/header/header.test.tsx b/src/plugins/index_pattern_management/public/components/edit_index_pattern/scripted_fields_table/components/header/header.test.tsx
index 11fdae39aee3c..75a3baad11b30 100644
--- a/src/plugins/index_pattern_management/public/components/edit_index_pattern/scripted_fields_table/components/header/header.test.tsx
+++ b/src/plugins/index_pattern_management/public/components/edit_index_pattern/scripted_fields_table/components/header/header.test.tsx
@@ -20,6 +20,7 @@
import React from 'react';
import { render } from 'enzyme';
import { RouteComponentProps } from 'react-router-dom';
+import { ScopedHistory } from 'kibana/public';
import { Header } from './header';
@@ -28,7 +29,7 @@ describe('Header', () => {
const component = render(
diff --git a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.test.tsx b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.test.tsx
index dea04a0eac396..e3efedbe8226a 100644
--- a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.test.tsx
+++ b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.test.tsx
@@ -67,6 +67,7 @@ describe('APIKeysGridPage', () => {
const getViewProperties = () => {
const { docLinks, notifications } = coreMock.createStart();
return {
+ getUrlForApp: (id: string) => id,
docLinks: new DocumentationLinksService(docLinks),
notifications,
apiKeysAPIClient: apiClientMock,
diff --git a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.tsx b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.tsx
index 9db09a34d3c3f..548ce21e30ff2 100644
--- a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.tsx
+++ b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.tsx
@@ -26,7 +26,7 @@ import {
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import moment from 'moment-timezone';
-import { NotificationsStart } from 'src/core/public';
+import { ApplicationStart, NotificationsStart } from 'src/core/public';
import { SectionLoading } from '../../../../../../../src/plugins/es_ui_shared/public';
import { ApiKey, ApiKeyToInvalidate } from '../../../../common/model';
import { APIKeysAPIClient } from '../api_keys_api_client';
@@ -40,6 +40,7 @@ interface Props {
notifications: NotificationsStart;
docLinks: DocumentationLinksService;
apiKeysAPIClient: PublicMethodsOf;
+ getUrlForApp: ApplicationStart['getUrlForApp'];
}
interface State {
@@ -137,7 +138,11 @@ export class APIKeysGridPage extends Component {
if (!isLoadingTable && apiKeys && apiKeys.length === 0) {
return (
-
+
);
}
diff --git a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/empty_prompt/empty_prompt.tsx b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/empty_prompt/empty_prompt.tsx
index ef1ac40ca4b32..b688a017e4540 100644
--- a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/empty_prompt/empty_prompt.tsx
+++ b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/empty_prompt/empty_prompt.tsx
@@ -5,6 +5,8 @@
*/
import React, { Fragment } from 'react';
+import { ApplicationStart } from 'kibana/public';
+
import { EuiEmptyPrompt, EuiButton, EuiLink } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { DocumentationLinksService } from '../../documentation_links';
@@ -12,9 +14,14 @@ import { DocumentationLinksService } from '../../documentation_links';
interface Props {
isAdmin: boolean;
docLinks: DocumentationLinksService;
+ getUrlForApp: ApplicationStart['getUrlForApp'];
}
-export const EmptyPrompt: React.FunctionComponent = ({ isAdmin, docLinks }) => (
+export const EmptyPrompt: React.FunctionComponent = ({
+ isAdmin,
+ docLinks,
+ getUrlForApp,
+}) => (
= ({ isAdmin, docLinks
}
actions={
-
+
{
});
expect(setBreadcrumbs).toHaveBeenCalledTimes(1);
- expect(setBreadcrumbs).toHaveBeenCalledWith([{ href: '#/some-base-path', text: 'API Keys' }]);
+ expect(setBreadcrumbs).toHaveBeenCalledWith([{ href: '/', text: 'API Keys' }]);
expect(container).toMatchInlineSnapshot(`