error-message.stories.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import ErrorMessage from '../../../js/features/file-tree/components/file-tree-create/error-message'
  2. import { createFileModalDecorator } from './create-file-modal-decorator'
  3. import { FetchError } from '../../../js/infrastructure/fetch-json'
  4. import {
  5. BlockedFilenameError,
  6. DuplicateFilenameError,
  7. InvalidFilenameError,
  8. } from '../../../js/features/file-tree/errors'
  9. export const KeyedErrors = () => {
  10. return (
  11. <>
  12. <ErrorMessage error="name-exists" />
  13. <ErrorMessage error="too-many-files" />
  14. <ErrorMessage error="remote-service-error" />
  15. <ErrorMessage error="rate-limit-hit" />
  16. {/* <ErrorMessage error="not-logged-in" /> */}
  17. <ErrorMessage error="something-else" />
  18. </>
  19. )
  20. }
  21. KeyedErrors.decorators = [createFileModalDecorator()]
  22. export const FetchStatusErrors = () => {
  23. return (
  24. <>
  25. <ErrorMessage
  26. error={
  27. new FetchError(
  28. 'There was an error',
  29. '/story',
  30. {},
  31. new Response(null, { status: 400 })
  32. )
  33. }
  34. />
  35. <ErrorMessage
  36. error={
  37. new FetchError(
  38. 'There was an error',
  39. '/story',
  40. {},
  41. new Response(null, { status: 403 })
  42. )
  43. }
  44. />
  45. <ErrorMessage
  46. error={
  47. new FetchError(
  48. 'There was an error',
  49. '/story',
  50. {},
  51. new Response(null, { status: 429 })
  52. )
  53. }
  54. />
  55. <ErrorMessage
  56. error={
  57. new FetchError(
  58. 'There was an error',
  59. '/story',
  60. {},
  61. new Response(null, { status: 500 })
  62. )
  63. }
  64. />
  65. </>
  66. )
  67. }
  68. export const FetchDataErrors = () => {
  69. return (
  70. <>
  71. <ErrorMessage
  72. error={
  73. new FetchError('Error', '/story', {}, new Response(), {
  74. message: 'There was an error!',
  75. })
  76. }
  77. />
  78. <ErrorMessage
  79. error={
  80. new FetchError('Error', '/story', {}, new Response(), {
  81. message: {
  82. text: 'There was an error with some text!',
  83. },
  84. })
  85. }
  86. />
  87. </>
  88. )
  89. }
  90. export const SpecificClassErrors = () => {
  91. return (
  92. <>
  93. <ErrorMessage error={new DuplicateFilenameError()} />
  94. <ErrorMessage error={new InvalidFilenameError()} />
  95. <ErrorMessage error={new BlockedFilenameError()} />
  96. <ErrorMessage error={new Error()} />
  97. </>
  98. )
  99. }
  100. export default {
  101. title: 'Editor / Modals / Create File / Error Message',
  102. component: ErrorMessage,
  103. }