NotFoundAlert.jsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. if (props.onPageCreateClicked === null) {
  9. return;
  10. }
  11. props.onPageCreateClicked(viewType);
  12. }
  13. if (isHidden) {
  14. return null;
  15. }
  16. return (
  17. <div className="border border-info p-3">
  18. <div
  19. className="col-md-12 p-0"
  20. id="create-page-btn-wrapper-for-tooltip"
  21. >
  22. <h2 className="text-info lead">
  23. <i className="icon-info pr-2 font-weight-bold" aria-hidden="true"></i>
  24. {t('not_found_page.page_not_exist_alert')}
  25. </h2>
  26. <button
  27. type="button"
  28. className={`m-1 pl-3 pr-3 btn bg-info text-white ${isGuestUserMode && 'disabled'}`}
  29. onClick={() => { clickHandler('edit') }}
  30. >
  31. <i className="icon-note icon-fw" />
  32. {t('not_found_page.Create Page')}
  33. </button>
  34. {isGuestUserMode && (
  35. <UncontrolledTooltip placement="top" target="create-page-btn-wrapper-for-tooltip" fade={false}>
  36. {t('Not available for guest')}
  37. </UncontrolledTooltip>
  38. )}
  39. </div>
  40. </div>
  41. );
  42. };
  43. NotFoundAlert.propTypes = {
  44. t: PropTypes.func.isRequired, // i18next
  45. onPageCreateClicked: PropTypes.func,
  46. isHidden: PropTypes.bool.isRequired,
  47. isGuestUserMode: PropTypes.bool.isRequired,
  48. };
  49. export default withTranslation()(NotFoundAlert);