NormalizeIndicesControls.jsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { withTranslation } from 'react-i18next';
  4. import { withUnstatedContainers } from '../../UnstatedUtils';
  5. class NormalizeIndicesControls extends React.PureComponent {
  6. render() {
  7. const { t, isNormalized, isRebuildingProcessing } = this.props;
  8. const isEnabled = (isNormalized != null) && !isNormalized && !isRebuildingProcessing;
  9. return (
  10. <>
  11. <button
  12. type="submit"
  13. className={`btn ${isEnabled ? 'btn-outline-info' : 'btn-outline-secondary'}`}
  14. onClick={() => { this.props.onNormalizingRequested() }}
  15. disabled={!isEnabled}
  16. >
  17. { t('full_text_search_management.normalize_button') }
  18. </button>
  19. <p className="form-text text-muted">
  20. { t('full_text_search_management.normalize_description') }<br />
  21. </p>
  22. </>
  23. );
  24. }
  25. }
  26. /**
  27. * Wrapper component for using unstated
  28. */
  29. const NormalizeIndicesControlsWrapper = withUnstatedContainers(NormalizeIndicesControls, []);
  30. NormalizeIndicesControls.propTypes = {
  31. t: PropTypes.func.isRequired, // i18next
  32. isRebuildingProcessing: PropTypes.bool.isRequired,
  33. onNormalizingRequested: PropTypes.func.isRequired,
  34. isNormalized: PropTypes.bool,
  35. };
  36. export default withTranslation()(NormalizeIndicesControlsWrapper);