2018-09-01 01:03:35 +00:00
|
|
|
// @flow
|
|
|
|
|
2020-05-20 10:57:03 +00:00
|
|
|
import React, { Component } from 'react';
|
2018-09-01 01:03:35 +00:00
|
|
|
|
|
|
|
import { translate } from '../../base/i18n';
|
2022-11-08 10:24:32 +00:00
|
|
|
import { Icon, IconPlus } from '../../base/icons';
|
2021-02-04 13:24:25 +00:00
|
|
|
import { Tooltip } from '../../base/tooltip';
|
2018-09-01 01:03:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} props of {@link JoinButton}.
|
|
|
|
*/
|
|
|
|
type Props = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The function called when the button is pressed.
|
|
|
|
*/
|
|
|
|
onPress: Function,
|
|
|
|
|
2018-09-06 15:23:38 +00:00
|
|
|
/**
|
|
|
|
* The meeting URL associated with the {@link JoinButton} instance.
|
|
|
|
*/
|
|
|
|
url: string,
|
|
|
|
|
2018-09-01 01:03:35 +00:00
|
|
|
/**
|
|
|
|
* Invoked to obtain translated strings.
|
|
|
|
*/
|
|
|
|
t: Function
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A React Component for joining an existing calendar meeting.
|
|
|
|
*
|
2021-11-04 21:10:43 +00:00
|
|
|
* @augments Component
|
2018-09-01 01:03:35 +00:00
|
|
|
*/
|
|
|
|
class JoinButton extends Component<Props> {
|
|
|
|
|
2018-09-06 15:23:38 +00:00
|
|
|
/**
|
|
|
|
* Initializes a new {@code JoinButton} instance.
|
|
|
|
*
|
|
|
|
* @param {*} props - The read-only properties with which the new instance
|
|
|
|
* is to be initialized.
|
|
|
|
*/
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
// Bind event handler so it is only bound once for every instance.
|
|
|
|
this._onClick = this._onClick.bind(this);
|
2021-06-10 12:48:44 +00:00
|
|
|
this._onKeyPress = this._onKeyPress.bind(this);
|
2018-09-06 15:23:38 +00:00
|
|
|
}
|
|
|
|
|
2018-09-01 01:03:35 +00:00
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
render() {
|
2018-09-06 15:23:38 +00:00
|
|
|
const { t } = this.props;
|
2018-09-01 01:03:35 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Tooltip
|
|
|
|
content = { t('calendarSync.joinTooltip') }>
|
2018-10-22 18:49:18 +00:00
|
|
|
<div
|
|
|
|
className = 'button join-button'
|
2021-06-10 12:48:44 +00:00
|
|
|
onClick = { this._onClick }
|
|
|
|
onKeyPress = { this._onKeyPress }
|
|
|
|
role = 'button'>
|
2020-10-19 07:37:19 +00:00
|
|
|
<Icon
|
|
|
|
size = '14'
|
2022-11-08 10:24:32 +00:00
|
|
|
src = { IconPlus } />
|
2018-10-22 18:49:18 +00:00
|
|
|
</div>
|
2018-09-01 01:03:35 +00:00
|
|
|
</Tooltip>
|
|
|
|
);
|
|
|
|
}
|
2018-09-06 15:23:38 +00:00
|
|
|
|
|
|
|
_onClick: (Object) => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback invoked when the component is clicked.
|
|
|
|
*
|
|
|
|
* @param {Object} event - The DOM click event.
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onClick(event) {
|
|
|
|
this.props.onPress(event, this.props.url);
|
|
|
|
}
|
2021-06-10 12:48:44 +00:00
|
|
|
|
|
|
|
_onKeyPress: (Object) => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* KeyPress handler for accessibility.
|
|
|
|
*
|
|
|
|
* @param {Object} e - The key event to handle.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onKeyPress(e) {
|
|
|
|
if (e.key === ' ' || e.key === 'Enter') {
|
|
|
|
e.preventDefault();
|
|
|
|
this._onClick();
|
|
|
|
}
|
|
|
|
}
|
2018-09-01 01:03:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(JoinButton);
|