Skip to content

Commit

Permalink
[FIX] Removes E2E action button, icon and banner when E2E is disabled. (
Browse files Browse the repository at this point in the history
  • Loading branch information
marceloschmidt authored and ggazzo committed Jun 21, 2019
1 parent dd45652 commit e614a95
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 22 deletions.
1 change: 1 addition & 0 deletions app/e2e/client/rocketchat.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ Meteor.startup(function() {
e2e.enabled.set(true);
} else {
e2e.enabled.set(false);
e2e.closeAlert();
}
}
});
Expand Down
32 changes: 20 additions & 12 deletions app/e2e/client/tabbar.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
import { Meteor } from 'meteor/meteor';
import { Session } from 'meteor/session';
import { Tracker } from 'meteor/tracker';

import { hasAllPermission } from '../../authorization';
import { call, TabBar } from '../../ui-utils';
import { ChatRoom } from '../../models';
import { settings } from '../../settings';

Meteor.startup(() => {
TabBar.addButton({
groups: ['direct', 'group'],
id: 'e2e',
i18nTitle: 'E2E',
icon: 'key',
class: () => (ChatRoom.findOne(Session.get('openedRoom')) || {}).encrypted && 'enabled',
action: () => {
const room = ChatRoom.findOne(Session.get('openedRoom'));
call('saveRoomSettings', room._id, 'encrypted', !room.encrypted);
},
order: 10,
condition: () => hasAllPermission('edit-room', Session.get('openedRoom')),
Tracker.autorun(() => {
if (settings.get('E2E_Enable')) {
TabBar.addButton({
groups: ['direct', 'group'],
id: 'e2e',
i18nTitle: 'E2E',
icon: 'key',
class: () => (ChatRoom.findOne(Session.get('openedRoom')) || {}).encrypted && 'enabled',
action: () => {
const room = ChatRoom.findOne(Session.get('openedRoom'));
call('saveRoomSettings', room._id, 'encrypted', !room.encrypted);
},
order: 10,
condition: () => hasAllPermission('edit-room', Session.get('openedRoom')),
});
} else {
TabBar.removeButton('e2e');
}
});
});
2 changes: 1 addition & 1 deletion app/ui/client/components/header/headerRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Template.headerRoom.helpers({
},
encryptionState() {
const room = ChatRoom.findOne(this._id);
return (room && room.encrypted) && 'encrypted';
return settings.get('E2E_Enable') && room && room.encrypted && 'encrypted';
},

userStatus() {
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e614a95

Please sign in to comment.