Rename Side Nav Link title and href attributes to label and url. (#10661)

Backports PR #10660

**Commit 1:**
Rename Side Nav Link title and href attributes to label and url.

* Original sha: 651a015fba
* Authored by CJ Cenizal <cj@cenizal.com> on 2017-03-02T18:41:01Z

**Commit 2:**
Fix test.

* Original sha: 05e3414021
* Authored by CJ Cenizal <cj@cenizal.com> on 2017-03-02T19:38:42Z
This commit is contained in:
jasper 2017-03-02 15:54:50 -05:00 committed by CJ Cenizal
parent 6b955f6910
commit 48e0046173
5 changed files with 13 additions and 33 deletions

View file

@ -1,4 +1,3 @@
<global-nav-link
ng-repeat="link in switcher.links"
ng-if="!link.hidden"
@ -6,7 +5,7 @@
is-disabled="link.disabled"
tooltip-content="switcher.getTooltip(link)"
on-click="switcher.ensureNavigation($event, link)"
href="link.active ? link.url : (link.lastSubUrl || link.url)"
url="link.active ? link.url : (link.lastSubUrl || link.url)"
icon="link.icon"
title="link.title"
label="link.title"
></global-nav-link>

View file

@ -46,7 +46,7 @@
tooltip-content="globalNavToggleButton.tooltipContent"
on-click="toggleGlobalNav($event)"
icon="'plugins/kibana/assets/play-circle.svg'"
title="globalNavToggleButton.title"
label="globalNavToggleButton.title"
></global-nav-link>
</div>
</div>

View file

@ -24,10 +24,10 @@ describe('globalNavLink directive', () => {
is-disabled="isDisabled"
tooltip-content="tooltipContent"
on-click="onClick()"
href="href"
url="href"
kbn-route="kbnRoute"
icon="icon"
title="title"
label="title"
/>
`;
@ -187,25 +187,5 @@ describe('globalNavLink directive', () => {
});
});
});
describe('title attribute', () => {
it('is displayed', () => {
const attrs = {
title: 'demo title',
};
const element = create(attrs);
const title = element.find('.global-nav-link__title');
expect(title.text().trim()).to.be(attrs.title);
});
it('is set as a title attribute on the anchor tag', () => {
const attrs = {
title: 'demo title',
};
const element = create(attrs);
const link = element.find('[data-test-subj=appLink]');
expect(link.attr('title')).to.be(attrs.title);
});
});
});
});

View file

@ -11,13 +11,14 @@
href="{{ getHref() }}"
ng-click="onClick({ $event: $event })"
data-test-subj="appLink"
title="{{ title }}"
>
<div class="global-nav-link__icon">
<!-- Empty alt attribute is for accessibility -->
<img
ng-if="icon"
class="global-nav-link__icon-image"
kbn-src="{{ '/' + icon }}"
alt=""
>
<span
@ -25,12 +26,12 @@
class="global-nav-link__icon-placeholder"
data-test-subj="appLinkIconPlaceholder"
>
{{ title[0] }}
{{ label[0] }}
</span>
</div>
<div class="global-nav-link__title">
{{ title }}
{{ label }}
</div>
</a>
</div>

View file

@ -14,16 +14,16 @@ module.directive('globalNavLink', chrome => {
isDisabled: '=',
tooltipContent: '=',
onClick: '&',
href: '=',
url: '=',
kbnRoute: '=',
icon: '=',
title: '=',
label: '=',
},
template: globalNavLinkTemplate,
link: scope => {
scope.getHref = () => {
if (scope.href) {
return scope.href;
if (scope.url) {
return scope.url;
}
if (scope.kbnRoute) {