Skip to content

Commit

Permalink
Remove some bad references to messageBox (#13954)
Browse files Browse the repository at this point in the history
  • Loading branch information
tassoevan authored and ggazzo committed Apr 1, 2019
1 parent 4d15868 commit 19c6eb7
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 44 deletions.
7 changes: 4 additions & 3 deletions app/ui-master/client/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { FlowRouter } from 'meteor/kadira:flow-router';
import { t, getUserPreference } from '../../utils';
import { Session } from 'meteor/session';
import { Template } from 'meteor/templating';
import { mainReady, Layout, iframeLogin, modal, popover, menu, fireGlobalEvent } from '../../ui-utils';
import { chatMessages } from '../../ui';
import { mainReady, Layout, iframeLogin, modal, popover, menu, fireGlobalEvent, RoomManager } from '../../ui-utils';
import { toolbarSearch } from '../../ui-sidenav';
import { settings } from '../../settings';
import { CachedChatSubscription, Roles, ChatSubscription } from '../../models';
Expand Down Expand Up @@ -78,8 +79,8 @@ Template.body.onRendered(function() {
if (target.id === 'pswp') {
return;
}
const inputMessage = $('.rc-message-box__textarea');
if (inputMessage.length === 0) {
const inputMessage = chatMessages[RoomManager.openedRoom] && chatMessages[RoomManager.openedRoom].input;
if (!inputMessage) {
return;
}
inputMessage.focus();
Expand Down
8 changes: 4 additions & 4 deletions app/ui-message/client/messageBox.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{{else}}
{{#if subscribed}}
{{> messageBoxAudioMessage rid=_id}}
<span class="rc-message-box__action-menu" data-desktop>
<span class="rc-message-box__action-menu js-action-menu" data-desktop>
{{#if actions}}
<span class="rc-message-box__icon">
{{> icon block="rc-input__icon-svg" icon="plus"}}
Expand All @@ -41,9 +41,9 @@
{{/if}}
{{/unless}}
<span class="rc-message-box__action-label js-message-actions" data-small>
{{#each actions}}
<span class="js-message-action">
{{> icon block="rc-message-box__action" icon=icon }}
{{#each action in actions}}
<span class="js-message-action" data-id="{{action.id}}">
{{> icon block="rc-message-box__action" icon=action.icon }}
</span>
{{/each}}
</span>
Expand Down
20 changes: 13 additions & 7 deletions app/ui-message/client/messageBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ Template.messageBox.events({
input.focus();
});
},
'click .rc-message-box__action-menu'(event) {
'click .js-action-menu'(event, instance) {
const groups = messageBox.actions.get();
const config = {
popoverClass: 'message-box',
Expand Down Expand Up @@ -409,19 +409,25 @@ Template.messageBox.events({
currentTarget: event.currentTarget.firstElementChild.firstElementChild,
data: {
rid: this._id,
messageBox: instance.firstNode,
},
activeElement: event.currentTarget,
};

popover.open(config);
},
'click .js-message-actions .js-message-action'(event, instance) {
this.action.apply(this, [{
rid: Template.parentData()._id,
messageBox: instance.find('.rc-message-box'),
element: event.currentTarget,
event,
}]);
const { id } = event.currentTarget.dataset;
const actions = messageBox.actions.getById(id);
actions
.filter(({ action }) => !!action)
.forEach(({ action }) => {
action.call(null, {
rid: this._id,
messageBox: instance.firstNode,
event,
});
});
},
'click .js-format'(e, t) {
applyFormatting.apply(this, [e, t]);
Expand Down
4 changes: 2 additions & 2 deletions app/ui-message/client/startup/messageBoxActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ messageBox.actions.add('Add_files_from', 'Computer', {
id: 'file-upload',
icon: 'computer',
condition: () => settings.get('FileUpload_Enabled'),
action({ event }) {
action({ event, messageBox }) {
event.preventDefault();
const $input = $(document.createElement('input'));
$input.css('display', 'none');
Expand All @@ -49,7 +49,7 @@ messageBox.actions.add('Add_files_from', 'Computer', {
};
});

fileUpload(filesToUpload, $('.rc-message-box__textarea.js-input-message'));
fileUpload(filesToUpload, $('.js-input-message', messageBox));
$input.remove();
});

Expand Down
11 changes: 0 additions & 11 deletions app/ui-sidenav/client/sidebarHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,8 @@ const extendedViewOption = (user) => {

const showToolbar = new ReactiveVar(false);

const selectorSearch = '.toolbar__search .rc-input__element';
export const toolbarSearch = {
shortcut: false,
clear() {
const $inputMessage = $('.js-input-message');

if (0 === $inputMessage.length) {
return;
}

$inputMessage.focus();
$(selectorSearch).val('');
},
show(fromShortcut) {
menu.open();
showToolbar.set(true);
Expand Down
9 changes: 0 additions & 9 deletions app/ui-sidenav/client/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,6 @@ Template.toolbar.events({
toolbarSearch.shortcut = false;
},

'keyup [role="search"] input'(e) {
if (e.which === 27) {
e.preventDefault();
e.stopPropagation();

toolbarSearch.clear();
}
},

'click [role="search"] button, touchend [role="search"] button'(e) {
if (hasAtLeastOnePermission(['create-c', 'create-p'])) {
// TODO: resolve this name menu/sidebar/sidebav/flex...
Expand Down
17 changes: 10 additions & 7 deletions app/ui-utils/client/lib/popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,16 @@ Template.popover.events({
},
'click [data-type="messagebox-action"]'(event, t) {
const { id } = event.currentTarget.dataset;
const action = messageBox.actions.getById(id);
if ((action[0] != null ? action[0].action : undefined) != null) {
action[0].action({ rid: t.data.data.rid, ...t.data.data, messageBox: document.querySelector('.rc-message-box'), element: event.currentTarget, event });
if (id !== 'audio-message') {
popover.close();
}
}
const actions = messageBox.actions.getById(id);
actions
.filter(({ action }) => !!action)
.forEach(({ action }) => {
action.call(null, {
...t.data.data,
event,
});
});
popover.close();
},
'click [data-type="message-action"]'(e, t) {
const button = MessageAction.getButtonById(e.currentTarget.dataset.id);
Expand Down
2 changes: 1 addition & 1 deletion tests/pageobjects/side-nav.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class SideNav extends Page {
openChannel(channelName) {
browser.waitForVisible(`.sidebar-item__ellipsis=${ channelName }`, 10000);
browser.click(`.sidebar-item__ellipsis=${ channelName }`);
browser.waitForVisible('.rc-message-box__container textarea', 5000);
browser.waitForVisible('.js-input-message', 5000);
browser.waitForVisible('.rc-header', 5000);
browser.waitUntil(function() {
browser.waitForVisible('.rc-header__name', 8000);
Expand Down

0 comments on commit 19c6eb7

Please sign in to comment.