Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
X
xpub-faraday
Manage
Activity
Members
Labels
Plan
Issues
2
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container Registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
xpub
xpub-faraday
Commits
8d7b3a32
Commit
8d7b3a32
authored
6 years ago
by
Bogdan Cochior
Browse files
Options
Downloads
Patches
Plain Diff
feat(review): add confirmation modal
parent
e7d98386
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!8
Sprint #10
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/component-manuscript/src/components/ReviewerReportForm.js
+41
-12
41 additions, 12 deletions
...component-manuscript/src/components/ReviewerReportForm.js
packages/components-faraday/src/redux/recommendations.js
+7
-0
7 additions, 0 deletions
packages/components-faraday/src/redux/recommendations.js
with
48 additions
and
12 deletions
packages/component-manuscript/src/components/ReviewerReportForm.js
+
41
−
12
View file @
8d7b3a32
...
@@ -3,7 +3,7 @@ import { connect } from 'react-redux'
...
@@ -3,7 +3,7 @@ import { connect } from 'react-redux'
import
{
required
}
from
'
xpub-validators
'
import
{
required
}
from
'
xpub-validators
'
import
styled
,
{
css
}
from
'
styled-components
'
import
styled
,
{
css
}
from
'
styled-components
'
import
{
compose
,
withHandlers
,
withProps
}
from
'
recompose
'
import
{
compose
,
withHandlers
,
withProps
}
from
'
recompose
'
import
{
th
,
Menu
,
ValidatedField
,
Icon
,
Button
,
Spinner
}
from
'
@pubsweet/ui
'
import
{
th
,
Menu
,
ValidatedField
,
Icon
,
Button
}
from
'
@pubsweet/ui
'
import
{
import
{
reduxForm
,
reduxForm
,
isSubmitting
,
isSubmitting
,
...
@@ -15,6 +15,14 @@ import {
...
@@ -15,6 +15,14 @@ import {
autosaveRequest
,
autosaveRequest
,
autosaveSuccess
,
autosaveSuccess
,
}
from
'
pubsweet-component-wizard/src/redux/autosave
'
}
from
'
pubsweet-component-wizard/src/redux/autosave
'
import
{
ConfirmationModal
,
withModal2
,
}
from
'
pubsweet-component-modal/src/components
'
import
{
selectFetching
,
selectError
,
}
from
'
pubsweet-components-faraday/src/redux/recommendations
'
import
{
parseReviewResponseToForm
,
parseReviewRequest
}
from
'
./utils
'
import
{
parseReviewResponseToForm
,
parseReviewRequest
}
from
'
./utils
'
...
@@ -149,11 +157,7 @@ const ReviewerReportForm = ({
...
@@ -149,11 +157,7 @@ const ReviewerReportForm = ({
<
Spacing
/>
<
Spacing
/>
<
Row
>
<
Row
>
{
isSubmitting
?
(
<
ActionButton
onClick
=
{
handleSubmit
}
>
Submit
report
<
/ActionButton
>
<
Spinner
size
=
{
4
}
/
>
)
:
(
<
ActionButton
onClick
=
{
handleSubmit
}
>
Submit
report
<
/ActionButton
>
)}
<
AutosaveIndicator
formName
=
"
reviewerReport
"
/>
<
AutosaveIndicator
formName
=
"
reviewerReport
"
/>
<
/Row
>
<
/Row
>
<
/Root
>
<
/Root
>
...
@@ -162,6 +166,15 @@ const ReviewerReportForm = ({
...
@@ -162,6 +166,15 @@ const ReviewerReportForm = ({
// To be removed
// To be removed
const
sleep
=
ms
=>
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
ms
))
const
sleep
=
ms
=>
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
ms
))
const
ModalWrapper
=
compose
(
connect
(
state
=>
({
fetching
:
selectFetching
(
state
),
modalError
:
selectError
(
state
),
})),
)(({
fetching
,
...
rest
})
=>
(
<
ConfirmationModal
{...
rest
}
isFetching
=
{
fetching
}
/
>
))
export
default
compose
(
export
default
compose
(
connect
(
connect
(
state
=>
({
state
=>
({
...
@@ -173,6 +186,9 @@ export default compose(
...
@@ -173,6 +186,9 @@ export default compose(
withProps
(()
=>
({
withProps
(()
=>
({
initialValues
:
parseReviewResponseToForm
({}),
initialValues
:
parseReviewResponseToForm
({}),
})),
})),
withModal2
(
props
=>
({
modalComponent
:
ModalWrapper
,
})),
withHandlers
({
withHandlers
({
changeField
:
({
changeForm
})
=>
(
field
,
value
)
=>
{
changeField
:
({
changeForm
})
=>
(
field
,
value
)
=>
{
changeForm
(
'
reviewerReport
'
,
field
,
value
)
changeForm
(
'
reviewerReport
'
,
field
,
value
)
...
@@ -186,12 +202,25 @@ export default compose(
...
@@ -186,12 +202,25 @@ export default compose(
dispatch
(
autosaveRequest
())
dispatch
(
autosaveRequest
())
sleep
(
1000
).
then
(()
=>
dispatch
(
autosaveSuccess
(
new
Date
())))
sleep
(
1000
).
then
(()
=>
dispatch
(
autosaveSuccess
(
new
Date
())))
},
},
onSubmit
:
(
values
,
dispatch
,
{
isSubmitting
})
=>
onSubmit
:
(
values
,
dispatch
,
{
isSubmitting
,
showModal
,
hideModal
})
=>
{
sleep
(
1000
).
then
(()
=>
{
showModal
({
// TODO: link to backend
title
:
'
Ready to Submit your Report?
'
,
const
review
=
parseReviewRequest
(
values
)
subtitle
:
'
Once submitted, the report can`t be modified
'
,
window
.
alert
(
`You submitted:\n\n
${
JSON
.
stringify
(
review
,
null
,
2
)}
`
)
confirmText
:
'
Submit report
'
,
}),
onConfirm
:
()
=>
{
sleep
(
1000
)
.
then
(
hideModal
)
.
then
(()
=>
{
// TODO: link to backend
const
review
=
parseReviewRequest
(
values
)
window
.
alert
(
`You submitted:\n\n
${
JSON
.
stringify
(
review
,
null
,
2
)}
`
,
)
})
},
onCancel
:
hideModal
,
})
},
}),
}),
)(
ReviewerReportForm
)
)(
ReviewerReportForm
)
...
...
This diff is collapsed.
Click to expand it.
packages/components-faraday/src/redux/recommendations.js
+
7
−
0
View file @
8d7b3a32
import
{
get
}
from
'
lodash
'
import
{
import
{
get
as
apiGet
,
get
as
apiGet
,
create
,
create
,
...
@@ -36,6 +37,12 @@ export const updateRecommendationSuccess = recommendation => ({
...
@@ -36,6 +37,12 @@ export const updateRecommendationSuccess = recommendation => ({
payload
:
{
recommendation
},
payload
:
{
recommendation
},
})
})
// Selectors
export
const
selectFetching
=
state
=>
get
(
state
,
'
recommendations.fetching
'
)
||
false
export
const
selectError
=
state
=>
get
(
state
,
'
recommendations.error
'
)
// Actions
// Actions
// State
// State
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment