RocketChat/Rocket.Chat

View on GitHub
apps/meteor/client/components/message/content/attachments/structure/AttachmentDownloadBase.tsx

Summary

Maintainability
A
0 mins
Test Coverage
import { useTranslation } from '@rocket.chat/ui-contexts';
import type { ComponentProps } from 'react';
import React from 'react';

import Action from '../../Action';

type AttachmentDownloadBaseProps = Omit<ComponentProps<typeof Action>, 'icon'> & { title?: string | undefined; href: string };

const AttachmentDownloadBase = ({ title, href, disabled, ...props }: AttachmentDownloadBaseProps) => {
    const t = useTranslation();

    return (
        <Action
            icon='cloud-arrow-down'
            href={`${href}?download`}
            title={disabled ? t('Download_Disabled') : t('Download')}
            is='a'
            target='_blank'
            rel='noopener noreferrer'
            download={title}
            disabled={disabled}
            {...props}
        />
    );
};

export default AttachmentDownloadBase;