From 6b1cb41c253fd28db65a1c6151d2f6f01ecda463 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Fri, 2 Dec 2022 21:25:24 -0800 Subject: [PATCH] share: hide download button if needed (fix #273) --- lib/Controller/PublicController.php | 3 +++ src/components/SelectionManager.vue | 6 ++++++ src/components/Viewer.vue | 3 ++- src/mixins/GlobalMixin.ts | 4 ++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/Controller/PublicController.php b/lib/Controller/PublicController.php index 4fe47bee..a4355458 100644 --- a/lib/Controller/PublicController.php +++ b/lib/Controller/PublicController.php @@ -109,6 +109,9 @@ class PublicController extends AuthPublicShareController // Video configuration $this->initialState->provideInitialState('notranscode', $this->config->getSystemValue('memories.no_transcode', 'UNSET')); + // Share info + $this->initialState->provideInitialState('no_download', $share->getHideDownload()); + $policy = new ContentSecurityPolicy(); $policy->addAllowedWorkerSrcDomain("'self'"); $policy->addAllowedScriptDomain("'self'"); diff --git a/src/components/SelectionManager.vue b/src/components/SelectionManager.vue index 05c513c3..f9bd1241 100644 --- a/src/components/SelectionManager.vue +++ b/src/components/SelectionManager.vue @@ -157,6 +157,7 @@ export default class SelectionManager extends Mixins(GlobalMixin, UserConfig) { icon: DownloadIcon, callback: this.downloadSelection.bind(this), allowPublic: true, + if: () => !this.allowDownload(), }, { name: t("memories", "Favorite"), @@ -216,6 +217,11 @@ export default class SelectionManager extends Mixins(GlobalMixin, UserConfig) { }; } + /** Download is not allowed on some public shares */ + private allowDownload(): boolean { + return this.state_noDownload; + } + /** Archive is not allowed only on folder routes */ private allowArchive() { return this.$route.name !== "folders"; diff --git a/src/components/Viewer.vue b/src/components/Viewer.vue index 93521d5e..13e24c2c 100644 --- a/src/components/Viewer.vue +++ b/src/components/Viewer.vue @@ -82,6 +82,7 @@ :aria-label="t('memories', 'Download')" @click="downloadCurrent" :close-after-click="true" + v-if="!this.state_noDownload" > {{ t("memories", "Download") }}