ReconnectControls.jsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { withTranslation } from 'react-i18next';
  4. import { createSubscribedElement } from '../../UnstatedUtils';
  5. class ReconnectControls extends React.PureComponent {
  6. render() {
  7. const { t, isEnabled, isProcessing } = this.props;
  8. return (
  9. <>
  10. <button
  11. type="submit"
  12. className={`btn ${isEnabled ? 'btn-outline-success' : 'btn-outline-secondary'}`}
  13. onClick={() => { this.props.onReconnectingRequested() }}
  14. disabled={!isEnabled}
  15. >
  16. { isProcessing && <i className="fa fa-spinner fa-pulse mr-2"></i> }
  17. { t('full_text_search_management.reconnect_button') }
  18. </button>
  19. <p className="form-text text-muted">
  20. { t('full_text_search_management.reconnect_description') }<br />
  21. </p>
  22. </>
  23. );
  24. }
  25. }
  26. /**
  27. * Wrapper component for using unstated
  28. */
  29. const ReconnectControlsWrapper = (props) => {
  30. return createSubscribedElement(ReconnectControls, props, []);
  31. };
  32. ReconnectControls.propTypes = {
  33. t: PropTypes.func.isRequired, // i18next
  34. isEnabled: PropTypes.bool,
  35. isProcessing: PropTypes.bool,
  36. onReconnectingRequested: PropTypes.func.isRequired,
  37. };
  38. export default withTranslation()(ReconnectControlsWrapper);