2022-10-31 22:05:09 +08:00
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
|
|
import BBBMenu from '/imports/ui/components/common/menu/component';
|
|
|
|
import Trigger from '/imports/ui/components/common/control-header/right/component';
|
|
|
|
import Service from './service';
|
2023-02-23 22:23:51 +08:00
|
|
|
import { uniqueId } from '/imports/utils/string-utils';
|
2022-10-31 22:05:09 +08:00
|
|
|
|
|
|
|
const DEBOUNCE_TIMEOUT = 15000;
|
|
|
|
const NOTES_CONFIG = Meteor.settings.public.notes;
|
|
|
|
const NOTES_IS_PINNABLE = NOTES_CONFIG.pinnable;
|
|
|
|
|
|
|
|
const intlMessages = defineMessages({
|
|
|
|
convertAndUploadLabel: {
|
2022-11-04 02:15:32 +08:00
|
|
|
id: 'app.notes.notesDropdown.covertAndUpload',
|
2022-10-31 22:05:09 +08:00
|
|
|
description: 'Export shared notes as a PDF and upload to the main room',
|
|
|
|
},
|
|
|
|
pinNotes: {
|
|
|
|
id: 'app.notes.notesDropdown.pinNotes',
|
|
|
|
description: 'Label for pin shared notes button',
|
|
|
|
},
|
|
|
|
options: {
|
|
|
|
id: 'app.notes.notesDropdown.notesOptions',
|
|
|
|
description: 'Label for shared notes options',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const propTypes = {
|
|
|
|
intl: PropTypes.shape({
|
|
|
|
formatMessage: PropTypes.func.isRequired,
|
|
|
|
}).isRequired,
|
|
|
|
amIPresenter: PropTypes.bool.isRequired,
|
|
|
|
isRTL: PropTypes.bool.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
class NotesDropdown extends PureComponent {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
converterButtonDisabled: false,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
setConverterButtonDisabled(value) {
|
|
|
|
return this.setState({ converterButtonDisabled: value });
|
|
|
|
}
|
|
|
|
|
|
|
|
getAvailableActions() {
|
|
|
|
const {
|
|
|
|
intl,
|
|
|
|
amIPresenter,
|
2023-10-20 20:38:04 +08:00
|
|
|
presentations,
|
2024-01-23 20:51:14 +08:00
|
|
|
setPresentation,
|
2024-01-23 21:55:40 +08:00
|
|
|
removePresentation,
|
2024-01-20 02:40:27 +08:00
|
|
|
stopExternalVideoShare,
|
2022-10-31 22:05:09 +08:00
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
const { converterButtonDisabled } = this.state;
|
|
|
|
|
|
|
|
const uploadIcon = 'upload';
|
|
|
|
const pinIcon = 'presentation';
|
|
|
|
|
|
|
|
this.menuItems = [];
|
|
|
|
|
|
|
|
if (amIPresenter) {
|
|
|
|
this.menuItems.push(
|
|
|
|
{
|
2023-02-23 22:23:51 +08:00
|
|
|
key: uniqueId('notes-option-'),
|
2022-10-31 22:05:09 +08:00
|
|
|
icon: uploadIcon,
|
|
|
|
dataTest: 'moveNotesToWhiteboard',
|
|
|
|
label: intl.formatMessage(intlMessages.convertAndUploadLabel),
|
|
|
|
disabled: converterButtonDisabled,
|
|
|
|
onClick: () => {
|
|
|
|
this.setConverterButtonDisabled(true);
|
|
|
|
setTimeout(() => this.setConverterButtonDisabled(false), DEBOUNCE_TIMEOUT);
|
2024-01-23 21:55:40 +08:00
|
|
|
return Service.convertAndUpload(presentations, setPresentation, removePresentation);
|
2022-10-31 22:05:09 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (amIPresenter && NOTES_IS_PINNABLE) {
|
|
|
|
this.menuItems.push(
|
|
|
|
{
|
2023-02-23 22:23:51 +08:00
|
|
|
key: uniqueId('notes-option-'),
|
2022-10-31 22:05:09 +08:00
|
|
|
icon: pinIcon,
|
|
|
|
dataTest: 'pinNotes',
|
|
|
|
label: intl.formatMessage(intlMessages.pinNotes),
|
|
|
|
onClick: () => {
|
2024-01-20 02:40:27 +08:00
|
|
|
Service.pinSharedNotes(stopExternalVideoShare);
|
2022-10-31 22:05:09 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.menuItems;
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
intl,
|
|
|
|
isRTL,
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
const actions = this.getAvailableActions();
|
|
|
|
|
|
|
|
if (actions.length === 0) return null;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<BBBMenu
|
|
|
|
trigger={
|
|
|
|
<Trigger
|
|
|
|
data-test="notesOptionsMenu"
|
|
|
|
icon="more"
|
|
|
|
label={intl.formatMessage(intlMessages.options)}
|
|
|
|
aria-label={intl.formatMessage(intlMessages.options)}
|
|
|
|
onClick={() => null}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
opts={{
|
|
|
|
id: 'notes-options-dropdown',
|
|
|
|
keepMounted: true,
|
|
|
|
transitionDuration: 0,
|
|
|
|
elevation: 3,
|
2023-05-10 09:31:48 +08:00
|
|
|
getcontentanchorel: null,
|
2022-10-31 22:05:09 +08:00
|
|
|
fullwidth: 'true',
|
|
|
|
anchorOrigin: { vertical: 'bottom', horizontal: isRTL ? 'right' : 'left' },
|
|
|
|
transformOrigin: { vertical: 'top', horizontal: isRTL ? 'right' : 'left' },
|
|
|
|
}}
|
|
|
|
actions={actions}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NotesDropdown.propTypes = propTypes;
|
|
|
|
|
|
|
|
export default injectIntl(NotesDropdown);
|