storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/browser/app/js/objects/ObjectsBulkActions.js (about) 1 /* 2 * MinIO Cloud Storage (C) 2018 MinIO, Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 import React from "react" 18 import { connect } from "react-redux" 19 import classNames from "classnames" 20 import * as actions from "./actions" 21 import { getCheckedList } from "./selectors" 22 import DeleteObjectConfirmModal from "./DeleteObjectConfirmModal" 23 24 export class ObjectsBulkActions extends React.Component { 25 constructor(props) { 26 super(props) 27 this.state = { 28 showDeleteConfirmation: false 29 } 30 } 31 handleDownload() { 32 const { checkedObjects, clearChecked, downloadChecked, downloadObject } = this.props 33 if (checkedObjects.length === 1 && !checkedObjects[0].endsWith('/')) { 34 downloadObject(checkedObjects[0]) 35 clearChecked() 36 } else { 37 downloadChecked() 38 } 39 } 40 deleteChecked() { 41 const { deleteChecked } = this.props 42 deleteChecked() 43 this.hideDeleteConfirmModal() 44 } 45 hideDeleteConfirmModal() { 46 this.setState({ 47 showDeleteConfirmation: false 48 }) 49 } 50 render() { 51 const { checkedObjects, clearChecked } = this.props 52 return ( 53 <div 54 className={ 55 "list-actions" + 56 classNames({ 57 " list-actions-toggled": checkedObjects.length > 0 58 }) 59 } 60 > 61 <span className="la-label"> 62 <i className="fas fa-check-circle" /> {checkedObjects.length} 63 {checkedObjects.length === 1 ? " Object " : " Objects "} 64 selected 65 </span> 66 <span className="la-actions pull-right"> 67 <button id="download-checked" onClick={this.handleDownload.bind(this)}> 68 {" "} 69 Download 70 {(checkedObjects.length === 1 && !checkedObjects[0].endsWith('/')) ? 71 " object" : " all as zip" }{" "} 72 </button> 73 </span> 74 <span className="la-actions pull-right"> 75 <button 76 id="delete-checked" 77 onClick={() => this.setState({ showDeleteConfirmation: true })} 78 > 79 {" "} 80 Delete selected{" "} 81 </button> 82 </span> 83 <i 84 className="la-close fas fa-times" 85 id="close-bulk-actions" 86 onClick={clearChecked} 87 /> 88 {this.state.showDeleteConfirmation && ( 89 <DeleteObjectConfirmModal 90 deleteObject={this.deleteChecked.bind(this)} 91 hideDeleteConfirmModal={this.hideDeleteConfirmModal.bind(this)} 92 /> 93 )} 94 </div> 95 ) 96 } 97 } 98 99 const mapStateToProps = state => { 100 return { 101 checkedObjects: getCheckedList(state) 102 } 103 } 104 105 const mapDispatchToProps = dispatch => { 106 return { 107 downloadObject: object => dispatch(actions.downloadObject(object)), 108 downloadChecked: () => dispatch(actions.downloadCheckedObjects()), 109 downloadObject: object => dispatch(actions.downloadObject(object)), 110 resetCheckedList: () => dispatch(actions.resetCheckedList()), 111 clearChecked: () => dispatch(actions.resetCheckedList()), 112 deleteChecked: () => dispatch(actions.deleteCheckedObjects()) 113 } 114 } 115 116 export default connect(mapStateToProps, mapDispatchToProps)(ObjectsBulkActions)