mirror of
https://github.com/minio/minio.git
synced 2024-12-24 22:25:54 -05:00
Share object expiry value modification modal was not working (#3860)
This commit is contained in:
parent
966818955e
commit
436db49bf3
@ -80,11 +80,12 @@ export const hideDeleteConfirmation = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const showShareObject = url => {
|
export const showShareObject = (object, url) => {
|
||||||
return {
|
return {
|
||||||
type: SET_SHARE_OBJECT,
|
type: SET_SHARE_OBJECT,
|
||||||
shareObject: {
|
shareObject: {
|
||||||
url: url,
|
object,
|
||||||
|
url,
|
||||||
show: true
|
show: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,9 +107,10 @@ export const shareObject = (object, expiry) => (dispatch, getState) => {
|
|||||||
let bucket = currentBucket
|
let bucket = currentBucket
|
||||||
|
|
||||||
if (!web.LoggedIn()) {
|
if (!web.LoggedIn()) {
|
||||||
dispatch(showShareObject(`${host}/${bucket}/${object}`))
|
dispatch(showShareObject(object, `${host}/${bucket}/${object}`))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
web.PresignedGet({
|
web.PresignedGet({
|
||||||
host,
|
host,
|
||||||
bucket,
|
bucket,
|
||||||
@ -116,7 +118,11 @@ export const shareObject = (object, expiry) => (dispatch, getState) => {
|
|||||||
expiry
|
expiry
|
||||||
})
|
})
|
||||||
.then(obj => {
|
.then(obj => {
|
||||||
dispatch(showShareObject(obj.url))
|
dispatch(showShareObject(object, obj.url))
|
||||||
|
dispatch(showAlert({
|
||||||
|
type: 'success',
|
||||||
|
message: `Object shared, expires in ${expiry} seconds`
|
||||||
|
}))
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
dispatch(showAlert({
|
dispatch(showAlert({
|
||||||
|
@ -251,25 +251,6 @@ export default class Browse extends React.Component {
|
|||||||
})))
|
})))
|
||||||
}
|
}
|
||||||
|
|
||||||
removeObjectSelected() {
|
|
||||||
const {web, dispatch, currentPath, currentBucket, checkedObjects} = this.props
|
|
||||||
web.RemoveObject({
|
|
||||||
bucketname: currentBucket,
|
|
||||||
objects: checkedObjects
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
this.hideDeleteConfirmation()
|
|
||||||
for (let i = 0; i < checkedObjects.length; i++) {
|
|
||||||
dispatch(actions.removeObject(checkedObjects[i].replace(currentPath, '')))
|
|
||||||
}
|
|
||||||
dispatch(actions.checkedObjectsReset())
|
|
||||||
})
|
|
||||||
.catch(e => dispatch(actions.showAlert({
|
|
||||||
type: 'danger',
|
|
||||||
message: e.message
|
|
||||||
})))
|
|
||||||
}
|
|
||||||
|
|
||||||
hideAlert(e) {
|
hideAlert(e) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
const {dispatch} = this.props
|
const {dispatch} = this.props
|
||||||
@ -290,7 +271,8 @@ export default class Browse extends React.Component {
|
|||||||
shareObject(e, object) {
|
shareObject(e, object) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
const {dispatch} = this.props
|
const {dispatch} = this.props
|
||||||
dispatch(actions.shareObject(object))
|
let expiry = 5 * 24 * 60 * 60 // 5 days expiry by default
|
||||||
|
dispatch(actions.shareObject(object, expiry))
|
||||||
}
|
}
|
||||||
|
|
||||||
hideShareObjectModal() {
|
hideShareObjectModal() {
|
||||||
@ -382,13 +364,19 @@ export default class Browse extends React.Component {
|
|||||||
this.refs.copyTextInput.select()
|
this.refs.copyTextInput.select()
|
||||||
}
|
}
|
||||||
|
|
||||||
handleExpireValue(targetInput, inc) {
|
handleExpireValue(targetInput, inc, object) {
|
||||||
inc === -1 ? this.refs[targetInput].stepDown(1) : this.refs[targetInput].stepUp(1)
|
inc === -1 ? this.refs[targetInput].stepDown(1) : this.refs[targetInput].stepUp(1)
|
||||||
|
|
||||||
if (this.refs.expireDays.value == 7) {
|
if (this.refs.expireDays.value == 7) {
|
||||||
this.refs.expireHours.value = 0
|
this.refs.expireHours.value = 0
|
||||||
this.refs.expireMins.value = 0
|
this.refs.expireMins.value = 0
|
||||||
}
|
}
|
||||||
|
if (this.refs.expireDays.value + this.refs.expireHours.value + this.refs.expireMins.value == 0) {
|
||||||
|
this.refs.expireDays.value = 7
|
||||||
|
}
|
||||||
|
const {dispatch} = this.props
|
||||||
|
let expiry = this.refs.expireDays.value * 24 * 60 * 60 + this.refs.expireHours.value * 60 * 60 + this.refs.expireMins.value * 60
|
||||||
|
dispatch(actions.shareObject(object, expiry))
|
||||||
}
|
}
|
||||||
|
|
||||||
checkObject(e, objectName) {
|
checkObject(e, objectName) {
|
||||||
@ -734,7 +722,7 @@ export default class Browse extends React.Component {
|
|||||||
</label>
|
</label>
|
||||||
<div className="set-expire">
|
<div className="set-expire">
|
||||||
<div className="set-expire-item">
|
<div className="set-expire-item">
|
||||||
<i className="set-expire-increase" onClick={ this.handleExpireValue.bind(this, 'expireDays', 1) }></i>
|
<i className="set-expire-increase" onClick={ this.handleExpireValue.bind(this, 'expireDays', 1, shareObject.object) }></i>
|
||||||
<div className="set-expire-title">
|
<div className="set-expire-title">
|
||||||
Days
|
Days
|
||||||
</div>
|
</div>
|
||||||
@ -743,12 +731,12 @@ export default class Browse extends React.Component {
|
|||||||
type="number"
|
type="number"
|
||||||
min={ 0 }
|
min={ 0 }
|
||||||
max={ 7 }
|
max={ 7 }
|
||||||
defaultValue={ 0 } />
|
defaultValue={ 5 } />
|
||||||
</div>
|
</div>
|
||||||
<i className="set-expire-decrease" onClick={ this.handleExpireValue.bind(this, 'expireDays', -1) }></i>
|
<i className="set-expire-decrease" onClick={ this.handleExpireValue.bind(this, 'expireDays', -1, shareObject.object) }></i>
|
||||||
</div>
|
</div>
|
||||||
<div className="set-expire-item">
|
<div className="set-expire-item">
|
||||||
<i className="set-expire-increase" onClick={ this.handleExpireValue.bind(this, 'expireHours', 1) }></i>
|
<i className="set-expire-increase" onClick={ this.handleExpireValue.bind(this, 'expireHours', 1, shareObject.object) }></i>
|
||||||
<div className="set-expire-title">
|
<div className="set-expire-title">
|
||||||
Hours
|
Hours
|
||||||
</div>
|
</div>
|
||||||
@ -756,30 +744,30 @@ export default class Browse extends React.Component {
|
|||||||
<input ref="expireHours"
|
<input ref="expireHours"
|
||||||
type="number"
|
type="number"
|
||||||
min={ 0 }
|
min={ 0 }
|
||||||
max={ 24 }
|
max={ 23 }
|
||||||
defaultValue={ 0 } />
|
defaultValue={ 0 } />
|
||||||
</div>
|
</div>
|
||||||
<i className="set-expire-decrease" onClick={ this.handleExpireValue.bind(this, 'expireHours', -1) }></i>
|
<i className="set-expire-decrease" onClick={ this.handleExpireValue.bind(this, 'expireHours', -1, shareObject.object) }></i>
|
||||||
</div>
|
</div>
|
||||||
<div className="set-expire-item">
|
<div className="set-expire-item">
|
||||||
<i className="set-expire-increase" onClick={ this.handleExpireValue.bind(this, 'expireMins', 1) }></i>
|
<i className="set-expire-increase" onClick={ this.handleExpireValue.bind(this, 'expireMins', 1, shareObject.object) }></i>
|
||||||
<div className="set-expire-title">
|
<div className="set-expire-title">
|
||||||
Minutes
|
Minutes
|
||||||
</div>
|
</div>
|
||||||
<div className="set-expire-value">
|
<div className="set-expire-value">
|
||||||
<input ref="expireMins"
|
<input ref="expireMins"
|
||||||
type="number"
|
type="number"
|
||||||
min={ 1 }
|
min={ 0 }
|
||||||
max={ 60 }
|
max={ 59 }
|
||||||
defaultValue={ 45 } />
|
defaultValue={ 0 } />
|
||||||
</div>
|
</div>
|
||||||
<i className="set-expire-decrease" onClick={ this.handleExpireValue.bind(this, 'expireMins', -1) }></i>
|
<i className="set-expire-decrease" onClick={ this.handleExpireValue.bind(this, 'expireMins', -1, shareObject.object) }></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
<div className="modal-footer">
|
<div className="modal-footer">
|
||||||
<CopyToClipboard text={ shareObject.url } onCopy={ this.showMessage.bind(this) }>
|
<CopyToClipboard text={ window.location.protocol + '//' + shareObject.url } onCopy={ this.showMessage.bind(this) }>
|
||||||
<button className="btn btn-success">
|
<button className="btn btn-success">
|
||||||
Copy Link
|
Copy Link
|
||||||
</button>
|
</button>
|
||||||
|
@ -54,7 +54,7 @@ export default (state = {
|
|||||||
shareObject: {
|
shareObject: {
|
||||||
show: false,
|
show: false,
|
||||||
url: '',
|
url: '',
|
||||||
expiry: 604800
|
object: ''
|
||||||
},
|
},
|
||||||
prefixWritable: false,
|
prefixWritable: false,
|
||||||
checkedObjects: []
|
checkedObjects: []
|
||||||
|
Loading…
Reference in New Issue
Block a user