-
-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/default expiry #161
Changes from 4 commits
a3554d3
4042cd0
a7acb27
140fa57
a514b0b
3ba9a95
bbf5b70
34057de
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,6 +114,8 @@ | |
</template> | ||
<script> | ||
/* global maxSecretExpire */ | ||
/* global defaultSecretExpire */ | ||
|
||
|
||
import appCrypto from '../crypto.js' | ||
import { bytesToHuman } from '../helpers' | ||
|
@@ -153,22 +155,18 @@ export default { | |
}, | ||
|
||
expiryChoices() { | ||
const choices = [{ text: this.$t('expire-default'), value: null }] | ||
const choices = [{ | ||
text: this.$t('expire-default') + " (" + this.getExpiryLabel(defaultSecretExpire) + ")", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be properly adjusted in the translation, not just appended. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also the label does not solve the issue when values other than |
||
value: defaultSecretExpire | ||
}] | ||
|
||
for (const choice of this.$root.customize.expiryChoices || defaultExpiryChoices) { | ||
if (maxSecretExpire > 0 && choice > maxSecretExpire) { | ||
continue | ||
} | ||
|
||
const option = { value: choice } | ||
if (choice >= 86400) { | ||
option.text = this.$tc('expire-n-days', Math.round(choice / 86400)) | ||
} else if (choice >= 3600) { | ||
option.text = this.$tc('expire-n-hours', Math.round(choice / 3600)) | ||
} else if (choice >= 60) { | ||
option.text = this.$tc('expire-n-minutes', Math.round(choice / 60)) | ||
} else { | ||
option.text = this.$tc('expire-n-seconds', choice) | ||
} | ||
option.text = this.getExpiryLabel(choice) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be joined with line above |
||
|
||
choices.push(option) | ||
} | ||
|
@@ -220,7 +218,7 @@ export default { | |
fileSize: 0, | ||
secret: '', | ||
securePassword: null, | ||
selectedExpiry: null, | ||
selectedExpiry: defaultSecretExpire, | ||
selectedFileMeta: [], | ||
} | ||
}, | ||
|
@@ -310,6 +308,21 @@ export default { | |
return false | ||
}, | ||
|
||
getExpiryLabel(duration) { | ||
if (duration >= 86400) { | ||
text = this.$tc('expire-n-days', Math.round(duration / 86400)) | ||
} else if (duration >= 3600) { | ||
text = this.$tc('expire-n-hours', Math.round(duration / 3600)) | ||
} else if (duration >= 60) { | ||
text = this.$tc('expire-n-minutes', Math.round(duration / 60)) | ||
} else if (duration > 0) { | ||
text = this.$tc('expire-n-seconds', duration) | ||
} else { | ||
text = this.$t('never') | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix formatting |
||
return text | ||
}, | ||
|
||
isAcceptedBy(fileMeta, accept) { | ||
if (/^(?:[a-z]+|\*)\/(?:[a-zA-Z0-9.+_-]+|\*)$/.test(accept)) { | ||
// That's likely supposed to be a mime-type | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename:
expire-never
(though as this is wrong on a functionality level, we don't need that)