route options to accountBox

pull/1504/head
Diego Sampaio 11 years ago
parent 8dacdd3776
commit 75eaad4b68
  1. 5
      packages/rocketchat-ui-sidenav/side-nav/sideNav.coffee
  2. 2
      packages/rocketchat-ui-sidenav/side-nav/sideNav.html
  3. 36
      packages/rocketchat-ui/lib/accountBox.coffee
  4. 2
      packages/rocketchat-ui/package.js

@ -36,7 +36,10 @@ Template.sideNav.helpers
return RocketChat.authz.hasAtLeastOnePermission( ['view-statistics', 'view-room-administration', 'view-user-administration', 'view-privileged-setting'])
registeredMenus: ->
return AccountBox.getOptions()
return AccountBox.getItems()
itemPath: ->
FlowRouter.path @route.name
Template.sideNav.events
'click .close-flex': ->

@ -21,7 +21,7 @@
<a href="" data-status="offline" class="status offline"><span>{{_ "Invisible"}}</span></a>
<a href="" id="account" class='account-link'><i class="icon-sliders"></i><span>{{_ "My_Account"}}</span></a>
{{#each registeredMenus}}
<a href="" class="{{class}}"><i class="{{icon}}"></i><span>{{name}}</span></a>
<a href="{{itemPath}}" class="{{class}}"><i class="{{icon}}"></i><span>{{name}}</span></a>
{{/each}}
{{#if showAdminOption }}
<a href="" id="admin" class='account-link'><i class="icon-wrench"></i><span>{{_ "Administration"}}</span></a>

@ -1,7 +1,7 @@
@AccountBox = (->
status = 0
self = {}
options = new ReactiveVar []
items = new ReactiveVar []
setStatus = (status) ->
Meteor.call('UserPresence:setDefaultStatus', status)
@ -30,20 +30,25 @@
###
# @param newOption:
# name: Button label
# icon: Button icon
# class: Class of item
# roles: Which roles see this options
# name: Button label
# icon: Button icon
# class: Class of the item
# permissions: Which permissions a user should have (all of them) to see this item
###
addOption = (newOption) ->
addItem = (newItem) ->
Tracker.nonreactive ->
actual = options.get()
actual.push newOption
options.set actual
getOptions = ->
return _.filter options.get(), (option) ->
if not option.roles? or RocketChat.authz.hasRole(Meteor.userId(), option.roles)
actual = items.get()
actual.push newItem
items.set actual
if newItem.route?.path? and newItem.route?.name? and newItem.route?.action?
FlowRouter.route newItem.route.path,
name: newItem.route.name
action: newItem.route.action
getItems = ->
return _.filter items.get(), (item) ->
if not item.permissions? or RocketChat.authz.hasAllPermission item.permissions
return true
setStatus: setStatus
@ -51,6 +56,7 @@
open: open
close: close
init: init
addOption: addOption
getOptions: getOptions
addItem: addItem
getItems: getItems
)()

@ -28,6 +28,8 @@ Package.onUse(function(api) {
'raix:ui-dropped-event'
]);
api.use('kadira:flow-router', 'client');
// LIB FILES
api.addFiles('lib/accountBox.coffee', 'client');
api.addFiles('lib/accounts.coffee', 'client');

Loading…
Cancel
Save