diff --git a/x-pack/plugins/index_management/public/register_routes.js b/x-pack/plugins/index_management/public/register_routes.js index 02666e81a0b5c..a9623231e57d9 100644 --- a/x-pack/plugins/index_management/public/register_routes.js +++ b/x-pack/plugins/index_management/public/register_routes.js @@ -8,6 +8,7 @@ import React from 'react'; import { render } from 'react-dom'; import { Provider } from 'react-redux'; import { HashRouter } from 'react-router-dom'; +import { i18n } from '@kbn/i18n'; import { I18nProvider } from '@kbn/i18n/react'; import { setHttpClient } from './services/api'; @@ -15,6 +16,7 @@ import { App } from './app'; import { BASE_PATH } from '../common/constants/base_path'; import routes from 'ui/routes'; +import { MANAGEMENT_BREADCRUMB } from 'ui/management'; import template from './main.html'; import { manageAngularLifecycle } from './lib/manage_angular_lifecycle'; @@ -35,6 +37,14 @@ const renderReact = async (elem) => { routes.when(`${BASE_PATH}:view?/:id?`, { template: template, + k7Breadcrumbs: () => [ + MANAGEMENT_BREADCRUMB, + { + text: i18n.translate('xpack.idxMgmt.breadcrumb', { + defaultMessage: 'Index management' + }), + } + ], controllerAs: 'indexManagement', controller: class IndexManagementController { constructor($scope, $route, $http) { diff --git a/x-pack/plugins/license_management/public/breadcrumbs.js b/x-pack/plugins/license_management/public/breadcrumbs.js new file mode 100644 index 0000000000000..0de04f4bd70fc --- /dev/null +++ b/x-pack/plugins/license_management/public/breadcrumbs.js @@ -0,0 +1,32 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { i18n } from '@kbn/i18n'; +import { MANAGEMENT_BREADCRUMB } from 'ui/management'; +import { BASE_PATH } from '../common/constants'; + +export function getDashboardBreadcrumbs() { + return [ + MANAGEMENT_BREADCRUMB, + { + text: i18n.translate('xpack.licenseMgmt.dashboard.breadcrumb', { + defaultMessage: 'License management' + }), + href: `#${BASE_PATH}home` + } + ]; +} + +export function getUploadBreadcrumbs() { + return [ + ...getDashboardBreadcrumbs(), + { + text: i18n.translate('xpack.licenseMgmt.upload.breadcrumb', { + defaultMessage: 'Upload' + }) + } + ]; +} diff --git a/x-pack/plugins/license_management/public/register_route.js b/x-pack/plugins/license_management/public/register_route.js index edb2542f3b1be..99ff1e57b5761 100644 --- a/x-pack/plugins/license_management/public/register_route.js +++ b/x-pack/plugins/license_management/public/register_route.js @@ -10,7 +10,7 @@ import { Provider } from 'react-redux'; import { HashRouter } from 'react-router-dom'; import { setTelemetryOptInService, setTelemetryEnabled, setHttpClient, TelemetryOptInProvider } from './lib/telemetry'; import { I18nProvider } from '@kbn/i18n/react'; - +import chrome from 'ui/chrome'; import App from './app'; import { BASE_PATH } from "../common/constants/base_path"; @@ -20,6 +20,7 @@ import { XPackInfoProvider as xpackInfoProvider } from 'plugins/xpack_main/servi import template from './main.html'; import { licenseManagementStore } from './store'; +import { getDashboardBreadcrumbs, getUploadBreadcrumbs } from './breadcrumbs'; const renderReact = (elem, store) => { render( @@ -44,6 +45,8 @@ const manageAngularLifecycle = ($scope, $route, elem) => { const currentRoute = $route.current; // if templates are the same we are on the same route if (lastRoute.$$route.template === currentRoute.$$route.template) { + // update the breadcrumbs by re-running the k7Breadcrumbs function + chrome.breadcrumbs.set(currentRoute.$$route.k7Breadcrumbs($route)); // this prevents angular from destroying scope $route.current = lastRoute; } @@ -65,6 +68,14 @@ const initializeTelemetry = ($injector) => { routes .when(`${BASE_PATH}:view?`, { template: template, + k7Breadcrumbs($route) { + switch ($route.current.params.view) { + case 'upload_license': + return getUploadBreadcrumbs(); + default: + return getDashboardBreadcrumbs(); + } + }, controllerAs: 'licenseManagement', controller: class LicenseManagementController {