From 384b4fdf289b957e971e0c1e4f316198d0cb90de Mon Sep 17 00:00:00 2001 From: Kaan Kabalak Date: Fri, 2 Mar 2018 10:23:50 -0800 Subject: [PATCH] Tweak fetchBuckets to comply with the changes made to the routes (#5592) This commit removes the argument in the fetchBuckets function that was introduced in #5580. Due to the adjustment made in #5584, we no longer need to differentiate between where the function has been called from. --- browser/app/js/buckets/BucketList.js | 4 ++-- browser/app/js/buckets/__tests__/actions.test.js | 6 +++--- browser/app/js/buckets/actions.js | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/browser/app/js/buckets/BucketList.js b/browser/app/js/buckets/BucketList.js index 76ff878c3..905553ad7 100644 --- a/browser/app/js/buckets/BucketList.js +++ b/browser/app/js/buckets/BucketList.js @@ -28,7 +28,7 @@ export class BucketList extends React.Component { componentWillMount() { const { fetchBuckets, setBucketList, selectBucket } = this.props if (web.LoggedIn()) { - fetchBuckets("list") + fetchBuckets() } else { const { bucket, prefix } = pathSlice(history.location.pathname) if (bucket) { @@ -65,7 +65,7 @@ const mapStateToProps = state => { const mapDispatchToProps = dispatch => { return { - fetchBuckets: action => dispatch(actionsBuckets.fetchBuckets(action)), + fetchBuckets: () => dispatch(actionsBuckets.fetchBuckets()), setBucketList: buckets => dispatch(actionsBuckets.setList(buckets)), selectBucket: bucket => dispatch(actionsBuckets.selectBucket(bucket)) } diff --git a/browser/app/js/buckets/__tests__/actions.test.js b/browser/app/js/buckets/__tests__/actions.test.js index 4d14dd245..dd77600d5 100644 --- a/browser/app/js/buckets/__tests__/actions.test.js +++ b/browser/app/js/buckets/__tests__/actions.test.js @@ -46,7 +46,7 @@ describe("Buckets actions", () => { { type: "buckets/SET_LIST", buckets: ["test1", "test2"] }, { type: "buckets/SET_CURRENT_BUCKET", bucket: "test1" } ] - return store.dispatch(actionsBuckets.fetchBuckets("list")).then(() => { + return store.dispatch(actionsBuckets.fetchBuckets()).then(() => { const actions = store.getActions() expect(actions).toEqual(expectedActions) }) @@ -60,7 +60,7 @@ describe("Buckets actions", () => { { type: "buckets/SET_CURRENT_BUCKET", bucket: "test2" } ] window.location - return store.dispatch(actionsBuckets.fetchBuckets("list")).then(() => { + return store.dispatch(actionsBuckets.fetchBuckets()).then(() => { const actions = store.getActions() expect(actions).toEqual(expectedActions) }) @@ -74,7 +74,7 @@ describe("Buckets actions", () => { { type: "buckets/SET_CURRENT_BUCKET", bucket: "test1" } ] window.location - return store.dispatch(actionsBuckets.fetchBuckets("list")).then(() => { + return store.dispatch(actionsBuckets.fetchBuckets()).then(() => { const actions = store.getActions() expect(actions).toEqual(expectedActions) }) diff --git a/browser/app/js/buckets/actions.js b/browser/app/js/buckets/actions.js index 7a68f52d0..562a0049f 100644 --- a/browser/app/js/buckets/actions.js +++ b/browser/app/js/buckets/actions.js @@ -29,7 +29,7 @@ export const SHOW_MAKE_BUCKET_MODAL = "buckets/SHOW_MAKE_BUCKET_MODAL" export const SHOW_BUCKET_POLICY = "buckets/SHOW_BUCKET_POLICY" export const SET_POLICIES = "buckets/SET_POLICIES" -export const fetchBuckets = action => { +export const fetchBuckets = () => { return function(dispatch) { return web.ListBuckets().then(res => { const buckets = res.buckets ? res.buckets.map(bucket => bucket.name) : [] @@ -41,7 +41,7 @@ export const fetchBuckets = action => { } else { dispatch(selectBucket(buckets[0])) } - } else if (action === "delete") { + } else { dispatch(selectBucket("")) history.replace("/") } @@ -112,7 +112,7 @@ export const deleteBucket = bucket => { }) ) dispatch(removeBucket(bucket)) - dispatch(fetchBuckets("delete")) + dispatch(fetchBuckets()) }) .catch(err => { dispatch(