From cfa2caacf1d78e1cba261f9b44ae5ccf98860edf Mon Sep 17 00:00:00 2001 From: skjnldsv Date: Fri, 19 Jul 2024 12:01:55 +0200 Subject: [PATCH 1/3] fix(files_sharing): default empty file request expiration Signed-off-by: skjnldsv --- .../src/components/NewFileRequestDialog.vue | 22 ++++++++----------- .../NewFileRequestDialogDatePassword.vue | 2 +- .../NewFileRequestDialogFinish.vue | 2 ++ apps/files_sharing/src/new/newFileRequest.ts | 4 +++- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/apps/files_sharing/src/components/NewFileRequestDialog.vue b/apps/files_sharing/src/components/NewFileRequestDialog.vue index 6b0bb5a1fc2..bdcaf1d90bf 100644 --- a/apps/files_sharing/src/components/NewFileRequestDialog.vue +++ b/apps/files_sharing/src/components/NewFileRequestDialog.vue @@ -270,19 +270,15 @@ export default defineComponent({ async createShare() { this.loading = true - // This should never happen™ - if (this.expirationDate == null) { - throw new Error('Expiration date is missing') + let expireDate = '' + if (this.expirationDate) { + const year = this.expirationDate.getFullYear() + const month = (this.expirationDate.getMonth() + 1).toString().padStart(2, '0') + const day = this.expirationDate.getDate().toString().padStart(2, '0') + + // Format must be YYYY-MM-DD + expireDate = `${year}-${month}-${day}` } - - const year = this.expirationDate.getFullYear() - const month = (this.expirationDate.getMonth() + 1).toString().padStart(2, '0') - const day = this.expirationDate.getDate().toString().padStart(2, '0') - - // Format must be YYYY-MM-DD - const expireDate = this.expirationDate - ? `${year}-${month}-${day}` - : undefined const shareUrl = generateOcsUrl('apps/files_sharing/api/v1/shares') try { const request = await axios.post(shareUrl, { @@ -296,7 +292,7 @@ export default defineComponent({ note: this.note, password: this.password || undefined, - expireDate, + expireDate: expireDate || undefined, // Empty string shareWith: '', diff --git a/apps/files_sharing/src/components/NewFileRequestDialog/NewFileRequestDialogDatePassword.vue b/apps/files_sharing/src/components/NewFileRequestDialog/NewFileRequestDialogDatePassword.vue index 0eb89388122..091679ae5c4 100644 --- a/apps/files_sharing/src/components/NewFileRequestDialog/NewFileRequestDialogDatePassword.vue +++ b/apps/files_sharing/src/components/NewFileRequestDialog/NewFileRequestDialogDatePassword.vue @@ -201,7 +201,7 @@ export default defineComponent({ methods: { onToggleDeadline(checked: boolean) { - this.$emit('update:expirationDate', checked ? new Date() : null) + this.$emit('update:expirationDate', checked ? (this.maxDate || this.minDate) : null) }, async onTogglePassword(checked: boolean) { diff --git a/apps/files_sharing/src/components/NewFileRequestDialog/NewFileRequestDialogFinish.vue b/apps/files_sharing/src/components/NewFileRequestDialog/NewFileRequestDialogFinish.vue index e626cb31751..dae1739d308 100644 --- a/apps/files_sharing/src/components/NewFileRequestDialog/NewFileRequestDialogFinish.vue +++ b/apps/files_sharing/src/components/NewFileRequestDialog/NewFileRequestDialogFinish.vue @@ -17,6 +17,7 @@ :readonly="true" :show-trailing-button="true" :trailing-button-label="t('files_sharing', 'Copy to clipboard')" + data-cy-file-request-dialog-fieldset="link" @click="copyShareLink" @trailing-button-click="copyShareLink">