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 classNames from "classnames"
|
|
|
|
import { connect } from "react-redux"
|
|
|
|
import ConfirmModal from "../browser/ConfirmModal"
|
|
|
|
import * as uploadsActions from "./actions"
|
|
|
|
|
|
|
|
export class AbortConfirmModal extends React.Component {
|
|
|
|
abortUploads() {
|
|
|
|
const { abort, uploads } = this.props
|
|
|
|
for (var slug in uploads) {
|
|
|
|
abort(slug)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
render() {
|
|
|
|
const { hideAbort } = this.props
|
|
|
|
let baseClass = classNames({
|
2018-03-22 15:25:56 -04:00
|
|
|
"abort-upload": true
|
2018-02-14 21:34:59 -05:00
|
|
|
})
|
|
|
|
let okIcon = classNames({
|
|
|
|
fa: true,
|
2018-03-22 15:25:56 -04:00
|
|
|
"fa-times": true
|
2018-02-14 21:34:59 -05:00
|
|
|
})
|
|
|
|
let cancelIcon = classNames({
|
|
|
|
fa: true,
|
2018-03-22 15:25:56 -04:00
|
|
|
"fa-cloud-upload": true
|
2018-02-14 21:34:59 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ConfirmModal
|
|
|
|
show={true}
|
|
|
|
baseClass={baseClass}
|
|
|
|
text="Abort uploads in progress?"
|
|
|
|
icon="fa fa-info-circle mci-amber"
|
|
|
|
sub="This cannot be undone!"
|
|
|
|
okText="Abort"
|
|
|
|
okIcon={okIcon}
|
2018-03-26 15:49:12 -04:00
|
|
|
cancelText="Upload"
|
2018-02-14 21:34:59 -05:00
|
|
|
cancelIcon={cancelIcon}
|
|
|
|
okHandler={this.abortUploads.bind(this)}
|
|
|
|
cancelHandler={hideAbort}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const mapStateToProps = state => {
|
|
|
|
return {
|
2018-03-22 15:25:56 -04:00
|
|
|
uploads: state.uploads.files
|
2018-02-14 21:34:59 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const mapDispatchToProps = dispatch => {
|
|
|
|
return {
|
|
|
|
abort: slug => dispatch(uploadsActions.abortUpload(slug)),
|
2018-03-22 15:25:56 -04:00
|
|
|
hideAbort: () => dispatch(uploadsActions.hideAbortModal())
|
2018-02-14 21:34:59 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(AbortConfirmModal)
|