diff --git a/app/models/server/models/Rooms.js b/app/models/server/models/Rooms.js
index 2d7f38770932..33ddcd10a45a 100644
--- a/app/models/server/models/Rooms.js
+++ b/app/models/server/models/Rooms.js
@@ -661,13 +661,13 @@ export class Rooms extends Base {
return this.find(query, options);
}
- findByTypes(types, options) {
+ findByTypes(types, discussion = false, options = {}) {
const query = {
t: {
$in: types,
},
+ prid: { $exists: discussion },
};
-
return this.find(query, options);
}
@@ -720,10 +720,11 @@ export class Rooms extends Base {
return this.find(query, options);
}
- findByNameContaining(name, options) {
+ findByNameContaining(name, discussion = false, options = {}) {
const nameRegex = new RegExp(s.trim(s.escapeRegExp(name)), 'i');
const query = {
+ prid: { $exists: discussion },
$or: [
{ name: nameRegex },
{
@@ -732,17 +733,17 @@ export class Rooms extends Base {
},
],
};
-
return this.find(query, options);
}
- findByNameContainingAndTypes(name, types, options) {
+ findByNameContainingAndTypes(name, types, discussion = false, options = {}) {
const nameRegex = new RegExp(s.trim(s.escapeRegExp(name)), 'i');
const query = {
t: {
$in: types,
},
+ prid: { $exists: discussion },
$or: [
{ name: nameRegex },
{
@@ -751,7 +752,6 @@ export class Rooms extends Base {
},
],
};
-
return this.find(query, options);
}
diff --git a/app/ui-admin/client/rooms/adminRooms.html b/app/ui-admin/client/rooms/adminRooms.html
index 722e8abc5000..d43334fae9f7 100644
--- a/app/ui-admin/client/rooms/adminRooms.html
+++ b/app/ui-admin/client/rooms/adminRooms.html
@@ -21,6 +21,8 @@
+
+
{{{_ "Showing_results" roomCount}}}
@@ -39,10 +41,10 @@
{{#each rooms}}
- {{> avatar username=name roomIcon="true"}}
+ {{> avatar url=url roomIcon="true"}}
- {{>icon icon="hashtag" block="rc-table-icon"}} {{name}}
+ {{>icon icon=getIcon block="rc-table-icon"}} {{roomName}}
|
diff --git a/app/ui-admin/client/rooms/adminRooms.js b/app/ui-admin/client/rooms/adminRooms.js
index e757c47d05e7..b7b66daf01af 100644
--- a/app/ui-admin/client/rooms/adminRooms.js
+++ b/app/ui-admin/client/rooms/adminRooms.js
@@ -16,6 +16,15 @@ import { ChannelSettings } from '../../../channel-settings';
export const AdminChatRoom = new Mongo.Collection('rocketchat_room');
Template.adminRooms.helpers({
+ url() {
+ return roomTypes.getConfig(this.t).getAvatarPath(this);
+ },
+ getIcon() {
+ return roomTypes.getIcon(this);
+ },
+ roomName() {
+ return roomTypes.getRoomName(this.t, this);
+ },
searchText() {
const instance = Template.instance();
return instance.filter && instance.filter.get();
@@ -110,11 +119,12 @@ Template.adminRooms.onCreated(function() {
return hasAllPermission('view-room-administration');
},
});
+ const allowedTypes = ['c', 'd', 'p'];
this.autorun(function() {
const filter = instance.filter.get();
let types = instance.types.get();
if (types.length === 0) {
- types = ['c', 'd', 'p'];
+ types = allowedTypes;
}
const limit = instance.limit.get();
const subscription = instance.subscribe('adminRooms', filter, types, limit);
@@ -130,13 +140,15 @@ Template.adminRooms.onCreated(function() {
types = [];
}
let query = {};
+ const discussion = types.includes('dicussions');
filter = s.trim(filter);
if (filter) {
const filterReg = new RegExp(s.escapeRegExp(filter), 'i');
- query = { $or: [{ name: filterReg }, { t: 'd', usernames: filterReg }] };
+ query = { ...discussion && { prid: { $exists: true } }, $or: [{ name: filterReg }, { t: 'd', usernames: filterReg }] };
}
- if (types.length) {
- query.t = { $in: types };
+
+ if (types.filter((type) => type !== 'dicussions').length) {
+ query.t = { $in: types.filter((type) => type !== 'dicussions') };
}
const limit = instance.limit && instance.limit.get();
return AdminChatRoom.find(query, { limit, sort: { default: -1, name: 1 } });
diff --git a/app/ui-admin/server/publications/adminRooms.js b/app/ui-admin/server/publications/adminRooms.js
index bd8971e6df4d..326e3530649f 100644
--- a/app/ui-admin/server/publications/adminRooms.js
+++ b/app/ui-admin/server/publications/adminRooms.js
@@ -1,23 +1,25 @@
import { Meteor } from 'meteor/meteor';
-import _ from 'underscore';
import s from 'underscore.string';
import { hasPermission } from '../../../authorization';
-import { Rooms } from '../../../models';
+import { Rooms } from '../../../models/server';
+
+Meteor.publish('adminRooms', function(filter, types = [], limit) {
+ const showTypes = Array.isArray(types) ? types.filter((type) => type !== 'dicussions') : [];
+ const discussion = types.includes('dicussions');
-Meteor.publish('adminRooms', function(filter, types, limit) {
if (!this.userId) {
return this.ready();
}
+
if (hasPermission(this.userId, 'view-room-administration') !== true) {
return this.ready();
}
- if (!_.isArray(types)) {
- types = [];
- }
const options = {
fields: {
+ prid: 1,
+ fname: 1,
name: 1,
t: 1,
cl: 1,
@@ -40,14 +42,17 @@ Meteor.publish('adminRooms', function(filter, types, limit) {
},
};
- filter = s.trim(filter);
- if (filter && types.length) {
+ const name = s.trim(filter);
+
+ if (name && showTypes.length) {
// CACHE: can we stop using publications here?
- return Rooms.findByNameContainingAndTypes(filter, types, options);
- } if (types.length) {
+ return Rooms.findByNameContainingAndTypes(name, showTypes, discussion, options);
+ }
+
+ if (showTypes.length) {
// CACHE: can we stop using publications here?
- return Rooms.findByTypes(types, options);
+ return Rooms.findByTypes(showTypes, discussion, options);
}
// CACHE: can we stop using publications here?
- return Rooms.findByNameContaining(filter, options);
+ return Rooms.findByNameContaining(filter, discussion, options);
});