error-message.stories.js 2.5 KB

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