-
- }
- emojiName="smile"
- reactions={
- Array [
- Object {
- "create_at": 0,
- "emoji_name": ":smile:",
- "post_id": "post_id",
- "user_id": "user_id_2",
- },
- Object {
- "create_at": 0,
- "emoji_name": ":smile:",
- "post_id": "post_id",
- "user_id": "user_id_3",
- },
- ]
- }
- />
-
- }
- placement="top"
- shouldUpdatePosition={true}
- trigger={
+
@@ -87,54 +64,31 @@ exports[`components/post_view/Reaction should apply read-only class if user does
-
+
`;
exports[`components/post_view/Reaction should apply read-only class if user does not have permission to remove reaction 1`] = `
-
-
- }
- emojiName="smile"
- reactions={
- Array [
- Object {
- "create_at": 0,
- "emoji_name": ":smile:",
- "post_id": "post_id",
- "user_id": "user_id_2",
- },
- Object {
- "create_at": 0,
- "emoji_name": ":smile:",
- "post_id": "post_id",
- "user_id": "user_id_3",
- },
- ]
- }
- />
-
- }
- placement="top"
- shouldUpdatePosition={true}
- trigger={
+
@@ -177,54 +131,31 @@ exports[`components/post_view/Reaction should apply read-only class if user does
-
+
`;
exports[`components/post_view/Reaction should match snapshot 1`] = `
-
-
- }
- emojiName="smile"
- reactions={
- Array [
- Object {
- "create_at": 0,
- "emoji_name": ":smile:",
- "post_id": "post_id",
- "user_id": "user_id_2",
- },
- Object {
- "create_at": 0,
- "emoji_name": ":smile:",
- "post_id": "post_id",
- "user_id": "user_id_3",
- },
- ]
- }
- />
-
- }
- placement="top"
- shouldUpdatePosition={true}
- trigger={
+
@@ -267,54 +198,31 @@ exports[`components/post_view/Reaction should match snapshot 1`] = `
-
+
`;
exports[`components/post_view/Reaction should match snapshot when a current user reacted to a post 1`] = `
-
-
- }
- emojiName="smile"
- reactions={
- Array [
- Object {
- "create_at": 0,
- "emoji_name": ":cry:",
- "post_id": "post_id",
- "user_id": "user_id_1",
- },
- Object {
- "create_at": 0,
- "emoji_name": ":smile:",
- "post_id": "post_id",
- "user_id": "user_id_3",
- },
- ]
- }
- />
-
- }
- placement="top"
- shouldUpdatePosition={true}
- trigger={
+
@@ -357,7 +265,7 @@ exports[`components/post_view/Reaction should match snapshot when a current user
-
+
`;
exports[`components/post_view/Reaction should return null/empty if no emojiImageUrl 1`] = `""`;
diff --git a/webapp/channels/src/components/post_view/reaction/reaction.scss b/webapp/channels/src/components/post_view/reaction/reaction.scss
index 15b1c911aa..bf19cf21d9 100644
--- a/webapp/channels/src/components/post_view/reaction/reaction.scss
+++ b/webapp/channels/src/components/post_view/reaction/reaction.scss
@@ -71,14 +71,6 @@
margin: 0 2px 0 0;
object-fit: contain;
vertical-align: middle;
-
- &--large {
- width: 48px;
- max-width: none;
- height: 48px;
- max-height: none;
- margin: 4px 0;
- }
}
&__emoji--post-menu {
diff --git a/webapp/channels/src/components/post_view/reaction/reaction.tsx b/webapp/channels/src/components/post_view/reaction/reaction.tsx
index 45e69a557e..1ec3fb4ef8 100644
--- a/webapp/channels/src/components/post_view/reaction/reaction.tsx
+++ b/webapp/channels/src/components/post_view/reaction/reaction.tsx
@@ -6,9 +6,6 @@ import React from 'react';
import type {Post} from '@mattermost/types/posts';
import type {Reaction as ReactionType} from '@mattermost/types/reactions';
-import OverlayTrigger from 'components/overlay_trigger';
-import Tooltip from 'components/tooltip';
-
import * as Utils from 'utils/utils';
import ReactionTooltip from './reaction_tooltip';
@@ -218,23 +215,14 @@ export default class Reaction extends React.PureComponent
{
);
return (
-
-
-
- }
- onEnter={this.loadMissingProfiles}
+
-
+
);
}
}
diff --git a/webapp/channels/src/components/post_view/reaction/reaction_tooltip/reaction_tooltip.tsx b/webapp/channels/src/components/post_view/reaction/reaction_tooltip/reaction_tooltip.tsx
index 19fdb91150..90b38399ca 100644
--- a/webapp/channels/src/components/post_view/reaction/reaction_tooltip/reaction_tooltip.tsx
+++ b/webapp/channels/src/components/post_view/reaction/reaction_tooltip/reaction_tooltip.tsx
@@ -2,16 +2,20 @@
// See LICENSE.txt for license information.
import React from 'react';
-import {FormattedMessage} from 'react-intl';
+import {useIntl} from 'react-intl';
import type {Reaction as ReactionType} from '@mattermost/types/reactions';
+import WithTooltip from 'components/with_tooltip';
+
type Props = {
canAddReactions: boolean;
canRemoveReactions: boolean;
+ children: React.ReactNode;
currentUserReacted: boolean;
emojiName: string;
- emojiIcon: React.ReactNode;
+ id: string;
+ onShow: () => void;
reactions: ReactionType[];
users: string[];
};
@@ -20,123 +24,120 @@ const ReactionTooltip: React.FC = (props: Props) => {
const {
canAddReactions,
canRemoveReactions,
+ children,
currentUserReacted,
- emojiIcon,
emojiName,
+ id,
+ onShow,
reactions,
users,
} = props;
+ const intl = useIntl();
+
const otherUsersCount = reactions.length - users.length;
- let names: React.ReactNode;
+ let names;
if (otherUsersCount > 0) {
if (users.length > 0) {
- names = (
-
+ names = intl.formatMessage(
+ {
+ id: 'reaction.usersAndOthersReacted',
+ defaultMessage: '{users} and {otherUsers, number} other {otherUsers, plural, one {user} other {users}}',
+ },
+ {
+ users: users.join(', '),
+ otherUsers: otherUsersCount,
+ },
);
} else {
- names = (
-
+ names = intl.formatMessage(
+ {
+ id: 'reaction.othersReacted',
+ defaultMessage: '{otherUsers, number} {otherUsers, plural, one {user} other {users}}',
+ },
+ {
+ otherUsers: otherUsersCount,
+ },
);
}
} else if (users.length > 1) {
- names = (
-
+ names = intl.formatMessage(
+ {
+ id: 'reaction.usersReacted',
+ defaultMessage: '{users} and {lastUser}',
+ },
+ {
+ users: users.slice(0, -1).join(', '),
+ lastUser: users[users.length - 1],
+ },
);
} else {
names = users[0];
}
- let reactionVerb: React.ReactNode;
+ let reactionVerb;
if (users.length + otherUsersCount > 1) {
if (currentUserReacted) {
- reactionVerb = (
-
- );
+ reactionVerb = intl.formatMessage({
+ id: 'reaction.reactionVerb.youAndUsers',
+ defaultMessage: 'reacted',
+ });
} else {
- reactionVerb = (
-
- );
+ reactionVerb = intl.formatMessage({
+ id: 'reaction.reactionVerb.users',
+ defaultMessage: 'reacted',
+ });
}
} else if (currentUserReacted) {
- reactionVerb = (
-
- );
+ reactionVerb = intl.formatMessage({
+ id: 'reaction.reactionVerb.you',
+ defaultMessage: 'reacted',
+ });
} else {
- reactionVerb = (
-
- );
+ reactionVerb = intl.formatMessage({
+ id: 'reaction.reactionVerb.user',
+ defaultMessage: 'reacted',
+ });
}
- const tooltip = (
- {names},
- reactionVerb,
- emoji: {':' + emojiName + ':'},
- }}
- />
+ const tooltip = intl.formatMessage(
+ {
+ id: 'reaction.reacted',
+ defaultMessage: '{users} {reactionVerb} with {emoji}',
+ },
+ {
+ users: names,
+ reactionVerb,
+ emoji: ':' + emojiName + ':',
+ },
);
- let clickTooltip: React.ReactNode;
+ let clickTooltip;
if (currentUserReacted && canRemoveReactions) {
- clickTooltip = (
-
- );
+ clickTooltip = intl.formatMessage({
+ id: 'reaction.clickToRemove',
+ defaultMessage: '(click to remove)',
+ });
} else if (!currentUserReacted && canAddReactions) {
- clickTooltip = (
-
- );
+ clickTooltip = intl.formatMessage({
+ id: 'reaction.clickToAdd',
+ defaultMessage: '(click to add)',
+ });
}
return (
- <>
- {emojiIcon}
- {tooltip}
-
- {clickTooltip}
- >
+
+ {children}
+
);
};
diff --git a/webapp/channels/src/components/post_view/reaction_list/__snapshots__/reactions_list.test.tsx.snap b/webapp/channels/src/components/post_view/reaction_list/__snapshots__/reactions_list.test.tsx.snap
index fe71ea5d0e..640168e29e 100644
--- a/webapp/channels/src/components/post_view/reaction_list/__snapshots__/reactions_list.test.tsx.snap
+++ b/webapp/channels/src/components/post_view/reaction_list/__snapshots__/reactions_list.test.tsx.snap
@@ -71,25 +71,14 @@ exports[`components/ReactionList should render when there are reactions 1`] = `
}
teamId="teamId"
>
-
-
-
- }
+
-
+
diff --git a/webapp/channels/src/components/post_view/reaction_list/reaction_list.tsx b/webapp/channels/src/components/post_view/reaction_list/reaction_list.tsx
index b52e44ceb5..6cdffcbdcb 100644
--- a/webapp/channels/src/components/post_view/reaction_list/reaction_list.tsx
+++ b/webapp/channels/src/components/post_view/reaction_list/reaction_list.tsx
@@ -2,28 +2,33 @@
// See LICENSE.txt for license information.
import React from 'react';
-import {FormattedMessage} from 'react-intl';
+import {defineMessages} from 'react-intl';
import type {Emoji} from '@mattermost/types/emojis';
import type {Post} from '@mattermost/types/posts';
import type {Reaction as ReactionType} from '@mattermost/types/reactions';
import Permissions from 'mattermost-redux/constants/permissions';
-import {isSystemEmoji} from 'mattermost-redux/utils/emoji_utils';
+import {getEmojiName} from 'mattermost-redux/utils/emoji_utils';
import EmojiPickerOverlay from 'components/emoji_picker/emoji_picker_overlay';
-import OverlayTrigger from 'components/overlay_trigger';
import ChannelPermissionGate from 'components/permissions_gates/channel_permission_gate';
import Reaction from 'components/post_view/reaction';
-import Tooltip from 'components/tooltip';
import AddReactionIcon from 'components/widgets/icons/add_reaction_icon';
+import WithTooltip from 'components/with_tooltip';
-import Constants from 'utils/constants';
import {localizeMessage} from 'utils/utils';
const DEFAULT_EMOJI_PICKER_RIGHT_OFFSET = 15;
const EMOJI_PICKER_WIDTH_OFFSET = 260;
+const messages = defineMessages({
+ addAReaction: {
+ id: 'reaction_list.addReactionTooltip',
+ defaultMessage: 'Add a reaction',
+ },
+});
+
type Props = {
/**
@@ -90,7 +95,7 @@ export default class ReactionList extends React.PureComponent