share: hide download button if needed (fix #273)

cap
Varun Patil 2022-12-02 21:25:24 -08:00
parent 0e17ef69a9
commit 6b1cb41c25
4 changed files with 15 additions and 1 deletions

View File

@ -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'");

View File

@ -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";

View File

@ -82,6 +82,7 @@
:aria-label="t('memories', 'Download')"
@click="downloadCurrent"
:close-after-click="true"
v-if="!this.state_noDownload"
>
{{ t("memories", "Download") }}
<template #icon>
@ -89,7 +90,7 @@
</template>
</NcActionButton>
<NcActionButton
v-if="currentPhoto?.liveid"
v-if="!this.state_noDownload && currentPhoto?.liveid"
:aria-label="t('memories', 'Download Video')"
@click="downloadCurrentLiveVideo"
:close-after-click="true"

View File

@ -1,6 +1,7 @@
import { Component, Vue } from "vue-property-decorator";
import { translate as t, translatePlural as n } from "@nextcloud/l10n";
import { constants } from "../services/Utils";
import { loadState } from "@nextcloud/initial-state";
@Component
export default class GlobalMixin extends Vue {
@ -10,4 +11,7 @@ export default class GlobalMixin extends Vue {
public readonly c = constants.c;
public readonly TagDayID = constants.TagDayID;
public readonly TagDayIDValueSet = constants.TagDayIDValueSet;
public readonly state_noDownload =
loadState("memories", "no_download", false) !== false;
}