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.

ReloadButton.js 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* @flow */
  2. import React, { Component } from 'react';
  3. import { reloadNow } from '../../app';
  4. import { translate } from '../../base/i18n';
  5. import { connect } from '../../base/redux';
  6. /**
  7. * The type of the React {@code Component} props of {@link ReloadButton}.
  8. */
  9. type Props = {
  10. /**
  11. * Reloads the page.
  12. */
  13. _reloadNow: Function,
  14. /**
  15. * The function to translate human-readable text.
  16. */
  17. t: Function,
  18. /**
  19. * The translation key for the text in the button.
  20. */
  21. textKey: string
  22. };
  23. /**
  24. * Implements a React Component for button for the overlays that will reload
  25. * the page.
  26. */
  27. class ReloadButton extends Component<Props> {
  28. /**
  29. * Renders the button for relaod the page if necessary.
  30. *
  31. * @private
  32. * @returns {ReactElement}
  33. */
  34. render() {
  35. const className
  36. = 'button-control button-control_overlay button-control_center';
  37. /* eslint-disable react/jsx-handler-names */
  38. return (
  39. <button
  40. className = { className }
  41. onClick = { this.props._reloadNow }>
  42. { this.props.t(this.props.textKey) }
  43. </button>
  44. );
  45. /* eslint-enable react/jsx-handler-names */
  46. }
  47. }
  48. /**
  49. * Maps part of redux actions to component's props.
  50. *
  51. * @param {Function} dispatch - Redux's {@code dispatch} function.
  52. * @private
  53. * @returns {Object}
  54. */
  55. function _mapDispatchToProps(dispatch: Function): Object {
  56. return {
  57. /**
  58. * Dispatches the redux action to reload the page.
  59. *
  60. * @protected
  61. * @returns {Object} Dispatched action.
  62. */
  63. _reloadNow() {
  64. dispatch(reloadNow());
  65. }
  66. };
  67. }
  68. export default translate(connect(undefined, _mapDispatchToProps)(ReloadButton));