Allow setting a class for top nav items (#30103)

This commit is contained in:
Tim Roes 2019-02-06 11:12:56 +01:00 committed by GitHub
parent d64648641b
commit 8b8f4c50df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View file

@ -81,6 +81,9 @@ function getEditConfig(action) {
defaultMessage: 'Switch to edit mode',
}),
testId: 'dashboardEditMode',
// We want to hide the "edit" button on small screens, since those have a responsive
// layout, which is not tied to the grid anymore, so we cannot edit the grid on that screens.
className: 'eui-hideFor--s eui-hideFor--xs',
run: action
};
}

View file

@ -72,4 +72,17 @@ describe('kbnTopNav directive', function () {
const { $scope } = build({ controller }, { config: 'controller' });
expect($scope.kbnTopNav).to.be(controller);
});
it('should allow setting CSS classes via className', () => {
const scope = {
config: [
{ key: 'foo', testId: 'foo', className: 'fooClass' },
{ key: 'test', testId: 'test', className: 'class1 class2' },
],
};
const { $el } = build(scope, { config: 'config' });
expect($el.find('[data-test-subj="foo"]').hasClass('fooClass')).to.be(true);
expect($el.find('[data-test-subj="test"]').hasClass('class1')).to.be(true);
expect($el.find('[data-test-subj="test"]').hasClass('class2')).to.be(true);
});
});

View file

@ -11,7 +11,7 @@
<div class="kuiLocalMenu kbnTopNav__mainMenu" ng-if="kbnTopNav.menuItems.length">
<button
class="kuiLocalMenuItem"
class="kuiLocalMenuItem {{menuItem.className}}"
ng-repeat="menuItem in kbnTopNav.menuItems"
aria-label="{{::menuItem.description}}"
aria-haspopup="{{!menuItem.hasFunction}}"