---------

**Commit 1:**
[chrome/nav] allow link properties to change over time

The current implementation uses Array#filter() to produce a list of "shown links", this changes it to a live filter with `ng-if` that will update the view, should the hidden property of the link change over time

* Original sha: e80ad49653
* Authored by spalger <email@spalger.com> on 2016-10-25T20:23:38Z
This commit is contained in:
Elastic Jasper 2016-10-25 18:58:45 -04:00
parent 9e7afe57cb
commit 32432d5bd8
2 changed files with 5 additions and 15 deletions

View file

@ -1,8 +1,9 @@
<global-nav-link
ng-repeat="link in switcher.shownNavLinks"
ng-repeat="link in switcher.links"
ng-if="!link.hidden"
is-active="link.active"
is-disabled="!switcher.isNavLinkEnabled(link)"
is-disabled="link.disabled"
tooltip-content="switcher.getTooltip(link)"
on-click="switcher.ensureNavigation($event, link)"
href="link.active ? link.url : (link.lastSubUrl || link.url)"

View file

@ -4,14 +4,6 @@ import { bindKey } from 'lodash';
import uiModules from 'ui/modules';
import appSwitcherTemplate from './app_switcher.html';
function isNavLinkEnabled(link) {
return !link.disabled;
}
function isNavLinkShown(link) {
return !link.hidden;
}
uiModules
.get('kibana')
.provider('appSwitcherEnsureNavigation', function () {
@ -25,7 +17,7 @@ uiModules
const domLocation = Private(DomLocationProvider);
return function (event, link) {
if (!isNavLinkEnabled(link)) {
if (link.disabled) {
event.preventDefault();
}
@ -64,10 +56,7 @@ uiModules
throw new TypeError('appSwitcher directive requires the "chrome" config-object');
}
this.isNavLinkEnabled = isNavLinkEnabled;
const allNavLinks = $scope.chrome.getNavLinks();
this.shownNavLinks = allNavLinks.filter(isNavLinkShown);
this.links = $scope.chrome.getNavLinks();
// links don't cause full-navigation events in certain scenarios
// so we force them when needed