Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[es-management] implement k7Breadcrumbs #26711

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions x-pack/plugins/index_management/public/register_routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ 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';

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';
Expand All @@ -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) {
Expand Down
32 changes: 32 additions & 0 deletions x-pack/plugins/license_management/public/breadcrumbs.js
Original file line number Diff line number Diff line change
@@ -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'
})
}
];
}
13 changes: 12 additions & 1 deletion x-pack/plugins/license_management/public/register_route.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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(
Expand All @@ -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;
}
Expand All @@ -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 {

Expand Down