mirror of
https://github.com/minio/minio.git
synced 2025-11-21 10:16:03 -05:00
Refactor make bucket and upload components (#5521)
This commit is contained in:
committed by
Harshavardhana
parent
9bfa07ecf5
commit
44f8f7059c
@@ -22,15 +22,6 @@ import * as actionsObjects from "./actions"
|
||||
import ObjectsList from "./ObjectsList"
|
||||
|
||||
export class ObjectsListContainer extends React.Component {
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { currentBucket, currentPrefix, loadObjects } = this.props
|
||||
if (
|
||||
currentBucket != nextProps.currentBucket ||
|
||||
currentPrefix != nextProps.currentPrefix
|
||||
) {
|
||||
loadObjects()
|
||||
}
|
||||
}
|
||||
render() {
|
||||
const { objects, isTruncated, currentBucket, loadObjects } = this.props
|
||||
return (
|
||||
|
||||
@@ -36,22 +36,4 @@ describe("ObjectsList", () => {
|
||||
{ name: "test2.jpg" }
|
||||
])
|
||||
})
|
||||
|
||||
it("should call loadObjects when currentBucket is changed", () => {
|
||||
const loadObjects = jest.fn()
|
||||
const wrapper = shallow(
|
||||
<ObjectsListContainer currentBucket="test1" loadObjects={loadObjects} />
|
||||
)
|
||||
wrapper.setProps({ currentBucket: "test2" })
|
||||
expect(loadObjects).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("should call loadObjects when currentPrefix is changed", () => {
|
||||
const loadObjects = jest.fn()
|
||||
const wrapper = shallow(
|
||||
<ObjectsListContainer currentPrefix="abc/" loadObjects={loadObjects} />
|
||||
)
|
||||
wrapper.setProps({ currentPrefix: "abc/xyz/" })
|
||||
expect(loadObjects).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -158,7 +158,8 @@ describe("Objects actions", () => {
|
||||
|
||||
it("should update browser url and creates objects/SET_CURRENT_PREFIX action when selectPrefix is called", () => {
|
||||
const store = mockStore({
|
||||
buckets: { currentBucket: "test" }
|
||||
buckets: { currentBucket: "test" },
|
||||
objects: { currentPrefix: "" }
|
||||
})
|
||||
const expectedActions = [
|
||||
{ type: "objects/SET_CURRENT_PREFIX", prefix: "abc/" }
|
||||
|
||||
@@ -21,9 +21,11 @@ import {
|
||||
sortObjectsBySize,
|
||||
sortObjectsByDate
|
||||
} from "../utils"
|
||||
import { getCurrentBucket } from "../buckets/selectors"
|
||||
|
||||
export const SET_LIST = "objects/SET_LIST"
|
||||
export const APPEND_LIST = "objects/APPEND_LIST"
|
||||
export const RESET = "objects/RESET"
|
||||
export const SET_SORT_BY = "objects/SET_SORT_BY"
|
||||
export const SET_SORT_ORDER = "objects/SET_SORT_ORDER"
|
||||
export const SET_CURRENT_PREFIX = "objects/SET_CURRENT_PREFIX"
|
||||
@@ -52,7 +54,7 @@ export const fetchObjects = append => {
|
||||
.ListObjects({
|
||||
bucketName: currentBucket,
|
||||
prefix: currentPrefix,
|
||||
marker: marker
|
||||
marker: append ? marker : ""
|
||||
})
|
||||
.then(res => {
|
||||
let objects = []
|
||||
@@ -113,7 +115,8 @@ export const setSortOrder = sortOrder => ({
|
||||
export const selectPrefix = prefix => {
|
||||
return function(dispatch, getState) {
|
||||
dispatch(setCurrentPrefix(prefix))
|
||||
const currentBucket = getState().buckets.currentBucket
|
||||
dispatch(fetchObjects())
|
||||
const currentBucket = getCurrentBucket(getState())
|
||||
history.replace(`/${currentBucket}/${prefix}`)
|
||||
}
|
||||
}
|
||||
|
||||
19
browser/app/js/objects/selectors.js
Normal file
19
browser/app/js/objects/selectors.js
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Minio Cloud Storage (C) 2018 Minio, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { createSelector } from "reselect"
|
||||
|
||||
export const getCurrentPrefix = state => state.objects.currentPrefix
|
||||
Reference in New Issue
Block a user