|
|
@@ -1,77 +1,76 @@
|
|
|
import React from 'react'
|
|
|
+import fetchMock from 'fetch-mock'
|
|
|
+import PropTypes from 'prop-types'
|
|
|
|
|
|
-import WordCountModalContent from '../js/features/word-count-modal/components/word-count-modal-content'
|
|
|
+import WordCountModal from '../js/features/word-count-modal/components/word-count-modal'
|
|
|
|
|
|
-// NOTE: WordCountModalContent is wrapped in modal classes, without modal behaviours
|
|
|
+export const Interactive = ({
|
|
|
+ mockResponse = 200,
|
|
|
+ mockResponseDelay = 500,
|
|
|
+ ...args
|
|
|
+}) => {
|
|
|
+ fetchMock.restore().get(
|
|
|
+ 'express:/project/:projectId/wordcount',
|
|
|
+ () => {
|
|
|
+ switch (mockResponse) {
|
|
|
+ case 400:
|
|
|
+ return { status: 400, body: 'The project id is not valid' }
|
|
|
|
|
|
-export const Loading = args => (
|
|
|
- <div className="modal-dialog">
|
|
|
- <div className="modal-content">
|
|
|
- <WordCountModalContent {...args} />
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-)
|
|
|
-Loading.args = {
|
|
|
- loading: true,
|
|
|
- error: false
|
|
|
-}
|
|
|
+ case 200:
|
|
|
+ return {
|
|
|
+ texcount: {
|
|
|
+ headers: 4,
|
|
|
+ mathDisplay: 40,
|
|
|
+ mathInline: 400,
|
|
|
+ textWords: 4000
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
-export const LoadingError = args => (
|
|
|
- <div className="modal-dialog">
|
|
|
- <div className="modal-content">
|
|
|
- <WordCountModalContent {...args} />
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-)
|
|
|
-LoadingError.args = {
|
|
|
- loading: false,
|
|
|
- error: true
|
|
|
-}
|
|
|
+ default:
|
|
|
+ return mockResponse
|
|
|
+ }
|
|
|
+ },
|
|
|
+ { delay: mockResponseDelay }
|
|
|
+ )
|
|
|
|
|
|
-export const Loaded = args => (
|
|
|
- <div className="modal-dialog">
|
|
|
- <div className="modal-content">
|
|
|
- <WordCountModalContent {...args} />
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-)
|
|
|
-Loaded.args = {
|
|
|
- loading: false,
|
|
|
- error: false,
|
|
|
- data: {
|
|
|
- headers: 4,
|
|
|
- mathDisplay: 40,
|
|
|
- mathInline: 400,
|
|
|
- textWords: 4000
|
|
|
- }
|
|
|
+ return <WordCountModal {...args} />
|
|
|
}
|
|
|
-
|
|
|
-export const Messages = args => (
|
|
|
- <div className="modal-dialog">
|
|
|
- <div className="modal-content">
|
|
|
- <WordCountModalContent {...args} />
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-)
|
|
|
-Messages.args = {
|
|
|
- loading: false,
|
|
|
- error: false,
|
|
|
- data: {
|
|
|
- messages: [
|
|
|
- 'Lorem ipsum dolor sit amet.',
|
|
|
- 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.'
|
|
|
- ].join('\n'),
|
|
|
- headers: 4,
|
|
|
- mathDisplay: 40,
|
|
|
- mathInline: 400,
|
|
|
- textWords: 4000
|
|
|
- }
|
|
|
+Interactive.propTypes = {
|
|
|
+ mockResponse: PropTypes.number,
|
|
|
+ mockResponseDelay: PropTypes.number
|
|
|
}
|
|
|
|
|
|
export default {
|
|
|
title: 'Word Count Modal',
|
|
|
- component: WordCountModalContent,
|
|
|
+ component: WordCountModal,
|
|
|
+ args: {
|
|
|
+ clsiServerId: 'server-id',
|
|
|
+ projectId: 'project-id',
|
|
|
+ show: true
|
|
|
+ },
|
|
|
argTypes: {
|
|
|
- handleHide: { action: 'handleHide' }
|
|
|
+ handleHide: { action: 'handleHide' },
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|