@@ -58,7 +54,9 @@ export const ObjectItem = ({
href="#"
onClick={e => {
e.preventDefault()
- checked ? uncheckObject(name) : checkObject(name)
+ if (onClick) {
+ onClick()
+ }
}}
>
{name}
diff --git a/browser/app/js/objects/ObjectsBulkActions.js b/browser/app/js/objects/ObjectsBulkActions.js
index ef06f7b47..3d72ab262 100644
--- a/browser/app/js/objects/ObjectsBulkActions.js
+++ b/browser/app/js/objects/ObjectsBulkActions.js
@@ -29,10 +29,10 @@ export class ObjectsBulkActions extends React.Component {
}
}
handleDownload() {
- const { checkedObjects, resetCheckedList, downloadChecked, downloadObject } = this.props
- if (checkedObjects.length === 1) {
+ const { checkedObjects, clearChecked, downloadChecked, downloadObject } = this.props
+ if (checkedObjects.length === 1 && !checkedObjects[0].endsWith('/')) {
downloadObject(checkedObjects[0])
- resetCheckedList()
+ clearChecked()
} else {
downloadChecked()
}
@@ -59,17 +59,16 @@ export class ObjectsBulkActions extends React.Component {
}
>
- {checkedObjects.length}
+ {checkedObjects.length}
{checkedObjects.length === 1 ? " Object " : " Objects "}
selected
-
@@ -105,6 +104,7 @@ const mapStateToProps = state => {
const mapDispatchToProps = dispatch => {
return {
+ downloadObject: object => dispatch(actions.downloadObject(object)),
downloadChecked: () => dispatch(actions.downloadCheckedObjects()),
downloadObject: object => dispatch(actions.downloadObject(object)),
resetCheckedList: () => dispatch(actions.resetCheckedList()),
diff --git a/browser/app/js/objects/__tests__/ObjectItem.test.js b/browser/app/js/objects/__tests__/ObjectItem.test.js
index b2f3ca04e..0d7ff61e9 100644
--- a/browser/app/js/objects/__tests__/ObjectItem.test.js
+++ b/browser/app/js/objects/__tests__/ObjectItem.test.js
@@ -28,22 +28,40 @@ describe("ObjectItem", () => {
expect(wrapper.prop("data-type")).toBe("image")
})
- it("should call checkObject when the object is selected", () => {
- const checkObject = jest.fn()
- const wrapper = shallow()
+ it("shouldn't call onClick when the object isclicked", () => {
+ const onClick = jest.fn()
+ const wrapper = shallow()
wrapper.find("a").simulate("click", { preventDefault: jest.fn() })
+ expect(onClick).not.toHaveBeenCalled()
+ })
+
+ it("should call onClick when the folder isclicked", () => {
+ const onClick = jest.fn()
+ const wrapper = shallow()
+ wrapper.find("a").simulate("click", { preventDefault: jest.fn() })
+ expect(onClick).toHaveBeenCalled()
+ })
+
+ it("should call checkObject when the object/prefix is checked", () => {
+ const checkObject = jest.fn()
+ const wrapper = shallow(
+
+ )
+ wrapper.find("input[type='checkbox']").simulate("change")
expect(checkObject).toHaveBeenCalledWith("test")
})
- it("should render highlighted row when object is selected", () => {
+ it("should render checked checkbox", () => {
const wrapper = shallow()
- expect(wrapper.find(".fesl-row").hasClass("fesl-row-selected")).toBeTruthy()
+ expect(wrapper.find("input[type='checkbox']").prop("checked")).toBeTruthy()
})
- it("should call uncheckObject when the object is deselected", () => {
+ it("should call uncheckObject when the object/prefix is unchecked", () => {
const uncheckObject = jest.fn()
- const wrapper = shallow()
- wrapper.find("a").simulate("click", { preventDefault: jest.fn() })
+ const wrapper = shallow(
+
+ )
+ wrapper.find("input[type='checkbox']").simulate("change")
expect(uncheckObject).toHaveBeenCalledWith("test")
})
})
diff --git a/browser/app/js/objects/__tests__/ObjectsBulkActions.test.js b/browser/app/js/objects/__tests__/ObjectsBulkActions.test.js
index f7cd51e87..2a315fd4f 100644
--- a/browser/app/js/objects/__tests__/ObjectsBulkActions.test.js
+++ b/browser/app/js/objects/__tests__/ObjectsBulkActions.test.js
@@ -20,7 +20,7 @@ import { ObjectsBulkActions } from "../ObjectsBulkActions"
describe("ObjectsBulkActions", () => {
it("should render without crashing", () => {
- shallow()
+ shallow()
})
it("should show actions when checkObjectsCount is more than 0", () => {
@@ -28,21 +28,33 @@ describe("ObjectsBulkActions", () => {
expect(wrapper.hasClass("list-actions-toggled")).toBeTruthy()
})
- it("should call downloadObject for single object when download button is clicked", () => {
+ it("should call downloadObject when single object is selected and download button is clicked", () => {
const downloadObject = jest.fn()
- const resetCheckedList = jest.fn()
+ const clearChecked = jest.fn()
const wrapper = shallow(
)
wrapper.find("#download-checked").simulate("click")
expect(downloadObject).toHaveBeenCalled()
})
- it("should call downloadChecked for multiple objects when download button is clicked", () => {
+ it("should call downloadChecked when a folder is selected and download button is clicked", () => {
+ const downloadChecked = jest.fn()
+ const wrapper = shallow(
+
+ )
+ wrapper.find("#download-checked").simulate("click")
+ expect(downloadChecked).toHaveBeenCalled()
+ })
+
+ it("should call downloadChecked when multiple objects are selected and download button is clicked", () => {
const downloadChecked = jest.fn()
const wrapper = shallow(
-
-
+
+