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

[FIX] set-toolbar-items postMessage #11109

Merged
merged 5 commits into from
Jun 14, 2018
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,14 @@
font-size: 12px;
font-weight: 600;
}
& + & {
border-left: 1px var(--color-gray) solid;

.rtl & {
border-left: 0;
border-right: 1px var(--color-gray) solid;
}
}
}

.tab-button-icon--star {
Expand Down
15 changes: 13 additions & 2 deletions packages/rocketchat-ui-flextab/client/flexTabBar.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ <h1 class="contextual-bar__header-title">{{_ label}}</h1>
</template>

<template name="RoomsActionTab">
{{# with postButtons}}
<div class="rc-room-actions iframe-toolbar">
{{#each .}}
<div class="rc-room-actions__action tab-button {{active}} {{visible}} {{class}} js-iframe-action" data-id="{{id}}">
<button class="rc-tooltip rc-tooltip--down rc-room-actions__button" aria-label="{{title}}">
{{> icon block="tab-button-icon" icon=icon }}
</button>
</div>
{{/each}}
</div>
{{/with}}
<div class="rc-room-actions">
{{#each buttons}}
<div class="rc-room-actions__action tab-button {{active}} {{visible}} {{class}} js-action" data-id="{{id}}">
Expand All @@ -39,10 +50,10 @@ <h1 class="contextual-bar__header-title">{{_ label}}</h1>
</button>
</div>
{{/each}}
{{# with moreButtons}}
{{# with moreButtons}}
<div class="rc-room-actions__action {{opened}}">
<button class="rc-tooltip rc-tooltip--down rc-room-actions__button js-more" aria-label="{{_ 'More'}}">
{{> icon block="tab-button-icon" icon="menu" }}
{{> icon block="tab-button-icon" icon="menu" }}
</button>
</div>
{{/with}}
Expand Down
10 changes: 10 additions & 0 deletions packages/rocketchat-ui-flextab/client/flexTabBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,16 @@ Template.RoomsActionTab.onCreated(function() {

Template.RoomsActionTab.helpers({
...commonHelpers,
postButtons() {
const toolbar = Session.get('toolbarButtons');
const buttons = Object.keys(toolbar.buttons).map(key => {
return {
id: key,
...toolbar.buttons[key]
};
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe compact mapper function as

id => ({ id, ...toolbar.buttons[id] })

return buttons;
},
active() {
if (this.template === Template.instance().tabBar.getTemplate() && Template.instance().tabBar.getState() === 'opened') {
return 'active';
Expand Down
25 changes: 19 additions & 6 deletions packages/rocketchat-ui/client/components/header/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,25 +104,38 @@ Template.header.helpers({
});

Template.header.events({
'click .iframe-toolbar button'() {
'click .iframe-toolbar .js-iframe-action'(e) {
fireGlobalEvent('click-toolbar-button', { id: this.id });
$('button', e.currentTarget).blur();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.currentTarget.querySelector('body').blur() should match the required browser supported.

return false;
},

'click .rc-header__toggle-favorite'(event) {
event.stopPropagation();
event.preventDefault();
return Meteor.call('toggleFavorite', this._id, !$(event.currentTarget).hasClass('favorite-room'), function(err) {
if (err) {
return handleError(err);
return Meteor.call(
'toggleFavorite',
this._id,
!$(event.currentTarget).hasClass('favorite-room'),
function(err) {
if (err) {
return handleError(err);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you avoid some extra lines using an arrow function?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes we can!

}
});
);
},

'click .edit-room-title'(event) {
event.preventDefault();
Session.set('editRoomTitle', true);
$('.rc-header').addClass('visible');
return Meteor.setTimeout(() => $('#room-title-field').focus().select(), 10);
return Meteor.setTimeout(
() =>
$('#room-title-field')
.focus()
.select(),
10
);
}
});

Expand Down
4 changes: 2 additions & 2 deletions packages/rocketchat-ui/client/lib/iframeCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ const commands = {
});
},

'set-toolbar-button'({ id, icon, label }) {
'set-toolbar-button'({ id, icon, label: i18nTitle }) {
const toolbar = Session.get('toolbarButtons') || { buttons: {} };
toolbar.buttons[id] = { icon, label };
toolbar.buttons[id] = { icon, i18nTitle };
Session.set('toolbarButtons', toolbar);
},

Expand Down