Refactor of components (#5499)

This commit is contained in:
Kanagaraj M
2018-02-10 08:04:14 +05:30
committed by Harshavardhana
parent 9ab6a8035f
commit feb726dd98
40 changed files with 1733 additions and 127 deletions
+11
View File
@@ -15,6 +15,7 @@
*/
import web from "../web"
import history from "../history"
export const SET_LIST = "buckets/SET_LIST"
export const SET_FILTER = "buckets/SET_FILTER"
@@ -25,6 +26,9 @@ export const fetchBuckets = () => {
return web.ListBuckets().then(res => {
const buckets = res.buckets ? res.buckets.map(bucket => bucket.name) : []
dispatch(setList(buckets))
if (buckets.length > 0) {
dispatch(selectBucket(buckets[0]))
}
})
}
}
@@ -43,6 +47,13 @@ export const setFilter = filter => {
}
}
export const selectBucket = bucket => {
return function(dispatch) {
dispatch(setCurrentBucket(bucket))
history.push(`/${bucket}`)
}
}
export const setCurrentBucket = bucket => {
return {
type: SET_CURRENT_BUCKET,