2018-02-14 21:34:59 -05:00
|
|
|
/*
|
|
|
|
* Minio Cloud Storage (C) 2018 Minio, Inc.
|
|
|
|
*
|
|
|
|
* 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 { connect } from "react-redux"
|
|
|
|
import { Modal, ModalBody } from "react-bootstrap"
|
|
|
|
import * as actionsBuckets from "./actions"
|
|
|
|
|
|
|
|
export class MakeBucketModal extends React.Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props)
|
|
|
|
this.state = {
|
2018-03-21 14:09:23 -04:00
|
|
|
bucketName: "",
|
2018-02-14 21:34:59 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
onSubmit(e) {
|
|
|
|
e.preventDefault()
|
|
|
|
const { makeBucket } = this.props
|
|
|
|
const bucket = this.state.bucketName
|
|
|
|
if (bucket) {
|
|
|
|
makeBucket(bucket)
|
|
|
|
this.hideModal()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
hideModal() {
|
|
|
|
this.setState({
|
2018-03-21 14:09:23 -04:00
|
|
|
bucketName: "",
|
2018-02-14 21:34:59 -05:00
|
|
|
})
|
|
|
|
this.props.hideMakeBucketModal()
|
|
|
|
}
|
|
|
|
render() {
|
|
|
|
const { showMakeBucketModal } = this.props
|
|
|
|
return (
|
|
|
|
<Modal
|
2018-03-21 14:09:23 -04:00
|
|
|
className="create-bucket"
|
2018-02-14 21:34:59 -05:00
|
|
|
bsSize="small"
|
|
|
|
animation={false}
|
|
|
|
show={showMakeBucketModal}
|
|
|
|
onHide={this.hideModal.bind(this)}
|
|
|
|
>
|
2018-03-21 14:09:23 -04:00
|
|
|
<i className="close" onClick={this.hideModal.bind(this)} />
|
|
|
|
<Modal.Body>
|
2018-02-14 21:34:59 -05:00
|
|
|
<form onSubmit={this.onSubmit.bind(this)}>
|
2018-03-21 14:09:23 -04:00
|
|
|
<div className="form-group form-group--centered">
|
2018-02-14 21:34:59 -05:00
|
|
|
<input
|
2018-03-21 14:09:23 -04:00
|
|
|
className="form-group__field"
|
2018-02-14 21:34:59 -05:00
|
|
|
type="text"
|
|
|
|
placeholder="Bucket Name"
|
|
|
|
value={this.state.bucketName}
|
2018-03-21 14:09:23 -04:00
|
|
|
onChange={e =>
|
|
|
|
this.setState({
|
|
|
|
bucketName: e.target.value,
|
|
|
|
})
|
|
|
|
}
|
2018-02-14 21:34:59 -05:00
|
|
|
autoFocus
|
|
|
|
/>
|
2018-03-21 14:09:23 -04:00
|
|
|
<i className="form-group__helper" />
|
2018-02-14 21:34:59 -05:00
|
|
|
</div>
|
|
|
|
</form>
|
2018-03-21 14:09:23 -04:00
|
|
|
</Modal.Body>
|
2018-02-14 21:34:59 -05:00
|
|
|
</Modal>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const mapStateToProps = state => {
|
|
|
|
return {
|
2018-03-21 14:09:23 -04:00
|
|
|
showMakeBucketModal: state.buckets.showMakeBucketModal,
|
2018-02-14 21:34:59 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const mapDispatchToProps = dispatch => {
|
|
|
|
return {
|
|
|
|
makeBucket: bucket => dispatch(actionsBuckets.makeBucket(bucket)),
|
2018-03-21 14:09:23 -04:00
|
|
|
hideMakeBucketModal: () => dispatch(actionsBuckets.hideMakeBucketModal()),
|
2018-02-14 21:34:59 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(MakeBucketModal)
|