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/client/components/Message/Actions/Action.tsx

38 lines
962 B

import { IconProps, Icon, Button } from '@rocket.chat/fuselage';
import React, { FC } from 'react';
import { TranslationKey, useTranslation } from '../../../contexts/TranslationContext';
type RunAction = () => void;
type ActionOptions = {
mid: string;
id: string;
icon: IconProps['name'];
i18nLabel?: TranslationKey;
label?: string;
runAction?: RunAction;
};
const resolveLegacyIcon = (legacyIcon: string | undefined): string | undefined => {
if (legacyIcon === 'icon-videocam') {
return 'video';
}
return legacyIcon && legacyIcon.replace(/^icon-/, '');
};
const Action: FC<ActionOptions> = ({ id, icon, i18nLabel, label, mid, runAction }) => {
const t = useTranslation();
const resolvedIcon = resolveLegacyIcon(icon);
return (
<Button id={id} data-mid={mid} data-actionlink={id} onClick={runAction} primary small>
{icon && <Icon name={resolvedIcon} />}
{i18nLabel ? t(i18nLabel) : label}
</Button>
);
};
export default Action;