[FIX] Remove Room info for Direct Messages (#9383) (#12429)

pull/13729/head
Filipe Vinadé 6 years ago committed by Guilherme Gazzo
parent b57f20873a
commit e4bb4920aa
  1. 2
      app/channel-settings/client/startup/tabBar.js
  2. 1
      app/e2e/client/rocketchat.e2e.js
  3. 21
      app/e2e/client/tabbar.js
  4. 2
      app/lib/lib/roomTypes/public.js
  5. 58
      app/theme/client/imports/components/header.css
  6. 2
      app/theme/client/imports/general/variables.css
  7. 19
      app/ui-flextab/client/flexTabBar.js
  8. 31
      app/ui/client/components/header/headerRoom.html
  9. 22
      app/ui/client/components/header/headerRoom.js
  10. 204
      app/ui/client/components/header/headerRoom_BACKUP_92159.js
  11. 184
      app/ui/client/components/header/headerRoom_BASE_92159.js
  12. 204
      app/ui/client/components/header/headerRoom_LOCAL_92159.js
  13. 184
      app/ui/client/components/header/headerRoom_REMOTE_92159.js
  14. 474
      package-lock.json
  15. 1
      packages/rocketchat-i18n/i18n/en.i18n.json

@ -3,7 +3,7 @@ import { TabBar } from '/app/ui-utils';
Meteor.startup(() => {
TabBar.addButton({
groups: ['channel', 'group', 'direct'],
groups: ['channel', 'group'],
id: 'channel-settings',
anonymous: true,
i18nTitle: 'Room_Info',

@ -28,6 +28,7 @@ import {
import './events.js';
import './accountEncryption.html';
import './tabbar';
import './accountEncryption.js';
let failedToDecodeKey = false;

@ -0,0 +1,21 @@
import { Meteor } from 'meteor/meteor';
import { Session } from 'meteor/session';
import { hasAllPermission } from '/app/authorization';
import { call, TabBar } from '/app/ui-utils';
import { ChatRoom } from '/app/models';
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')),
});
});

@ -99,6 +99,8 @@ export class PublicRoomType extends RoomTypeConfig {
return !room.broadcast;
case RoomSettingsEnum.REACT_WHEN_READ_ONLY:
return !room.broadcast && room.ro;
case RoomSettingsEnum.E2E:
return false;
case RoomSettingsEnum.SYSTEM_MESSAGES:
default:
return true;

@ -50,8 +50,35 @@
align-items: center;
&--action {
&-action {
position: relative;
cursor: pointer;
& + & {
&::before,
&::after {
position: absolute;
height: 1rem;
content: "";
}
&::before {
border-left: 1px #cccccc solid;
}
.rtl & {
&::after {
border-right: 1px var(--color-gray) solid;
}
&::before {
border-left: 0;
}
}
}
}
}
@ -208,6 +235,22 @@
}
}
&__toggle-encryption {
color: var(--header-toggle-encryption-on-color);
&.empty {
color: var(--header-toggle-encryption-off-color);
& .rc-header__icon {
fill: none;
}
}
&:hover {
color: var(--header-toggle-encryption-on-color);
}
}
&__icon {
font-size: 1rem;
}
@ -247,6 +290,10 @@
color: var(--rc-color-link-active);
}
&.enabled {
color: var(--header-toggle-encryption-on-color);
}
&.live {
position: relative;
}
@ -345,6 +392,15 @@
&__block-action {
order: 2;
& + & {
border-left: 1px var(--color-gray) solid;
.rtl & {
border-right: 1px var(--color-gray) solid;
border-left: 0;
}
}
}
&__favorite {

@ -279,6 +279,8 @@
--header-padding: 16px;
--header-toggle-favorite-color: var(--color-gray-medium);
--header-toggle-favorite-star-color: var(--rc-color-alert-light);
--header-toggle-encryption-off-color: var(--color-gray-medium);
--header-toggle-encryption-on-color: var(--rc-color-alert-message-secondary);
--header-title-username-color-darker: var(--color-dark);
--header-title-font-size: var(--text-default-size);
--header-title-font-size--subtitle: var(--text-small-size);

@ -96,6 +96,10 @@ const commonEvents = {
return t.tabBar.close();
}
if (this.action) {
return this.action();
}
$flexTab.attr('template', this.template);
t.tabBar.setData({
label: this.i18nTitle,
@ -111,11 +115,13 @@ const action = function(e, t) {
e.preventDefault();
const $flexTab = $('.flex-tab-container .flex-tab');
if (this.actionDefault) {
return this.actionDefault();
}
if (t.tabBar.getState() === 'opened' && t.tabBar.getTemplate() === this.template) {
$flexTab.attr('template', '');
return t.tabBar.close();
}
$flexTab.attr('template', this.template);
t.tabBar.setData({
label: this.i18nTitle,
@ -170,11 +176,12 @@ Template.RoomsActionTab.events({
$(e.currentTarget).blur();
e.preventDefault();
const buttons = TabBar.getButtons().filter((button) => filterButtons(button, t.anonymous, t.data.rid));
const groups = [{ items:(t.small.get() ? buttons : buttons.slice(TabBar.size)).map((item) => {
item.name = TAPi18n.__(item.i18nTitle);
item.action = action;
return item;
}) }];
const groups = [{ items:(t.small.get() ? buttons : buttons.slice(TabBar.size)).map((item) => ({
...item,
name: TAPi18n.__(item.i18nTitle),
actionDefault: item.action !== action && item.action,
action,
})) }];
const columns = [groups];
columns[0] = { groups };
const config = {

@ -18,15 +18,11 @@
</div>
{{/if}}
<!-- TODO: fix it style and helper -->
{{#if tokenAccessChannel}}
<i class="icon-tokenpass" aria-label="{{_ "Tokenpass_Channel_Label"}}"></i>
{{/if}}
{{#if encryptedChannel}}
<i class="icon-key" aria-label="{{_ "Encrypted_Channel_Label"}}"></i>
{{/if}}
<div class="rc-header__content rc-header__block">
{{#if isDirect}}
<div class="rc-header__block">
@ -64,27 +60,16 @@
{{#if isSection}}
<span class="rc-header__block">{{_ sectionName}}</span>
{{/if}}
{{#if encryptionState}}
<div class="rc-header__block rc-header__block-action rc-header__encryption">
<div class="rc-room-actions">
<button aria-label="{{_ 'E2E_Enabled'}}" class="rc-tooltip rc-tooltip--down rc-room-actions__action tab-button rc-header__toggle-encryption js-toggle-encryption {{encryptionState}}">{{> icon icon="key"}}</button>
</div>
</div>
{{/if}}
{{#if Template.contentBlock}}
{{> Template.contentBlock}}
{{> Template.contentBlock}}
{{/if}}
{{#unless isChannel}}
{{# unless hideHelp}}
<div class="rc-header__section-help"></div>
{{/unless}}
{{/unless}}
{{#with toolbarButtons}}
<div class="iframe-toolbar">
{{#each buttons}}
<button class="{{id}}">
{{#if icon}}<i class="{{icon}}"></i>{{/if}}
{{label}}
</button>
{{/each}}
</div>
{{/with}}
</div>
</header>
</template>

@ -1,3 +1,4 @@
import toastr from 'toastr';
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { Session } from 'meteor/session';
@ -9,6 +10,8 @@ import { settings } from '/app/settings';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { emoji } from '/app/emoji';
import { Markdown } from '/app/markdown';
import { hasAllPermission } from '/app/authorization';
import { call } from '/app/ui-utils';
const isSubscribed = (_id) => ChatSubscription.find({ rid: _id }).count() > 0;
@ -101,10 +104,9 @@ Template.headerRoom.helpers({
tokenAccessChannel() {
return Template.instance().hasTokenpass.get();
},
encryptedChannel() {
const roomData = Session.get(`roomData${ this._id }`);
return roomData && roomData.encrypted;
encryptionState() {
const room = ChatRoom.findOne(this._id);
return (room && room.encrypted) && 'encrypted';
},
userStatus() {
@ -167,6 +169,18 @@ Template.headerRoom.events({
const { prid } = t.currentChannel;
FlowRouter.goToRoomById(prid);
},
'click .js-toggle-encryption'(event) {
event.stopPropagation();
event.preventDefault();
const room = ChatRoom.findOne(this._id);
if (hasAllPermission('edit-room', this._id)) {
call('saveRoomSettings', this._id, 'encrypted', !(room && room.encrypted)).then(() => {
toastr.success(
t('Encrypted_setting_changed_successfully')
);
});
}
},
});
Template.headerRoom.onCreated(function() {

@ -0,0 +1,204 @@
import toastr from 'toastr';
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { Session } from 'meteor/session';
import { Template } from 'meteor/templating';
import { t, roomTypes, handleError, RoomSettingsEnum } from '/app/utils';
import { TabBar, fireGlobalEvent } from '/app/ui-utils';
import { ChatSubscription, Rooms, ChatRoom } from '/app/models';
import { settings } from '/app/settings';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { emoji } from '/app/emoji';
import { Markdown } from '/app/markdown';
import { hasAllPermission } from '/app/authorization';
import { call } from '/app/ui-utils';
const isSubscribed = (_id) => ChatSubscription.find({ rid: _id }).count() > 0;
const favoritesEnabled = () => settings.get('Favorite_Rooms');
const isThread = ({ _id }) => {
const room = ChatRoom.findOne({ _id });
return !!(room && room.prid);
};
Template.headerRoom.helpers({
back() {
return Template.instance().data.back;
},
avatarBackground() {
const roomData = Session.get(`roomData${ this._id }`);
if (!roomData) { return ''; }
return roomTypes.getSecondaryRoomName(roomData.t, roomData) || roomTypes.getRoomName(roomData.t, roomData);
},
buttons() {
return TabBar.getButtons();
},
isThread() {
return isThread(Template.instance().data);
},
isTranslated() {
const sub = ChatSubscription.findOne({ rid: this._id }, { fields: { autoTranslate: 1, autoTranslateLanguage: 1 } });
return settings.get('AutoTranslate_Enabled') && ((sub != null ? sub.autoTranslate : undefined) === true) && (sub.autoTranslateLanguage != null);
},
state() {
const sub = ChatSubscription.findOne({ rid: this._id }, { fields: { f: 1 } });
if (((sub != null ? sub.f : undefined) != null) && sub.f && favoritesEnabled()) { return ' favorite-room'; }
return 'empty';
},
favoriteLabel() {
const sub = ChatSubscription.findOne({ rid: this._id }, { fields: { f: 1 } });
if (((sub != null ? sub.f : undefined) != null) && sub.f && favoritesEnabled()) { return 'Unfavorite'; }
return 'Favorite';
},
isDirect() {
return Rooms.findOne(this._id).t === 'd';
},
roomName() {
const roomData = Session.get(`roomData${ this._id }`);
if (!roomData) { return ''; }
return roomTypes.getRoomName(roomData.t, roomData);
},
secondaryName() {
const roomData = Session.get(`roomData${ this._id }`);
if (!roomData) { return ''; }
return roomTypes.getSecondaryRoomName(roomData.t, roomData);
},
roomTopic() {
const roomData = Session.get(`roomData${ this._id }`);
if (!roomData || !roomData.topic) { return ''; }
let roomTopic = Markdown.parse(roomData.topic);
// &#39; to apostrophe (') for emojis such as :')
roomTopic = roomTopic.replace(/&#39;/g, '\'');
Object.keys(emoji.packages).forEach((emojiPackage) => {
roomTopic = emoji.packages[emojiPackage].render(roomTopic);
});
// apostrophe (') back to &#39;
roomTopic = roomTopic.replace(/\'/g, '&#39;');
return roomTopic;
},
roomIcon() {
const roomData = Session.get(`roomData${ this._id }`);
if (!(roomData != null ? roomData.t : undefined)) { return ''; }
return roomTypes.getIcon(roomData);
},
tokenAccessChannel() {
return Template.instance().hasTokenpass.get();
},
canViewEncryption() {
const room = ChatRoom.findOne(this._id);
return room && roomTypes.roomTypes[room.t].allowRoomSettingChange(room, RoomSettingsEnum.E2E) && (room && room.encrypted);
},
encryptionState() {
const room = ChatRoom.findOne(this._id);
return (room && room.encrypted) ? 'encrypted' : 'empty';
},
userStatus() {
const roomData = Session.get(`roomData${ this._id }`);
return roomTypes.getUserStatus(roomData.t, this._id) || t('offline');
},
showToggleFavorite() {
return !isThread(Template.instance().data) && isSubscribed(this._id) && favoritesEnabled();
},
fixedHeight() {
return Template.instance().data.fixedHeight;
},
fullpage() {
return Template.instance().data.fullpage;
},
isChannel() {
return Template.instance().currentChannel != null;
},
isSection() {
return Template.instance().data.sectionName != null;
},
});
Template.headerRoom.events({
'click .iframe-toolbar .js-iframe-action'(e) {
fireGlobalEvent('click-toolbar-button', { id: this.id });
e.currentTarget.querySelector('button').blur();
return false;
},
'click .rc-header__toggle-favorite'(event) {
event.stopPropagation();
event.preventDefault();
return Meteor.call(
'toggleFavorite',
this._id,
!$(event.currentTarget).hasClass('favorite-room'),
(err) => err && handleError(err)
);
},
'click .edit-room-title'(event) {
event.preventDefault();
Session.set('editRoomTitle', true);
$('.rc-header').addClass('visible');
return Meteor.setTimeout(() =>
$('#room-title-field')
.focus()
.select(),
10);
},
'click .js-open-parent-channel'(event, t) {
event.preventDefault();
const { prid } = t.currentChannel;
FlowRouter.goToRoomById(prid);
},
'click .js-toggle-encryption'(event) {
event.stopPropagation();
event.preventDefault();
const room = ChatRoom.findOne(this._id);
if (hasAllPermission('edit-room', this._id)) {
call('saveRoomSettings', this._id, 'encrypted', !(room && room.encrypted)).then(() => {
toastr.success(
t('Encrypted_setting_changed_successfully')
);
});
}
},
});
Template.headerRoom.onCreated(function() {
this.currentChannel = (this.data && this.data._id && Rooms.findOne(this.data._id)) || undefined;
this.hasTokenpass = new ReactiveVar(false);
if (settings.get('API_Tokenpass_URL') !== '') {
Meteor.call('getChannelTokenpass', this.data._id, (error, result) => {
if (!error) {
this.hasTokenpass.set(!!(result && result.tokens && result.tokens.length > 0));
}
});
}
});

@ -0,0 +1,184 @@
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { Session } from 'meteor/session';
import { Template } from 'meteor/templating';
import { t, roomTypes, handleError } from 'meteor/rocketchat:utils';
import { TabBar, fireGlobalEvent } from 'meteor/rocketchat:ui-utils';
import { ChatSubscription, Rooms, ChatRoom } from 'meteor/rocketchat:models';
import { settings } from 'meteor/rocketchat:settings';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { emoji } from 'meteor/rocketchat:emoji';
import { Markdown } from 'meteor/rocketchat:markdown';
const isSubscribed = (_id) => ChatSubscription.find({ rid: _id }).count() > 0;
const favoritesEnabled = () => settings.get('Favorite_Rooms');
const isThread = ({ _id }) => {
const room = ChatRoom.findOne({ _id });
return !!(room && room.prid);
};
Template.headerRoom.helpers({
back() {
return Template.instance().data.back;
},
avatarBackground() {
const roomData = Session.get(`roomData${ this._id }`);
if (!roomData) { return ''; }
return roomTypes.getSecondaryRoomName(roomData.t, roomData) || roomTypes.getRoomName(roomData.t, roomData);
},
buttons() {
return TabBar.getButtons();
},
isThread() {
return isThread(Template.instance().data);
},
isTranslated() {
const sub = ChatSubscription.findOne({ rid: this._id }, { fields: { autoTranslate: 1, autoTranslateLanguage: 1 } });
return settings.get('AutoTranslate_Enabled') && ((sub != null ? sub.autoTranslate : undefined) === true) && (sub.autoTranslateLanguage != null);
},
state() {
const sub = ChatSubscription.findOne({ rid: this._id }, { fields: { f: 1 } });
if (((sub != null ? sub.f : undefined) != null) && sub.f && favoritesEnabled()) { return ' favorite-room'; }
return 'empty';
},
favoriteLabel() {
const sub = ChatSubscription.findOne({ rid: this._id }, { fields: { f: 1 } });
if (((sub != null ? sub.f : undefined) != null) && sub.f && favoritesEnabled()) { return 'Unfavorite'; }
return 'Favorite';
},
isDirect() {
return Rooms.findOne(this._id).t === 'd';
},
roomName() {
const roomData = Session.get(`roomData${ this._id }`);
if (!roomData) { return ''; }
return roomTypes.getRoomName(roomData.t, roomData);
},
secondaryName() {
const roomData = Session.get(`roomData${ this._id }`);
if (!roomData) { return ''; }
return roomTypes.getSecondaryRoomName(roomData.t, roomData);
},
roomTopic() {
const roomData = Session.get(`roomData${ this._id }`);
if (!roomData || !roomData.topic) { return ''; }
let roomTopic = Markdown.parse(roomData.topic);
// &#39; to apostrophe (') for emojis such as :')
roomTopic = roomTopic.replace(/&#39;/g, '\'');
Object.keys(emoji.packages).forEach((emojiPackage) => {
roomTopic = emoji.packages[emojiPackage].render(roomTopic);
});
// apostrophe (') back to &#39;
roomTopic = roomTopic.replace(/\'/g, '&#39;');
return roomTopic;
},
roomIcon() {
const roomData = Session.get(`roomData${ this._id }`);
if (!(roomData != null ? roomData.t : undefined)) { return ''; }
return roomTypes.getIcon(roomData);
},
tokenAccessChannel() {
return Template.instance().hasTokenpass.get();
},
encryptedChannel() {
const roomData = Session.get(`roomData${ this._id }`);
return roomData && roomData.encrypted;
},
userStatus() {
const roomData = Session.get(`roomData${ this._id }`);
return roomTypes.getUserStatus(roomData.t, this._id) || t('offline');
},
showToggleFavorite() {
return !isThread(Template.instance().data) && isSubscribed(this._id) && favoritesEnabled();
},
fixedHeight() {
return Template.instance().data.fixedHeight;
},
fullpage() {
return Template.instance().data.fullpage;
},
isChannel() {
return Template.instance().currentChannel != null;
},
isSection() {
return Template.instance().data.sectionName != null;
},
});
Template.headerRoom.events({
'click .iframe-toolbar .js-iframe-action'(e) {
fireGlobalEvent('click-toolbar-button', { id: this.id });
e.currentTarget.querySelector('button').blur();
return false;
},
'click .rc-header__toggle-favorite'(event) {
event.stopPropagation();
event.preventDefault();
return Meteor.call(
'toggleFavorite',
this._id,
!$(event.currentTarget).hasClass('favorite-room'),
(err) => err && handleError(err)
);
},
'click .edit-room-title'(event) {
event.preventDefault();
Session.set('editRoomTitle', true);
$('.rc-header').addClass('visible');
return Meteor.setTimeout(() =>
$('#room-title-field')
.focus()
.select(),
10);
},
'click .js-open-parent-channel'(event, t) {
event.preventDefault();
const { prid } = t.currentChannel;
FlowRouter.goToRoomById(prid);
},
});
Template.headerRoom.onCreated(function() {
this.currentChannel = (this.data && this.data._id && Rooms.findOne(this.data._id)) || undefined;
this.hasTokenpass = new ReactiveVar(false);
if (settings.get('API_Tokenpass_URL') !== '') {
Meteor.call('getChannelTokenpass', this.data._id, (error, result) => {
if (!error) {
this.hasTokenpass.set(!!(result && result.tokens && result.tokens.length > 0));
}
});
}
});

@ -0,0 +1,204 @@
import toastr from 'toastr';
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { Session } from 'meteor/session';
import { Template } from 'meteor/templating';
import { t, roomTypes, handleError, RoomSettingsEnum } from 'meteor/rocketchat:utils';
import { TabBar, fireGlobalEvent, call } from 'meteor/rocketchat:ui-utils';
import { ChatSubscription, Rooms, ChatRoom } from 'meteor/rocketchat:models';
import { settings } from 'meteor/rocketchat:settings';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { emoji } from 'meteor/rocketchat:emoji';
import { Markdown } from 'meteor/rocketchat:markdown';
import { hasAllPermission } from 'meteor/rocketchat:authorization';
const isSubscribed = (_id) => ChatSubscription.find({ rid: _id }).count() > 0;
const favoritesEnabled = () => settings.get('Favorite_Rooms');
const isThread = ({ _id }) => {
const room = ChatRoom.findOne({ _id });
return !!(room && room.prid);
};
Template.headerRoom.helpers({
back() {
return Template.instance().data.back;
},
avatarBackground() {
const roomData = Session.get(`roomData${ this._id }`);
if (!roomData) { return ''; }
return roomTypes.getSecondaryRoomName(roomData.t, roomData) || roomTypes.getRoomName(roomData.t, roomData);
},
buttons() {
return TabBar.getButtons();
},
isThread() {
return isThread(Template.instance().data);
},
isTranslated() {
const sub = ChatSubscription.findOne({ rid: this._id }, { fields: { autoTranslate: 1, autoTranslateLanguage: 1 } });
return settings.get('AutoTranslate_Enabled') && ((sub != null ? sub.autoTranslate : undefined) === true) && (sub.autoTranslateLanguage != null);
},
state() {
const sub = ChatSubscription.findOne({ rid: this._id }, { fields: { f: 1 } });
if (((sub != null ? sub.f : undefined) != null) && sub.f && favoritesEnabled()) { return ' favorite-room'; }
return 'empty';
},
favoriteLabel() {
const sub = ChatSubscription.findOne({ rid: this._id }, { fields: { f: 1 } });
if (((sub != null ? sub.f : undefined) != null) && sub.f && favoritesEnabled()) { return 'Unfavorite'; }
return 'Favorite';
},
isDirect() {
return Rooms.findOne(this._id).t === 'd';
},
roomName() {
const roomData = Session.get(`roomData${ this._id }`);
if (!roomData) { return ''; }
return roomTypes.getRoomName(roomData.t, roomData);
},
secondaryName() {
const roomData = Session.get(`roomData${ this._id }`);
if (!roomData) { return ''; }
return roomTypes.getSecondaryRoomName(roomData.t, roomData);
},
roomTopic() {
const roomData = Session.get(`roomData${ this._id }`);
if (!roomData || !roomData.topic) { return ''; }
let roomTopic = Markdown.parse(roomData.topic);
// &#39; to apostrophe (') for emojis such as :')
roomTopic = roomTopic.replace(/&#39;/g, '\'');
Object.keys(emoji.packages).forEach((emojiPackage) => {
roomTopic = emoji.packages[emojiPackage].render(roomTopic);
});
// apostrophe (') back to &#39;
roomTopic = roomTopic.replace(/\'/g, '&#39;');
return roomTopic;
},
roomIcon() {
const roomData = Session.get(`roomData${ this._id }`);
if (!(roomData != null ? roomData.t : undefined)) { return ''; }
return roomTypes.getIcon(roomData);
},
tokenAccessChannel() {
return Template.instance().hasTokenpass.get();
},
canViewEncryption() {
const room = ChatRoom.findOne(this._id);
return room && roomTypes.roomTypes[room.t].allowRoomSettingChange(room, RoomSettingsEnum.E2E) && (room && room.encrypted);
},
encryptionState() {
const room = ChatRoom.findOne(this._id);
return (room && room.encrypted) ? 'encrypted' : 'empty';
},
userStatus() {
const roomData = Session.get(`roomData${ this._id }`);
return roomTypes.getUserStatus(roomData.t, this._id) || t('offline');
},
showToggleFavorite() {
return !isThread(Template.instance().data) && isSubscribed(this._id) && favoritesEnabled();
},
fixedHeight() {
return Template.instance().data.fixedHeight;
},
fullpage() {
return Template.instance().data.fullpage;
},
isChannel() {
return Template.instance().currentChannel != null;
},
isSection() {
return Template.instance().data.sectionName != null;
},
});
Template.headerRoom.events({
'click .iframe-toolbar .js-iframe-action'(e) {
fireGlobalEvent('click-toolbar-button', { id: this.id });
e.currentTarget.querySelector('button').blur();
return false;
},
'click .rc-header__toggle-favorite'(event) {
event.stopPropagation();
event.preventDefault();
return Meteor.call(
'toggleFavorite',
this._id,
!$(event.currentTarget).hasClass('favorite-room'),
(err) => err && handleError(err)
);
},
'click .edit-room-title'(event) {
event.preventDefault();
Session.set('editRoomTitle', true);
$('.rc-header').addClass('visible');
return Meteor.setTimeout(() =>
$('#room-title-field')
.focus()
.select(),
10);
},
'click .js-open-parent-channel'(event, t) {
event.preventDefault();
const { prid } = t.currentChannel;
FlowRouter.goToRoomById(prid);
},
'click .js-toggle-encryption'(event) {
event.stopPropagation();
event.preventDefault();
const room = ChatRoom.findOne(this._id);
if (hasAllPermission('edit-room', this._id)) {
call('saveRoomSettings', this._id, 'encrypted', !(room && room.encrypted)).then(() => {
toastr.success(
t('Encrypted_setting_changed_successfully')
);
});
}
},
});
Template.headerRoom.onCreated(function() {
this.currentChannel = (this.data && this.data._id && Rooms.findOne(this.data._id)) || undefined;
this.hasTokenpass = new ReactiveVar(false);
if (settings.get('API_Tokenpass_URL') !== '') {
Meteor.call('getChannelTokenpass', this.data._id, (error, result) => {
if (!error) {
this.hasTokenpass.set(!!(result && result.tokens && result.tokens.length > 0));
}
});
}
});

@ -0,0 +1,184 @@
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { Session } from 'meteor/session';
import { Template } from 'meteor/templating';
import { t, roomTypes, handleError } from '/app/utils';
import { TabBar, fireGlobalEvent } from '/app/ui-utils';
import { ChatSubscription, Rooms, ChatRoom } from '/app/models';
import { settings } from '/app/settings';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { emoji } from '/app/emoji';
import { Markdown } from '/app/markdown';
const isSubscribed = (_id) => ChatSubscription.find({ rid: _id }).count() > 0;
const favoritesEnabled = () => settings.get('Favorite_Rooms');
const isThread = ({ _id }) => {
const room = ChatRoom.findOne({ _id });
return !!(room && room.prid);
};
Template.headerRoom.helpers({
back() {
return Template.instance().data.back;
},
avatarBackground() {
const roomData = Session.get(`roomData${ this._id }`);
if (!roomData) { return ''; }
return roomTypes.getSecondaryRoomName(roomData.t, roomData) || roomTypes.getRoomName(roomData.t, roomData);
},
buttons() {
return TabBar.getButtons();
},
isThread() {
return isThread(Template.instance().data);
},
isTranslated() {
const sub = ChatSubscription.findOne({ rid: this._id }, { fields: { autoTranslate: 1, autoTranslateLanguage: 1 } });
return settings.get('AutoTranslate_Enabled') && ((sub != null ? sub.autoTranslate : undefined) === true) && (sub.autoTranslateLanguage != null);
},
state() {
const sub = ChatSubscription.findOne({ rid: this._id }, { fields: { f: 1 } });
if (((sub != null ? sub.f : undefined) != null) && sub.f && favoritesEnabled()) { return ' favorite-room'; }
return 'empty';
},
favoriteLabel() {
const sub = ChatSubscription.findOne({ rid: this._id }, { fields: { f: 1 } });
if (((sub != null ? sub.f : undefined) != null) && sub.f && favoritesEnabled()) { return 'Unfavorite'; }
return 'Favorite';
},
isDirect() {
return Rooms.findOne(this._id).t === 'd';
},
roomName() {
const roomData = Session.get(`roomData${ this._id }`);
if (!roomData) { return ''; }
return roomTypes.getRoomName(roomData.t, roomData);
},
secondaryName() {
const roomData = Session.get(`roomData${ this._id }`);
if (!roomData) { return ''; }
return roomTypes.getSecondaryRoomName(roomData.t, roomData);
},
roomTopic() {
const roomData = Session.get(`roomData${ this._id }`);
if (!roomData || !roomData.topic) { return ''; }
let roomTopic = Markdown.parse(roomData.topic);
// &#39; to apostrophe (') for emojis such as :')
roomTopic = roomTopic.replace(/&#39;/g, '\'');
Object.keys(emoji.packages).forEach((emojiPackage) => {
roomTopic = emoji.packages[emojiPackage].render(roomTopic);
});
// apostrophe (') back to &#39;
roomTopic = roomTopic.replace(/\'/g, '&#39;');
return roomTopic;
},
roomIcon() {
const roomData = Session.get(`roomData${ this._id }`);
if (!(roomData != null ? roomData.t : undefined)) { return ''; }
return roomTypes.getIcon(roomData);
},
tokenAccessChannel() {
return Template.instance().hasTokenpass.get();
},
encryptedChannel() {
const roomData = Session.get(`roomData${ this._id }`);
return roomData && roomData.encrypted;
},
userStatus() {
const roomData = Session.get(`roomData${ this._id }`);
return roomTypes.getUserStatus(roomData.t, this._id) || t('offline');
},
showToggleFavorite() {
return !isThread(Template.instance().data) && isSubscribed(this._id) && favoritesEnabled();
},
fixedHeight() {
return Template.instance().data.fixedHeight;
},
fullpage() {
return Template.instance().data.fullpage;
},
isChannel() {
return Template.instance().currentChannel != null;
},
isSection() {
return Template.instance().data.sectionName != null;
},
});
Template.headerRoom.events({
'click .iframe-toolbar .js-iframe-action'(e) {
fireGlobalEvent('click-toolbar-button', { id: this.id });
e.currentTarget.querySelector('button').blur();
return false;
},
'click .rc-header__toggle-favorite'(event) {
event.stopPropagation();
event.preventDefault();
return Meteor.call(
'toggleFavorite',
this._id,
!$(event.currentTarget).hasClass('favorite-room'),
(err) => err && handleError(err)
);
},
'click .edit-room-title'(event) {
event.preventDefault();
Session.set('editRoomTitle', true);
$('.rc-header').addClass('visible');
return Meteor.setTimeout(() =>
$('#room-title-field')
.focus()
.select(),
10);
},
'click .js-open-parent-channel'(event, t) {
event.preventDefault();
const { prid } = t.currentChannel;
FlowRouter.goToRoomById(prid);
},
});
Template.headerRoom.onCreated(function() {
this.currentChannel = (this.data && this.data._id && Rooms.findOne(this.data._id)) || undefined;
this.hasTokenpass = new ReactiveVar(false);
if (settings.get('API_Tokenpass_URL') !== '') {
Meteor.call('getChannelTokenpass', this.data._id, (error, result) => {
if (!error) {
this.hasTokenpass.set(!!(result && result.tokens && result.tokens.length > 0));
}
});
}
});

474
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -1062,6 +1062,7 @@
"Duplicate_private_group_name": "A Private Group with name '%s' exists",
"Duration": "Duration",
"E2E Encryption": "E2E Encryption",
"E2E_Enabled": "E2E Enabled",
"E2E_Enable_alert": "This feature is currently in beta! Please report bugs to github.com/RocketChat/Rocket.Chat/issues and be aware of:<br/>- Encrypted messages of encrypted rooms will not be found by search operations.<br/>- The mobile apps may not support the encypted messages (they are implementing it).<br/>- Bots may not be able to see encrypted messages until they implement support for it.<br/>- Uploads will not be encrypted in this version.",
"E2E_Enable_description": "Enable option to create encrypted groups and be able to change groups and direct messages to be encrypted",
"E2E_Encryption_Password_Explanation": "You can now create encrypted private groups and direct messages. You may also change existing private groups or DMs to encrypted.<br/><br/>This is end to end encryption so the key to encode/decode your messages will not be saved on the server. For that reason you need to store your password somewhere safe. You will be required to enter it on other devices you wish to use e2e encryption on.",

Loading…
Cancel
Save