From c87a30d3afc0f03553bcf6183d7ad68fe3287d19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20J=C3=A4gle?= Date: Sun, 19 Nov 2017 20:20:05 +0100 Subject: [PATCH] Add path to permission title --- .../client/views/permissions.js | 14 +++++++++++++- .../server/publications/permissions.js | 2 +- .../rocketchat-authorization/server/startup.js | 4 +++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/packages/rocketchat-authorization/client/views/permissions.js b/packages/rocketchat-authorization/client/views/permissions.js index 49ed36dfac48b..bd33ff69ec5cd 100644 --- a/packages/rocketchat-authorization/client/views/permissions.js +++ b/packages/rocketchat-authorization/client/views/permissions.js @@ -56,7 +56,19 @@ Template.permissionsTable.helpers({ }, permissionName(permission) { - return permission.level === permissionLevel.SETTING ? t(permission.settingId) : t(permission._id); + if (permission.level === permissionLevel.SETTING) { + let path = ''; + if (permission.group) { + path = `${ t(permission.group) } > `; + } + if (permission.section) { + path = `${ path }${ t(permission.section) } > `; + } + path = `${ path }${ t(permission.settingId) }`; + return path; + } else { + return t(permission._id); + } }, permissionDescription(permission) { diff --git a/packages/rocketchat-authorization/server/publications/permissions.js b/packages/rocketchat-authorization/server/publications/permissions.js index a18e3faff476e..1c967cfa76196 100644 --- a/packages/rocketchat-authorization/server/publications/permissions.js +++ b/packages/rocketchat-authorization/server/publications/permissions.js @@ -28,7 +28,7 @@ Meteor.methods({ const records = RocketChat.models.Permissions.find({ level: permissionLevel.SETTING, groupPermissionId: {$exists: true} //filter group permissions themselves, as they are being assigned implicitly - }).fetch(); + }, {}, {sort:{group: 1, section: 1}}).fetch(); if (updatedAt instanceof Date) { return { diff --git a/packages/rocketchat-authorization/server/startup.js b/packages/rocketchat-authorization/server/startup.js index db32471cc2ce2..23ad9738708cd 100644 --- a/packages/rocketchat-authorization/server/startup.js +++ b/packages/rocketchat-authorization/server/startup.js @@ -114,7 +114,9 @@ Meteor.startup(function() { const permission = { _id: permissionId, level: permissionLevel.SETTING, - settingId: setting._id + settingId: setting._id, + group: setting.group, + section: setting.section }; // copy previously assigned roles if available if (previousSettingPermissions[permissionId] && previousSettingPermissions[permissionId].roles) {