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
acf46417
Commit
acf46417
authored
7 years ago
by
Alexandru Munteanu
Browse files
Options
Downloads
Patches
Plain Diff
Send file type to upload S3
parent
3e0ea858
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/component-wizard/src/components/Files.js
+10
-2
10 additions, 2 deletions
packages/component-wizard/src/components/Files.js
packages/component-wizard/src/redux/files.js
+18
-4
18 additions, 4 deletions
packages/component-wizard/src/redux/files.js
with
28 additions
and
6 deletions
packages/component-wizard/src/components/Files.js
+
10
−
2
View file @
acf46417
...
...
@@ -102,7 +102,7 @@ export default compose(
project
,
version
,
})
=>
type
=>
file
=>
{
uploadFile
(
file
).
then
(
fileResponse
=>
{
uploadFile
(
file
,
type
).
then
(
fileResponse
=>
{
setFiles
([...
files
[
type
],
fileResponse
],
type
)
updateFragment
(
project
,
{
submitted
:
new
Date
(),
...
...
@@ -119,8 +119,16 @@ export default compose(
moveItem
:
({
setFiles
,
files
})
=>
type
=>
(
dragIndex
,
hoverIndex
)
=>
{
setFiles
(
SortableList
.
moveItem
(
files
[
type
],
dragIndex
,
hoverIndex
),
type
)
},
removeFile
:
()
=>
type
=>
name
=>
e
=>
{
removeFile
:
({
setFiles
,
files
,
deleteFile
,
project
,
version
,
updateFragment
,
})
=>
type
=>
id
=>
e
=>
{
e
.
preventDefault
()
// changeFiles(prev => ({
// ...prev,
// [type]: prev[type].filter(f => f.name !== name),
...
...
This diff is collapsed.
Click to expand it.
packages/component-wizard/src/redux/files.js
+
18
−
4
View file @
acf46417
import
request
from
'
pubsweet-client/src/helpers/api
'
import
request
,
{
remove
}
from
'
pubsweet-client/src/helpers/api
'
const
initialState
=
{
isFetching
:
false
,
...
...
@@ -14,6 +14,10 @@ const UPLOAD_REQUEST = 'files/UPLOAD_REQUEST'
const
UPLOAD_FAILURE
=
'
files/UPLOAD_FAILURE
'
const
UPLOAD_SUCCESS
=
'
files/UPLOAD_SUCCESS
'
const
REMOVE_REQUEST
=
'
files/REMOVE_REQUEST
'
const
REMOVE_FAILURE
=
'
files/REMOVE_FAILURE
'
const
REMOVE_SUCCESS
=
'
files/REMOVE_SUCCESS
'
const
SET_FILES
=
'
files/SET_FILES
'
export
const
setFiles
=
(
files
,
fileType
)
=>
({
...
...
@@ -35,9 +39,10 @@ const uploadSuccess = () => ({
type
:
UPLOAD_SUCCESS
,
})
const
createFileData
=
file
=>
{
const
createFileData
=
(
file
,
type
)
=>
{
const
data
=
new
FormData
()
data
.
append
(
'
file
'
,
file
)
data
.
append
(
'
fileType
'
,
type
)
return
{
method
:
'
POST
'
,
...
...
@@ -48,11 +53,15 @@ const createFileData = file => {
}
}
const
removeRequest
=
()
=>
({
type
:
REMOVE_REQUEST
,
})
export
const
getFiles
=
state
=>
state
.
files
.
files
export
const
uploadFile
=
file
=>
dispatch
=>
{
export
const
uploadFile
=
(
file
,
type
)
=>
dispatch
=>
{
dispatch
(
uploadRequest
())
return
request
(
'
/aws-upload
'
,
createFileData
(
file
))
return
request
(
'
/aws-upload
'
,
createFileData
(
file
,
type
))
.
then
(
r
=>
{
dispatch
(
uploadSuccess
())
return
r
...
...
@@ -60,6 +69,11 @@ export const uploadFile = file => dispatch => {
.
catch
(
err
=>
dispatch
(
uploadFailure
(
err
.
message
)))
}
export
const
deleteFile
=
fileId
=>
dispatch
=>
{
dispatch
(
removeRequest
())
return
remove
(
`/aws-delete/
${
fileId
}
`
)
}
export
default
(
state
=
initialState
,
action
)
=>
{
switch
(
action
.
type
)
{
case
UPLOAD_REQUEST
:
...
...
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