You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AddMeetingUrlButton.web.js 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { connect } from 'react-redux';
  4. import Tooltip from '@atlaskit/tooltip';
  5. import {
  6. createCalendarClickedEvent,
  7. sendAnalytics
  8. } from '../../analytics';
  9. import { translate } from '../../base/i18n';
  10. import { updateCalendarEvent } from '../actions';
  11. /**
  12. * The type of the React {@code Component} props of {@link AddMeetingUrlButton}.
  13. */
  14. type Props = {
  15. /**
  16. * The calendar ID associated with the calendar event.
  17. */
  18. calendarId: string,
  19. /**
  20. * Invoked to add a meeting URL to a calendar event.
  21. */
  22. dispatch: Dispatch<*>,
  23. /**
  24. * The ID of the calendar event that will have a meeting URL added on click.
  25. */
  26. eventId: string,
  27. /**
  28. * Invoked to obtain translated strings.
  29. */
  30. t: Function
  31. };
  32. /**
  33. * A React Component for adding a meeting URL to an existing calendar event.
  34. *
  35. * @extends Component
  36. */
  37. class AddMeetingUrlButton extends Component<Props> {
  38. /**
  39. * Initializes a new {@code AddMeetingUrlButton} instance.
  40. *
  41. * @inheritdoc
  42. */
  43. constructor(props: Props) {
  44. super(props);
  45. // Bind event handler so it is only bound once for every instance.
  46. this._onClick = this._onClick.bind(this);
  47. }
  48. /**
  49. * Implements React's {@link Component#render}.
  50. *
  51. * @inheritdoc
  52. */
  53. render() {
  54. return (
  55. <Tooltip content = { this.props.t('calendarSync.addMeetingURL') }>
  56. <div
  57. className = 'button add-button'
  58. onClick = { this._onClick }>
  59. <i className = { 'icon-add' } />
  60. </div>
  61. </Tooltip>
  62. );
  63. }
  64. _onClick: () => void;
  65. /**
  66. * Dispatches an action to adding a meeting URL to a calendar event.
  67. *
  68. * @returns {void}
  69. */
  70. _onClick() {
  71. const { calendarId, dispatch, eventId } = this.props;
  72. sendAnalytics(createCalendarClickedEvent('calendar.add.url'));
  73. dispatch(updateCalendarEvent(eventId, calendarId));
  74. }
  75. }
  76. export default translate(connect()(AddMeetingUrlButton));