Skip to content

Commit

Permalink
Hide some actions based on node permissions and share attributes
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <louis@chmn.me>

Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
  • Loading branch information
artonge authored and nextcloud-command committed Feb 21, 2024
1 parent a385d71 commit 7ad95b2
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
30 changes: 30 additions & 0 deletions apps/files_versions/src/components/Version.vue
Expand Up @@ -136,6 +136,9 @@ import { translate } 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',
Expand Down Expand Up @@ -260,6 +263,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: {
openVersionLabelModal() {
Expand Down

0 comments on commit 7ad95b2

Please sign in to comment.