diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json index 7514464264779d7f643f02742bc3f8f6cfaf4153..bacfd3fded4e8b3f660a2064cbe2a284f7609ceb 100644 --- a/i18n/en.i18n.json +++ b/i18n/en.i18n.json @@ -67,6 +67,7 @@ "Activate" : "Activate", "Add_custom_oauth" : "Add custom oauth", "Add_Members" : "Add Members", + "Add_User" : "Add User", "Add_users" : "Add users", "Administration" : "Administration", "After_OAuth2_authentication_users_will_be_redirected_to_this_URL" : "After OAuth2 authentication, users will be redirected to this URL", @@ -414,6 +415,7 @@ "Remove_custom_oauth" : "Remove custom oauth", "Remove_from_room" : "Remove from room", "Removed" : "Removed", + "Require_password_change" : "Require password change", "Reset" : "Reset", "Reset_password" : "Reset password", "Restart" : "Restart", diff --git a/packages/rocketchat-authorization/server/startup.coffee b/packages/rocketchat-authorization/server/startup.coffee index 7febc408c37ea789fcf0026dc4491a4d7a747545..5a418ef66a639ff48a6f86320ac1822116fe50eb 100644 --- a/packages/rocketchat-authorization/server/startup.coffee +++ b/packages/rocketchat-authorization/server/startup.coffee @@ -24,6 +24,9 @@ Meteor.startup -> { _id: 'view-full-other-user-info', roles : ['admin']} + { _id: 'add-user', + roles : ['admin']} + { _id: 'edit-other-user-info', roles : ['admin']} diff --git a/packages/rocketchat-ui-admin/admin/users/adminUserEdit.coffee b/packages/rocketchat-ui-admin/admin/users/adminUserEdit.coffee index aeb9352b1558b88b9733e57184d6fcfdcc410f76..4706fbe11b1f29ec5aca7666ab9c4586dc7e1a0d 100644 --- a/packages/rocketchat-ui-admin/admin/users/adminUserEdit.coffee +++ b/packages/rocketchat-ui-admin/admin/users/adminUserEdit.coffee @@ -1,6 +1,9 @@ Template.adminUserEdit.helpers - email: -> - return @emails?[0]?.address + canEditOrAdd: -> + return (Session.get('adminSelectedUser') and RocketChat.authz.hasAtLeastOnePermission('edit-other-user-info')) or (not Session.get('adminSelectedUser') and RocketChat.authz.hasAtLeastOnePermission('add-user')) + + user: -> + return Meteor.users.findOne(Session.get('adminSelectedUser')) Template.adminUserEdit.events 'click .cancel': (e, t) -> diff --git a/packages/rocketchat-ui-admin/admin/users/adminUserEdit.html b/packages/rocketchat-ui-admin/admin/users/adminUserEdit.html index f1e620f95f96097c3dc9e0066633a6be064e5e37..34b3d5b5d4a8ee26ccaa701c6f1a6b418b4417fe 100644 --- a/packages/rocketchat-ui-admin/admin/users/adminUserEdit.html +++ b/packages/rocketchat-ui-admin/admin/users/adminUserEdit.html @@ -1,23 +1,37 @@ <template name="adminUserEdit"> - {{#unless hasPermission 'edit-other-user-info'}} + {{#unless canEditOrAdd}} <p>You are not authorized to view this page.</p> {{else}} <div class="about clearfix"> <form class="edit-form"> - <h3>{{name}}</h3> + {{#if user}} + <h3>{{user.name}}</h3> + {{else}} + <h3>{{_ "Add_User"}}</h3> + {{/if}} <div class="input-line"> <label for="name">{{_ "Name"}}</label> - <input type="text" id="name" autocomplete="off" value="{{name}}"> + <input type="text" id="name" autocomplete="off" value="{{user.name}}"> </div> <div class="input-line"> <label for="username">{{_ "Username"}}</label> - <input type="text" id="username" autocomplete="off" value="{{username}}"> + <input type="text" id="username" autocomplete="off" value="{{user.username}}"> + </div> + <div class="input-line"> + <label for="email">{{_ "E-mail"}}</label> + <input type="text" id="email" autocomplete="off" value="{{user.emails.[0].address}}"> </div> {{#if hasPermission 'edit-other-user-password'}} <div class="input-line"> <label for="password">{{_ "Password"}}</label> <input type="password" id="password" autocomplete="off" value=""> </div> + <div class="input-line"> + <label for="changePassword"> + <input type="checkbox" id="changePassword" value="1" checked="{{user.requirePasswordChange}}"> + {{_ "Require_password_change"}} + </label> + </div> {{/if}} </form> </div> diff --git a/packages/rocketchat-ui-admin/admin/users/adminUsers.coffee b/packages/rocketchat-ui-admin/admin/users/adminUsers.coffee index e09e66e2a09394293e03edf38fbbce508c348542..077be9bc825f4cca285b3b6a0f7594f73f779fe1 100644 --- a/packages/rocketchat-ui-admin/admin/users/adminUsers.coffee +++ b/packages/rocketchat-ui-admin/admin/users/adminUsers.coffee @@ -41,18 +41,30 @@ Template.adminUsers.onCreated -> groups: ['adminusers', 'adminusers-selected'], id: 'invite-user', i18nTitle: 'Invite_Users', - icon: 'icon-plus', + icon: 'icon-paper-plane', template: 'adminInviteUser', order: 1 }) + RocketChat.TabBar.addButton({ + groups: ['adminusers', 'adminusers-selected'], + id: 'add-user', + i18nTitle: 'Add_User', + icon: 'icon-plus', + template: 'adminUserEdit', + openClick: (e, t) -> + Session.set('adminSelectedUser') + return true + order: 2 + }) + RocketChat.TabBar.addButton({ groups: ['adminusers-selected'] id: 'admin-user-info', i18nTitle: 'User_Info', icon: 'icon-user', template: 'adminUserInfo', - order: 2 + order: 3 }) @autorun -> diff --git a/packages/rocketchat-ui-flextab/flex-tab/flexTabBar.coffee b/packages/rocketchat-ui-flextab/flex-tab/flexTabBar.coffee index f308646ffbbbcdf3563cbdfc8c0696ab979e1c8f..d4b4a4cdd169bdc29f2426379aeda7534ebe25dc 100644 --- a/packages/rocketchat-ui-flextab/flex-tab/flexTabBar.coffee +++ b/packages/rocketchat-ui-flextab/flex-tab/flexTabBar.coffee @@ -17,14 +17,15 @@ Template.flexTabBar.events RocketChat.TabBar.closeFlex() $('.flex-tab').css('max-width', '') else - if @width? - $('.flex-tab').css('max-width', "#{@width}px") - else - $('.flex-tab').css('max-width', '') + if not @openClick? or @openClick(e,t) + if @width? + $('.flex-tab').css('max-width', "#{@width}px") + else + $('.flex-tab').css('max-width', '') - RocketChat.TabBar.setTemplate @template, -> - $('.flex-tab')?.find("input[type='text']:first")?.focus() - $('.flex-tab .content')?.scrollTop(0) + RocketChat.TabBar.setTemplate @template, -> + $('.flex-tab')?.find("input[type='text']:first")?.focus() + $('.flex-tab .content')?.scrollTop(0) Template.flexTabBar.onCreated -> # close flex if the visible group changed and the opened template is not in the new visible group