clone-project-modal.stories.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import useFetchMock from './hooks/use-fetch-mock'
  2. import CloneProjectModal from '../js/features/clone-project-modal/components/clone-project-modal'
  3. import { ScopeDecorator } from './decorators/scope'
  4. export const Success = args => {
  5. useFetchMock(fetchMock => {
  6. fetchMock.post(
  7. 'express:/project/:projectId/clone',
  8. { status: 200 },
  9. { delay: 250 }
  10. )
  11. })
  12. return <CloneProjectModal {...args} />
  13. }
  14. export const GenericErrorResponse = args => {
  15. useFetchMock(fetchMock => {
  16. fetchMock.post(
  17. 'express:/project/:projectId/clone',
  18. { status: 500 },
  19. { delay: 250 }
  20. )
  21. })
  22. return <CloneProjectModal {...args} />
  23. }
  24. export const SpecificErrorResponse = args => {
  25. useFetchMock(fetchMock => {
  26. fetchMock.post(
  27. 'express:/project/:projectId/clone',
  28. { status: 400, body: 'The project name is not valid' },
  29. { delay: 250 }
  30. )
  31. })
  32. return <CloneProjectModal {...args} />
  33. }
  34. export default {
  35. title: 'Editor / Modals / Clone Project',
  36. component: CloneProjectModal,
  37. args: {
  38. show: true,
  39. },
  40. argTypes: {
  41. handleHide: { action: 'close modal' },
  42. openProject: { action: 'open project' },
  43. handleAfterCloned: { action: 'after cloned' },
  44. },
  45. decorators: [ScopeDecorator],
  46. }