2021-01-06 05:30:08 -05:00
|
|
|
import React from 'react'
|
2021-03-05 08:00:13 -05:00
|
|
|
import fetchMock from 'fetch-mock'
|
|
|
|
import PropTypes from 'prop-types'
|
2021-01-06 05:30:08 -05:00
|
|
|
|
2021-03-05 08:00:13 -05:00
|
|
|
import CloneProjectModal from '../js/features/clone-project-modal/components/clone-project-modal'
|
2021-01-06 05:30:08 -05:00
|
|
|
|
2021-03-05 08:00:13 -05:00
|
|
|
export const Interactive = ({
|
|
|
|
mockResponse = 200,
|
|
|
|
mockResponseDelay = 500,
|
|
|
|
...args
|
|
|
|
}) => {
|
|
|
|
fetchMock.restore().post(
|
|
|
|
'express:/project/:projectId/clone',
|
|
|
|
() => {
|
|
|
|
switch (mockResponse) {
|
|
|
|
case 400:
|
|
|
|
return { status: 400, body: 'The project name is not valid' }
|
2021-01-06 05:30:08 -05:00
|
|
|
|
2021-03-05 08:00:13 -05:00
|
|
|
default:
|
|
|
|
return mockResponse
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ delay: mockResponseDelay }
|
|
|
|
)
|
2021-01-06 05:30:08 -05:00
|
|
|
|
2021-03-05 08:00:13 -05:00
|
|
|
return <CloneProjectModal {...args} />
|
2021-01-06 05:30:08 -05:00
|
|
|
}
|
2021-03-05 08:00:13 -05:00
|
|
|
Interactive.propTypes = {
|
|
|
|
mockResponse: PropTypes.number,
|
|
|
|
mockResponseDelay: PropTypes.number
|
2021-01-06 05:30:08 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
2021-03-25 06:11:45 -04:00
|
|
|
title: 'Modals / Clone Project',
|
2021-03-05 08:00:13 -05:00
|
|
|
component: CloneProjectModal,
|
2021-01-06 05:30:08 -05:00
|
|
|
args: {
|
2021-03-05 08:00:13 -05:00
|
|
|
projectId: 'original-project',
|
|
|
|
projectName: 'Project Title',
|
|
|
|
show: true
|
2021-01-06 05:30:08 -05:00
|
|
|
},
|
|
|
|
argTypes: {
|
2021-03-05 08:00:13 -05:00
|
|
|
handleHide: { action: 'close modal' },
|
|
|
|
openProject: { action: 'open project' },
|
|
|
|
mockResponse: {
|
|
|
|
name: 'Mock Response Status',
|
|
|
|
type: { name: 'number', required: false },
|
|
|
|
description: 'The status code that should be returned by the mock server',
|
|
|
|
defaultValue: 200,
|
|
|
|
control: {
|
|
|
|
type: 'radio',
|
|
|
|
options: [200, 500, 400]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mockResponseDelay: {
|
|
|
|
name: 'Mock Response Delay',
|
|
|
|
type: { name: 'number', required: false },
|
|
|
|
description: 'The delay before returning a response from the mock server',
|
|
|
|
defaultValue: 500,
|
|
|
|
control: {
|
|
|
|
type: 'range',
|
|
|
|
min: 0,
|
|
|
|
max: 2500,
|
|
|
|
step: 250
|
|
|
|
}
|
|
|
|
}
|
2021-01-06 05:30:08 -05:00
|
|
|
}
|
|
|
|
}
|