The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/client/components/message/content/actions/MessageAction.tsx

36 lines
1.1 KiB

import { Button } from '@rocket.chat/fuselage';
import type { Keys as IconName } from '@rocket.chat/icons';
import type { TranslationKey } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
import { useTranslation } from 'react-i18next';
const resolveLegacyIcon = (legacyIcon: IconName | `icon-${IconName | 'videocam'}`): IconName => {
if (legacyIcon === 'icon-videocam') {
return 'video';
}
return legacyIcon?.replace(/^icon-/, '') as IconName;
};
type MessageActionProps = {
icon: IconName;
i18nLabel?: TranslationKey;
label?: string;
methodId: string;
runAction: (actionId: string) => () => void;
danger?: boolean;
};
const MessageAction = ({ icon, methodId, i18nLabel, label, runAction, danger }: MessageActionProps): ReactElement => {
const { t } = useTranslation();
const resolvedIcon = resolveLegacyIcon(icon);
return (
<Button icon={resolvedIcon} data-method-id={methodId} onClick={runAction(methodId)} marginInline={4} small danger={danger}>
{i18nLabel ? t(i18nLabel) : label}
</Button>
);
};
export default MessageAction;