2018-08-27 15:13:59 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import React, { Component } from 'react';
|
2019-03-19 15:42:25 +00:00
|
|
|
import type { Dispatch } from 'redux';
|
2018-08-27 15:13:59 +00:00
|
|
|
|
2018-09-01 01:03:35 +00:00
|
|
|
import {
|
|
|
|
createCalendarClickedEvent,
|
|
|
|
sendAnalytics
|
|
|
|
} from '../../analytics';
|
2018-08-27 15:13:59 +00:00
|
|
|
import { translate } from '../../base/i18n';
|
2019-08-30 16:39:06 +00:00
|
|
|
import { Icon, IconAdd } from '../../base/icons';
|
2019-03-21 16:38:29 +00:00
|
|
|
import { connect } from '../../base/redux';
|
2021-02-04 13:24:25 +00:00
|
|
|
import { Tooltip } from '../../base/tooltip';
|
2018-08-27 15:13:59 +00:00
|
|
|
import { updateCalendarEvent } from '../actions';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} props of {@link AddMeetingUrlButton}.
|
|
|
|
*/
|
|
|
|
type Props = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The calendar ID associated with the calendar event.
|
|
|
|
*/
|
|
|
|
calendarId: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoked to add a meeting URL to a calendar event.
|
|
|
|
*/
|
2019-03-19 15:42:25 +00:00
|
|
|
dispatch: Dispatch<any>,
|
2018-08-27 15:13:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The ID of the calendar event that will have a meeting URL added on click.
|
|
|
|
*/
|
|
|
|
eventId: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoked to obtain translated strings.
|
|
|
|
*/
|
|
|
|
t: Function
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A React Component for adding a meeting URL to an existing calendar event.
|
|
|
|
*
|
2021-11-04 21:10:43 +00:00
|
|
|
* @augments Component
|
2018-08-27 15:13:59 +00:00
|
|
|
*/
|
|
|
|
class AddMeetingUrlButton extends Component<Props> {
|
|
|
|
/**
|
|
|
|
* Initializes a new {@code AddMeetingUrlButton} instance.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
constructor(props: 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-08-27 15:13:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
return (
|
2018-08-28 00:56:17 +00:00
|
|
|
<Tooltip content = { this.props.t('calendarSync.addMeetingURL') }>
|
2018-10-22 18:49:18 +00:00
|
|
|
<div
|
|
|
|
className = 'button add-button'
|
2021-06-10 12:48:44 +00:00
|
|
|
onClick = { this._onClick }
|
|
|
|
onKeyPress = { this._onKeyPress }
|
|
|
|
role = 'button'>
|
2019-08-30 16:39:06 +00:00
|
|
|
<Icon src = { IconAdd } />
|
2018-10-22 18:49:18 +00:00
|
|
|
</div>
|
2018-08-28 00:56:17 +00:00
|
|
|
</Tooltip>
|
2018-08-27 15:13:59 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
_onClick: () => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Dispatches an action to adding a meeting URL to a calendar event.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onClick() {
|
|
|
|
const { calendarId, dispatch, eventId } = this.props;
|
|
|
|
|
2021-11-09 10:20:40 +00:00
|
|
|
sendAnalytics(createCalendarClickedEvent('add.url'));
|
2018-09-01 01:03:35 +00:00
|
|
|
|
2018-08-27 15:13:59 +00:00
|
|
|
dispatch(updateCalendarEvent(eventId, calendarId));
|
|
|
|
}
|
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-08-27 15:13:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(connect()(AddMeetingUrlButton));
|