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

99 lines
2.7 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 { defineMessages, injectIntl } from 'react-intl';
import injectWbResizeEvent from '/imports/ui/components/presentation/resize-wrapper/component';
import Button from '/imports/ui/components/button/component';
2021-05-18 04:25:07 +08:00
import NoteService from '/imports/ui/components/note/service';
2018-12-13 04:10:27 +08:00
import { styles } from './styles';
2021-05-18 04:25:07 +08:00
import { PANELS, ACTIONS } from '../layout/enums';
2018-12-13 04:10:27 +08:00
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,
2021-08-05 19:03:24 +08:00
layoutContextDispatch,
2019-12-17 05:06:41 +08:00
} = 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={() => {
2021-08-05 19:03:24 +08:00
layoutContextDispatch({
2021-05-18 04:25:07 +08:00
type: ACTIONS.SET_SIDEBAR_CONTENT_IS_OPEN,
value: false,
});
2021-08-05 19:03:24 +08:00
layoutContextDispatch({
2021-05-18 04:25:07 +08:00
type: ACTIONS.SET_SIDEBAR_CONTENT_PANEL,
value: PANELS.NONE,
});
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));