2017-01-24 03:07:22 +01:00
|
|
|
/*
|
2017-02-23 02:27:26 +01:00
|
|
|
* Minio Cloud Storage (C) 2016 Minio, Inc.
|
2017-01-24 03:07:22 +01:00
|
|
|
*
|
|
|
|
* 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 React from 'react'
|
|
|
|
import Moment from 'moment'
|
|
|
|
import humanize from 'humanize'
|
|
|
|
import connect from 'react-redux/lib/components/connect'
|
|
|
|
import Dropdown from 'react-bootstrap/lib/Dropdown'
|
|
|
|
|
2017-02-22 23:51:38 +01:00
|
|
|
let ObjectsList = ({objects, currentPath, selectPrefix, dataType, showDeleteConfirmation, shareObject, loadPath, checkObject, checkedObjectsArray}) => {
|
2017-01-24 03:07:22 +01:00
|
|
|
const list = objects.map((object, i) => {
|
|
|
|
let size = object.name.endsWith('/') ? '-' : humanize.filesize(object.size)
|
|
|
|
let lastModified = object.name.endsWith('/') ? '-' : Moment(object.lastModified).format('lll')
|
|
|
|
let loadingClass = loadPath === `${currentPath}${object.name}` ? 'fesl-loading' : ''
|
|
|
|
let actionButtons = ''
|
|
|
|
let deleteButton = ''
|
|
|
|
if (web.LoggedIn())
|
|
|
|
deleteButton = <a href="" className="fiad-action" onClick={ (e) => showDeleteConfirmation(e, `${currentPath}${object.name}`) }><i className="fa fa-trash"></i></a>
|
2017-03-07 00:43:43 +01:00
|
|
|
|
|
|
|
if (!checkedObjectsArray.length > 0) {
|
|
|
|
if (!object.name.endsWith('/')) {
|
|
|
|
actionButtons = <Dropdown id={ "fia-dropdown-" + object.name.replace('.', '-') }>
|
|
|
|
<Dropdown.Toggle noCaret className="fia-toggle"></Dropdown.Toggle>
|
|
|
|
<Dropdown.Menu>
|
|
|
|
<a href="" className="fiad-action" onClick={ (e) => shareObject(e, `${currentPath}${object.name}`) }><i className="fa fa-copy"></i></a>
|
|
|
|
{ deleteButton }
|
|
|
|
</Dropdown.Menu>
|
|
|
|
</Dropdown>
|
|
|
|
}
|
2017-01-24 03:07:22 +01:00
|
|
|
}
|
2017-02-22 23:51:38 +01:00
|
|
|
|
2017-03-07 00:43:43 +01:00
|
|
|
let activeClass = ''
|
|
|
|
let isChecked = ''
|
|
|
|
|
|
|
|
if (checkedObjectsArray.indexOf(object.name) > -1) {
|
|
|
|
activeClass = ' fesl-row-selected'
|
|
|
|
isChecked = true
|
|
|
|
}
|
2017-02-22 23:51:38 +01:00
|
|
|
|
2017-01-24 03:07:22 +01:00
|
|
|
return (
|
2017-02-22 23:51:38 +01:00
|
|
|
<div key={ i } className={ "fesl-row " + loadingClass + activeClass } data-type={ dataType(object.name, object.contentType) }>
|
|
|
|
<div className="fesl-item fesl-item-icon">
|
|
|
|
<div className="fi-select">
|
2017-03-07 00:43:43 +01:00
|
|
|
<input type="checkbox"
|
|
|
|
name={ object.name }
|
|
|
|
checked={ isChecked }
|
|
|
|
onChange={ (e) => checkObject(e, object.name) } />
|
2017-02-22 23:51:38 +01:00
|
|
|
<i className="fis-icon"></i>
|
|
|
|
<i className="fis-helper"></i>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="fesl-item fesl-item-name">
|
2017-01-24 03:07:22 +01:00
|
|
|
<a href="" onClick={ (e) => selectPrefix(e, `${currentPath}${object.name}`) }>
|
|
|
|
{ object.name }
|
|
|
|
</a>
|
|
|
|
</div>
|
2017-02-22 23:51:38 +01:00
|
|
|
<div className="fesl-item fesl-item-size">
|
2017-01-24 03:07:22 +01:00
|
|
|
{ size }
|
|
|
|
</div>
|
2017-02-22 23:51:38 +01:00
|
|
|
<div className="fesl-item fesl-item-modified">
|
2017-01-24 03:07:22 +01:00
|
|
|
{ lastModified }
|
|
|
|
</div>
|
2017-02-22 23:51:38 +01:00
|
|
|
<div className="fesl-item fesl-item-actions">
|
2017-01-24 03:07:22 +01:00
|
|
|
{ actionButtons }
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
})
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
{ list }
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subscribe it to state changes.
|
|
|
|
export default connect(state => {
|
|
|
|
return {
|
|
|
|
objects: state.objects,
|
|
|
|
currentPath: state.currentPath,
|
|
|
|
loadPath: state.loadPath
|
|
|
|
}
|
2017-02-22 23:51:38 +01:00
|
|
|
})(ObjectsList)
|