preview-first-error-pop-up.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import React from 'react'
  2. import PropTypes from 'prop-types'
  3. import { useTranslation } from 'react-i18next'
  4. import Icon from '../../../shared/components/icon'
  5. import PreviewLogEntry from './preview-log-entry'
  6. function PreviewFirstErrorPopUp({
  7. logEntry,
  8. onGoToErrorLocation,
  9. onViewLogs,
  10. onClose
  11. }) {
  12. const { t } = useTranslation()
  13. function handleGoToErrorLocation() {
  14. const { file, line, column } = logEntry
  15. onGoToErrorLocation({ file, line, column })
  16. }
  17. return (
  18. <div
  19. className="first-error-popup"
  20. role="alertdialog"
  21. aria-label={t('first_error_popup_label')}
  22. >
  23. <PreviewLogEntry
  24. {...logEntry}
  25. showLineAndNoLink={false}
  26. showCloseButton
  27. onClose={onClose}
  28. />
  29. <div className="first-error-popup-actions">
  30. <button
  31. className="btn btn-info btn-xs first-error-btn"
  32. type="button"
  33. onClick={handleGoToErrorLocation}
  34. >
  35. <Icon type="chain" />
  36. &nbsp;
  37. {t('go_to_error_location')}
  38. </button>
  39. <button
  40. className="btn btn-info btn-xs first-error-btn"
  41. type="button"
  42. onClick={onViewLogs}
  43. >
  44. <Icon type="file-text-o" />
  45. &nbsp;
  46. {t('view_all_errors')}
  47. </button>
  48. </div>
  49. </div>
  50. )
  51. }
  52. PreviewFirstErrorPopUp.propTypes = {
  53. logEntry: PropTypes.object.isRequired,
  54. onGoToErrorLocation: PropTypes.func.isRequired,
  55. onViewLogs: PropTypes.func.isRequired,
  56. onClose: PropTypes.func.isRequired
  57. }
  58. export default PreviewFirstErrorPopUp