Refactor make bucket and upload components (#5521)

This commit is contained in:
Kanagaraj M
2018-02-15 08:04:59 +05:30
committed by Harshavardhana
parent 9bfa07ecf5
commit 44f8f7059c
29 changed files with 1329 additions and 213 deletions

View File

@@ -16,10 +16,14 @@
import web from "../web"
import history from "../history"
import * as alertActions from "../alert/actions"
import * as objectsActions from "../objects/actions"
export const SET_LIST = "buckets/SET_LIST"
export const ADD = "buckets/ADD"
export const SET_FILTER = "buckets/SET_FILTER"
export const SET_CURRENT_BUCKET = "buckets/SET_CURRENT_BUCKET"
export const SHOW_MAKE_BUCKET_MODAL = "buckets/SHOW_MAKE_BUCKET_MODAL"
export const fetchBuckets = () => {
return function(dispatch) {
@@ -50,6 +54,7 @@ export const setFilter = filter => {
export const selectBucket = bucket => {
return function(dispatch) {
dispatch(setCurrentBucket(bucket))
dispatch(objectsActions.selectPrefix(""))
history.push(`/${bucket}`)
}
}
@@ -60,3 +65,39 @@ export const setCurrentBucket = bucket => {
bucket
}
}
export const makeBucket = bucket => {
return function(dispatch) {
return web
.MakeBucket({
bucketName: bucket
})
.then(() => {
dispatch(addBucket(bucket))
dispatch(selectBucket(bucket))
})
.catch(err =>
dispatch(
alertActions.set({
type: "danger",
message: err.message
})
)
)
}
}
export const addBucket = bucket => ({
type: ADD,
bucket
})
export const showMakeBucketModal = () => ({
type: SHOW_MAKE_BUCKET_MODAL,
show: true
})
export const hideMakeBucketModal = () => ({
type: SHOW_MAKE_BUCKET_MODAL,
show: false
})