From 84ff1152f7552dd866e25a90972d970b9861107e Mon Sep 17 00:00:00 2001 From: gasoved Date: Thu, 9 Sep 2021 00:17:25 +0300 Subject: [PATCH] feat: headers for global privs #9717 (#9762) * feat: headers for global privs #9717 * fix: don't spoil headers to adminPrivs Co-authored-by: Julian Lam --- public/src/admin/manage/privileges.js | 3 ++- src/controllers/admin/privileges.js | 7 ++++--- src/privileges/global.js | 8 ++++---- src/views/admin/partials/privileges/global.tpl | 14 ++++++++++++++ 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/public/src/admin/manage/privileges.js b/public/src/admin/manage/privileges.js index e45f967475..afb9c45a6b 100644 --- a/public/src/admin/manage/privileges.js +++ b/public/src/admin/manage/privileges.js @@ -183,7 +183,8 @@ define('admin/manage/privileges', [ api.get(`/categories/${cid}/privileges`, {}).then((privileges) => { ajaxify.data.privileges = { ...ajaxify.data.privileges, ...privileges }; const tpl = parseInt(cid, 10) ? 'admin/partials/privileges/category' : 'admin/partials/privileges/global'; - app.parseAndTranslate(tpl, { privileges }).then((html) => { + const isAdminPriv = ajaxify.currentPage.endsWith('admin/manage/privileges/admin'); + app.parseAndTranslate(tpl, { privileges, isAdminPriv }).then((html) => { // Get currently selected filters const btnIndices = $('.privilege-filters button.btn-warning').map((idx, el) => $(el).index()).get(); $('.privilege-table-container').html(html); diff --git a/src/controllers/admin/privileges.js b/src/controllers/admin/privileges.js index fbcd504a53..c3ab23b9d6 100644 --- a/src/controllers/admin/privileges.js +++ b/src/controllers/admin/privileges.js @@ -44,8 +44,9 @@ privilegesController.get = async function (req, res) { res.render('admin/manage/privileges', { privileges: privilegesData, categories: categoriesData, - selectedCategory: selectedCategory, - cid: cid, - group: group, + selectedCategory, + cid, + group, + isAdminPriv, }); }; diff --git a/src/privileges/global.js b/src/privileges/global.js index 206e7769c3..33e19e3566 100644 --- a/src/privileges/global.js +++ b/src/privileges/global.js @@ -16,8 +16,8 @@ privsGlobal.privilegeLabels = [ { name: '[[admin/manage/privileges:upload-images]]' }, { name: '[[admin/manage/privileges:upload-files]]' }, { name: '[[admin/manage/privileges:signature]]' }, - { name: '[[admin/manage/privileges:ban]]' }, { name: '[[admin/manage/privileges:invite]]' }, + { name: '[[admin/manage/privileges:allow-group-creation]]' }, { name: '[[admin/manage/privileges:search-content]]' }, { name: '[[admin/manage/privileges:search-users]]' }, { name: '[[admin/manage/privileges:search-tags]]' }, @@ -25,7 +25,7 @@ privsGlobal.privilegeLabels = [ { name: '[[admin/manage/privileges:view-tags]]' }, { name: '[[admin/manage/privileges:view-groups]]' }, { name: '[[admin/manage/privileges:allow-local-login]]' }, - { name: '[[admin/manage/privileges:allow-group-creation]]' }, + { name: '[[admin/manage/privileges:ban]]' }, { name: '[[admin/manage/privileges:view-users-info]]' }, ]; @@ -34,8 +34,8 @@ privsGlobal.userPrivilegeList = [ 'upload:post:image', 'upload:post:file', 'signature', - 'ban', 'invite', + 'group:create', 'search:content', 'search:users', 'search:tags', @@ -43,7 +43,7 @@ privsGlobal.userPrivilegeList = [ 'view:tags', 'view:groups', 'local:login', - 'group:create', + 'ban', 'view:users:info', ]; diff --git a/src/views/admin/partials/privileges/global.tpl b/src/views/admin/partials/privileges/global.tpl index eec5fab737..b0a971e11b 100644 --- a/src/views/admin/partials/privileges/global.tpl +++ b/src/views/admin/partials/privileges/global.tpl @@ -1,6 +1,20 @@ + {{{ if !isAdminPriv }}} + + + + + + + {{{ end }}}
+ [[admin/manage/categories:privileges.section-posting]] + + [[admin/manage/categories:privileges.section-viewing]] + + [[admin/manage/categories:privileges.section-moderation]] +
[[admin/manage/categories:privileges.section-group]] [[admin/manage/privileges:select-clear-all]]