2023-04-14 22:04:24 +08:00
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
|
|
import BBBMenu from '/imports/ui/components/common/menu/component';
|
|
|
|
import { uniqueId } from '/imports/utils/string-utils';
|
|
|
|
import Trigger from '/imports/ui/components/common/control-header/right/component';
|
2023-05-03 19:50:36 +08:00
|
|
|
import PresentationDownloadDropdownWrapper from './presentation-download-dropdown-wrapper/component'
|
2023-04-14 22:04:24 +08:00
|
|
|
|
|
|
|
const intlMessages = defineMessages({
|
2023-04-20 19:48:43 +08:00
|
|
|
enableOriginalPresentationDownload: {
|
|
|
|
id: 'app.presentationUploader.enableOriginalPresentationDownload',
|
|
|
|
description: 'Send original presentation to chat',
|
|
|
|
},
|
|
|
|
disableOriginalPresentationDownload: {
|
|
|
|
id: 'app.presentationUploader.disableOriginalPresentationDownload',
|
2023-04-14 22:04:24 +08:00
|
|
|
description: 'Send original presentation to chat',
|
|
|
|
},
|
|
|
|
sendAnnotatedDocument: {
|
|
|
|
id: 'app.presentationUploader.exportAnnotatedPresentation',
|
|
|
|
description: 'Send presentation to chat with annotations label',
|
|
|
|
},
|
|
|
|
copySuccess: {
|
|
|
|
id: 'app.chat.copySuccess',
|
|
|
|
description: 'aria success alert',
|
|
|
|
},
|
|
|
|
copyErr: {
|
|
|
|
id: 'app.chat.copyErr',
|
|
|
|
description: 'aria error alert',
|
|
|
|
},
|
|
|
|
options: {
|
|
|
|
id: 'app.presentationUploader.dropdownExportOptions',
|
|
|
|
description: 'Chat Options',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
class PresentationDownloadDropdown extends PureComponent {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.actionsKey = [
|
|
|
|
uniqueId('action-item-'),
|
|
|
|
uniqueId('action-item-'),
|
|
|
|
uniqueId('action-item-'),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
getAvailableActions() {
|
|
|
|
const {
|
|
|
|
intl,
|
2023-04-20 19:48:43 +08:00
|
|
|
handleDownloadingOfPresentation,
|
|
|
|
handleToggleDownloadable,
|
|
|
|
isDownloadable,
|
|
|
|
item,
|
2023-05-03 19:50:36 +08:00
|
|
|
closeModal,
|
2023-05-04 19:48:32 +08:00
|
|
|
hasAnnotations
|
2023-04-14 22:04:24 +08:00
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
this.menuItems = [];
|
|
|
|
|
2023-04-20 19:48:43 +08:00
|
|
|
const toggleDownloadOriginalPresentation = (enableDownload) => {
|
2023-05-03 19:50:36 +08:00
|
|
|
handleToggleDownloadable(item);
|
2023-04-20 19:48:43 +08:00
|
|
|
if (enableDownload) {
|
|
|
|
handleDownloadingOfPresentation("Original");
|
|
|
|
}
|
2023-05-03 19:50:36 +08:00
|
|
|
closeModal();
|
2023-04-20 19:48:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!isDownloadable) {
|
|
|
|
this.menuItems.push(
|
|
|
|
{
|
|
|
|
key: this.actionsKey[0],
|
|
|
|
dataTest: 'enableOriginalPresentationDownload',
|
|
|
|
label: intl.formatMessage(intlMessages.enableOriginalPresentationDownload),
|
|
|
|
onClick: () => toggleDownloadOriginalPresentation(true),
|
|
|
|
},
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
this.menuItems.push(
|
|
|
|
{
|
|
|
|
key: this.actionsKey[0],
|
|
|
|
dataTest: 'disableOriginalPresentationDownload',
|
|
|
|
label: intl.formatMessage(intlMessages.disableOriginalPresentationDownload),
|
|
|
|
onClick: () => toggleDownloadOriginalPresentation(false),
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
2023-04-14 22:04:24 +08:00
|
|
|
|
2023-05-04 19:48:32 +08:00
|
|
|
if (hasAnnotations) {
|
|
|
|
this.menuItems.push(
|
|
|
|
{
|
|
|
|
key: this.actionsKey[1],
|
|
|
|
id: 'sendAnnotatedDocument',
|
|
|
|
dataTest: 'sendAnnotatedDocument',
|
|
|
|
label: intl.formatMessage(intlMessages.sendAnnotatedDocument),
|
|
|
|
onClick: () => {
|
|
|
|
closeModal();
|
|
|
|
handleDownloadingOfPresentation("Annotated");
|
|
|
|
},
|
2023-05-03 19:50:36 +08:00
|
|
|
},
|
2023-05-04 19:48:32 +08:00
|
|
|
);
|
|
|
|
}
|
2023-04-14 22:04:24 +08:00
|
|
|
|
|
|
|
return this.menuItems;
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
intl,
|
|
|
|
isRTL,
|
2023-05-03 19:50:36 +08:00
|
|
|
disabled
|
2023-04-14 22:04:24 +08:00
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
return (
|
2023-05-03 19:50:36 +08:00
|
|
|
<PresentationDownloadDropdownWrapper
|
|
|
|
disabled={disabled}
|
|
|
|
>
|
2023-04-14 22:04:24 +08:00
|
|
|
<BBBMenu
|
|
|
|
trigger={
|
|
|
|
<Trigger
|
|
|
|
data-test="presentationOptionsDownload"
|
|
|
|
icon="more"
|
|
|
|
label={intl.formatMessage(intlMessages.options)}
|
|
|
|
aria-label={intl.formatMessage(intlMessages.options)}
|
|
|
|
onClick={() => null}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
opts={{
|
|
|
|
id: 'presentation-download-dropdown',
|
|
|
|
keepMounted: true,
|
|
|
|
transitionDuration: 0,
|
|
|
|
elevation: 2,
|
|
|
|
getContentAnchorEl: null,
|
|
|
|
fullwidth: 'true',
|
|
|
|
anchorOrigin: { vertical: 'bottom', horizontal: isRTL ? 'right' : 'left' },
|
|
|
|
transformOrigin: { vertical: 'top', horizontal: isRTL ? 'right' : 'left' },
|
|
|
|
}}
|
|
|
|
actions={this.getAvailableActions()}
|
|
|
|
/>
|
2023-05-03 19:50:36 +08:00
|
|
|
</PresentationDownloadDropdownWrapper>
|
2023-04-14 22:04:24 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default injectIntl(PresentationDownloadDropdown);
|