Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW] Changes all 'mergeChannels' to 'groupByType'. #10055

Merged
merged 2 commits into from
May 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/rocketchat-api/server/v1/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ RocketChat.API.v1.addRoute('users.setPreferences', { authRequired: true }, {
sidebarSortby: Match.Optional(String),
sidebarViewMode: Match.Optional(String),
sidebarHideAvatar: Match.Optional(Boolean),
mergeChannels: Match.Optional(Boolean),
groupByType: Match.Optional(Boolean),
muteFocusedConversations: Match.Optional(Boolean)
})
});
Expand Down
3 changes: 2 additions & 1 deletion packages/rocketchat-lib/lib/roomTypes/conversation.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class ConversationRoomType extends RoomTypeConfig {

condition() {
const user = Meteor.user();
return RocketChat.getUserPreference(user, 'mergeChannels');
// returns true only if groupByType is not set
return !RocketChat.getUserPreference(user, 'groupByType');
}
}
4 changes: 2 additions & 2 deletions packages/rocketchat-lib/lib/roomTypes/direct.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ export class DirectMessageRoomType extends RoomTypeConfig {

condition() {
const user = Meteor.user();
const mergeChannels = RocketChat.getUserPreference(user, 'mergeChannels');
return !mergeChannels && RocketChat.authz.hasAtLeastOnePermission(['view-d-room', 'view-joined-room']);
const groupByType = RocketChat.getUserPreference(user, 'groupByType');
return groupByType && RocketChat.authz.hasAtLeastOnePermission(['view-d-room', 'view-joined-room']);
}

getUserStatus(roomId) {
Expand Down
4 changes: 2 additions & 2 deletions packages/rocketchat-lib/lib/roomTypes/private.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export class PrivateRoomType extends RoomTypeConfig {

condition() {
const user = Meteor.user();
const mergeChannels = RocketChat.getUserPreference(user, 'mergeChannels');
return !mergeChannels && RocketChat.authz.hasAllPermission('view-p-room');
const groupByType = RocketChat.getUserPreference(user, 'groupByType');
return groupByType && RocketChat.authz.hasAllPermission('view-p-room');
}

isGroupChat() {
Expand Down
4 changes: 2 additions & 2 deletions packages/rocketchat-lib/lib/roomTypes/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export class PublicRoomType extends RoomTypeConfig {
condition() {
const user = Meteor.user();
// const roomsListExhibitionMode = RocketChat.getUserPreference(user, 'roomsListExhibitionMode');
const mergeChannels = RocketChat.getUserPreference(user, 'mergeChannels');
return !mergeChannels && (RocketChat.authz.hasAtLeastOnePermission(['view-c-room', 'view-joined-room']) || RocketChat.settings.get('Accounts_AllowAnonymousRead') === true);
const groupByType = RocketChat.getUserPreference(user, 'groupByType');
return groupByType && (RocketChat.authz.hasAtLeastOnePermission(['view-c-room', 'view-joined-room']) || RocketChat.settings.get('Accounts_AllowAnonymousRead') === true);
}

showJoinLink(roomId) {
Expand Down
8 changes: 4 additions & 4 deletions packages/rocketchat-ui-sidenav/client/sideNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ Template.sideNav.onRendered(function() {
});

Template.sideNav.onCreated(function() {
this.mergedChannels = new ReactiveVar(false);
this.groupedByType = new ReactiveVar(false);

this.autorun(() => {
const user = RocketChat.models.Users.findOne(Meteor.userId(), {
fields: {
'settings.preferences.roomsListExhibitionMode': 1,
'settings.preferences.mergeChannels': 1
'settings.preferences.groupByType': 1
}
});
const userPref = RocketChat.getUserPreference(user, 'roomsListExhibitionMode') === 'category' && RocketChat.getUserPreference(user, 'mergeChannels');
this.mergedChannels.set(userPref ? userPref : RocketChat.settings.get('UI_Merge_Channels_Groups'));
const userPref = RocketChat.getUserPreference(user, 'roomsListExhibitionMode') === 'category' && RocketChat.getUserPreference(user, 'groupByType');
this.groupedByType.set(userPref ? userPref : !RocketChat.settings.get('UI_Merge_Channels_Groups'));
});
});
4 changes: 2 additions & 2 deletions packages/rocketchat-ui-sidenav/client/sortlist.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
</ul>
<span class="rc-popover__divider"></span>
<ul class="rc-popover__list">
<li class="rc-popover__item {{bold 'mergeChannels'}}">
<li class="rc-popover__item {{bold 'groupByType'}}">
<label class="rc-popover__label">
<input type="checkbox" name="mergeChannels" class="hidden" checked="{{checked 'mergeChannels'}}"/>
<input type="checkbox" name="groupByType" class="hidden" checked="{{checked 'groupByType'}}"/>
<span class="rc-popover__icon">
{{> icon block="rc-popover__icon-element" icon='sort-amount-down' }}
</span>
Expand Down
5 changes: 2 additions & 3 deletions packages/rocketchat-ui-sidenav/client/sortlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ const checked = function(prop, field) {
if (prop === 'sidebarShowFavorites') {
return RocketChat.getUserPreference(user, 'sidebarShowFavorites');
}
if (prop === 'mergeChannels') {
// TODO change mergeChannels to GroupByType
return !RocketChat.getUserPreference(user, 'mergeChannels');
if (prop === 'groupByType') {
return RocketChat.getUserPreference(user, 'groupByType');
}
if (prop === 'sidebarShowUnread') {
return RocketChat.getUserPreference(user, 'sidebarShowUnread');
Expand Down
7 changes: 4 additions & 3 deletions server/methods/channelsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ Meteor.methods({

if (channelType !== 'public' && RocketChat.authz.hasPermission(Meteor.userId(), 'view-p-room')) {
const user = Meteor.user();
const userPref = RocketChat.getUserPreference(user, 'mergeChannels') && RocketChat.getUserPreference(user, 'roomsListExhibitionMode') === 'category';
const userPref = RocketChat.getUserPreference(user, 'groupByType') && RocketChat.getUserPreference(user, 'roomsListExhibitionMode') === 'category';
const globalPref = RocketChat.settings.get('UI_Merge_Channels_Groups');
const mergeChannels = userPref !== undefined ? userPref : globalPref;
// needs to negate globalPref because userPref represents its opposite
const groupByType = userPref !== undefined ? userPref : !globalPref;

if (mergeChannels) {
if (!groupByType) {
roomTypes.push({
type: 'p',
username: user.username
Expand Down
8 changes: 4 additions & 4 deletions server/methods/saveUserPreferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ Meteor.methods({
muteFocusedConversations: Match.Optional(Boolean)
};
check(settings, Match.ObjectIncluding(keys));
if (settings.mergeChannels) {
if (settings.groupByType) {
check(settings, Match.ObjectIncluding({
mergeChannels: Match.OneOf(Number, Boolean) //eslint-disable-line new-cap
groupByType: Match.OneOf(Number, Boolean) //eslint-disable-line new-cap
}));
}
const user = Meteor.userId();
Expand All @@ -48,8 +48,8 @@ Meteor.methods({
RocketChat.models.Users.setLanguage(user, settings.language);
}

if (settings.mergeChannels != null) {
settings.mergeChannels = ['1', true].includes(settings.mergeChannels);
if (settings.groupByType != null) {
settings.groupByType = ['1', true].includes(settings.groupByType);
}


Expand Down