1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- // @flow
-
- import Button from '@atlaskit/button';
- import React, { Component } from 'react';
- import { connect } from 'react-redux';
- import Tooltip from '@atlaskit/tooltip';
-
- import {
- createCalendarClickedEvent,
- sendAnalytics
- } from '../../analytics';
- import { translate } from '../../base/i18n';
-
- 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.
- */
- dispatch: Dispatch<*>,
-
- /**
- * 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.
- *
- * @extends Component
- */
- 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);
- }
-
- /**
- * Implements React's {@link Component#render}.
- *
- * @inheritdoc
- */
- render() {
- return (
- <Tooltip content = { this.props.t('calendarSync.addMeetingURL') }>
- <Button
- appearance = 'primary'
- onClick = { this._onClick }
- type = 'button'>
- <i className = { 'icon-add' } />
- </Button>
- </Tooltip>
- );
- }
-
- _onClick: () => void;
-
- /**
- * Dispatches an action to adding a meeting URL to a calendar event.
- *
- * @returns {void}
- */
- _onClick() {
- const { calendarId, dispatch, eventId } = this.props;
-
- sendAnalytics(createCalendarClickedEvent('calendar.add.url'));
-
- dispatch(updateCalendarEvent(eventId, calendarId));
- }
- }
-
- export default translate(connect()(AddMeetingUrlButton));
|