Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

AddMeetingUrlButton.web.js 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 {
  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<*>,
  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. <Button
  58. appearance = 'primary'
  59. onClick = { this._onClick }
  60. type = 'button'>
  61. <i className = { 'icon-add' } />
  62. </Button>
  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));