Skip to content
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
49 changes: 49 additions & 0 deletions x-pack/plugins/watcher/public/lib/breadcrumbs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* 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 chrome from 'ui/chrome';
import { i18n } from '@kbn/i18n';

import { MANAGEMENT_BREADCRUMB } from 'ui/management';

const uiSettings = chrome.getUiSettingsClient();

export function getWatchListBreadcrumbs() {
return [
MANAGEMENT_BREADCRUMB,
{
text: i18n.translate('xpack.watcher.list.breadcrumb', {
defaultMessage: 'Watcher'
}),
href: '#/management/elasticsearch/watcher/watches/'
}
];
}

export function getWatchDetailBreadcrumbs($route) {
const watch = $route.current.locals.watch || $route.current.locals.xpackWatch;

return [
...getWatchListBreadcrumbs(),
{
text: !watch.isNew
? watch.name
: i18n.translate('xpack.watcher.create.breadcrumb', { defaultMessage: 'Create' }),
href: '#/management/elasticsearch/watcher/watches/watch/23eebf28-94fd-47e9-ac44-6fee6e427c33'
}
];
}

export function getWatchHistoryBreadcrumbs($route) {
const { watchHistoryItem } = $route.current.locals;

return [
...getWatchDetailBreadcrumbs($route),
{
text: watchHistoryItem.startTime.format(uiSettings.get('dateFormat'))
}
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import './components/watch_detail';
import { WATCH_HISTORY } from '../../../common/constants';
import { updateWatchSections } from 'plugins/watcher/lib/update_management_sections';
import 'plugins/watcher/services/license';
import { getWatchDetailBreadcrumbs } from '../../lib/breadcrumbs';

routes
.when('/management/elasticsearch/watcher/watches/watch/:id', {
Expand All @@ -22,6 +23,7 @@ routes
routes
.when('/management/elasticsearch/watcher/watches/watch/:id/status', {
template: template,
k7Breadcrumbs: getWatchDetailBreadcrumbs,
resolve: {
watchTabs: ($injector) => {
const $route = $injector.get('$route');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ import './components/threshold_watch_edit';
import { WATCH_TYPES } from 'plugins/watcher/../common/constants';
import { updateWatchSections } from 'plugins/watcher/lib/update_management_sections';
import 'plugins/watcher/services/license';
import { getWatchDetailBreadcrumbs } from '../../lib/breadcrumbs';

routes
.when('/management/elasticsearch/watcher/watches/watch/:id/edit')
.when('/management/elasticsearch/watcher/watches/new-watch/:watchType')
.defaults(/management\/elasticsearch\/watcher\/watches\/(new-watch\/:watchType|watch\/:id\/edit)/, {
template: template,
k7Breadcrumbs: getWatchDetailBreadcrumbs,
controller: class WatchEditRouteController {
constructor($injector) {
const $route = $injector.get('$route');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ import 'plugins/watcher/services/watch';
import 'plugins/watcher/services/watch_history';
import './components/watch_history_item';
import { updateHistorySection } from 'plugins/watcher/lib/update_management_sections';
import { getWatchHistoryBreadcrumbs } from '../../lib/breadcrumbs';

routes
.when('/management/elasticsearch/watcher/watches/watch/:watchId/history-item/:watchHistoryItemId', {
template: template,
k7Breadcrumbs: getWatchHistoryBreadcrumbs,
resolve: {
watch: function ($injector) {
const $route = $injector.get('$route');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { toastNotifications } from 'ui/notify';
import template from './watch_list_route.html';
import './components/watch_list';
import 'plugins/watcher/services/license';
import { getWatchListBreadcrumbs } from '../../lib/breadcrumbs';

routes
.when('/management/elasticsearch/watcher/', {
Expand All @@ -26,6 +27,7 @@ routes
}
},
controllerAs: 'watchListRoute',
k7Breadcrumbs: getWatchListBreadcrumbs,
resolve: {
watches: ($injector) => {
const watchesService = $injector.get('xpackWatcherWatchesService');
Expand Down