mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 03:55:55 +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();
|
initialTags = selectedTags.slice();
|
||||||
|
|
||||||
|
const toggleSearchVisibilty = searchEl.parent('[component="tag/filter"]').length &&
|
||||||
|
app.user.privileges['search:tags'];
|
||||||
|
|
||||||
el.on('show.bs.dropdown', function () {
|
el.on('show.bs.dropdown', function () {
|
||||||
el.find('.dropdown-toggle').css({ visibility: 'hidden' });
|
if (toggleSearchVisibilty) {
|
||||||
searchEl.removeClass('hidden');
|
el.find('.dropdown-toggle').css({ visibility: 'hidden' });
|
||||||
searchEl.css({
|
searchEl.removeClass('hidden');
|
||||||
'z-index': el.find('.dropdown-toggle').css('z-index') + 1,
|
searchEl.css({
|
||||||
});
|
'z-index': el.find('.dropdown-toggle').css('z-index') + 1,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function doSearch() {
|
function doSearch() {
|
||||||
const val = searchEl.find('input').val();
|
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 () {
|
el.on('hidden.bs.dropdown', function () {
|
||||||
el.find('.dropdown-toggle').css({ visibility: 'inherit' });
|
if (toggleSearchVisibilty) {
|
||||||
searchEl.addClass('hidden');
|
el.find('.dropdown-toggle').css({ visibility: 'inherit' });
|
||||||
|
searchEl.addClass('hidden');
|
||||||
|
}
|
||||||
|
|
||||||
searchEl.off('click');
|
searchEl.off('click');
|
||||||
searchEl.find('input').off('keyup');
|
searchEl.find('input').off('keyup');
|
||||||
|
|
||||||
|
|||||||
@@ -73,11 +73,6 @@ module.exports = function (SocketTopics) {
|
|||||||
|
|
||||||
// used by tag filter search
|
// used by tag filter search
|
||||||
SocketTopics.tagFilterSearch = async function (socket, data) {
|
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 = [];
|
let cids = [];
|
||||||
if (Array.isArray(data.cids)) {
|
if (Array.isArray(data.cids)) {
|
||||||
cids = await privileges.categories.filterCids('topics:read', data.cids, socket.uid);
|
cids = await privileges.categories.filterCids('topics:read', data.cids, socket.uid);
|
||||||
@@ -87,6 +82,10 @@ module.exports = function (SocketTopics) {
|
|||||||
|
|
||||||
let tags = [];
|
let tags = [];
|
||||||
if (data.query) {
|
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({
|
tags = await topics.searchTags({
|
||||||
query: data.query,
|
query: data.query,
|
||||||
cid: cids.length === 1 ? cids[0] : null,
|
cid: cids.length === 1 ? cids[0] : null,
|
||||||
|
|||||||
Reference in New Issue
Block a user