NotFoundAlert.jsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { withTranslation } from 'react-i18next';
  4. import { UncontrolledTooltip } from 'reactstrap';
  5. const NotFoundAlert = (props) => {
  6. const { t, isHidden, isGuestUserMode } = props;
  7. function clickHandler(viewType) {
  8. // check guest user,
  9. // disabled of button cannot be used for using tooltip.
  10. if (isGuestUserMode) {
  11. return;
  12. }
  13. if (props.onPageCreateClicked === null) {
  14. return;
  15. }
  16. props.onPageCreateClicked(viewType);
  17. }
  18. if (isHidden) {
  19. return null;
  20. }
  21. return (
  22. <div className="border border-info p-3">
  23. <div
  24. className="col-md-12 p-0"
  25. >
  26. <h2 className="text-info lead">
  27. <i className="icon-info pr-2 font-weight-bold" aria-hidden="true"></i>
  28. {t('not_found_page.page_not_exist_alert')}
  29. </h2>
  30. <div id="create-page-btn-wrapper-for-tooltip" className="d-inline-block">
  31. <button
  32. type="button"
  33. className={`pl-3 pr-3 btn bg-info text-white ${isGuestUserMode ? 'disabled' : ''}`}
  34. onClick={() => { clickHandler('edit') }}
  35. >
  36. <i className="icon-note icon-fw" />
  37. {t('not_found_page.Create Page')}
  38. </button>
  39. </div>
  40. {isGuestUserMode && (
  41. <UncontrolledTooltip placement="bottom" target="create-page-btn-wrapper-for-tooltip" fade={false}>
  42. {t('Not available for guest')}
  43. </UncontrolledTooltip>
  44. )}
  45. </div>
  46. </div>
  47. );
  48. };
  49. NotFoundAlert.propTypes = {
  50. t: PropTypes.func.isRequired, // i18next
  51. onPageCreateClicked: PropTypes.func,
  52. isHidden: PropTypes.bool.isRequired,
  53. isGuestUserMode: PropTypes.bool.isRequired,
  54. };
  55. export default withTranslation()(NotFoundAlert);