mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
chore(files_sharing): cleanup NewFileRequestDialog vue
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
This commit is contained in:
parent
a65cdd1e70
commit
bc5839e5b5
5 changed files with 29 additions and 23 deletions
|
|
@ -18,7 +18,7 @@ use OCA\Files_Sharing\External\Storage;
|
|||
use OCA\Files_Sharing\ResponseDefinitions;
|
||||
use OCA\Files_Sharing\SharedStorage;
|
||||
use OCP\App\IAppManager;
|
||||
use OCP\AppFramework\Http\Attribute\BruteForceProtection;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
|
||||
use OCP\AppFramework\Http\Attribute\UserRateLimit;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
<form ref="form"
|
||||
class="file-request-dialog__form"
|
||||
aria-labelledby="file-request-dialog-description"
|
||||
aria-live="polite"
|
||||
data-cy-file-request-dialog-form
|
||||
@submit.prevent.stop="">
|
||||
<FileRequestIntro v-show="currentStep === STEP.FIRST"
|
||||
|
|
@ -33,8 +34,8 @@
|
|||
:note.sync="note" />
|
||||
|
||||
<FileRequestDatePassword v-show="currentStep === STEP.SECOND"
|
||||
:deadline.sync="deadline"
|
||||
:disabled="loading"
|
||||
:expiration-date.sync="expirationDate"
|
||||
:password.sync="password" />
|
||||
|
||||
<FileRequestFinish v-if="share"
|
||||
|
|
@ -124,9 +125,9 @@ import NcNoteCard from '@nextcloud/vue/dist/Components/NcNoteCard.js'
|
|||
import IconCheck from 'vue-material-design-icons/Check.vue'
|
||||
import IconNext from 'vue-material-design-icons/ArrowRight.vue'
|
||||
|
||||
import FileRequestDatePassword from './NewFileRequestDialog/FileRequestDatePassword.vue'
|
||||
import FileRequestFinish from './NewFileRequestDialog/FileRequestFinish.vue'
|
||||
import FileRequestIntro from './NewFileRequestDialog/FileRequestIntro.vue'
|
||||
import FileRequestDatePassword from './NewFileRequestDialog/NewFileRequestDialogDatePassword.vue'
|
||||
import FileRequestFinish from './NewFileRequestDialog/NewFileRequestDialogFinish.vue'
|
||||
import FileRequestIntro from './NewFileRequestDialog/NewFileRequestDialogIntro.vue'
|
||||
import Share from '../models/Share'
|
||||
import logger from '../services/logger'
|
||||
|
||||
|
|
@ -182,7 +183,7 @@ export default defineComponent({
|
|||
label: '',
|
||||
note: '',
|
||||
|
||||
deadline: null as Date | null,
|
||||
expirationDate: null as Date | null,
|
||||
password: null as string | null,
|
||||
|
||||
share: null as Share | null,
|
||||
|
|
@ -249,7 +250,7 @@ export default defineComponent({
|
|||
this.loading = true
|
||||
|
||||
// Format must be YYYY-MM-DD
|
||||
const expireDate = this.deadline ? this.deadline.toISOString().split('T')[0] : undefined
|
||||
const expireDate = this.expirationDate ? this.expirationDate.toISOString().split('T')[0] : undefined
|
||||
const shareUrl = generateOcsUrl('apps/files_sharing/api/v1/shares')
|
||||
try {
|
||||
const request = await axios.post<OCSResponse>(shareUrl, {
|
||||
|
|
|
|||
|
|
@ -19,25 +19,25 @@
|
|||
<!-- Enable expiration -->
|
||||
<legend>{{ t('files_sharing', 'When should the request expire ?') }}</legend>
|
||||
<NcCheckboxRadioSwitch v-show="!defaultExpireDateEnforced"
|
||||
:checked="defaultExpireDateEnforced || deadline !== null"
|
||||
:checked="defaultExpireDateEnforced || expirationDate !== null"
|
||||
:disabled="disabled || defaultExpireDateEnforced"
|
||||
@update:checked="onToggleDeadline">
|
||||
{{ t('files_sharing', 'Set a submission deadline') }}
|
||||
{{ t('files_sharing', 'Set a submission expirationDate') }}
|
||||
</NcCheckboxRadioSwitch>
|
||||
|
||||
<!-- Date picker -->
|
||||
<NcDateTimePickerNative v-if="deadline !== null"
|
||||
id="file-request-dialog-deadline"
|
||||
<NcDateTimePickerNative v-if="expirationDate !== null"
|
||||
id="file-request-dialog-expirationDate"
|
||||
:disabled="disabled"
|
||||
:hide-label="true"
|
||||
:max="maxDate"
|
||||
:min="minDate"
|
||||
:placeholder="t('files_sharing', 'Select a date')"
|
||||
:required="defaultExpireDateEnforced"
|
||||
:value="deadline"
|
||||
name="deadline"
|
||||
:value="expirationDate"
|
||||
name="expirationDate"
|
||||
type="date"
|
||||
@update:value="$emit('update:deadline', $event)"/>
|
||||
@update:value="$emit('update:expirationDate', $event)"/>
|
||||
</fieldset>
|
||||
|
||||
<!-- Password -->
|
||||
|
|
@ -113,7 +113,7 @@ export default defineComponent({
|
|||
required: false,
|
||||
default: false,
|
||||
},
|
||||
deadline: {
|
||||
expirationDate: {
|
||||
type: Date as PropType<Date | null>,
|
||||
required: false,
|
||||
default: null,
|
||||
|
|
@ -126,7 +126,7 @@ export default defineComponent({
|
|||
},
|
||||
|
||||
emits: [
|
||||
'update:deadline',
|
||||
'update:expirationDate',
|
||||
'update:password',
|
||||
],
|
||||
|
||||
|
|
@ -157,15 +157,15 @@ export default defineComponent({
|
|||
|
||||
computed: {
|
||||
passwordAndExpirationSummary(): string {
|
||||
if (this.deadline && this.password) {
|
||||
if (this.expirationDate && this.password) {
|
||||
return this.t('files_sharing', 'The request will expire on {date} at midnight and will be password protected.', {
|
||||
date: this.deadline.toLocaleDateString(),
|
||||
date: this.expirationDate.toLocaleDateString(),
|
||||
})
|
||||
}
|
||||
|
||||
if (this.deadline) {
|
||||
if (this.expirationDate) {
|
||||
return this.t('files_sharing', 'The request will expire on {date} at midnight.', {
|
||||
date: this.deadline.toLocaleDateString(),
|
||||
date: this.expirationDate.toLocaleDateString(),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -180,7 +180,7 @@ export default defineComponent({
|
|||
mounted() {
|
||||
// If defined, we set the default expiration date
|
||||
if (this.defaultExpireDate) {
|
||||
this.$emit('update:deadline', sharingConfig.defaultExpirationDate)
|
||||
this.$emit('update:expirationDate', sharingConfig.defaultExpirationDate)
|
||||
}
|
||||
|
||||
// If enforced, we cannot set a date before the default expiration days (see admin settings)
|
||||
|
|
@ -196,7 +196,7 @@ export default defineComponent({
|
|||
|
||||
methods: {
|
||||
onToggleDeadline(checked: boolean) {
|
||||
this.$emit('update:deadline', checked ? new Date() : null)
|
||||
this.$emit('update:expirationDate', checked ? new Date() : null)
|
||||
},
|
||||
|
||||
async onTogglePassword(checked: boolean) {
|
||||
|
|
@ -124,9 +124,14 @@ export default defineComponent({
|
|||
|
||||
methods: {
|
||||
async copyShareLink(event: MouseEvent) {
|
||||
if (this.isCopied) {
|
||||
this.isCopied = false
|
||||
return
|
||||
}
|
||||
|
||||
if (!navigator.clipboard) {
|
||||
// Clipboard API not available
|
||||
showError(this.t('files_sharing', 'Clipboard is not available'))
|
||||
window.prompt(this.t('files_sharing', 'Automatically copying failed, please copy the share link manually'), this.shareLink)
|
||||
return
|
||||
}
|
||||
|
||||
Loading…
Reference in a new issue