NotFoundAlert.jsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { withTranslation } from 'react-i18next';
  4. const NotFoundAlert = (props) => {
  5. const { t, isForbidden, isNotCreatable } = props;
  6. function clickHandler(viewType) {
  7. if (props.onPageCreateClicked === null) {
  8. return;
  9. }
  10. props.onPageCreateClicked(viewType);
  11. }
  12. if (isForbidden || isNotCreatable) {
  13. return null;
  14. }
  15. return (
  16. <div className="border border-info m-4 p-3">
  17. <div className="col-md-12 p-0">
  18. <h2 className="text-info lead">
  19. <i className="icon-info pr-2 font-weight-bold" aria-hidden="true"></i>
  20. {t('not_found_page.page_not_exist_alert')}
  21. </h2>
  22. <button
  23. type="button"
  24. className="m-1 pl-3 pr-3 btn bg-info text-white"
  25. onClick={() => { clickHandler('edit') }}
  26. >
  27. <i className="icon-note icon-fw" />
  28. {t('not_found_page.Create Page')}
  29. </button>
  30. </div>
  31. </div>
  32. );
  33. };
  34. NotFoundAlert.propTypes = {
  35. t: PropTypes.func.isRequired, // i18next
  36. onPageCreateClicked: PropTypes.func,
  37. isForbidden: PropTypes.bool.isRequired,
  38. isNotCreatable: PropTypes.bool.isRequired,
  39. };
  40. export default withTranslation()(NotFoundAlert);