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

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