storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/browser/app/js/objects/PreviewObjectModal.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 { Modal, ModalHeader, ModalBody } from "react-bootstrap" 19 20 class PreviewObjectModal extends React.Component { 21 constructor(props) { 22 super(props) 23 this.state = { 24 url: "", 25 } 26 } 27 28 componentDidMount() { 29 this.props.getObjectURL(this.props.object.name, (url) => { 30 this.setState({ 31 url: url, 32 }) 33 }) 34 } 35 36 render() { 37 const { hidePreviewModal } = this.props 38 return ( 39 <Modal 40 show={true} 41 animation={false} 42 onHide={hidePreviewModal} 43 bsSize="large" 44 > 45 <ModalHeader>Preview</ModalHeader> 46 <ModalBody> 47 <div className="input-group"> 48 {this.state.url && ( 49 <object data={this.state.url} style={{ display: "block", width: "100%" }}> 50 <h3 style={{ textAlign: "center", display: "block", width: "100%" }}> 51 Do not have read permissions to preview "{this.props.object.name}" 52 </h3> 53 </object> 54 )} 55 </div> 56 </ModalBody> 57 <div className="modal-footer"> 58 { 59 <button className="btn btn-link" onClick={hidePreviewModal}> 60 Cancel 61 </button> 62 } 63 </div> 64 </Modal> 65 ) 66 } 67 } 68 export default PreviewObjectModal