Browse Source

Hide some actions based on node permissions and share attributes

Signed-off-by: Louis Chemineau <louis@chmn.me>

Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
tags/v28.0.3rc2
Louis Chemineau 4 months ago
parent
commit
986459e1e4

+ 35
- 4
apps/files_versions/src/components/Version.vue View File

</div> </div>
</template> </template>
<template #actions> <template #actions>
<NcActionButton v-if="enableLabeling"
<NcActionButton v-if="enableLabeling && hasUpdatePermissions"
:close-after-click="true" :close-after-click="true"
@click="labelUpdate"> @click="labelUpdate">
<template #icon> <template #icon>
</template> </template>
{{ t('files_versions', 'Compare to current version') }} {{ t('files_versions', 'Compare to current version') }}
</NcActionButton> </NcActionButton>
<NcActionButton v-if="!isCurrent"
<NcActionButton v-if="!isCurrent && hasUpdatePermissions"
:close-after-click="true" :close-after-click="true"
@click="restoreVersion"> @click="restoreVersion">
<template #icon> <template #icon>
</template> </template>
{{ t('files_versions', 'Restore version') }} {{ t('files_versions', 'Restore version') }}
</NcActionButton> </NcActionButton>
<NcActionLink :href="downloadURL"
<NcActionLink v-if="isDownloadable"
:href="downloadURL"
:close-after-click="true" :close-after-click="true"
:download="downloadURL"> :download="downloadURL">
<template #icon> <template #icon>
</template> </template>
{{ t('files_versions', 'Download version') }} {{ t('files_versions', 'Download version') }}
</NcActionLink> </NcActionLink>
<NcActionButton v-if="!isCurrent && enableDeletion"
<NcActionButton v-if="!isCurrent && enableDeletion && hasDeletePermissions"
:close-after-click="true" :close-after-click="true"
@click="deleteVersion"> @click="deleteVersion">
<template #icon> <template #icon>
import { joinPaths } from '@nextcloud/paths' import { joinPaths } from '@nextcloud/paths'
import { getRootUrl } from '@nextcloud/router' import { getRootUrl } from '@nextcloud/router'
import { loadState } from '@nextcloud/initial-state' import { loadState } from '@nextcloud/initial-state'
import { Permission } from '@nextcloud/files'

import { hasPermissions } from '../../../files_sharing/src/lib/SharePermissionsToolBox.js'


export default { export default {
name: 'Version', name: 'Version',
enableDeletion() { enableDeletion() {
return this.capabilities.files.version_deletion === true 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: { methods: {
labelUpdate() { labelUpdate() {

+ 2
- 2
dist/files_versions-files_versions.js
File diff suppressed because it is too large
View File


+ 22
- 0
dist/files_versions-files_versions.js.LICENSE.txt View File

* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */


/**
* @copyright 2022 Louis Chmn <louis@chmn.me>
*
* @author Louis Chmn <louis@chmn.me>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

/** /**
* @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com> * @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>
* *

+ 1
- 1
dist/files_versions-files_versions.js.map
File diff suppressed because it is too large
View File


Loading…
Cancel
Save