Skip to content

Commit

Permalink
[timelion] implement k7Breadcrumbs (#26729)
Browse files Browse the repository at this point in the history
* [timelion] implement k7Breadcrumbs

* [timelion] show "Create" breadcrumb by default
  • Loading branch information
Spencer authored Dec 6, 2018
1 parent 5111281 commit 2d8026a
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/legacy/core_plugins/timelion/public/_app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@

.timApp__stats {
font-weight: $euiFontWeightRegular;
color: $euiColorMediumShade
}
9 changes: 9 additions & 0 deletions src/legacy/core_plugins/timelion/public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { notify, fatalError, toastNotifications } from 'ui/notify';
import { timezoneProvider } from 'ui/vis/lib/timezone';
import { recentlyAccessed } from 'ui/persisted_log';
import { timefilter } from 'ui/timefilter';
import { getSavedSheetBreadcrumbs, getCreateBreadcrumbs } from './breadcrumbs';

// import the uiExports that we want to "use"
import 'uiExports/fieldFormats';
Expand Down Expand Up @@ -57,6 +58,11 @@ require('ui/routes')
.when('/:id?', {
template: require('plugins/timelion/index.html'),
reloadOnSearch: false,
k7Breadcrumbs: ($injector, $route) => $injector.invoke(
$route.current.params.id
? getSavedSheetBreadcrumbs
: getCreateBreadcrumbs
),
resolve: {
savedSheet: function (redirectWhenMissing, savedSheets, $route) {
return savedSheets.get($route.current.params.id)
Expand All @@ -73,6 +79,9 @@ require('ui/routes')
'search': '/'
}));
}
},
controller($scope, config) {
config.bindToScope($scope, 'k7design');
}
});

Expand Down
48 changes: 48 additions & 0 deletions src/legacy/core_plugins/timelion/public/breadcrumbs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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';

const ROOT_BREADCRUMB = {
text: i18n.translate('timelion.breadcrumbs.root', {
defaultMessage: 'Timelion'
}),
href: '#'
};

export function getCreateBreadcrumbs() {
return [
ROOT_BREADCRUMB,
{
text: i18n.translate('timelion.breadcrumbs.create', {
defaultMessage: 'Create'
}),
}
];
}

export function getSavedSheetBreadcrumbs($route) {
const { savedSheet } = $route.current.locals;
return [
ROOT_BREADCRUMB,
{
text: savedSheet.title,
}
];
}
15 changes: 9 additions & 6 deletions src/legacy/core_plugins/timelion/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
<!-- Transcluded elements. -->
<div data-transclude-slots>
<div data-transclude-slot="topLeftCorner">
<span class="kuiLocalTitle" ng-show="opts.savedSheet.id">
{{opts.savedSheet.lastSavedTitle}}
&nbsp;
<span class="fa fa-bolt" ng-click="showStats = !showStats"></span>
&nbsp;
<span class="timApp__stats" ng-show="showStats">
<span class="kuiLocalTitle">
<span ng-show="opts.savedSheet.id && !k7design">
{{opts.savedSheet.lastSavedTitle}}
&nbsp;
<span class="fa fa-bolt" ng-click="showStats = !showStats"></span>
&nbsp;
</span>

<span class="timApp__stats" ng-show="stats && (showStats || k7design)">
<span
i18n-id="timelion.topNavMenu.statsDescription"
i18n-default-message="Query Time {queryTime}ms / Processing Time {processingTime}ms"
Expand Down

0 comments on commit 2d8026a

Please sign in to comment.