From aafaa3951550347f47e53b44675cd66c77916535 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Fri, 15 Jul 2022 17:11:54 +0200 Subject: Multiple fixes - Fix tests - Use non deprecated event stuff - Add a bit of type hinting to the new stuff - More safe handling of instanceOfStorage (share might not be the first wrapper) - Fix resharing Signed-off-by: Carl Schwan --- apps/files_sharing/src/components/SharingEntry.vue | 33 +++++++++++++++++++++- .../src/components/SharingEntryLink.vue | 9 ++++-- 2 files changed, 39 insertions(+), 3 deletions(-) (limited to 'apps/files_sharing/src') diff --git a/apps/files_sharing/src/components/SharingEntry.vue b/apps/files_sharing/src/components/SharingEntry.vue index d8bf5bcccc9..ad4147f0c9b 100644 --- a/apps/files_sharing/src/components/SharingEntry.vue +++ b/apps/files_sharing/src/components/SharingEntry.vue @@ -80,8 +80,9 @@ - {{ t('files_sharing', 'Allow download') }} + {{ allowDownloadText }} @@ -407,6 +408,36 @@ export default { return (typeof this.share.status === 'object' && !Array.isArray(this.share.status)) }, + /** + * @return {string} + */ + allowDownloadText() { + if (this.isFolder) { + return t('files_sharing', 'Allow download of office files') + } else { + return t('files_sharing', 'Allow download') + } + }, + + /** + * @return {boolean} + */ + isSetDownloadButtonVisible() { + const allowedMimetypes = [ + // Office documents + 'application/msword', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'application/vnd.ms-powerpoint', + 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'application/vnd.ms-excel', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'application/vnd.oasis.opendocument.text', + 'application/vnd.oasis.opendocument.spreadsheet', + 'application/vnd.oasis.opendocument.presentation', + ] + + return this.isFolder || allowedMimetypes.includes(this.fileInfo.mimetype) + }, }, methods: { diff --git a/apps/files_sharing/src/components/SharingEntryLink.vue b/apps/files_sharing/src/components/SharingEntryLink.vue index d5acf64c202..2dc10de5484 100644 --- a/apps/files_sharing/src/components/SharingEntryLink.vue +++ b/apps/files_sharing/src/components/SharingEntryLink.vue @@ -158,7 +158,7 @@ {{ t('files_sharing', 'Hide download') }} @@ -606,6 +606,12 @@ export default { isPasswordPolicyEnabled() { return typeof this.config.passwordPolicy === 'object' }, + + canChangeHideDownload() { + const hasDisabledDownload = (shareAttribute) => shareAttribute.key === 'download' && shareAttribute.scope === 'permissions' && shareAttribute.enabled === false + + return this.fileInfo.shareAttributes.some(hasDisabledDownload) + }, }, methods: { @@ -867,7 +873,6 @@ export default { this.$emit('remove:share', this.share) }, }, - } -- cgit v1.2.3