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.2KB

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