bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/note/component.jsx

92 lines
2.4 KiB
React
Raw Normal View History

2019-12-17 05:06:41 +08:00
import React, { Component } from 'react';
2018-12-13 04:10:27 +08:00
import PropTypes from 'prop-types';
import { Session } from 'meteor/session';
import { defineMessages, injectIntl } from 'react-intl';
import injectWbResizeEvent from '/imports/ui/components/presentation/resize-wrapper/component';
import Button from '/imports/ui/components/button/component';
import NoteService from './service';
2018-12-13 04:10:27 +08:00
import { styles } from './styles';
const intlMessages = defineMessages({
hideNoteLabel: {
id: 'app.note.hideNoteLabel',
description: 'Label for hiding note button',
},
2019-01-10 02:06:23 +08:00
title: {
id: 'app.note.title',
description: 'Title for the shared notes',
},
tipLabel: {
id: 'app.note.tipLabel',
description: 'Label for tip on how to escape iframe',
},
2018-12-13 04:10:27 +08:00
});
const propTypes = {
isLocked: PropTypes.bool.isRequired,
2018-12-13 04:10:27 +08:00
intl: PropTypes.shape({
formatMessage: PropTypes.func.isRequired,
}).isRequired,
};
2019-12-17 05:06:41 +08:00
class Note extends Component {
constructor(props) {
super(props);
2018-12-13 04:10:27 +08:00
2019-12-17 05:06:41 +08:00
this.noteURL = NoteService.getNoteURL();
this.readOnlyURL = NoteService.getReadOnlyURL();
}
2018-12-13 04:10:27 +08:00
2019-12-17 05:06:41 +08:00
componentWillUnmount() {
const revs = NoteService.getRevs();
NoteService.setLastRevs(revs);
}
render() {
const {
isLocked,
intl,
isRTL,
} = this.props;
const url = isLocked ? this.readOnlyURL : this.noteURL;
return (
<div
data-test="note"
className={styles.note}
>
<header className={styles.header}>
<div
data-test="noteTitle"
className={styles.title}
>
<Button
onClick={() => {
Session.set('openPanel', 'userlist');
window.dispatchEvent(new Event('panelChanged'));
2019-12-17 05:06:41 +08:00
}}
2020-07-21 05:19:24 +08:00
data-test="hideNoteLabel"
2019-12-17 05:06:41 +08:00
aria-label={intl.formatMessage(intlMessages.hideNoteLabel)}
label={intl.formatMessage(intlMessages.title)}
2020-07-21 05:19:24 +08:00
icon={isRTL ? 'right_arrow' : 'left_arrow'}
2019-12-17 05:06:41 +08:00
className={styles.hideBtn}
/>
</div>
</header>
<iframe
title="etherpad"
src={url}
aria-describedby="sharedNotesEscapeHint"
/>
<span id="sharedNotesEscapeHint" className={styles.hint} aria-hidden>
{intl.formatMessage(intlMessages.tipLabel)}
</span>
</div>
);
}
}
2018-12-13 04:10:27 +08:00
Note.propTypes = propTypes;
export default injectWbResizeEvent(injectIntl(Note));