Refactor download object and bulk action components (#5546)

This commit is contained in:
Kanagaraj M
2018-02-21 07:30:43 +05:30
committed by Harshavardhana
parent da4558a8f7
commit 6a42727e00
14 changed files with 604 additions and 24 deletions

View File

@@ -19,12 +19,17 @@ import { connect } from "react-redux"
import humanize from "humanize"
import Moment from "moment"
import { getDataType } from "../mime"
import * as actions from "./actions"
import { getCheckedList } from "./selectors"
export const ObjectItem = ({
name,
contentType,
size,
lastModified,
checked,
checkObject,
uncheckObject,
actionButtons,
onClick
}) => {
@@ -32,7 +37,14 @@ export const ObjectItem = ({
<div className={"fesl-row"} data-type={getDataType(name, contentType)}>
<div className="fesl-item fesl-item-icon">
<div className="fi-select">
<input type="checkbox" name={name} checked={false} />
<input
type="checkbox"
name={name}
checked={checked}
onChange={() => {
checked ? uncheckObject(name) : checkObject(name)
}}
/>
<i className="fis-icon" />
<i className="fis-helper" />
</div>
@@ -55,4 +67,17 @@ export const ObjectItem = ({
)
}
export default ObjectItem
const mapStateToProps = (state, ownProps) => {
return {
checked: getCheckedList(state).indexOf(ownProps.name) >= 0
}
}
const mapDispatchToProps = dispatch => {
return {
checkObject: name => dispatch(actions.checkObject(name)),
uncheckObject: name => dispatch(actions.uncheckObject(name))
}
}
export default connect(mapStateToProps, mapDispatchToProps)(ObjectItem)