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
7c8055c2
Commit
7c8055c2
authored
7 years ago
by
Giannis Kopanas
Browse files
Options
Downloads
Patches
Plain Diff
changing redux actions and states of uploading manuscript
parent
87ef3412
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/component-dashboard/src/components/UploadManuscript.js
+31
-10
31 additions, 10 deletions
...es/component-dashboard/src/components/UploadManuscript.js
packages/component-dashboard/src/redux/conversion.js
+7
-16
7 additions, 16 deletions
packages/component-dashboard/src/redux/conversion.js
with
38 additions
and
26 deletions
packages/component-dashboard/src/components/UploadManuscript.js
+
31
−
10
View file @
7c8055c2
...
...
@@ -4,23 +4,45 @@ import classnames from 'classnames'
import
{
Icon
}
from
'
@pubsweet/ui
'
import
classes
from
'
./UploadManuscript.local.scss
'
const
isIdle
=
conversion
=>
!
(
conversion
.
converting
||
conversion
.
complete
||
conversion
.
error
)
const
isIdle
=
conversion
=>
!
(
conversion
.
converting
||
conversion
.
error
)
class
UploadManuscript
extends
Component
{
constructor
(
props
)
{
super
(
props
)
this
.
state
=
{
complete
:
props
.
conversion
.
complete
,
completed
:
false
,
error
:
false
,
}
this
.
showErrorAndHide
=
this
.
showErrorAndHide
.
bind
(
this
)
}
componentWillReceiveProps
(
nextProps
)
{
if
(
nextProps
.
conversion
.
complete
===
true
)
{
if
(
this
.
props
.
conversion
.
converting
!==
nextProps
.
conversion
.
converting
&&
this
.
props
.
conversion
.
converting
===
true
)
{
this
.
setState
({
complete
:
true
,
completed
:
true
,
error
:
false
,
})
}
if
(
nextProps
.
conversion
.
error
!==
undefined
)
{
this
.
showErrorAndHide
()
}
}
showErrorAndHide
()
{
this
.
setState
({
error
:
true
,
completed
:
false
,
})
setTimeout
(()
=>
{
this
.
setState
({
error
:
false
,
completed
:
false
,
})
},
3000
)
}
render
()
{
...
...
@@ -36,23 +58,22 @@ class UploadManuscript extends Component {
className
=
{
classnames
({
[
classes
.
idle
]:
isIdle
(
conversion
),
[
classes
.
converting
]:
conversion
.
converting
,
[
classes
.
error
]:
conversion
.
error
,
[
classes
.
complete
]:
conversion
.
complete
,
[
classes
.
error
]:
this
.
state
.
error
,
})}
>
<
span
className
=
{
classes
.
icon
}
>
<
Icon
color
=
"
var(--color-primary)
"
>
{
this
.
state
.
complete
?
'
check_circle
'
:
'
plus_circle
'
}
{
this
.
state
.
complete
d
?
'
check_circle
'
:
'
plus_circle
'
}
<
/Icon
>
<
/span
>
<
/div
>
<
div
className
=
{
classes
.
main
}
>
{
conversion
.
error
?
(
{
this
.
state
.
error
?
(
<
div
className
=
{
classes
.
error
}
>
{
conversion
.
error
.
message
}
<
/div
>
)
:
(
<
div
className
=
{
classes
.
info
}
>
{
this
.
state
.
complete
{
this
.
state
.
complete
d
?
'
Submission created
'
:
'
Create submission
'
}
<
/div
>
...
...
This diff is collapsed.
Click to expand it.
packages/component-dashboard/src/redux/conversion.js
+
7
−
16
View file @
7c8055c2
...
...
@@ -8,7 +8,6 @@ import { generateTitle, extractTitle } from '../lib/title'
export
const
UPLOAD_MANUSCRIPT_REQUEST
=
'
UPLOAD_MANUSCRIPT_REQUEST
'
export
const
UPLOAD_MANUSCRIPT_SUCCESS
=
'
UPLOAD_MANUSCRIPT_SUCCESS
'
export
const
UPLOAD_MANUSCRIPT_FAILURE
=
'
UPLOAD_MANUSCRIPT_FAILURE
'
export
const
INITIAL_MANUSCRIPT
=
'
INITIAL_MANUSCRIPT
'
/* actions */
...
...
@@ -40,6 +39,11 @@ export const uploadManuscript = (acceptedFiles, history) => dispatch => {
request
.
addEventListener
(
'
load
'
,
event
=>
{
if
(
request
.
status
>=
400
)
{
dispatch
(
uploadManuscriptFailure
({
message
:
'
There was an error uploading the file
'
,
}),
)
throw
new
Error
(
'
There was an error uploading the file
'
)
}
...
...
@@ -88,9 +92,6 @@ export const uploadManuscript = (acceptedFiles, history) => dispatch => {
}
/submit`
// redirect after a short delay
window
.
setTimeout
(()
=>
{
dispatch
({
type
:
INITIAL_MANUSCRIPT
,
})
history
.
push
(
route
)
},
2000
)
})
...
...
@@ -98,7 +99,6 @@ export const uploadManuscript = (acceptedFiles, history) => dispatch => {
)
})
.
catch
(
error
=>
{
console
.
error
(
error
)
dispatch
(
uploadManuscriptFailure
(
error
))
throw
error
// rethrow
})
...
...
@@ -108,35 +108,26 @@ export const uploadManuscript = (acceptedFiles, history) => dispatch => {
/* reducer */
const
initialState
=
{
complete
:
false
,
converting
:
false
,
error
:
false
,
error
:
undefined
,
}
export
default
(
state
=
initialState
,
action
)
=>
{
switch
(
action
.
type
)
{
case
UPLOAD_MANUSCRIPT_REQUEST
:
return
{
complete
:
false
,
converting
:
true
,
error
:
undefined
,
}
case
INITIAL_MANUSCRIPT
:
return
{
complete
:
false
,
converting
:
false
,
}
case
UPLOAD_MANUSCRIPT_SUCCESS
:
return
{
complete
:
true
,
converting
:
false
,
error
:
undefined
,
}
case
UPLOAD_MANUSCRIPT_FAILURE
:
return
{
complete
:
false
,
converting
:
false
,
error
:
action
.
error
,
}
...
...
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