NotFoundAlert.jsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. >
  21. <h2 className="text-info lead">
  22. <i className="icon-info pr-2 font-weight-bold" aria-hidden="true"></i>
  23. {t('not_found_page.page_not_exist_alert')}
  24. </h2>
  25. <button
  26. type="button"
  27. className="m-1 pl-3 pr-3 btn bg-info text-white"
  28. onClick={() => { clickHandler('edit') }}
  29. disabled={isGuestUserMode}
  30. >
  31. <div id="create-page-btn-wrapper-for-tooltip">
  32. <i className="icon-note icon-fw" />
  33. {t('not_found_page.Create Page')}
  34. </div>
  35. </button>
  36. {isGuestUserMode && (
  37. <UncontrolledTooltip placement="bottom" target="create-page-btn-wrapper-for-tooltip" fade={false}>
  38. {t('Not available for guest')}
  39. </UncontrolledTooltip>
  40. )}
  41. </div>
  42. </div>
  43. );
  44. };
  45. NotFoundAlert.propTypes = {
  46. t: PropTypes.func.isRequired, // i18next
  47. onPageCreateClicked: PropTypes.func,
  48. isHidden: PropTypes.bool.isRequired,
  49. isGuestUserMode: PropTypes.bool.isRequired,
  50. };
  51. export default withTranslation()(NotFoundAlert);