您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

AddMeetingUrlButton.web.js 1.9KB

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