diff --git a/modules/articles/client/config/articles.client.config.js b/modules/articles/client/config/articles.client.config.js index 5ad71e82dd..fc24f7cd08 100644 --- a/modules/articles/client/config/articles.client.config.js +++ b/modules/articles/client/config/articles.client.config.js @@ -19,7 +19,8 @@ angular.module('articles').run(['Menus', // Add the dropdown create item Menus.addSubMenuItem('topbar', 'articles', { title: 'Create Articles', - state: 'articles.create' + state: 'articles.create', + roles: ['user'] }); } ]); diff --git a/modules/chat/client/config/chat.client.config.js b/modules/chat/client/config/chat.client.config.js index 381ef5d6e3..a3856be798 100644 --- a/modules/chat/client/config/chat.client.config.js +++ b/modules/chat/client/config/chat.client.config.js @@ -6,7 +6,8 @@ angular.module('chat').run(['Menus', // Set top bar menu items Menus.addMenuItem('topbar', { title: 'Chat', - state: 'chat' + state: 'chat', + roles: ['user'] }); } ]); diff --git a/modules/core/client/services/menus.client.service.js b/modules/core/client/services/menus.client.service.js index df9b5eafe2..e681d58ca7 100644 --- a/modules/core/client/services/menus.client.service.js +++ b/modules/core/client/services/menus.client.service.js @@ -11,20 +11,16 @@ angular.module('core').service('Menus', [ // A private function for rendering decision var shouldRender = function (user) { - if (user) { - if (!!~this.roles.indexOf('*')) { - return true; - } else { - for (var userRoleIndex in user.roles) { - for (var roleIndex in this.roles) { - if (this.roles[roleIndex] === user.roles[userRoleIndex]) { - return true; - } + if (!!~this.roles.indexOf('*')) { + return true; + } else { + for (var userRoleIndex in user.roles) { + for (var roleIndex in this.roles) { + if (this.roles[roleIndex] === user.roles[userRoleIndex]) { + return true; } } } - } else { - return this.isPublic; } return false; @@ -60,7 +56,6 @@ angular.module('core').service('Menus', [ // Create the new menu this.menus[menuId] = { - isPublic: ((options.isPublic === null || typeof options.isPublic === 'undefined') ? true : options.isPublic), roles: options.roles || this.defaultRoles, items: options.items || [], shouldRender: shouldRender @@ -92,7 +87,6 @@ angular.module('core').service('Menus', [ state: options.state || '', type: options.type || 'item', class: options.class, - isPublic: ((options.isPublic === null || typeof options.isPublic === 'undefined') ? this.menus[menuId].isPublic : options.isPublic), roles: ((options.roles === null || typeof options.roles === 'undefined') ? this.menus[menuId].roles : options.roles), position: options.position || 0, items: [], @@ -124,7 +118,6 @@ angular.module('core').service('Menus', [ this.menus[menuId].items[itemIndex].items.push({ title: options.title || '', state: options.state || '', - isPublic: ((options.isPublic === null || typeof options.isPublic === 'undefined') ? this.menus[menuId].items[itemIndex].isPublic : options.isPublic), roles: ((options.roles === null || typeof options.roles === 'undefined') ? this.menus[menuId].items[itemIndex].roles : options.roles), position: options.position || 0, shouldRender: shouldRender @@ -171,8 +164,6 @@ angular.module('core').service('Menus', [ }; //Adding the topbar menu - this.addMenu('topbar', { - isPublic: false - }); + this.addMenu('topbar'); } ]); diff --git a/modules/core/tests/client/menus.client.service.tests.js b/modules/core/tests/client/menus.client.service.tests.js index e693eae448..68ad871ff7 100644 --- a/modules/core/tests/client/menus.client.service.tests.js +++ b/modules/core/tests/client/menus.client.service.tests.js @@ -17,10 +17,6 @@ expect(Menus.menus.topbar).toBeDefined(); }); - it('should have private topbar', function() { - expect(Menus.menus.topbar.isPublic).toBeFalsy(); - }); - it('should have default roles to *', function() { expect(Menus.defaultRoles).toEqual(['*']); }); @@ -45,10 +41,6 @@ expect(menu.items).toEqual([]); }); - it('should be public by default', function() { - expect(menu.isPublic).toBeTruthy(); - }); - it('should set shouldRender to shouldRender function handle', function() { expect(menu.shouldRender()).toBeTruthy(); }); @@ -64,17 +56,6 @@ menu = Menus.addMenu('menu1', options); }); - it('should set isPublic to true if options.isPublic equal to null', function() { - var menu = Menus.addMenu('menu1', { - isPublic: null - }); - expect(menu.isPublic).toBeTruthy(); - }); - - it('should set isPublic to true if options.isPublic equal to undefined', function() { - expect(menu.isPublic).toBeTruthy(); - }); - it('should set items to options.items list', function() { expect(menu.items).toBe(options.items); }); @@ -99,12 +80,12 @@ expect(menu.shouldRender()).toBeTruthy(); }); - it('should not render if menu is private', function() { - menu = Menus.addMenu('menu1', { - isPublic: false - }); - expect(menu.shouldRender()).toBeFalsy(); - }); + // it('should not render if menu is private', function() { + // menu = Menus.addMenu('menu1', { + // isPublic: false + // }); + // expect(menu.shouldRender()).toBeFalsy(); + // }); }); describe('when logged in', function() { @@ -250,10 +231,6 @@ expect(menuItem.class).toBe(menuItemOptions.class); }); - it('should set menu item isPublic to options isPublic', function() { - expect(menuItem.isPublic).toBe(menuItemOptions.isPublic); - }); - it('should set menu item position to options position', function() { expect(menuItem.position).toBe(menuItemOptions.position); }); @@ -278,8 +255,8 @@ expect(menuItem.title).toBe(''); }); - it('should set menu item isPublic to menu.isPublic', function() { - expect(menuItem.isPublic).toBe(menu.isPublic); + it('should set menu item isPublic to false', function() { + expect(menuItem.isPublic).toBeFalsy(); }); it('should set menu item roles to menu roles', function() { @@ -393,10 +370,6 @@ expect(menuItem1.items.length).toBe(1); }); - it('should set isPublic to options isPublic', function() { - expect(subMenuItem.isPublic).toBe(subItemOptions.isPublic); - }); - it('should set title to options title', function() { expect(subMenuItem.title).toBe(subItemOptions.title); }); @@ -424,10 +397,6 @@ expect(menuItem2.items.length).toBe(1); }); - it('should set isPublic to parent isPublic', function() { - expect(subMenuItem.isPublic).toBe(menuItem2.isPublic); - }); - it('should set title to blank', function() { expect(subMenuItem.title).toBe(''); });