Skip to content

Commit 31317ab

Browse files
committed
feat(sidemenu): add limit for shown organizations
1 parent e204c30 commit 31317ab

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

public/app/core/components/sidemenu/sidemenu.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
{{::menuItem.text}}
2323
</a>
2424
</li>
25-
<li><input ng-model="::ctrl.orgFilter" type="text" ng-change="::ctrl.loadOrgsItems();" class="gf-form-input" placeholder="Filter"></li>
25+
<li ng-show="ctrl.orgs.length > ctrl.maxShownOrgs">
26+
<input ng-model="::ctrl.orgFilter" type="text" ng-change="::ctrl.loadOrgsItems();" class="gf-input-small" placeholder="Filter">
27+
<span class="sidemenu-item-text">Max shown : {{::ctrl.maxShownOrgs}}</span>
28+
</li>
2629
<li ng-repeat="orgItem in ctrl.orgItems" ng-class="::orgItem.cssClass">
2730
<a href="{{::orgItem.url}}" ng-show="::orgItem.url" target="{{::orgItem.target}}">
2831
<i class="{{::orgItem.icon}}" ng-show="::orgItem.icon"></i>

public/app/core/components/sidemenu/sidemenu.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ export class SideMenuCtrl {
1515
orgFilter: string;
1616
orgItems: any;
1717
orgs: any;
18+
maxShownOrgs: number;
1819

1920
/** @ngInject */
2021
constructor(private $scope, private $location, private contextSrv, private backendSrv, private $element) {
2122
this.isSignedIn = contextSrv.isSignedIn;
2223
this.user = contextSrv.user;
2324
this.appSubUrl = config.appSubUrl;
2425
this.showSignout = this.contextSrv.isSignedIn && !config['authProxyEnabled'];
25-
26+
this.maxShownOrgs = 10;
2627

2728
this.mainLinks = config.bootData.mainNavLinks;
2829
this.openUserDropdown();
@@ -79,7 +80,7 @@ export class SideMenuCtrl {
7980
return;
8081
}
8182

82-
if (this.orgFilter === '' || org.name.indexOf(this.orgFilter) !== -1){
83+
if (this.orgItems.length < this.maxShownOrgs && (this.orgFilter === '' || org.name.indexOf(this.orgFilter) !== -1)){
8384
this.orgItems.push({
8485
text: "Switch to " + org.name,
8586
icon: "fa fa-fw fa-random",

0 commit comments

Comments
 (0)