mirror of
https://github.com/minio/minio.git
synced 2025-11-26 04:26:12 -05:00
Fix failing unit tests in browser (#5688)
* format js files using prettier Used the following command to format the files prettier --write "browser/app/js/**/*.js" * fix failing unit tests in browser
This commit is contained in:
committed by
Harshavardhana
parent
cb3818be27
commit
c0e45f9098
@@ -19,7 +19,7 @@ import ConfirmModal from "../browser/ConfirmModal"
|
||||
|
||||
export const DeleteObjectConfirmModal = ({
|
||||
deleteObject,
|
||||
hideDeleteConfirmModal,
|
||||
hideDeleteConfirmModal
|
||||
}) => (
|
||||
<ConfirmModal
|
||||
show={true}
|
||||
|
||||
@@ -27,14 +27,14 @@ export const ObjectContainer = ({ object, downloadObject }) => {
|
||||
name: object.name,
|
||||
contentType: object.contentType,
|
||||
size: humanize.filesize(object.size),
|
||||
lastModified: Moment(object.lastModified).format("lll"),
|
||||
lastModified: Moment(object.lastModified).format("lll")
|
||||
}
|
||||
return <ObjectItem {...props} onClick={() => downloadObject(object.name)} />
|
||||
}
|
||||
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
downloadObject: object => dispatch(actionsObjects.downloadObject(object)),
|
||||
downloadObject: object => dispatch(actionsObjects.downloadObject(object))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,13 +29,13 @@ export const ObjectItem = ({
|
||||
checked,
|
||||
checkObject,
|
||||
uncheckObject,
|
||||
onClick,
|
||||
onClick
|
||||
}) => {
|
||||
return (
|
||||
<div
|
||||
className={classNames({
|
||||
objects__row: true,
|
||||
"objects__row--directory": getDataType(name, contentType) == "folder",
|
||||
"objects__row--directory": getDataType(name, contentType) == "folder"
|
||||
})}
|
||||
>
|
||||
<div
|
||||
@@ -75,14 +75,14 @@ export const ObjectItem = ({
|
||||
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
return {
|
||||
checked: getCheckedList(state).indexOf(ownProps.name) >= 0,
|
||||
checked: getCheckedList(state).indexOf(ownProps.name) >= 0
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
checkObject: name => dispatch(actions.checkObject(name)),
|
||||
uncheckObject: name => dispatch(actions.uncheckObject(name)),
|
||||
uncheckObject: name => dispatch(actions.uncheckObject(name))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ export const ObjectsHeader = ({
|
||||
sortNameOrder,
|
||||
sortSizeOrder,
|
||||
sortLastModifiedOrder,
|
||||
sortObjects,
|
||||
sortObjects
|
||||
}) => (
|
||||
<div className="objects__row objects__header hidden-xs">
|
||||
<div
|
||||
@@ -38,7 +38,7 @@ export const ObjectsHeader = ({
|
||||
objects__sort: true,
|
||||
zmdi: true,
|
||||
"zmdi-sort-desc": sortNameOrder,
|
||||
"zmdi-sort-asc": !sortNameOrder,
|
||||
"zmdi-sort-asc": !sortNameOrder
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
@@ -54,7 +54,7 @@ export const ObjectsHeader = ({
|
||||
objects__sort: true,
|
||||
zmdi: true,
|
||||
"zmdi-sort-amount-desc": sortSizeOrder,
|
||||
"zmdi-sort-amount-asc": !sortSizeOrder,
|
||||
"zmdi-sort-amount-asc": !sortSizeOrder
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
@@ -70,7 +70,7 @@ export const ObjectsHeader = ({
|
||||
objects__sort: true,
|
||||
zmdi: true,
|
||||
"zmdi-sort-amount-desc": sortLastModifiedOrder,
|
||||
"zmdi-sort-amount-asc": !sortLastModifiedOrder,
|
||||
"zmdi-sort-amount-asc": !sortLastModifiedOrder
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
@@ -82,13 +82,13 @@ const mapStateToProps = state => {
|
||||
sortNameOrder: state.objects.sortBy == "name" && state.objects.sortOrder,
|
||||
sortSizeOrder: state.objects.sortBy == "size" && state.objects.sortOrder,
|
||||
sortLastModifiedOrder:
|
||||
state.objects.sortBy == "last-modified" && state.objects.sortOrder,
|
||||
state.objects.sortBy == "last-modified" && state.objects.sortOrder
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
sortObjects: sortBy => dispatch(actionsObjects.sortObjects(sortBy)),
|
||||
sortObjects: sortBy => dispatch(actionsObjects.sortObjects(sortBy))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,16 +54,16 @@ const mapStateToProps = state => {
|
||||
currentBucket: state.buckets.currentBucket,
|
||||
currentPrefix: state.objects.currentPrefix,
|
||||
objects: state.objects.list,
|
||||
isTruncated: state.objects.isTruncated,
|
||||
isTruncated: state.objects.isTruncated
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
loadObjects: append => dispatch(actionsObjects.fetchObjects(append)),
|
||||
loadObjects: append => dispatch(actionsObjects.fetchObjects(append))
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(
|
||||
ObjectsListContainer,
|
||||
ObjectsListContainer
|
||||
)
|
||||
|
||||
@@ -53,13 +53,13 @@ export const Path = ({ currentBucket, currentPrefix, selectPrefix }) => {
|
||||
const mapStateToProps = state => {
|
||||
return {
|
||||
currentBucket: getCurrentBucket(state),
|
||||
currentPrefix: state.objects.currentPrefix,
|
||||
currentPrefix: state.objects.currentPrefix
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
selectPrefix: prefix => dispatch(actionsObjects.selectPrefix(prefix)),
|
||||
selectPrefix: prefix => dispatch(actionsObjects.selectPrefix(prefix))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ export const PrefixContainer = ({ object, currentPrefix, selectPrefix }) => {
|
||||
const props = {
|
||||
name: object.name,
|
||||
contentType: object.contentType,
|
||||
onClick: () => selectPrefix(`${currentPrefix}${object.name}`),
|
||||
onClick: () => selectPrefix(`${currentPrefix}${object.name}`)
|
||||
}
|
||||
|
||||
return <ObjectItem {...props} />
|
||||
@@ -32,13 +32,13 @@ export const PrefixContainer = ({ object, currentPrefix, selectPrefix }) => {
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
return {
|
||||
object: ownProps.object,
|
||||
currentPrefix: state.objects.currentPrefix,
|
||||
currentPrefix: state.objects.currentPrefix
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
selectPrefix: prefix => dispatch(actionsObjects.selectPrefix(prefix)),
|
||||
selectPrefix: prefix => dispatch(actionsObjects.selectPrefix(prefix))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import * as alertActions from "../alert/actions"
|
||||
import {
|
||||
SHARE_OBJECT_EXPIRY_DAYS,
|
||||
SHARE_OBJECT_EXPIRY_HOURS,
|
||||
SHARE_OBJECT_EXPIRY_MINUTES,
|
||||
SHARE_OBJECT_EXPIRY_MINUTES
|
||||
} from "../constants"
|
||||
|
||||
export class ShareObjectModal extends React.Component {
|
||||
@@ -34,22 +34,22 @@ export class ShareObjectModal extends React.Component {
|
||||
expiry: {
|
||||
days: SHARE_OBJECT_EXPIRY_DAYS,
|
||||
hours: SHARE_OBJECT_EXPIRY_HOURS,
|
||||
minutes: SHARE_OBJECT_EXPIRY_MINUTES,
|
||||
},
|
||||
minutes: SHARE_OBJECT_EXPIRY_MINUTES
|
||||
}
|
||||
}
|
||||
this.expiryRange = {
|
||||
days: {
|
||||
min: 0,
|
||||
max: 7,
|
||||
max: 7
|
||||
},
|
||||
hours: {
|
||||
min: 0,
|
||||
max: 23,
|
||||
max: 23
|
||||
},
|
||||
minutes: {
|
||||
min: 0,
|
||||
max: 59,
|
||||
},
|
||||
max: 59
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ export class ShareObjectModal extends React.Component {
|
||||
}
|
||||
|
||||
this.setState({
|
||||
expiry,
|
||||
expiry
|
||||
})
|
||||
|
||||
const { shareObjectDetails: { object }, shareObject } = this.props
|
||||
@@ -207,7 +207,7 @@ export class ShareObjectModal extends React.Component {
|
||||
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
return {
|
||||
shareObjectDetails: state.objects.shareObject,
|
||||
shareObjectDetails: state.objects.shareObject
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,9 +220,9 @@ const mapDispatchToProps = dispatch => {
|
||||
dispatch(
|
||||
alertActions.set({
|
||||
type: "success",
|
||||
message: message,
|
||||
}),
|
||||
),
|
||||
message: message
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,14 +28,14 @@ import * as objectsActions from "./actions"
|
||||
import {
|
||||
SHARE_OBJECT_EXPIRY_DAYS,
|
||||
SHARE_OBJECT_EXPIRY_HOURS,
|
||||
SHARE_OBJECT_EXPIRY_MINUTES,
|
||||
SHARE_OBJECT_EXPIRY_MINUTES
|
||||
} from "../constants"
|
||||
|
||||
export class ObjectsBulkActions extends React.Component {
|
||||
export class Toolbar extends React.Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.state = {
|
||||
showDeleteConfirmation: false,
|
||||
showDeleteConfirmation: false
|
||||
}
|
||||
}
|
||||
deleteChecked() {
|
||||
@@ -45,7 +45,7 @@ export class ObjectsBulkActions extends React.Component {
|
||||
}
|
||||
hideDeleteConfirmModal() {
|
||||
this.setState({
|
||||
showDeleteConfirmation: false,
|
||||
showDeleteConfirmation: false
|
||||
})
|
||||
}
|
||||
shareObject(e) {
|
||||
@@ -59,7 +59,7 @@ export class ObjectsBulkActions extends React.Component {
|
||||
object,
|
||||
SHARE_OBJECT_EXPIRY_DAYS,
|
||||
SHARE_OBJECT_EXPIRY_HOURS,
|
||||
SHARE_OBJECT_EXPIRY_MINUTES,
|
||||
SHARE_OBJECT_EXPIRY_MINUTES
|
||||
)
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ export class ObjectsBulkActions extends React.Component {
|
||||
checkedObjectsCount,
|
||||
downloadChecked,
|
||||
object,
|
||||
showShareObjectModal,
|
||||
showShareObjectModal
|
||||
} = this.props
|
||||
const loggedIn = web.LoggedIn()
|
||||
|
||||
@@ -79,7 +79,7 @@ export class ObjectsBulkActions extends React.Component {
|
||||
className="toolbar__item zmdi zmdi-delete"
|
||||
onClick={() =>
|
||||
this.setState({
|
||||
showDeleteConfirmation: true,
|
||||
showDeleteConfirmation: true
|
||||
})
|
||||
}
|
||||
disabled={!checkedObjectsCount}
|
||||
@@ -126,7 +126,7 @@ const mapStateToProps = state => {
|
||||
return {
|
||||
checkedObjects: getCheckedList(state),
|
||||
checkedObjectsCount: getCheckedList(state).length,
|
||||
showShareObjectModal: state.objects.shareObject.show,
|
||||
showShareObjectModal: state.objects.shareObject.show
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,8 +137,8 @@ const mapDispatchToProps = dispatch => {
|
||||
deleteChecked: () => dispatch(actions.deleteCheckedObjects()),
|
||||
toggleSidebar: () => dispatch(actionsCommon.toggleSidebar()),
|
||||
shareObject: (object, days, hours, minutes) =>
|
||||
dispatch(objectsActions.shareObject(object, days, hours, minutes)),
|
||||
dispatch(objectsActions.shareObject(object, days, hours, minutes))
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(ObjectsBulkActions)
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(Toolbar)
|
||||
@@ -26,7 +26,7 @@ describe("DeleteObjectConfirmModal", () => {
|
||||
it("should call deleteObject when Delete is clicked", () => {
|
||||
const deleteObject = jest.fn()
|
||||
const wrapper = shallow(
|
||||
<DeleteObjectConfirmModal deleteObject={deleteObject} />,
|
||||
<DeleteObjectConfirmModal deleteObject={deleteObject} />
|
||||
)
|
||||
wrapper.find("ConfirmModal").prop("okHandler")()
|
||||
expect(deleteObject).toHaveBeenCalled()
|
||||
@@ -37,7 +37,7 @@ describe("DeleteObjectConfirmModal", () => {
|
||||
const wrapper = shallow(
|
||||
<DeleteObjectConfirmModal
|
||||
hideDeleteConfirmModal={hideDeleteConfirmModal}
|
||||
/>,
|
||||
/>
|
||||
)
|
||||
wrapper.find("ConfirmModal").prop("cancelHandler")()
|
||||
expect(hideDeleteConfirmModal).toHaveBeenCalled()
|
||||
|
||||
@@ -28,28 +28,4 @@ describe("ObjectContainer", () => {
|
||||
expect(wrapper.find("Connect(ObjectItem)").length).toBe(1)
|
||||
expect(wrapper.find("Connect(ObjectItem)").prop("name")).toBe("test1.jpg")
|
||||
})
|
||||
|
||||
it("should pass actions to ObjectItem", () => {
|
||||
const wrapper = shallow(
|
||||
<ObjectContainer
|
||||
object={{ name: "test1.jpg" }}
|
||||
checkedObjectsCount={0}
|
||||
/>,
|
||||
)
|
||||
expect(wrapper.find("Connect(ObjectItem)").prop("actionButtons")).not.toBe(
|
||||
undefined,
|
||||
)
|
||||
})
|
||||
|
||||
it("should pass empty actions to ObjectItem when checkedObjectCount is more than 0", () => {
|
||||
const wrapper = shallow(
|
||||
<ObjectContainer
|
||||
object={{ name: "test1.jpg" }}
|
||||
checkedObjectsCount={1}
|
||||
/>,
|
||||
)
|
||||
expect(wrapper.find("Connect(ObjectItem)").prop("actionButtons")).toBe(
|
||||
undefined,
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -25,14 +25,16 @@ describe("ObjectItem", () => {
|
||||
|
||||
it("should render with content type", () => {
|
||||
const wrapper = shallow(<ObjectItem name={"test.jpg"} contentType={""} />)
|
||||
expect(wrapper.prop("data-type")).toBe("image")
|
||||
expect(
|
||||
wrapper.find(".objects__column--select").prop("data-object-type")
|
||||
).toBe("image")
|
||||
})
|
||||
|
||||
it("should call onClick when the object isclicked", () => {
|
||||
const onClick = jest.fn()
|
||||
const wrapper = shallow(<ObjectItem name={"test"} onClick={onClick} />)
|
||||
wrapper.find("a").simulate("click", {
|
||||
preventDefault: jest.fn(),
|
||||
preventDefault: jest.fn()
|
||||
})
|
||||
expect(onClick).toHaveBeenCalled()
|
||||
})
|
||||
@@ -40,7 +42,7 @@ describe("ObjectItem", () => {
|
||||
it("should call checkObject when the object/prefix is checked", () => {
|
||||
const checkObject = jest.fn()
|
||||
const wrapper = shallow(
|
||||
<ObjectItem name={"test"} checked={false} checkObject={checkObject} />,
|
||||
<ObjectItem name={"test"} checked={false} checkObject={checkObject} />
|
||||
)
|
||||
wrapper.find("input[type='checkbox']").simulate("change")
|
||||
expect(checkObject).toHaveBeenCalledWith("test")
|
||||
@@ -54,7 +56,7 @@ describe("ObjectItem", () => {
|
||||
it("should call uncheckObject when the object/prefix is unchecked", () => {
|
||||
const uncheckObject = jest.fn()
|
||||
const wrapper = shallow(
|
||||
<ObjectItem name={"test"} checked={true} uncheckObject={uncheckObject} />,
|
||||
<ObjectItem name={"test"} checked={true} uncheckObject={uncheckObject} />
|
||||
)
|
||||
wrapper.find("input[type='checkbox']").simulate("change")
|
||||
expect(uncheckObject).toHaveBeenCalledWith("test")
|
||||
|
||||
@@ -28,43 +28,43 @@ describe("ObjectsHeader", () => {
|
||||
const sortObjects = jest.fn()
|
||||
const wrapper = shallow(<ObjectsHeader sortObjects={sortObjects} />)
|
||||
expect(
|
||||
wrapper.find("#sort-by-name i").hasClass("fa-sort-alpha-asc"),
|
||||
wrapper.find("#sort-by-name i").hasClass("zmdi-sort-asc")
|
||||
).toBeTruthy()
|
||||
expect(
|
||||
wrapper.find("#sort-by-size i").hasClass("fa-sort-amount-asc"),
|
||||
wrapper.find("#sort-by-size i").hasClass("zmdi-sort-amount-asc")
|
||||
).toBeTruthy()
|
||||
expect(
|
||||
wrapper.find("#sort-by-last-modified i").hasClass("fa-sort-numeric-asc"),
|
||||
wrapper.find("#sort-by-last-modified i").hasClass("zmdi-sort-amount-asc")
|
||||
).toBeTruthy()
|
||||
})
|
||||
|
||||
it("should render name column with desc class when objects are sorted by name", () => {
|
||||
const sortObjects = jest.fn()
|
||||
const wrapper = shallow(
|
||||
<ObjectsHeader sortObjects={sortObjects} sortNameOrder={true} />,
|
||||
<ObjectsHeader sortObjects={sortObjects} sortNameOrder={true} />
|
||||
)
|
||||
expect(
|
||||
wrapper.find("#sort-by-name i").hasClass("fa-sort-alpha-desc"),
|
||||
wrapper.find("#sort-by-name i").hasClass("zmdi-sort-desc")
|
||||
).toBeTruthy()
|
||||
})
|
||||
|
||||
it("should render size column with desc class when objects are sorted by size", () => {
|
||||
const sortObjects = jest.fn()
|
||||
const wrapper = shallow(
|
||||
<ObjectsHeader sortObjects={sortObjects} sortSizeOrder={true} />,
|
||||
<ObjectsHeader sortObjects={sortObjects} sortSizeOrder={true} />
|
||||
)
|
||||
expect(
|
||||
wrapper.find("#sort-by-size i").hasClass("fa-sort-amount-desc"),
|
||||
wrapper.find("#sort-by-size i").hasClass("zmdi-sort-amount-desc")
|
||||
).toBeTruthy()
|
||||
})
|
||||
|
||||
it("should render last modified column with desc class when objects are sorted by last modified", () => {
|
||||
const sortObjects = jest.fn()
|
||||
const wrapper = shallow(
|
||||
<ObjectsHeader sortObjects={sortObjects} sortLastModifiedOrder={true} />,
|
||||
<ObjectsHeader sortObjects={sortObjects} sortLastModifiedOrder={true} />
|
||||
)
|
||||
expect(
|
||||
wrapper.find("#sort-by-last-modified i").hasClass("fa-sort-numeric-desc"),
|
||||
wrapper.find("#sort-by-last-modified i").hasClass("zmdi-sort-amount-desc")
|
||||
).toBeTruthy()
|
||||
})
|
||||
|
||||
|
||||
@@ -25,14 +25,14 @@ describe("ObjectsList", () => {
|
||||
|
||||
it("should render ObjectContainer for every object", () => {
|
||||
const wrapper = shallow(
|
||||
<ObjectsList objects={[{ name: "test1.jpg" }, { name: "test2.jpg" }]} />,
|
||||
<ObjectsList objects={[{ name: "test1.jpg" }, { name: "test2.jpg" }]} />
|
||||
)
|
||||
expect(wrapper.find("Connect(ObjectContainer)").length).toBe(2)
|
||||
})
|
||||
|
||||
it("should render PrefixContainer for every prefix", () => {
|
||||
const wrapper = shallow(
|
||||
<ObjectsList objects={[{ name: "abc/" }, { name: "xyz/" }]} />,
|
||||
<ObjectsList objects={[{ name: "abc/" }, { name: "xyz/" }]} />
|
||||
)
|
||||
expect(wrapper.find("Connect(PrefixContainer)").length).toBe(2)
|
||||
})
|
||||
|
||||
@@ -28,26 +28,26 @@ describe("ObjectsList", () => {
|
||||
<ObjectsListContainer
|
||||
objects={[{ name: "test1.jpg" }, { name: "test2.jpg" }]}
|
||||
loadObjects={jest.fn()}
|
||||
/>,
|
||||
/>
|
||||
)
|
||||
expect(wrapper.find("ObjectsList").length).toBe(1)
|
||||
expect(wrapper.find("ObjectsList").prop("objects")).toEqual([
|
||||
{
|
||||
name: "test1.jpg",
|
||||
name: "test1.jpg"
|
||||
},
|
||||
{
|
||||
name: "test2.jpg",
|
||||
},
|
||||
name: "test2.jpg"
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it("should show the loading indicator at the bottom if there are more elements to display", () => {
|
||||
const wrapper = shallow(
|
||||
<ObjectsListContainer currentBucket="test1" isTruncated={true} />,
|
||||
<ObjectsListContainer currentBucket="test1" isTruncated={true} />
|
||||
)
|
||||
expect(wrapper.find(".text-center").prop("style")).toHaveProperty(
|
||||
"display",
|
||||
"block",
|
||||
"block"
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -25,32 +25,32 @@ describe("Path", () => {
|
||||
|
||||
it("should render only bucket if there is no prefix", () => {
|
||||
const wrapper = shallow(<Path currentBucket={"test1"} currentPrefix={""} />)
|
||||
expect(wrapper.find("span").length).toBe(1)
|
||||
expect(wrapper.find("a").length).toBe(1)
|
||||
expect(wrapper.text()).toBe("test1")
|
||||
})
|
||||
|
||||
it("should render bucket and prefix", () => {
|
||||
const wrapper = shallow(
|
||||
<Path currentBucket={"test1"} currentPrefix={"a/b/"} />,
|
||||
<Path currentBucket={"test1"} currentPrefix={"a/b/"} />
|
||||
)
|
||||
expect(wrapper.find("span").length).toBe(3)
|
||||
expect(wrapper.find("a").length).toBe(3)
|
||||
expect(
|
||||
wrapper
|
||||
.find("span")
|
||||
.find("a")
|
||||
.at(0)
|
||||
.text(),
|
||||
.text()
|
||||
).toBe("test1")
|
||||
expect(
|
||||
wrapper
|
||||
.find("span")
|
||||
.find("a")
|
||||
.at(1)
|
||||
.text(),
|
||||
.text()
|
||||
).toBe("a")
|
||||
expect(
|
||||
wrapper
|
||||
.find("span")
|
||||
.find("a")
|
||||
.at(2)
|
||||
.text(),
|
||||
.text()
|
||||
).toBe("b")
|
||||
})
|
||||
|
||||
@@ -61,13 +61,13 @@ describe("Path", () => {
|
||||
currentBucket={"test1"}
|
||||
currentPrefix={"a/b/"}
|
||||
selectPrefix={selectPrefix}
|
||||
/>,
|
||||
/>
|
||||
)
|
||||
wrapper
|
||||
.find("a")
|
||||
.at(2)
|
||||
.simulate("click", {
|
||||
preventDefault: jest.fn(),
|
||||
preventDefault: jest.fn()
|
||||
})
|
||||
expect(selectPrefix).toHaveBeenCalledWith("a/b/")
|
||||
})
|
||||
|
||||
@@ -36,7 +36,7 @@ describe("PrefixContainer", () => {
|
||||
object={{ name: "abc/" }}
|
||||
currentPrefix={"xyz/"}
|
||||
selectPrefix={selectPrefix}
|
||||
/>,
|
||||
/>
|
||||
)
|
||||
wrapper.find("Connect(ObjectItem)").prop("onClick")()
|
||||
expect(selectPrefix).toHaveBeenCalledWith("xyz/abc/")
|
||||
|
||||
@@ -20,13 +20,13 @@ import { ShareObjectModal } from "../ShareObjectModal"
|
||||
import {
|
||||
SHARE_OBJECT_EXPIRY_DAYS,
|
||||
SHARE_OBJECT_EXPIRY_HOURS,
|
||||
SHARE_OBJECT_EXPIRY_MINUTES,
|
||||
SHARE_OBJECT_EXPIRY_MINUTES
|
||||
} from "../../constants"
|
||||
|
||||
jest.mock("../../web", () => ({
|
||||
LoggedIn: jest.fn(() => {
|
||||
return true
|
||||
}),
|
||||
})
|
||||
}))
|
||||
|
||||
describe("ShareObjectModal", () => {
|
||||
@@ -35,7 +35,7 @@ describe("ShareObjectModal", () => {
|
||||
<ShareObjectModal
|
||||
object={{ name: "obj1" }}
|
||||
shareObjectDetails={{ show: true, object: "obj1", url: "test" }}
|
||||
/>,
|
||||
/>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -46,7 +46,7 @@ describe("ShareObjectModal", () => {
|
||||
object={{ name: "obj1" }}
|
||||
shareObjectDetails={{ show: true, object: "obj1", url: "test" }}
|
||||
hideShareObject={hideShareObject}
|
||||
/>,
|
||||
/>
|
||||
)
|
||||
wrapper
|
||||
.find("button")
|
||||
@@ -60,13 +60,13 @@ describe("ShareObjectModal", () => {
|
||||
<ShareObjectModal
|
||||
object={{ name: "obj1" }}
|
||||
shareObjectDetails={{ show: true, object: "obj1", url: "test" }}
|
||||
/>,
|
||||
/>
|
||||
)
|
||||
expect(
|
||||
wrapper
|
||||
.find("input")
|
||||
.first()
|
||||
.prop("value"),
|
||||
.prop("value")
|
||||
).toBe(`${window.location.protocol}//test`)
|
||||
})
|
||||
|
||||
@@ -79,7 +79,7 @@ describe("ShareObjectModal", () => {
|
||||
shareObjectDetails={{ show: true, object: "obj1", url: "test" }}
|
||||
hideShareObject={hideShareObject}
|
||||
showCopyAlert={showCopyAlert}
|
||||
/>,
|
||||
/>
|
||||
)
|
||||
wrapper.find("CopyToClipboard").prop("onCopy")()
|
||||
expect(showCopyAlert).toHaveBeenCalledWith("Link copied to clipboard!")
|
||||
@@ -89,40 +89,40 @@ describe("ShareObjectModal", () => {
|
||||
describe("Update expiry values", () => {
|
||||
const props = {
|
||||
object: {
|
||||
name: "obj1",
|
||||
name: "obj1"
|
||||
},
|
||||
shareObjectDetails: {
|
||||
show: true,
|
||||
object: "obj1",
|
||||
url: "test",
|
||||
},
|
||||
url: "test"
|
||||
}
|
||||
}
|
||||
it("should have default expiry values", () => {
|
||||
const wrapper = shallow(<ShareObjectModal {...props} />)
|
||||
expect(wrapper.state("expiry")).toEqual({
|
||||
days: SHARE_OBJECT_EXPIRY_DAYS,
|
||||
hours: SHARE_OBJECT_EXPIRY_HOURS,
|
||||
minutes: SHARE_OBJECT_EXPIRY_MINUTES,
|
||||
minutes: SHARE_OBJECT_EXPIRY_MINUTES
|
||||
})
|
||||
})
|
||||
|
||||
it("should not allow any increments when days is already max", () => {
|
||||
const shareObject = jest.fn()
|
||||
const wrapper = shallow(
|
||||
<ShareObjectModal {...props} shareObject={shareObject} />,
|
||||
<ShareObjectModal {...props} shareObject={shareObject} />
|
||||
)
|
||||
wrapper.setState({
|
||||
expiry: {
|
||||
days: 7,
|
||||
hours: 0,
|
||||
minutes: 0,
|
||||
},
|
||||
minutes: 0
|
||||
}
|
||||
})
|
||||
wrapper.find("#increase-hours").simulate("click")
|
||||
expect(wrapper.state("expiry")).toEqual({
|
||||
days: 7,
|
||||
hours: 0,
|
||||
minutes: 0,
|
||||
minutes: 0
|
||||
})
|
||||
expect(shareObject).not.toHaveBeenCalled()
|
||||
})
|
||||
@@ -130,14 +130,14 @@ describe("ShareObjectModal", () => {
|
||||
it("should not allow expiry values less than minimum value", () => {
|
||||
const shareObject = jest.fn()
|
||||
const wrapper = shallow(
|
||||
<ShareObjectModal {...props} shareObject={shareObject} />,
|
||||
<ShareObjectModal {...props} shareObject={shareObject} />
|
||||
)
|
||||
wrapper.setState({
|
||||
expiry: {
|
||||
days: 5,
|
||||
hours: 0,
|
||||
minutes: 0,
|
||||
},
|
||||
minutes: 0
|
||||
}
|
||||
})
|
||||
wrapper.find("#decrease-hours").simulate("click")
|
||||
expect(wrapper.state("expiry").hours).toBe(0)
|
||||
@@ -149,14 +149,14 @@ describe("ShareObjectModal", () => {
|
||||
it("should not allow expiry values more than maximum value", () => {
|
||||
const shareObject = jest.fn()
|
||||
const wrapper = shallow(
|
||||
<ShareObjectModal {...props} shareObject={shareObject} />,
|
||||
<ShareObjectModal {...props} shareObject={shareObject} />
|
||||
)
|
||||
wrapper.setState({
|
||||
expiry: {
|
||||
days: 1,
|
||||
hours: 23,
|
||||
minutes: 59,
|
||||
},
|
||||
minutes: 59
|
||||
}
|
||||
})
|
||||
wrapper.find("#increase-hours").simulate("click")
|
||||
expect(wrapper.state("expiry").hours).toBe(23)
|
||||
@@ -168,20 +168,20 @@ describe("ShareObjectModal", () => {
|
||||
it("should set hours and minutes to 0 when days reaches max", () => {
|
||||
const shareObject = jest.fn()
|
||||
const wrapper = shallow(
|
||||
<ShareObjectModal {...props} shareObject={shareObject} />,
|
||||
<ShareObjectModal {...props} shareObject={shareObject} />
|
||||
)
|
||||
wrapper.setState({
|
||||
expiry: {
|
||||
days: 6,
|
||||
hours: 5,
|
||||
minutes: 30,
|
||||
},
|
||||
minutes: 30
|
||||
}
|
||||
})
|
||||
wrapper.find("#increase-days").simulate("click")
|
||||
expect(wrapper.state("expiry")).toEqual({
|
||||
days: 7,
|
||||
hours: 0,
|
||||
minutes: 0,
|
||||
minutes: 0
|
||||
})
|
||||
expect(shareObject).toHaveBeenCalled()
|
||||
})
|
||||
@@ -189,20 +189,20 @@ describe("ShareObjectModal", () => {
|
||||
it("should set days to MAX when all of them becomes 0", () => {
|
||||
const shareObject = jest.fn()
|
||||
const wrapper = shallow(
|
||||
<ShareObjectModal {...props} shareObject={shareObject} />,
|
||||
<ShareObjectModal {...props} shareObject={shareObject} />
|
||||
)
|
||||
wrapper.setState({
|
||||
expiry: {
|
||||
days: 0,
|
||||
hours: 1,
|
||||
minutes: 0,
|
||||
},
|
||||
minutes: 0
|
||||
}
|
||||
})
|
||||
wrapper.find("#decrease-hours").simulate("click")
|
||||
expect(wrapper.state("expiry")).toEqual({
|
||||
days: 7,
|
||||
hours: 0,
|
||||
minutes: 0,
|
||||
minutes: 0
|
||||
})
|
||||
expect(shareObject).toHaveBeenCalledWith("obj1", 7, 0, 0)
|
||||
})
|
||||
|
||||
@@ -16,45 +16,38 @@
|
||||
|
||||
import React from "react"
|
||||
import { shallow } from "enzyme"
|
||||
import { ObjectsBulkActions } from "../ObjectsBulkActions"
|
||||
import { Toolbar } from "../Toolbar"
|
||||
|
||||
describe("ObjectsBulkActions", () => {
|
||||
jest.mock("../../web", () => ({
|
||||
LoggedIn: jest
|
||||
.fn(() => true)
|
||||
.mockReturnValueOnce(true)
|
||||
.mockReturnValueOnce(false)
|
||||
}))
|
||||
|
||||
describe("Toolbar", () => {
|
||||
it("should render without crashing", () => {
|
||||
shallow(<ObjectsBulkActions checkedObjectsCount={0} />)
|
||||
shallow(<Toolbar checkedObjectsCount={0} />)
|
||||
})
|
||||
|
||||
it("should show actions when checkObjectsCount is more than 0", () => {
|
||||
const wrapper = shallow(<ObjectsBulkActions checkedObjectsCount={1} />)
|
||||
expect(wrapper.hasClass("list-actions-toggled")).toBeTruthy()
|
||||
it("should render Login button when the user has not LoggedIn", () => {
|
||||
const wrapper = shallow(<Toolbar checkedObjectsCount={0} />)
|
||||
expect(wrapper.find("a").text()).toBe("Login")
|
||||
})
|
||||
|
||||
it("should call downloadChecked when download button is clicked", () => {
|
||||
const downloadChecked = jest.fn()
|
||||
const wrapper = shallow(
|
||||
<ObjectsBulkActions
|
||||
checkedObjectsCount={1}
|
||||
downloadChecked={downloadChecked}
|
||||
/>,
|
||||
)
|
||||
wrapper.find("#download-checked").simulate("click")
|
||||
expect(downloadChecked).toHaveBeenCalled()
|
||||
it("should render StorageInfo and BrowserDropdown when the user has LoggedIn", () => {
|
||||
const wrapper = shallow(<Toolbar checkedObjectsCount={0} />)
|
||||
expect(wrapper.find("Connect(BrowserDropdown)").length).toBe(1)
|
||||
})
|
||||
|
||||
it("should call clearChecked when close button is clicked", () => {
|
||||
const clearChecked = jest.fn()
|
||||
const wrapper = shallow(
|
||||
<ObjectsBulkActions
|
||||
checkedObjectsCount={1}
|
||||
clearChecked={clearChecked}
|
||||
/>,
|
||||
)
|
||||
wrapper.find("#close-bulk-actions").simulate("click")
|
||||
expect(clearChecked).toHaveBeenCalled()
|
||||
it("should enable delete action when checkObjectsCount is more than 0", () => {
|
||||
const wrapper = shallow(<Toolbar checkedObjectsCount={1} />)
|
||||
expect(wrapper.find(".zmdi-delete").prop("disabled")).toBeFalsy()
|
||||
})
|
||||
|
||||
it("shoud show DeleteObjectConfirmModal when delete-checked button is clicked", () => {
|
||||
const wrapper = shallow(<ObjectsBulkActions checkedObjectsCount={1} />)
|
||||
wrapper.find("#delete-checked").simulate("click")
|
||||
it("shoud show DeleteObjectConfirmModal when delete button is clicked", () => {
|
||||
const wrapper = shallow(<Toolbar checkedObjectsCount={1} />)
|
||||
wrapper.find("button.zmdi-delete").simulate("click")
|
||||
wrapper.update()
|
||||
expect(wrapper.find("DeleteObjectConfirmModal").length).toBe(1)
|
||||
})
|
||||
@@ -62,16 +55,22 @@ describe("ObjectsBulkActions", () => {
|
||||
it("shoud call deleteChecked when Delete is clicked on confirmation modal", () => {
|
||||
const deleteChecked = jest.fn()
|
||||
const wrapper = shallow(
|
||||
<ObjectsBulkActions
|
||||
checkedObjectsCount={1}
|
||||
deleteChecked={deleteChecked}
|
||||
/>,
|
||||
<Toolbar checkedObjectsCount={1} deleteChecked={deleteChecked} />
|
||||
)
|
||||
wrapper.find("#delete-checked").simulate("click")
|
||||
wrapper.find("button.zmdi-delete").simulate("click")
|
||||
wrapper.update()
|
||||
wrapper.find("DeleteObjectConfirmModal").prop("deleteObject")()
|
||||
expect(deleteChecked).toHaveBeenCalled()
|
||||
wrapper.update()
|
||||
expect(wrapper.find("DeleteObjectConfirmModal").length).toBe(0)
|
||||
})
|
||||
|
||||
it("should call downloadChecked when download button is clicked", () => {
|
||||
const downloadChecked = jest.fn()
|
||||
const wrapper = shallow(
|
||||
<Toolbar checkedObjectsCount={1} downloadChecked={downloadChecked} />
|
||||
)
|
||||
wrapper.find("button.zmdi-download").simulate("click")
|
||||
expect(downloadChecked).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
@@ -26,21 +26,21 @@ jest.mock("../../web", () => ({
|
||||
return Promise.resolve({
|
||||
objects: [
|
||||
{
|
||||
name: "test1",
|
||||
name: "test1"
|
||||
},
|
||||
{
|
||||
name: "test2",
|
||||
},
|
||||
name: "test2"
|
||||
}
|
||||
],
|
||||
istruncated: false,
|
||||
nextmarker: "test2",
|
||||
writable: false,
|
||||
writable: false
|
||||
})
|
||||
}),
|
||||
RemoveObject: jest.fn(({ bucketName, objects }) => {
|
||||
if (!bucketName) {
|
||||
return Promise.reject({
|
||||
message: "Invalid bucket",
|
||||
message: "Invalid bucket"
|
||||
})
|
||||
}
|
||||
return Promise.resolve({})
|
||||
@@ -48,30 +48,30 @@ jest.mock("../../web", () => ({
|
||||
PresignedGet: jest.fn(({ bucket, object }) => {
|
||||
if (!bucket) {
|
||||
return Promise.reject({
|
||||
message: "Invalid bucket",
|
||||
message: "Invalid bucket"
|
||||
})
|
||||
}
|
||||
return Promise.resolve({
|
||||
url: "https://test.com/bk1/pre1/b.txt",
|
||||
url: "https://test.com/bk1/pre1/b.txt"
|
||||
})
|
||||
}),
|
||||
CreateURLToken: jest
|
||||
.fn()
|
||||
.mockImplementationOnce(() => {
|
||||
return Promise.resolve({
|
||||
token: "test",
|
||||
token: "test"
|
||||
})
|
||||
})
|
||||
.mockImplementationOnce(() => {
|
||||
return Promise.reject({
|
||||
message: "Error in creating token",
|
||||
message: "Error in creating token"
|
||||
})
|
||||
})
|
||||
.mockImplementationOnce(() => {
|
||||
return Promise.resolve({
|
||||
token: "test",
|
||||
token: "test"
|
||||
})
|
||||
}),
|
||||
})
|
||||
}))
|
||||
|
||||
const middlewares = [thunk]
|
||||
@@ -85,29 +85,29 @@ describe("Objects actions", () => {
|
||||
type: "objects/SET_LIST",
|
||||
objects: [
|
||||
{
|
||||
name: "test1",
|
||||
name: "test1"
|
||||
},
|
||||
{
|
||||
name: "test2",
|
||||
},
|
||||
name: "test2"
|
||||
}
|
||||
],
|
||||
isTruncated: false,
|
||||
marker: "test2",
|
||||
},
|
||||
marker: "test2"
|
||||
}
|
||||
]
|
||||
store.dispatch(
|
||||
actionsObjects.setList(
|
||||
[
|
||||
{
|
||||
name: "test1",
|
||||
name: "test1"
|
||||
},
|
||||
{
|
||||
name: "test2",
|
||||
},
|
||||
name: "test2"
|
||||
}
|
||||
],
|
||||
"test2",
|
||||
false,
|
||||
),
|
||||
false
|
||||
)
|
||||
)
|
||||
const actions = store.getActions()
|
||||
expect(actions).toEqual(expectedActions)
|
||||
@@ -118,8 +118,8 @@ describe("Objects actions", () => {
|
||||
const expectedActions = [
|
||||
{
|
||||
type: "objects/SET_SORT_BY",
|
||||
sortBy: "name",
|
||||
},
|
||||
sortBy: "name"
|
||||
}
|
||||
]
|
||||
store.dispatch(actionsObjects.setSortBy("name"))
|
||||
const actions = store.getActions()
|
||||
@@ -131,8 +131,8 @@ describe("Objects actions", () => {
|
||||
const expectedActions = [
|
||||
{
|
||||
type: "objects/SET_SORT_ORDER",
|
||||
sortOrder: true,
|
||||
},
|
||||
sortOrder: true
|
||||
}
|
||||
]
|
||||
store.dispatch(actionsObjects.setSortOrder(true))
|
||||
const actions = store.getActions()
|
||||
@@ -142,38 +142,38 @@ describe("Objects actions", () => {
|
||||
it("creates objects/SET_LIST after fetching the objects", () => {
|
||||
const store = mockStore({
|
||||
buckets: {
|
||||
currentBucket: "bk1",
|
||||
currentBucket: "bk1"
|
||||
},
|
||||
objects: {
|
||||
currentPrefix: "",
|
||||
},
|
||||
currentPrefix: ""
|
||||
}
|
||||
})
|
||||
const expectedActions = [
|
||||
{
|
||||
type: "objects/SET_LIST",
|
||||
objects: [
|
||||
{
|
||||
name: "test1",
|
||||
name: "test1"
|
||||
},
|
||||
{
|
||||
name: "test2",
|
||||
},
|
||||
name: "test2"
|
||||
}
|
||||
],
|
||||
marker: "test2",
|
||||
isTruncated: false,
|
||||
isTruncated: false
|
||||
},
|
||||
{
|
||||
type: "objects/SET_SORT_BY",
|
||||
sortBy: "",
|
||||
sortBy: ""
|
||||
},
|
||||
{
|
||||
type: "objects/SET_SORT_ORDER",
|
||||
sortOrder: false,
|
||||
sortOrder: false
|
||||
},
|
||||
{
|
||||
type: "objects/SET_PREFIX_WRITABLE",
|
||||
prefixWritable: false,
|
||||
},
|
||||
prefixWritable: false
|
||||
}
|
||||
]
|
||||
return store.dispatch(actionsObjects.fetchObjects()).then(() => {
|
||||
const actions = store.getActions()
|
||||
@@ -184,30 +184,30 @@ describe("Objects actions", () => {
|
||||
it("creates objects/APPEND_LIST after fetching more objects", () => {
|
||||
const store = mockStore({
|
||||
buckets: {
|
||||
currentBucket: "bk1",
|
||||
currentBucket: "bk1"
|
||||
},
|
||||
objects: {
|
||||
currentPrefix: "",
|
||||
},
|
||||
currentPrefix: ""
|
||||
}
|
||||
})
|
||||
const expectedActions = [
|
||||
{
|
||||
type: "objects/APPEND_LIST",
|
||||
objects: [
|
||||
{
|
||||
name: "test1",
|
||||
name: "test1"
|
||||
},
|
||||
{
|
||||
name: "test2",
|
||||
},
|
||||
name: "test2"
|
||||
}
|
||||
],
|
||||
marker: "test2",
|
||||
isTruncated: false,
|
||||
isTruncated: false
|
||||
},
|
||||
{
|
||||
type: "objects/SET_PREFIX_WRITABLE",
|
||||
prefixWritable: false,
|
||||
},
|
||||
prefixWritable: false
|
||||
}
|
||||
]
|
||||
return store.dispatch(actionsObjects.fetchObjects(true)).then(() => {
|
||||
const actions = store.getActions()
|
||||
@@ -222,24 +222,24 @@ describe("Objects actions", () => {
|
||||
sortBy: "",
|
||||
sortOrder: false,
|
||||
isTruncated: false,
|
||||
marker: "",
|
||||
},
|
||||
marker: ""
|
||||
}
|
||||
})
|
||||
const expectedActions = [
|
||||
{
|
||||
type: "objects/SET_SORT_BY",
|
||||
sortBy: "name",
|
||||
sortBy: "name"
|
||||
},
|
||||
{
|
||||
type: "objects/SET_SORT_ORDER",
|
||||
sortOrder: true,
|
||||
sortOrder: true
|
||||
},
|
||||
{
|
||||
type: "objects/SET_LIST",
|
||||
objects: [],
|
||||
isTruncated: false,
|
||||
marker: "",
|
||||
},
|
||||
marker: ""
|
||||
}
|
||||
]
|
||||
store.dispatch(actionsObjects.sortObjects("name"))
|
||||
const actions = store.getActions()
|
||||
@@ -249,20 +249,20 @@ describe("Objects actions", () => {
|
||||
it("should update browser url and creates objects/SET_CURRENT_PREFIX and objects/CHECKED_LIST_RESET actions when selectPrefix is called", () => {
|
||||
const store = mockStore({
|
||||
buckets: {
|
||||
currentBucket: "test",
|
||||
currentBucket: "test"
|
||||
},
|
||||
objects: {
|
||||
currentPrefix: "",
|
||||
},
|
||||
currentPrefix: ""
|
||||
}
|
||||
})
|
||||
const expectedActions = [
|
||||
{
|
||||
type: "objects/SET_CURRENT_PREFIX",
|
||||
prefix: "abc/",
|
||||
prefix: "abc/"
|
||||
},
|
||||
{
|
||||
type: "objects/CHECKED_LIST_RESET",
|
||||
},
|
||||
type: "objects/CHECKED_LIST_RESET"
|
||||
}
|
||||
]
|
||||
store.dispatch(actionsObjects.selectPrefix("abc/"))
|
||||
const actions = store.getActions()
|
||||
@@ -275,8 +275,8 @@ describe("Objects actions", () => {
|
||||
const expectedActions = [
|
||||
{
|
||||
type: "objects/SET_PREFIX_WRITABLE",
|
||||
prefixWritable: true,
|
||||
},
|
||||
prefixWritable: true
|
||||
}
|
||||
]
|
||||
store.dispatch(actionsObjects.setPrefixWritable(true))
|
||||
const actions = store.getActions()
|
||||
@@ -288,8 +288,8 @@ describe("Objects actions", () => {
|
||||
const expectedActions = [
|
||||
{
|
||||
type: "objects/REMOVE",
|
||||
object: "obj1",
|
||||
},
|
||||
object: "obj1"
|
||||
}
|
||||
]
|
||||
store.dispatch(actionsObjects.removeObject("obj1"))
|
||||
const actions = store.getActions()
|
||||
@@ -299,17 +299,17 @@ describe("Objects actions", () => {
|
||||
it("creates objects/REMOVE action when object is deleted", () => {
|
||||
const store = mockStore({
|
||||
buckets: {
|
||||
currentBucket: "test",
|
||||
currentBucket: "test"
|
||||
},
|
||||
objects: {
|
||||
currentPrefix: "pre1/",
|
||||
},
|
||||
currentPrefix: "pre1/"
|
||||
}
|
||||
})
|
||||
const expectedActions = [
|
||||
{
|
||||
type: "objects/REMOVE",
|
||||
object: "obj1",
|
||||
},
|
||||
object: "obj1"
|
||||
}
|
||||
]
|
||||
store.dispatch(actionsObjects.deleteObject("obj1")).then(() => {
|
||||
const actions = store.getActions()
|
||||
@@ -320,11 +320,11 @@ describe("Objects actions", () => {
|
||||
it("creates alert/SET action when invalid bucket is provided", () => {
|
||||
const store = mockStore({
|
||||
buckets: {
|
||||
currentBucket: "",
|
||||
currentBucket: ""
|
||||
},
|
||||
objects: {
|
||||
currentPrefix: "pre1/",
|
||||
},
|
||||
currentPrefix: "pre1/"
|
||||
}
|
||||
})
|
||||
const expectedActions = [
|
||||
{
|
||||
@@ -332,9 +332,9 @@ describe("Objects actions", () => {
|
||||
alert: {
|
||||
type: "danger",
|
||||
message: "Invalid bucket",
|
||||
id: 0,
|
||||
},
|
||||
},
|
||||
id: 0
|
||||
}
|
||||
}
|
||||
]
|
||||
return store.dispatch(actionsObjects.deleteObject("obj1")).then(() => {
|
||||
const actions = store.getActions()
|
||||
@@ -349,8 +349,8 @@ describe("Objects actions", () => {
|
||||
type: "objects/SET_SHARE_OBJECT",
|
||||
show: true,
|
||||
object: "b.txt",
|
||||
url: "test",
|
||||
},
|
||||
url: "test"
|
||||
}
|
||||
]
|
||||
store.dispatch(actionsObjects.showShareObject("b.txt", "test"))
|
||||
const actions = store.getActions()
|
||||
@@ -364,8 +364,8 @@ describe("Objects actions", () => {
|
||||
type: "objects/SET_SHARE_OBJECT",
|
||||
show: false,
|
||||
object: "",
|
||||
url: "",
|
||||
},
|
||||
url: ""
|
||||
}
|
||||
]
|
||||
store.dispatch(actionsObjects.hideShareObject())
|
||||
const actions = store.getActions()
|
||||
@@ -375,27 +375,27 @@ describe("Objects actions", () => {
|
||||
it("creates objects/SET_SHARE_OBJECT when object is shared", () => {
|
||||
const store = mockStore({
|
||||
buckets: {
|
||||
currentBucket: "bk1",
|
||||
currentBucket: "bk1"
|
||||
},
|
||||
objects: {
|
||||
currentPrefix: "pre1/",
|
||||
},
|
||||
currentPrefix: "pre1/"
|
||||
}
|
||||
})
|
||||
const expectedActions = [
|
||||
{
|
||||
type: "objects/SET_SHARE_OBJECT",
|
||||
show: true,
|
||||
object: "a.txt",
|
||||
url: "https://test.com/bk1/pre1/b.txt",
|
||||
url: "https://test.com/bk1/pre1/b.txt"
|
||||
},
|
||||
{
|
||||
type: "alert/SET",
|
||||
alert: {
|
||||
type: "success",
|
||||
message: "Object shared. Expires in 1 days 0 hours 0 minutes",
|
||||
id: alertActions.alertId,
|
||||
},
|
||||
},
|
||||
id: alertActions.alertId
|
||||
}
|
||||
}
|
||||
]
|
||||
return store
|
||||
.dispatch(actionsObjects.shareObject("a.txt", 1, 0, 0))
|
||||
@@ -408,11 +408,11 @@ describe("Objects actions", () => {
|
||||
it("creates alert/SET when shareObject is failed", () => {
|
||||
const store = mockStore({
|
||||
buckets: {
|
||||
currentBucket: "",
|
||||
currentBucket: ""
|
||||
},
|
||||
objects: {
|
||||
currentPrefix: "pre1/",
|
||||
},
|
||||
currentPrefix: "pre1/"
|
||||
}
|
||||
})
|
||||
const expectedActions = [
|
||||
{
|
||||
@@ -420,9 +420,9 @@ describe("Objects actions", () => {
|
||||
alert: {
|
||||
type: "danger",
|
||||
message: "Invalid bucket",
|
||||
id: alertActions.alertId,
|
||||
},
|
||||
},
|
||||
id: alertActions.alertId
|
||||
}
|
||||
}
|
||||
]
|
||||
return store
|
||||
.dispatch(actionsObjects.shareObject("a.txt", 1, 0, 0))
|
||||
@@ -438,15 +438,15 @@ describe("Objects actions", () => {
|
||||
Object.defineProperty(window, "location", {
|
||||
set(url) {
|
||||
setLocation(url)
|
||||
},
|
||||
}
|
||||
})
|
||||
const store = mockStore({
|
||||
buckets: {
|
||||
currentBucket: "bk1",
|
||||
currentBucket: "bk1"
|
||||
},
|
||||
objects: {
|
||||
currentPrefix: "pre1/",
|
||||
},
|
||||
currentPrefix: "pre1/"
|
||||
}
|
||||
})
|
||||
store.dispatch(actionsObjects.downloadObject("obj1"))
|
||||
const url = `${
|
||||
@@ -460,21 +460,21 @@ describe("Objects actions", () => {
|
||||
Object.defineProperty(window, "location", {
|
||||
set(url) {
|
||||
setLocation(url)
|
||||
},
|
||||
}
|
||||
})
|
||||
const store = mockStore({
|
||||
buckets: {
|
||||
currentBucket: "bk1",
|
||||
currentBucket: "bk1"
|
||||
},
|
||||
objects: {
|
||||
currentPrefix: "pre1/",
|
||||
},
|
||||
currentPrefix: "pre1/"
|
||||
}
|
||||
})
|
||||
return store.dispatch(actionsObjects.downloadObject("obj1")).then(() => {
|
||||
const url = `${
|
||||
window.location.origin
|
||||
}${minioBrowserPrefix}/download/bk1/${encodeURI(
|
||||
"pre1/obj1",
|
||||
"pre1/obj1"
|
||||
)}?token=test`
|
||||
expect(setLocation).toHaveBeenCalledWith(url)
|
||||
})
|
||||
@@ -483,11 +483,11 @@ describe("Objects actions", () => {
|
||||
it("create alert/SET action when CreateUrlToken fails", () => {
|
||||
const store = mockStore({
|
||||
buckets: {
|
||||
currentBucket: "bk1",
|
||||
currentBucket: "bk1"
|
||||
},
|
||||
objects: {
|
||||
currentPrefix: "pre1/",
|
||||
},
|
||||
currentPrefix: "pre1/"
|
||||
}
|
||||
})
|
||||
const expectedActions = [
|
||||
{
|
||||
@@ -495,9 +495,9 @@ describe("Objects actions", () => {
|
||||
alert: {
|
||||
type: "danger",
|
||||
message: "Error in creating token",
|
||||
id: alertActions.alertId,
|
||||
},
|
||||
},
|
||||
id: alertActions.alertId
|
||||
}
|
||||
}
|
||||
]
|
||||
return store.dispatch(actionsObjects.downloadObject("obj1")).then(() => {
|
||||
const actions = store.getActions()
|
||||
@@ -511,8 +511,8 @@ describe("Objects actions", () => {
|
||||
const expectedActions = [
|
||||
{
|
||||
type: "objects/CHECKED_LIST_ADD",
|
||||
object: "obj1",
|
||||
},
|
||||
object: "obj1"
|
||||
}
|
||||
]
|
||||
store.dispatch(actionsObjects.checkObject("obj1"))
|
||||
const actions = store.getActions()
|
||||
@@ -524,8 +524,8 @@ describe("Objects actions", () => {
|
||||
const expectedActions = [
|
||||
{
|
||||
type: "objects/CHECKED_LIST_REMOVE",
|
||||
object: "obj1",
|
||||
},
|
||||
object: "obj1"
|
||||
}
|
||||
]
|
||||
store.dispatch(actionsObjects.uncheckObject("obj1"))
|
||||
const actions = store.getActions()
|
||||
@@ -536,8 +536,8 @@ describe("Objects actions", () => {
|
||||
const store = mockStore()
|
||||
const expectedActions = [
|
||||
{
|
||||
type: "objects/CHECKED_LIST_RESET",
|
||||
},
|
||||
type: "objects/CHECKED_LIST_RESET"
|
||||
}
|
||||
]
|
||||
store.dispatch(actionsObjects.resetCheckedList())
|
||||
const actions = store.getActions()
|
||||
@@ -549,18 +549,18 @@ describe("Objects actions", () => {
|
||||
const send = jest.fn()
|
||||
const xhrMockClass = () => ({
|
||||
open: open,
|
||||
send: send,
|
||||
send: send
|
||||
})
|
||||
window.XMLHttpRequest = jest.fn().mockImplementation(xhrMockClass)
|
||||
|
||||
const store = mockStore({
|
||||
buckets: {
|
||||
currentBucket: "bk1",
|
||||
currentBucket: "bk1"
|
||||
},
|
||||
objects: {
|
||||
currentPrefix: "pre1/",
|
||||
checkedList: ["obj1"],
|
||||
},
|
||||
checkedList: ["obj1"]
|
||||
}
|
||||
})
|
||||
return store.dispatch(actionsObjects.downloadCheckedObjects()).then(() => {
|
||||
const requestUrl = `${
|
||||
@@ -571,8 +571,8 @@ describe("Objects actions", () => {
|
||||
JSON.stringify({
|
||||
bucketName: "bk1",
|
||||
prefix: "pre1/",
|
||||
objects: ["obj1"],
|
||||
}),
|
||||
objects: ["obj1"]
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -31,9 +31,9 @@ describe("objects reducer", () => {
|
||||
shareObject: {
|
||||
show: false,
|
||||
object: "",
|
||||
url: "",
|
||||
url: ""
|
||||
},
|
||||
checkedList: [],
|
||||
checkedList: []
|
||||
})
|
||||
})
|
||||
|
||||
@@ -42,22 +42,22 @@ describe("objects reducer", () => {
|
||||
type: actions.SET_LIST,
|
||||
objects: [
|
||||
{
|
||||
name: "obj1",
|
||||
name: "obj1"
|
||||
},
|
||||
{
|
||||
name: "obj2",
|
||||
},
|
||||
name: "obj2"
|
||||
}
|
||||
],
|
||||
marker: "obj2",
|
||||
isTruncated: false,
|
||||
isTruncated: false
|
||||
})
|
||||
expect(newState.list).toEqual([
|
||||
{
|
||||
name: "obj1",
|
||||
name: "obj1"
|
||||
},
|
||||
{
|
||||
name: "obj2",
|
||||
},
|
||||
name: "obj2"
|
||||
}
|
||||
])
|
||||
expect(newState.marker).toBe("obj2")
|
||||
expect(newState.isTruncated).toBeFalsy()
|
||||
@@ -68,42 +68,42 @@ describe("objects reducer", () => {
|
||||
{
|
||||
list: [
|
||||
{
|
||||
name: "obj1",
|
||||
name: "obj1"
|
||||
},
|
||||
{
|
||||
name: "obj2",
|
||||
},
|
||||
name: "obj2"
|
||||
}
|
||||
],
|
||||
marker: "obj2",
|
||||
isTruncated: true,
|
||||
isTruncated: true
|
||||
},
|
||||
{
|
||||
type: actions.APPEND_LIST,
|
||||
objects: [
|
||||
{
|
||||
name: "obj3",
|
||||
name: "obj3"
|
||||
},
|
||||
{
|
||||
name: "obj4",
|
||||
},
|
||||
name: "obj4"
|
||||
}
|
||||
],
|
||||
marker: "obj4",
|
||||
isTruncated: false,
|
||||
},
|
||||
isTruncated: false
|
||||
}
|
||||
)
|
||||
expect(newState.list).toEqual([
|
||||
{
|
||||
name: "obj1",
|
||||
name: "obj1"
|
||||
},
|
||||
{
|
||||
name: "obj2",
|
||||
name: "obj2"
|
||||
},
|
||||
{
|
||||
name: "obj3",
|
||||
name: "obj3"
|
||||
},
|
||||
{
|
||||
name: "obj4",
|
||||
},
|
||||
name: "obj4"
|
||||
}
|
||||
])
|
||||
expect(newState.marker).toBe("obj4")
|
||||
expect(newState.isTruncated).toBeFalsy()
|
||||
@@ -114,22 +114,22 @@ describe("objects reducer", () => {
|
||||
{
|
||||
list: [
|
||||
{
|
||||
name: "obj1",
|
||||
name: "obj1"
|
||||
},
|
||||
{
|
||||
name: "obj2",
|
||||
},
|
||||
],
|
||||
name: "obj2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: actions.REMOVE,
|
||||
object: "obj1",
|
||||
},
|
||||
object: "obj1"
|
||||
}
|
||||
)
|
||||
expect(newState.list).toEqual([
|
||||
{
|
||||
name: "obj2",
|
||||
},
|
||||
name: "obj2"
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
@@ -138,32 +138,32 @@ describe("objects reducer", () => {
|
||||
{
|
||||
list: [
|
||||
{
|
||||
name: "obj1",
|
||||
name: "obj1"
|
||||
},
|
||||
{
|
||||
name: "obj2",
|
||||
},
|
||||
],
|
||||
name: "obj2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: actions.REMOVE,
|
||||
object: "obj3",
|
||||
},
|
||||
object: "obj3"
|
||||
}
|
||||
)
|
||||
expect(newState.list).toEqual([
|
||||
{
|
||||
name: "obj1",
|
||||
name: "obj1"
|
||||
},
|
||||
{
|
||||
name: "obj2",
|
||||
},
|
||||
name: "obj2"
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it("should handle SET_SORT_BY", () => {
|
||||
const newState = reducer(undefined, {
|
||||
type: actions.SET_SORT_BY,
|
||||
sortBy: "name",
|
||||
sortBy: "name"
|
||||
})
|
||||
expect(newState.sortBy).toEqual("name")
|
||||
})
|
||||
@@ -171,7 +171,7 @@ describe("objects reducer", () => {
|
||||
it("should handle SET_SORT_ORDER", () => {
|
||||
const newState = reducer(undefined, {
|
||||
type: actions.SET_SORT_ORDER,
|
||||
sortOrder: true,
|
||||
sortOrder: true
|
||||
})
|
||||
expect(newState.sortOrder).toEqual(true)
|
||||
})
|
||||
@@ -181,12 +181,12 @@ describe("objects reducer", () => {
|
||||
{
|
||||
currentPrefix: "test1/",
|
||||
marker: "abc",
|
||||
isTruncated: true,
|
||||
isTruncated: true
|
||||
},
|
||||
{
|
||||
type: actions.SET_CURRENT_PREFIX,
|
||||
prefix: "test2/",
|
||||
},
|
||||
prefix: "test2/"
|
||||
}
|
||||
)
|
||||
expect(newState.currentPrefix).toEqual("test2/")
|
||||
expect(newState.marker).toEqual("")
|
||||
@@ -196,7 +196,7 @@ describe("objects reducer", () => {
|
||||
it("should handle SET_PREFIX_WRITABLE", () => {
|
||||
const newState = reducer(undefined, {
|
||||
type: actions.SET_PREFIX_WRITABLE,
|
||||
prefixWritable: true,
|
||||
prefixWritable: true
|
||||
})
|
||||
expect(newState.prefixWritable).toBeTruthy()
|
||||
})
|
||||
@@ -206,19 +206,19 @@ describe("objects reducer", () => {
|
||||
type: actions.SET_SHARE_OBJECT,
|
||||
show: true,
|
||||
object: "a.txt",
|
||||
url: "test",
|
||||
url: "test"
|
||||
})
|
||||
expect(newState.shareObject).toEqual({
|
||||
show: true,
|
||||
object: "a.txt",
|
||||
url: "test",
|
||||
url: "test"
|
||||
})
|
||||
})
|
||||
|
||||
it("should handle CHECKED_LIST_ADD", () => {
|
||||
const newState = reducer(undefined, {
|
||||
type: actions.CHECKED_LIST_ADD,
|
||||
object: "obj1",
|
||||
object: "obj1"
|
||||
})
|
||||
expect(newState.checkedList).toEqual(["obj1"])
|
||||
})
|
||||
@@ -226,12 +226,12 @@ describe("objects reducer", () => {
|
||||
it("should handle SELECTED_LIST_REMOVE", () => {
|
||||
const newState = reducer(
|
||||
{
|
||||
checkedList: ["obj1", "obj2"],
|
||||
checkedList: ["obj1", "obj2"]
|
||||
},
|
||||
{
|
||||
type: actions.CHECKED_LIST_REMOVE,
|
||||
object: "obj1",
|
||||
},
|
||||
object: "obj1"
|
||||
}
|
||||
)
|
||||
expect(newState.checkedList).toEqual(["obj2"])
|
||||
})
|
||||
@@ -239,11 +239,11 @@ describe("objects reducer", () => {
|
||||
it("should handle CHECKED_LIST_RESET", () => {
|
||||
const newState = reducer(
|
||||
{
|
||||
checkedList: ["obj1", "obj2"],
|
||||
checkedList: ["obj1", "obj2"]
|
||||
},
|
||||
{
|
||||
type: actions.CHECKED_LIST_RESET,
|
||||
},
|
||||
type: actions.CHECKED_LIST_RESET
|
||||
}
|
||||
)
|
||||
expect(newState.checkedList).toEqual([])
|
||||
})
|
||||
|
||||
@@ -19,7 +19,7 @@ import history from "../history"
|
||||
import {
|
||||
sortObjectsByName,
|
||||
sortObjectsBySize,
|
||||
sortObjectsByDate,
|
||||
sortObjectsByDate
|
||||
} from "../utils"
|
||||
import { getCurrentBucket } from "../buckets/selectors"
|
||||
import { getCurrentPrefix, getCheckedList } from "./selectors"
|
||||
@@ -42,28 +42,28 @@ export const setList = (objects, marker, isTruncated) => ({
|
||||
type: SET_LIST,
|
||||
objects,
|
||||
marker,
|
||||
isTruncated,
|
||||
isTruncated
|
||||
})
|
||||
|
||||
export const appendList = (objects, marker, isTruncated) => ({
|
||||
type: APPEND_LIST,
|
||||
objects,
|
||||
marker,
|
||||
isTruncated,
|
||||
isTruncated
|
||||
})
|
||||
|
||||
export const fetchObjects = append => {
|
||||
return function(dispatch, getState) {
|
||||
const {
|
||||
buckets: { currentBucket },
|
||||
objects: { currentPrefix, marker },
|
||||
objects: { currentPrefix, marker }
|
||||
} = getState()
|
||||
if (currentBucket) {
|
||||
return web
|
||||
.ListObjects({
|
||||
bucketName: currentBucket,
|
||||
prefix: currentPrefix,
|
||||
marker: append ? marker : "",
|
||||
marker: append ? marker : ""
|
||||
})
|
||||
.then(res => {
|
||||
let objects = []
|
||||
@@ -71,7 +71,7 @@ export const fetchObjects = append => {
|
||||
objects = res.objects.map(object => {
|
||||
return {
|
||||
...object,
|
||||
name: object.name.replace(currentPrefix, ""),
|
||||
name: object.name.replace(currentPrefix, "")
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -88,8 +88,8 @@ export const fetchObjects = append => {
|
||||
dispatch(
|
||||
alertActions.set({
|
||||
type: "danger",
|
||||
message: err.message,
|
||||
}),
|
||||
message: err.message
|
||||
})
|
||||
)
|
||||
history.push("/login")
|
||||
})
|
||||
@@ -124,12 +124,12 @@ export const sortObjects = sortBy => {
|
||||
|
||||
export const setSortBy = sortBy => ({
|
||||
type: SET_SORT_BY,
|
||||
sortBy,
|
||||
sortBy
|
||||
})
|
||||
|
||||
export const setSortOrder = sortOrder => ({
|
||||
type: SET_SORT_ORDER,
|
||||
sortOrder,
|
||||
sortOrder
|
||||
})
|
||||
|
||||
export const selectPrefix = prefix => {
|
||||
@@ -145,13 +145,13 @@ export const selectPrefix = prefix => {
|
||||
export const setCurrentPrefix = prefix => {
|
||||
return {
|
||||
type: SET_CURRENT_PREFIX,
|
||||
prefix,
|
||||
prefix
|
||||
}
|
||||
}
|
||||
|
||||
export const setPrefixWritable = prefixWritable => ({
|
||||
type: SET_PREFIX_WRITABLE,
|
||||
prefixWritable,
|
||||
prefixWritable
|
||||
})
|
||||
|
||||
export const deleteObject = object => {
|
||||
@@ -162,7 +162,7 @@ export const deleteObject = object => {
|
||||
return web
|
||||
.RemoveObject({
|
||||
bucketName: currentBucket,
|
||||
objects: [objectName],
|
||||
objects: [objectName]
|
||||
})
|
||||
.then(() => {
|
||||
dispatch(removeObject(object))
|
||||
@@ -171,8 +171,8 @@ export const deleteObject = object => {
|
||||
dispatch(
|
||||
alertActions.set({
|
||||
type: "danger",
|
||||
message: e.message,
|
||||
}),
|
||||
message: e.message
|
||||
})
|
||||
)
|
||||
})
|
||||
}
|
||||
@@ -180,7 +180,7 @@ export const deleteObject = object => {
|
||||
|
||||
export const removeObject = object => ({
|
||||
type: REMOVE,
|
||||
object,
|
||||
object
|
||||
})
|
||||
|
||||
export const deleteCheckedObjects = () => {
|
||||
@@ -204,23 +204,23 @@ export const shareObject = (object, days, hours, minutes) => {
|
||||
host: location.host,
|
||||
bucket: currentBucket,
|
||||
object: objectName,
|
||||
expiry,
|
||||
expiry
|
||||
})
|
||||
.then(obj => {
|
||||
dispatch(showShareObject(object, obj.url))
|
||||
dispatch(
|
||||
alertActions.set({
|
||||
type: "success",
|
||||
message: `Object shared. Expires in ${days} days ${hours} hours ${minutes} minutes`,
|
||||
}),
|
||||
message: `Object shared. Expires in ${days} days ${hours} hours ${minutes} minutes`
|
||||
})
|
||||
)
|
||||
})
|
||||
.catch(err => {
|
||||
dispatch(
|
||||
alertActions.set({
|
||||
type: "danger",
|
||||
message: err.message,
|
||||
}),
|
||||
message: err.message
|
||||
})
|
||||
)
|
||||
})
|
||||
}
|
||||
@@ -230,14 +230,14 @@ export const showShareObject = (object, url) => ({
|
||||
type: SET_SHARE_OBJECT,
|
||||
show: true,
|
||||
object,
|
||||
url,
|
||||
url
|
||||
})
|
||||
|
||||
export const hideShareObject = (object, url) => ({
|
||||
type: SET_SHARE_OBJECT,
|
||||
show: false,
|
||||
object: "",
|
||||
url: "",
|
||||
url: ""
|
||||
})
|
||||
|
||||
export const downloadObject = object => {
|
||||
@@ -261,8 +261,8 @@ export const downloadObject = object => {
|
||||
dispatch(
|
||||
alertActions.set({
|
||||
type: "danger",
|
||||
message: err.message,
|
||||
}),
|
||||
message: err.message
|
||||
})
|
||||
)
|
||||
})
|
||||
} else {
|
||||
@@ -276,16 +276,16 @@ export const downloadObject = object => {
|
||||
|
||||
export const checkObject = object => ({
|
||||
type: CHECKED_LIST_ADD,
|
||||
object,
|
||||
object
|
||||
})
|
||||
|
||||
export const uncheckObject = object => ({
|
||||
type: CHECKED_LIST_REMOVE,
|
||||
object,
|
||||
object
|
||||
})
|
||||
|
||||
export const resetCheckedList = () => ({
|
||||
type: CHECKED_LIST_RESET,
|
||||
type: CHECKED_LIST_RESET
|
||||
})
|
||||
|
||||
export const downloadCheckedObjects = () => {
|
||||
@@ -294,7 +294,7 @@ export const downloadCheckedObjects = () => {
|
||||
const req = {
|
||||
bucketName: getCurrentBucket(state),
|
||||
prefix: getCurrentPrefix(state),
|
||||
objects: getCheckedList(state),
|
||||
objects: getCheckedList(state)
|
||||
}
|
||||
if (!web.LoggedIn()) {
|
||||
const requestUrl = location.origin + "/minio/zip?token=''"
|
||||
@@ -312,9 +312,9 @@ export const downloadCheckedObjects = () => {
|
||||
dispatch(
|
||||
alertActions.set({
|
||||
type: "danger",
|
||||
message: err.message,
|
||||
}),
|
||||
),
|
||||
message: err.message
|
||||
})
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -332,7 +332,7 @@ const downloadZip = (url, req, dispatch) => {
|
||||
if (this.status == 200) {
|
||||
dispatch(resetCheckedList())
|
||||
var blob = new Blob([this.response], {
|
||||
type: "octet/stream",
|
||||
type: "octet/stream"
|
||||
})
|
||||
var blobUrl = window.URL.createObjectURL(blob)
|
||||
var separator = req.prefix.length > 1 ? "-" : ""
|
||||
|
||||
@@ -36,11 +36,11 @@ export default (
|
||||
shareObject: {
|
||||
show: false,
|
||||
object: "",
|
||||
url: "",
|
||||
url: ""
|
||||
},
|
||||
checkedList: [],
|
||||
checkedList: []
|
||||
},
|
||||
action,
|
||||
action
|
||||
) => {
|
||||
switch (action.type) {
|
||||
case actionsObjects.SET_LIST:
|
||||
@@ -48,41 +48,41 @@ export default (
|
||||
...state,
|
||||
list: action.objects,
|
||||
marker: action.marker,
|
||||
isTruncated: action.isTruncated,
|
||||
isTruncated: action.isTruncated
|
||||
}
|
||||
case actionsObjects.APPEND_LIST:
|
||||
return {
|
||||
...state,
|
||||
list: [...state.list, ...action.objects],
|
||||
marker: action.marker,
|
||||
isTruncated: action.isTruncated,
|
||||
isTruncated: action.isTruncated
|
||||
}
|
||||
case actionsObjects.REMOVE:
|
||||
return {
|
||||
...state,
|
||||
list: removeObject(state.list, action.object, object => object.name),
|
||||
list: removeObject(state.list, action.object, object => object.name)
|
||||
}
|
||||
case actionsObjects.SET_SORT_BY:
|
||||
return {
|
||||
...state,
|
||||
sortBy: action.sortBy,
|
||||
sortBy: action.sortBy
|
||||
}
|
||||
case actionsObjects.SET_SORT_ORDER:
|
||||
return {
|
||||
...state,
|
||||
sortOrder: action.sortOrder,
|
||||
sortOrder: action.sortOrder
|
||||
}
|
||||
case actionsObjects.SET_CURRENT_PREFIX:
|
||||
return {
|
||||
...state,
|
||||
currentPrefix: action.prefix,
|
||||
marker: "",
|
||||
isTruncated: false,
|
||||
isTruncated: false
|
||||
}
|
||||
case actionsObjects.SET_PREFIX_WRITABLE:
|
||||
return {
|
||||
...state,
|
||||
prefixWritable: action.prefixWritable,
|
||||
prefixWritable: action.prefixWritable
|
||||
}
|
||||
case actionsObjects.SET_SHARE_OBJECT:
|
||||
return {
|
||||
@@ -90,13 +90,13 @@ export default (
|
||||
shareObject: {
|
||||
show: action.show,
|
||||
object: action.object,
|
||||
url: action.url,
|
||||
},
|
||||
url: action.url
|
||||
}
|
||||
}
|
||||
case actionsObjects.CHECKED_LIST_ADD:
|
||||
return {
|
||||
...state,
|
||||
checkedList: [...state.checkedList, action.object],
|
||||
checkedList: [...state.checkedList, action.object]
|
||||
}
|
||||
case actionsObjects.CHECKED_LIST_REMOVE:
|
||||
return {
|
||||
@@ -104,13 +104,13 @@ export default (
|
||||
checkedList: removeObject(
|
||||
state.checkedList,
|
||||
action.object,
|
||||
object => object,
|
||||
),
|
||||
object => object
|
||||
)
|
||||
}
|
||||
case actionsObjects.CHECKED_LIST_RESET:
|
||||
return {
|
||||
...state,
|
||||
checkedList: [],
|
||||
checkedList: []
|
||||
}
|
||||
default:
|
||||
return state
|
||||
|
||||
Reference in New Issue
Block a user