Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d179552
Add reaction modal
MartinSchoeler Jul 15, 2020
2c95b23
import
MartinSchoeler Jul 15, 2020
d3b45fe
Merge branch 'develop' into reaction-view
tassoevan Jul 15, 2020
448f4d3
Update app/ui-utils/client/lib/MessageAction.js
MartinSchoeler Jul 16, 2020
a04cd25
Update app/ui-utils/client/lib/MessageAction.js
MartinSchoeler Jul 16, 2020
49a6290
Update app/ui-utils/client/lib/reactionListContent.js
MartinSchoeler Jul 16, 2020
4ff7fc1
Update app/ui-utils/client/lib/reactionListContent.js
MartinSchoeler Jul 16, 2020
4dbef83
fix some reviews
MartinSchoeler Jul 16, 2020
b0f2f26
fix more reviews
MartinSchoeler Jul 16, 2020
6bf2f86
remove wrapper and use the component directly
MartinSchoeler Jul 16, 2020
98d9b38
fix lint
MartinSchoeler Jul 16, 2020
ea97d07
Update reactionListContent.js
MartinSchoeler Jul 16, 2020
40e5c29
Merge branch 'develop' into reaction-view
tassoevan Jul 17, 2020
4922d96
Update app/ui-utils/client/lib/reactionListContent.js
ggazzo Jul 17, 2020
c1b1f08
Update app/ui-utils/client/lib/MessageAction.js
ggazzo Jul 17, 2020
fcf78a6
WIP
ggazzo Jul 17, 2020
390324a
Merge branch 'develop' into reaction-view
tassoevan Jul 20, 2020
9ea34cf
Merge branch 'develop' into reaction-view
gabriellsh Sep 18, 2020
3b12d45
Merge branch 'develop' into reaction-view
MartinSchoeler Oct 5, 2020
71f2db0
review
MartinSchoeler Oct 5, 2020
07432b8
fix review and overflows
MartinSchoeler Oct 5, 2020
52dff1b
lint
MartinSchoeler Oct 5, 2020
28af04c
remove line
MartinSchoeler Oct 5, 2020
6a7fb13
fix margin
MartinSchoeler Oct 5, 2020
79c8d49
lint
MartinSchoeler Oct 5, 2020
1de295a
Merge branch 'develop' into reaction-view
gabriellsh Oct 7, 2020
96c13e0
Use real name setting, open user card
gabriellsh Oct 7, 2020
90c0bbd
Fix missing names after new emoji
gabriellsh Oct 7, 2020
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
24 changes: 24 additions & 0 deletions app/ui-utils/client/lib/MessageAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import { TAPi18n } from 'meteor/rocketchat:tap-i18n';
import { ReactiveVar } from 'meteor/reactive-var';
import { Tracker } from 'meteor/tracker';
import { Session } from 'meteor/session';
import { HTML } from 'meteor/htmljs';

import { createTemplateForComponent } from '../../../../client/reactAdapters';
import { messageArgs } from './messageArgs';
import { roomTypes, canDeleteMessage } from '../../../utils/client';
import { Messages, Rooms, Subscriptions } from '../../../models/client';
Expand Down Expand Up @@ -355,4 +357,26 @@ Meteor.startup(async function() {
order: 17,
group: 'menu',
});

MessageAction.addButton({
id: 'reaction-list',
icon: 'emoji',
label: 'Reactions',
context: ['message', 'message-mobile', 'threads'],
action(_, roomInstance) {
const { msg: { reactions } } = messageArgs(this);

modal.open({
template: createTemplateForComponent('reactionList', () => import('./ReactionListContent'), {
renderContainerView: () => HTML.DIV({ style: 'margin: -16px; height: 100%; display: flex; flex-direction: column; overflow: hidden;' }), // eslint-disable-line new-cap
}),
data: { reactions, roomInstance, onClose: () => modal.close() },
});
},
condition({ msg: { reactions } }) {
return !!reactions;
},
order: 18,
group: 'menu',
});
});
68 changes: 68 additions & 0 deletions app/ui-utils/client/lib/ReactionListContent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import React from 'react';
import { Box, Tag, Modal, ButtonGroup, Button, Scrollable } from '@rocket.chat/fuselage';
import { useMutableCallback } from '@rocket.chat/fuselage-hooks';

import { useTranslation } from '../../../../client/contexts/TranslationContext';
import { useSetting } from '../../../../client/contexts/SettingsContext';
import { useSession } from '../../../../client/contexts/SessionContext';
import Emoji from '../../../../client/components/basic/Emoji';
import { openUserCard } from '../../../ui/client/lib/UserCard';
import { openProfileTabOrOpenDM } from '../../../ui/client/views/app/room';

export function Reactions({ reactions, roomInstance, onClose }) {
const useRealName = useSetting('UI_Use_Real_Name');

return <Scrollable>
<Box>
{Object.entries(reactions).map(([reaction, { names = [], usernames }]) => <Box key={reaction}>
<Box display='flex' flexWrap='wrap' overflowX='hidden' mb='x8'>
<Emoji emojiHandle={reaction} />
<Box paddingBlock='x4' mis='x4'>
{usernames.map((username, i) => <Username
key={username}
displayName={useRealName ? names[i] || username : username}
username={username}
roomInstance={roomInstance}
onClose={onClose}
/>)}
</Box>
</Box>
</Box>)}
</Box>
</Scrollable>;
}

export function Username({ username, displayName, roomInstance, onClose }) {
const openedRoom = useSession('openedRoom');
const handleUserCard = useMutableCallback((e) => openUserCard({
username,
rid: openedRoom,
target: e.currentTarget,
open: (e) => {
e.preventDefault();
onClose();
openProfileTabOrOpenDM(e, roomInstance, username);
},
}));

return <Tag onClick={handleUserCard} marginInlineEnd='x4' key={displayName}>{displayName}</Tag>;
}

export default function ReactionListContent({ reactions, roomInstance, onClose }) {
const t = useTranslation();

return <>
<Modal.Header>
<Modal.Title>{t('Users_reacted')}</Modal.Title>
<Modal.Close onClick={onClose}/>
</Modal.Header>
<Modal.Content fontScale='p1'>
<Reactions reactions={reactions} roomInstance={roomInstance} onClose={onClose}/>
</Modal.Content>
<Modal.Footer>
<ButtonGroup align='end'>
<Button primary onClick={onClose}>{t('Ok')}</Button>
</ButtonGroup>
</Modal.Footer>
</>;
}
2 changes: 1 addition & 1 deletion app/ui/client/views/app/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const openProfileTab = (e, instance, username) => {
instance.tabBar.open('members-list');
};

const openProfileTabOrOpenDM = (e, instance, username) => {
export const openProfileTabOrOpenDM = (e, instance, username) => {
// if (settings.get('UI_Click_Direct_Message')) {
// Meteor.call('createDirectMessage', username, (error, result) => {
// if (error) {
Expand Down
10 changes: 10 additions & 0 deletions client/components/basic/Emoji.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';

import { renderEmoji } from '../../../app/emoji/client/index';

function Emoji({ emojiHandle }) {
const markup = { __html: `${ renderEmoji(emojiHandle) }` };
return <div dangerouslySetInnerHTML={ markup }></div>;
}

export default Emoji;
1 change: 1 addition & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -3775,6 +3775,7 @@
"User_not_found_or_incorrect_password": "User not found or incorrect password",
"User_or_channel_name": "User or channel name",
"User_Presence": "User Presence",
"Users_reacted": "Users that Reacted",
"User_removed": "User removed",
"User_removed_by": "User <em>__user_removed__</em> removed by <em>__user_by__</em>.",
"User_sent_a_message_on_channel": "<strong>__username__</strong> sent a message on <strong>__channel__</strong>",
Expand Down