Skip to content

Commit

Permalink
Closes #2950
Browse files Browse the repository at this point in the history
Add setting to disable displaying role tags
  • Loading branch information
marceloschmidt committed Apr 25, 2016
1 parent c6ad7dc commit 0842d5f
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Meteor.methods
if not user?._id?
throw new Meteor.Error 'error-invalid-user', 'Invalid user', { method: 'authorization:addUserToRole' }

RocketChat.Notifications.notifyAll('roles-change', { type: 'added', _id: roleName, u: { _id: user._id, username: username }, scope: scope });
if RocketChat.settings.get('UI_DisplayRoles')
RocketChat.Notifications.notifyAll('roles-change', { type: 'added', _id: roleName, u: { _id: user._id, username: username }, scope: scope });

return RocketChat.models.Roles.addUserRoles user._id, roleName, scope
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Meteor.methods
if not user?._id?
throw new Meteor.Error 'error-invalid-user', 'Invalid user', { method: 'authorization:removeUserFromRole' }

RocketChat.Notifications.notifyAll('roles-change', { type: 'removed', _id: roleName, u: { _id: user._id, username: username }, scope: scope });
if RocketChat.settings.get('UI_DisplayRoles')
RocketChat.Notifications.notifyAll('roles-change', { type: 'removed', _id: roleName, u: { _id: user._id, username: username }, scope: scope });

return RocketChat.models.Roles.removeUserRoles user._id, roleName, scope
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Meteor.methods
if roleData.scope not in ['Users', 'Subscriptions']
roleData.scope = 'Users'

RocketChat.Notifications.notifyAll('roles-change', { type: 'changed', _id: roleData.name });
if RocketChat.settings.get('UI_DisplayRoles')
RocketChat.Notifications.notifyAll('roles-change', { type: 'changed', _id: roleData.name });

return RocketChat.models.Roles.createOrUpdate roleData.name, roleData.scope, roleData.description
1 change: 1 addition & 0 deletions packages/rocketchat-lib/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,7 @@
"True" : "True",
"Type" : "Type",
"Type_your_new_password" : "Type your new password",
"UI_DisplayRoles" : "Display Roles",
"Unarchive" : "Unarchive",
"Unmute_someone_in_room" : "Unmute someone in the room",
"Unmute_user" : "Unmute user",
Expand Down
3 changes: 3 additions & 0 deletions packages/rocketchat-lib/server/startup/settings.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ RocketChat.settings.addGroup 'Layout', ->
@add 'Custom_Script_Logged_Out', '//Add your script', { type: 'code', multiline: true, public: true }
@add 'Custom_Script_Logged_In', '//Add your script', { type: 'code', multiline: true, public: true }

@section 'User Interface', ->
@add 'UI_DisplayRoles', true, { type: 'boolean', public: true }


RocketChat.settings.addGroup 'Logs', ->
@add 'Debug_Level', 'error', { type: 'select', values: [ { key: 'error', i18nLabel: 'Only_errors' }, { key: 'debug', i18nLabel: 'All_logs' } ] }
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-ui-message/message/message.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ Template.message.helpers
isBot: ->
return 'bot' if this.bot?
roleTags: ->
unless RocketChat.settings.get('UI_DisplayRoles')
return []
roles = _.union(UserRoles.findOne(this.u?._id)?.roles, RoomRoles.findOne({'u._id': this.u?._id, rid: this.rid })?.roles)
return _.compact(_.map(roles, (role) -> return RocketChat.models.Roles.findOne({ _id: role, description: { $exists: 1 } })?.description));
isGroupable: ->
Expand Down
3 changes: 2 additions & 1 deletion server/methods/addRoomModerator.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Meteor.methods
username: fromUser.username
role: 'moderator'

RocketChat.Notifications.notifyAll('roles-change', { type: 'added', _id: 'moderator', u: { _id: user._id, username: user.username }, scope: rid });
if RocketChat.settings.get('UI_DisplayRoles')
RocketChat.Notifications.notifyAll('roles-change', { type: 'added', _id: 'moderator', u: { _id: user._id, username: user.username }, scope: rid });

return true
3 changes: 2 additions & 1 deletion server/methods/addRoomOwner.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Meteor.methods
username: fromUser.username
role: 'owner'

RocketChat.Notifications.notifyAll('roles-change', { type: 'added', _id: 'owner', u: { _id: user._id, username: user.username }, scope: rid });
if RocketChat.settings.get('UI_DisplayRoles')
RocketChat.Notifications.notifyAll('roles-change', { type: 'added', _id: 'owner', u: { _id: user._id, username: user.username }, scope: rid });

return true
3 changes: 2 additions & 1 deletion server/methods/removeRoomModerator.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Meteor.methods
username: fromUser.username
role: 'moderator'

RocketChat.Notifications.notifyAll('roles-change', { type: 'removed', _id: 'moderator', u: { _id: user._id, username: user.username }, scope: rid });
if RocketChat.settings.get('UI_DisplayRoles')
RocketChat.Notifications.notifyAll('roles-change', { type: 'removed', _id: 'moderator', u: { _id: user._id, username: user.username }, scope: rid });

return true
3 changes: 2 additions & 1 deletion server/methods/removeRoomOwner.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Meteor.methods
username: fromUser.username
role: 'owner'

RocketChat.Notifications.notifyAll('roles-change', { type: 'removed', _id: 'owner', u: { _id: user._id, username: user.username }, scope: rid });
if RocketChat.settings.get('UI_DisplayRoles')
RocketChat.Notifications.notifyAll('roles-change', { type: 'removed', _id: 'owner', u: { _id: user._id, username: user.username }, scope: rid });

return true

0 comments on commit 0842d5f

Please sign in to comment.