mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
fix: dont show search input if user doesn't have tag search priv
This commit is contained in:
@@ -27,12 +27,17 @@ define('tagFilter', ['hooks', 'alerts', 'bootstrap'], function (hooks, alerts, b
|
||||
}
|
||||
initialTags = selectedTags.slice();
|
||||
|
||||
const toggleSearchVisibilty = searchEl.parent('[component="tag/filter"]').length &&
|
||||
app.user.privileges['search:tags'];
|
||||
|
||||
el.on('show.bs.dropdown', function () {
|
||||
if (toggleSearchVisibilty) {
|
||||
el.find('.dropdown-toggle').css({ visibility: 'hidden' });
|
||||
searchEl.removeClass('hidden');
|
||||
searchEl.css({
|
||||
'z-index': el.find('.dropdown-toggle').css('z-index') + 1,
|
||||
});
|
||||
}
|
||||
|
||||
function doSearch() {
|
||||
const val = searchEl.find('input').val();
|
||||
@@ -61,8 +66,11 @@ define('tagFilter', ['hooks', 'alerts', 'bootstrap'], function (hooks, alerts, b
|
||||
});
|
||||
|
||||
el.on('hidden.bs.dropdown', function () {
|
||||
if (toggleSearchVisibilty) {
|
||||
el.find('.dropdown-toggle').css({ visibility: 'inherit' });
|
||||
searchEl.addClass('hidden');
|
||||
}
|
||||
|
||||
searchEl.off('click');
|
||||
searchEl.find('input').off('keyup');
|
||||
|
||||
|
||||
@@ -73,11 +73,6 @@ module.exports = function (SocketTopics) {
|
||||
|
||||
// used by tag filter search
|
||||
SocketTopics.tagFilterSearch = async function (socket, data) {
|
||||
const allowed = await privileges.global.can('search:tags', socket.uid);
|
||||
if (!allowed) {
|
||||
throw new Error('[[error:no-privileges]]');
|
||||
}
|
||||
|
||||
let cids = [];
|
||||
if (Array.isArray(data.cids)) {
|
||||
cids = await privileges.categories.filterCids('topics:read', data.cids, socket.uid);
|
||||
@@ -87,6 +82,10 @@ module.exports = function (SocketTopics) {
|
||||
|
||||
let tags = [];
|
||||
if (data.query) {
|
||||
const allowed = await privileges.global.can('search:tags', socket.uid);
|
||||
if (!allowed) {
|
||||
throw new Error('[[error:no-privileges]]');
|
||||
}
|
||||
tags = await topics.searchTags({
|
||||
query: data.query,
|
||||
cid: cids.length === 1 ? cids[0] : null,
|
||||
|
||||
Reference in New Issue
Block a user