From 7c4d10089a8dcb290176fa26c3830dcc456c54be Mon Sep 17 00:00:00 2001 From: Benedikt Kulmann Date: Wed, 27 Apr 2022 17:30:58 +0200 Subject: [PATCH] Make file actions available on share routes --- .../src/mixins/actions/createPublicLink.js | 1 - .../web-app-files/src/mixins/actions/delete.js | 1 + .../src/mixins/actions/downloadArchive.js | 1 + .../src/mixins/actions/downloadFile.js | 1 + .../src/mixins/actions/showShares.js | 1 - packages/web-app-files/src/quickActions.js | 17 ++++++++++++----- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/packages/web-app-files/src/mixins/actions/createPublicLink.js b/packages/web-app-files/src/mixins/actions/createPublicLink.js index 1d83a4653af..5bf9f1a4123 100644 --- a/packages/web-app-files/src/mixins/actions/createPublicLink.js +++ b/packages/web-app-files/src/mixins/actions/createPublicLink.js @@ -20,7 +20,6 @@ export default { if (resources[0].status !== ShareStatus.accepted) { return false } - // FIXME: also check via capabilities if resharing is enabled + resharing is allowed on the share } return canShare(resources[0], this.$store) }, diff --git a/packages/web-app-files/src/mixins/actions/delete.js b/packages/web-app-files/src/mixins/actions/delete.js index 1810a04bb47..d5cc965f432 100644 --- a/packages/web-app-files/src/mixins/actions/delete.js +++ b/packages/web-app-files/src/mixins/actions/delete.js @@ -18,6 +18,7 @@ export default { if ( !isLocationSpacesActive(this.$router, 'files-spaces-personal-home') && !isLocationSpacesActive(this.$router, 'files-spaces-project') && + !isLocationSpacesActive(this.$router, 'files-spaces-share') && !isLocationPublicActive(this.$router, 'files-public-files') ) { return false diff --git a/packages/web-app-files/src/mixins/actions/downloadArchive.js b/packages/web-app-files/src/mixins/actions/downloadArchive.js index 1daa426b140..800c5719ff4 100644 --- a/packages/web-app-files/src/mixins/actions/downloadArchive.js +++ b/packages/web-app-files/src/mixins/actions/downloadArchive.js @@ -25,6 +25,7 @@ export default { this.$_isFilesAppActive && !isLocationSpacesActive(this.$router, 'files-spaces-personal-home') && !isLocationSpacesActive(this.$router, 'files-spaces-project') && + !isLocationSpacesActive(this.$router, 'files-spaces-share') && !isLocationPublicActive(this.$router, 'files-public-files') && !isLocationCommonActive(this.$router, 'files-common-favorites') ) { diff --git a/packages/web-app-files/src/mixins/actions/downloadFile.js b/packages/web-app-files/src/mixins/actions/downloadFile.js index 24925867dfe..615128ed643 100644 --- a/packages/web-app-files/src/mixins/actions/downloadFile.js +++ b/packages/web-app-files/src/mixins/actions/downloadFile.js @@ -22,6 +22,7 @@ export default { this.$_isFilesAppActive && !isLocationSpacesActive(this.$router, 'files-spaces-personal-home') && !isLocationSpacesActive(this.$router, 'files-spaces-project') && + !isLocationSpacesActive(this.$router, 'files-spaces-share') && !isLocationPublicActive(this.$router, 'files-public-files') && !isLocationCommonActive(this.$router, 'files-common-favorites') ) { diff --git a/packages/web-app-files/src/mixins/actions/showShares.js b/packages/web-app-files/src/mixins/actions/showShares.js index 19b58b51982..ce567ea888a 100644 --- a/packages/web-app-files/src/mixins/actions/showShares.js +++ b/packages/web-app-files/src/mixins/actions/showShares.js @@ -33,7 +33,6 @@ export default { if (resources[0].status !== ShareStatus.accepted) { return false } - // FIXME: also check via capabilities if resharing is enabled + resharing is allowed on the share } return canShare(resources[0], this.$store) }, diff --git a/packages/web-app-files/src/quickActions.js b/packages/web-app-files/src/quickActions.js index c9fce52a031..33b07c3ecd3 100644 --- a/packages/web-app-files/src/quickActions.js +++ b/packages/web-app-files/src/quickActions.js @@ -55,11 +55,18 @@ export async function openSpaceMembersPanel(ctx) { } export function canShare(item, store) { - return ( - store.state.user.capabilities.files_sharing && - store.state.user.capabilities.files_sharing.api_enabled && - item.canShare() - ) + const { capabilities } = store.state.user + if ( + !capabilities.files_sharing || + !capabilities.files_sharing.api_enabled || + !capabilities.files_sharing.can_share + ) { + return false + } + if (item.isReceivedShare() && !capabilities.resharing) { + return false + } + return item.canShare() } export default {