Skip to content

Commit fb0b24c

Browse files
chore: Stop hardcoding tooltips on message actions (RocketChat#37127)
1 parent ae632f7 commit fb0b24c

5 files changed

Lines changed: 7 additions & 4 deletions

File tree

apps/meteor/app/ui-utils/client/lib/MessageAction.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export type MessageActionConfig = {
2323
icon: IconName;
2424
variant?: 'danger' | 'success' | 'warning';
2525
label: TranslationKey;
26+
tooltip?: string;
2627
order: number;
2728
group: MessageActionGroup;
2829
context?: MessageActionContext[];

apps/meteor/client/components/message/toolbar/MessageToolbarActionMenu.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,8 @@ const MessageToolbarActionMenu = ({ message, context, room, subscription, onChan
9999
content: t(option.label),
100100
onClick: option.action,
101101
type: option.type,
102+
...(option.tooltip && { tooltip: option.tooltip }),
102103
...(typeof option.disabled === 'boolean' && { disabled: option.disabled }),
103-
...(typeof option.disabled === 'boolean' &&
104-
option.disabled && { tooltip: t('Action_not_available_encrypted_content', { action: t(option.label) }) }),
105104
}))
106105
.reduce((acc, option) => {
107106
const group = option.type ? option.type : '';

apps/meteor/client/components/message/toolbar/MessageToolbarStarsActionMenu.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ const MessageToolbarStarsActionMenu = ({ message, context, onChangeMenuVisibilit
3737
content: t(option.label),
3838
onClick: option.action,
3939
type: option.type,
40+
...(option.tooltip && { tooltip: option.tooltip }),
4041
...(typeof option.disabled === 'boolean' && { disabled: option.disabled }),
41-
...(typeof option.disabled === 'boolean' &&
42-
option.disabled && { tooltip: t('Action_not_available_encrypted_content', { action: t(option.label) }) }),
4342
};
4443

4544
const group = option.type || '';

apps/meteor/client/components/message/toolbar/usePermalinkAction.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@ export const usePermalinkAction = (
3434
order,
3535
group: 'menu',
3636
disabled: encrypted,
37+
...(encrypted && { tooltip: t('Action_not_available_encrypted_content', { action: t('Copy_link') }) }),
3738
};
3839
};

apps/meteor/client/components/message/toolbar/useReplyInDMAction.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { type IMessage, type ISubscription, type IRoom, isE2EEMessage } from '@rocket.chat/core-typings';
22
import { usePermission, useRouter, useUser } from '@rocket.chat/ui-contexts';
33
import { useCallback, useMemo } from 'react';
4+
import { useTranslation } from 'react-i18next';
45
import { useShallow } from 'zustand/shallow';
56

67
import type { MessageActionConfig } from '../../../../app/ui-utils/client/lib/MessageAction';
@@ -17,6 +18,7 @@ export const useReplyInDMAction = (
1718
const encrypted = isE2EEMessage(message);
1819
const canCreateDM = usePermission('create-d');
1920
const isLayoutEmbedded = useEmbeddedLayout();
21+
const { t } = useTranslation();
2022

2123
const roomPredicate = useCallback(
2224
(record: IRoom): boolean => {
@@ -70,5 +72,6 @@ export const useReplyInDMAction = (
7072
order: 0,
7173
group: 'menu',
7274
disabled: encrypted,
75+
...(encrypted && { tooltip: t('Action_not_available_encrypted_content', { action: t('Reply_in_direct_message') }) }),
7376
};
7477
};

0 commit comments

Comments
 (0)