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

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