mirror of
https://github.com/minio/minio.git
synced 2025-11-20 18:06:10 -05:00
Refactor download object and bulk action components (#5546)
This commit is contained in:
committed by
Harshavardhana
parent
da4558a8f7
commit
6a42727e00
@@ -15,22 +15,41 @@
|
||||
*/
|
||||
|
||||
import React from "react"
|
||||
import { connect } from "react-redux"
|
||||
import humanize from "humanize"
|
||||
import Moment from "moment"
|
||||
import ObjectItem from "./ObjectItem"
|
||||
import ObjectActions from "./ObjectActions"
|
||||
import * as actionsObjects from "./actions"
|
||||
import { getCheckedList } from "./selectors"
|
||||
|
||||
export const ObjectContainer = ({ object }) => {
|
||||
const actionButtons = <ObjectActions object={object} />
|
||||
const props = {
|
||||
export const ObjectContainer = ({
|
||||
object,
|
||||
checkedObjectsCount,
|
||||
downloadObject
|
||||
}) => {
|
||||
let props = {
|
||||
name: object.name,
|
||||
contentType: object.contentType,
|
||||
size: humanize.filesize(object.size),
|
||||
lastModified: Moment(object.lastModified).format("lll"),
|
||||
actionButtons: actionButtons
|
||||
lastModified: Moment(object.lastModified).format("lll")
|
||||
}
|
||||
return <ObjectItem {...props} />
|
||||
if (checkedObjectsCount == 0) {
|
||||
props.actionButtons = <ObjectActions object={object} />
|
||||
}
|
||||
return <ObjectItem {...props} onClick={() => downloadObject(object.name)} />
|
||||
}
|
||||
|
||||
export default ObjectContainer
|
||||
const mapStateToProps = state => {
|
||||
return {
|
||||
checkedObjectsCount: getCheckedList(state).length
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
downloadObject: object => dispatch(actionsObjects.downloadObject(object))
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(ObjectContainer)
|
||||
|
||||
Reference in New Issue
Block a user