diff --git a/browser/app/js/actions.js b/browser/app/js/actions.js index ebf606089..5ea3afbf7 100644 --- a/browser/app/js/actions.js +++ b/browser/app/js/actions.js @@ -80,11 +80,12 @@ export const hideDeleteConfirmation = () => { } } -export const showShareObject = url => { +export const showShareObject = (object, url) => { return { type: SET_SHARE_OBJECT, shareObject: { - url: url, + object, + url, show: true } } @@ -106,9 +107,10 @@ export const shareObject = (object, expiry) => (dispatch, getState) => { let bucket = currentBucket if (!web.LoggedIn()) { - dispatch(showShareObject(`${host}/${bucket}/${object}`)) + dispatch(showShareObject(object, `${host}/${bucket}/${object}`)) return } + web.PresignedGet({ host, bucket, @@ -116,7 +118,11 @@ export const shareObject = (object, expiry) => (dispatch, getState) => { expiry }) .then(obj => { - dispatch(showShareObject(obj.url)) + dispatch(showShareObject(object, obj.url)) + dispatch(showAlert({ + type: 'success', + message: `Object shared, expires in ${expiry} seconds` + })) }) .catch(err => { dispatch(showAlert({ @@ -604,4 +610,4 @@ export const checkedObjectsReset = (objectName) => { type: CHECKED_OBJECTS_RESET, objectName } -} \ No newline at end of file +} diff --git a/browser/app/js/components/Browse.js b/browser/app/js/components/Browse.js index adf89a6a1..60daf1bf5 100644 --- a/browser/app/js/components/Browse.js +++ b/browser/app/js/components/Browse.js @@ -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) { e.preventDefault() const {dispatch} = this.props @@ -290,7 +271,8 @@ export default class Browse extends React.Component { shareObject(e, object) { e.preventDefault() 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() { @@ -382,13 +364,19 @@ export default class Browse extends React.Component { this.refs.copyTextInput.select() } - handleExpireValue(targetInput, inc) { + handleExpireValue(targetInput, inc, object) { inc === -1 ? this.refs[targetInput].stepDown(1) : this.refs[targetInput].stepUp(1) if (this.refs.expireDays.value == 7) { this.refs.expireHours.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) { @@ -734,7 +722,7 @@ export default class Browse extends React.Component {