storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/browser/app/js/objects/PrefixActions.js (about) 1 /* 2 * MinIO Cloud Storage (C) 2020 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 { Dropdown } from "react-bootstrap" 20 import DeleteObjectConfirmModal from "./DeleteObjectConfirmModal" 21 import * as actions from "./actions" 22 23 export class PrefixActions extends React.Component { 24 constructor(props) { 25 super(props) 26 this.state = { 27 showDeleteConfirmation: false, 28 } 29 } 30 handleDownload(e) { 31 e.preventDefault() 32 const { object, downloadPrefix } = this.props 33 downloadPrefix(object.name) 34 } 35 deleteObject() { 36 const { object, deleteObject } = this.props 37 deleteObject(object.name) 38 } 39 showDeleteConfirmModal(e) { 40 e.preventDefault() 41 this.setState({ showDeleteConfirmation: true }) 42 } 43 hideDeleteConfirmModal() { 44 this.setState({ 45 showDeleteConfirmation: false, 46 }) 47 } 48 render() { 49 const { object, showShareObjectModal, shareObjectName } = this.props 50 return ( 51 <Dropdown id={`obj-actions-${object.name}`}> 52 <Dropdown.Toggle noCaret className="fia-toggle" /> 53 <Dropdown.Menu> 54 <a 55 href="" 56 className="fiad-action" 57 title="Download as zip" 58 onClick={this.handleDownload.bind(this)} 59 > 60 <i className="fas fa-cloud-download-alt" /> 61 </a> 62 <a 63 href="" 64 className="fiad-action" 65 title="Delete" 66 onClick={this.showDeleteConfirmModal.bind(this)} 67 > 68 <i className="fas fa-trash-alt" /> 69 </a> 70 </Dropdown.Menu> 71 {this.state.showDeleteConfirmation && ( 72 <DeleteObjectConfirmModal 73 deleteObject={this.deleteObject.bind(this)} 74 hideDeleteConfirmModal={this.hideDeleteConfirmModal.bind(this)} 75 /> 76 )} 77 </Dropdown> 78 ) 79 } 80 } 81 82 const mapStateToProps = (state, ownProps) => { 83 return { 84 object: ownProps.object, 85 } 86 } 87 88 const mapDispatchToProps = (dispatch) => { 89 return { 90 downloadPrefix: object => dispatch(actions.downloadPrefix(object)), 91 deleteObject: (object) => dispatch(actions.deleteObject(object)), 92 } 93 } 94 95 export default connect(mapStateToProps, mapDispatchToProps)(PrefixActions)