diff options
author | Louis Chemineau <louis@chmn.me> | 2024-02-21 16:47:19 +0100 |
---|---|---|
committer | Louis Chemineau <louis@chmn.me> | 2024-02-21 16:47:19 +0100 |
commit | 18b32e892c58c37872d683199575ad4e41b8edaf (patch) | |
tree | 0d189134aa6c94089dedcd5f5fbbafb61138a145 /apps/files_versions/src | |
parent | 046b8f320f2ce1c37f658130ec84071218262deb (diff) | |
download | nextcloud-server-18b32e892c58c37872d683199575ad4e41b8edaf.tar.gz nextcloud-server-18b32e892c58c37872d683199575ad4e41b8edaf.zip |
Hide some actions based on node permissions and share attributes
Signed-off-by: Louis Chemineau <louis@chmn.me>
Diffstat (limited to 'apps/files_versions/src')
-rw-r--r-- | apps/files_versions/src/components/Version.vue | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/apps/files_versions/src/components/Version.vue b/apps/files_versions/src/components/Version.vue index a03e71bc5df..4a24891d49a 100644 --- a/apps/files_versions/src/components/Version.vue +++ b/apps/files_versions/src/components/Version.vue @@ -46,7 +46,7 @@ </div> </template> <template #actions> - <NcActionButton v-if="enableLabeling" + <NcActionButton v-if="enableLabeling && hasUpdatePermissions" :close-after-click="true" @click="labelUpdate"> <template #icon> @@ -62,7 +62,7 @@ </template> {{ t('files_versions', 'Compare to current version') }} </NcActionButton> - <NcActionButton v-if="!isCurrent" + <NcActionButton v-if="!isCurrent && hasUpdatePermissions" :close-after-click="true" @click="restoreVersion"> <template #icon> @@ -70,7 +70,8 @@ </template> {{ t('files_versions', 'Restore version') }} </NcActionButton> - <NcActionLink :href="downloadURL" + <NcActionLink v-if="isDownloadable" + :href="downloadURL" :close-after-click="true" :download="downloadURL"> <template #icon> @@ -78,7 +79,7 @@ </template> {{ t('files_versions', 'Download version') }} </NcActionLink> - <NcActionButton v-if="!isCurrent && enableDeletion" + <NcActionButton v-if="!isCurrent && enableDeletion && hasDeletePermissions" :close-after-click="true" @click="deleteVersion"> <template #icon> @@ -106,6 +107,9 @@ import { translate as t } from '@nextcloud/l10n' import { joinPaths } from '@nextcloud/paths' import { getRootUrl } from '@nextcloud/router' import { loadState } from '@nextcloud/initial-state' +import { Permission } from '@nextcloud/files' + +import { hasPermissions } from '../../../files_sharing/src/lib/SharePermissionsToolBox.js' export default { name: 'Version', @@ -224,6 +228,33 @@ export default { enableDeletion() { return this.capabilities.files.version_deletion === true }, + + /** @return {boolean} */ + hasDeletePermissions() { + return hasPermissions(this.fileInfo.permissions, Permission.DELETE) + }, + + /** @return {boolean} */ + hasUpdatePermissions() { + return hasPermissions(this.fileInfo.permissions, Permission.UPDATE) + }, + + /** @return {boolean} */ + isDownloadable() { + if ((this.fileInfo.permissions & Permission.READ) === 0) { + return false + } + + // If the mount type is a share, ensure it got download permissions. + if (this.fileInfo.mountType === 'shared') { + const downloadAttribute = this.fileInfo.shareAttributes.find((attribute) => attribute.scope === 'permissions' && attribute.key === 'download') + if (downloadAttribute !== undefined && downloadAttribute.enabled === false) { + return false + } + } + + return true + }, }, methods: { labelUpdate() { |