summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2024-02-27 15:09:21 +0100
committerGitHub <noreply@github.com>2024-02-27 15:09:21 +0100
commit455a209b9c4f3b95a016ce1c0bcd1bcfa3fc86bf (patch)
tree14d91dbc09bc1d25b5a10c2d857bdb7d7f098897 /apps
parent250084f8b913e326e20ccc60c86091beab0a6524 (diff)
parentf7a0246290c0b4fd73fa11017004066f037d21f6 (diff)
downloadnextcloud-server-455a209b9c4f3b95a016ce1c0bcd1bcfa3fc86bf.tar.gz
nextcloud-server-455a209b9c4f3b95a016ce1c0bcd1bcfa3fc86bf.zip
Merge pull request #43768 from nextcloud/artonge/tests/add_tests_for_versions_actions
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/lib/Server.php10
-rw-r--r--apps/files_sharing/src/components/SharePermissionsEditor.vue290
-rw-r--r--apps/files_sharing/src/components/SharingEntry.vue1
-rw-r--r--apps/files_sharing/src/views/SharingDetailsTab.vue35
-rw-r--r--apps/files_versions/src/components/Version.vue13
5 files changed, 44 insertions, 305 deletions
diff --git a/apps/dav/lib/Server.php b/apps/dav/lib/Server.php
index 2bff8e7ebd6..3c7e0936735 100644
--- a/apps/dav/lib/Server.php
+++ b/apps/dav/lib/Server.php
@@ -241,11 +241,6 @@ class Server {
$this->server->addPlugin(new FakeLockerPlugin());
}
- // Allow view-only plugin for webdav requests
- $this->server->addPlugin(new ViewOnlyPlugin(
- \OC::$server->getUserFolder(),
- ));
-
if (BrowserErrorPagePlugin::isBrowserRequest($request)) {
$this->server->addPlugin(new BrowserErrorPagePlugin());
}
@@ -255,6 +250,11 @@ class Server {
// wait with registering these until auth is handled and the filesystem is setup
$this->server->on('beforeMethod:*', function () use ($root, $lazySearchBackend, $logger) {
+ // Allow view-only plugin for webdav requests
+ $this->server->addPlugin(new ViewOnlyPlugin(
+ \OC::$server->getUserFolder(),
+ ));
+
// custom properties plugin must be the last one
$userSession = \OC::$server->getUserSession();
$user = $userSession->getUser();
diff --git a/apps/files_sharing/src/components/SharePermissionsEditor.vue b/apps/files_sharing/src/components/SharePermissionsEditor.vue
deleted file mode 100644
index cc1a150ecc1..00000000000
--- a/apps/files_sharing/src/components/SharePermissionsEditor.vue
+++ /dev/null
@@ -1,290 +0,0 @@
-<!--
- - @copyright Copyright (c) 2022 Louis Chmn <louis@chmn.me>
- -
- - @author Louis Chmn <louis@chmn.me>
- -
- - @license GNU AGPL version 3 or any later version
- -
- - 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/>.
- -
- -->
-
-<template>
- <li>
- <ul>
- <!-- file -->
- <NcActionCheckbox v-if="!isFolder"
- :checked="shareHasPermissions(atomicPermissions.UPDATE)"
- @update:checked="toggleSharePermissions(atomicPermissions.UPDATE)">
- {{ t('files_sharing', 'Allow editing') }}
- </NcActionCheckbox>
-
- <!-- folder -->
- <template v-if="isFolder && fileHasCreatePermission && config.isPublicUploadEnabled">
- <template v-if="!showCustomPermissionsForm">
- <NcActionRadio :checked="sharePermissionEqual(bundledPermissions.READ_ONLY)"
- :value="bundledPermissions.READ_ONLY"
- :name="randomFormName"
- @change="setSharePermissions(bundledPermissions.READ_ONLY)">
- {{ t('files_sharing', 'Read only') }}
- </NcActionRadio>
-
- <NcActionRadio :checked="sharePermissionEqual(bundledPermissions.UPLOAD_AND_UPDATE)"
- :value="bundledPermissions.UPLOAD_AND_UPDATE"
- :name="randomFormName"
- @change="setSharePermissions(bundledPermissions.UPLOAD_AND_UPDATE)">
- {{ t('files_sharing', 'Allow upload and editing') }}
- </NcActionRadio>
- <NcActionRadio :checked="sharePermissionEqual(bundledPermissions.FILE_DROP)"
- :value="bundledPermissions.FILE_DROP"
- :name="randomFormName"
- class="sharing-entry__action--public-upload"
- @change="setSharePermissions(bundledPermissions.FILE_DROP)">
- {{ t('files_sharing', 'File drop (upload only)') }}
- </NcActionRadio>
-
- <!-- custom permissions button -->
- <NcActionButton :title="t('files_sharing', 'Custom permissions')"
- @click="showCustomPermissionsForm = true">
- <template #icon>
- <Tune />
- </template>
- {{ sharePermissionsIsBundle ? "" : sharePermissionsSummary }}
- </NcActionButton>
- </template>
-
- <!-- custom permissions -->
- <span v-else :class="{error: !sharePermissionsSetIsValid}">
- <NcActionCheckbox :checked="shareHasPermissions(atomicPermissions.READ)"
- :disabled="!canToggleSharePermissions(atomicPermissions.READ)"
- @update:checked="toggleSharePermissions(atomicPermissions.READ)">
- {{ t('files_sharing', 'Read') }}
- </NcActionCheckbox>
- <NcActionCheckbox :checked="shareHasPermissions(atomicPermissions.CREATE)"
- :disabled="!canToggleSharePermissions(atomicPermissions.CREATE)"
- @update:checked="toggleSharePermissions(atomicPermissions.CREATE)">
- {{ t('files_sharing', 'Upload') }}
- </NcActionCheckbox>
- <NcActionCheckbox :checked="shareHasPermissions(atomicPermissions.UPDATE)"
- :disabled="!canToggleSharePermissions(atomicPermissions.UPDATE)"
- @update:checked="toggleSharePermissions(atomicPermissions.UPDATE)">
- {{ t('files_sharing', 'Edit') }}
- </NcActionCheckbox>
- <NcActionCheckbox :checked="shareHasPermissions(atomicPermissions.DELETE)"
- :disabled="!canToggleSharePermissions(atomicPermissions.DELETE)"
- @update:checked="toggleSharePermissions(atomicPermissions.DELETE)">
- {{ t('files_sharing', 'Delete') }}
- </NcActionCheckbox>
-
- <NcActionButton @click="showCustomPermissionsForm = false">
- <template #icon>
- <ChevronLeft />
- </template>
- {{ t('files_sharing', 'Bundled permissions') }}
- </NcActionButton>
- </span>
- </template>
- </ul>
- </li>
-</template>
-
-<script>
-import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
-import NcActionRadio from '@nextcloud/vue/dist/Components/NcActionRadio.js'
-import NcActionCheckbox from '@nextcloud/vue/dist/Components/NcActionCheckbox.js'
-
-import SharesMixin from '../mixins/SharesMixin.js'
-import {
- ATOMIC_PERMISSIONS,
- BUNDLED_PERMISSIONS,
- hasPermissions,
- permissionsSetIsValid,
- togglePermissions,
- canTogglePermissions,
-} from '../lib/SharePermissionsToolBox.js'
-
-import Tune from 'vue-material-design-icons/Tune.vue'
-import ChevronLeft from 'vue-material-design-icons/ChevronLeft.vue'
-
-export default {
- name: 'SharePermissionsEditor',
-
- components: {
- NcActionButton,
- NcActionCheckbox,
- NcActionRadio,
- Tune,
- ChevronLeft,
- },
-
- mixins: [SharesMixin],
-
- data() {
- return {
- randomFormName: Math.random().toString(27).substring(2),
-
- showCustomPermissionsForm: false,
-
- atomicPermissions: ATOMIC_PERMISSIONS,
- bundledPermissions: BUNDLED_PERMISSIONS,
- }
- },
-
- computed: {
- /**
- * Return the summary of custom checked permissions.
- *
- * @return {string}
- */
- sharePermissionsSummary() {
- return Object.values(this.atomicPermissions)
- .filter(permission => this.shareHasPermissions(permission))
- .map(permission => {
- switch (permission) {
- case this.atomicPermissions.CREATE:
- return this.t('files_sharing', 'Upload')
- case this.atomicPermissions.READ:
- return this.t('files_sharing', 'Read')
- case this.atomicPermissions.UPDATE:
- return this.t('files_sharing', 'Edit')
- case this.atomicPermissions.DELETE:
- return this.t('files_sharing', 'Delete')
- default:
- return null
- }
- })
- .filter(permissionLabel => permissionLabel !== null)
- .join(', ')
- },
-
- /**
- * Return whether the share's permission is a bundle.
- *
- * @return {boolean}
- */
- sharePermissionsIsBundle() {
- return Object.values(BUNDLED_PERMISSIONS)
- .map(bundle => this.sharePermissionEqual(bundle))
- .filter(isBundle => isBundle)
- .length > 0
- },
-
- /**
- * Return whether the share's permission is valid.
- *
- * @return {boolean}
- */
- sharePermissionsSetIsValid() {
- return permissionsSetIsValid(this.share.permissions)
- },
-
- /**
- * Is the current share a folder ?
- * TODO: move to a proper FileInfo model?
- *
- * @return {boolean}
- */
- isFolder() {
- return this.fileInfo.type === 'dir'
- },
-
- /**
- * Does the current file/folder have create permissions.
- * TODO: move to a proper FileInfo model?
- *
- * @return {boolean}
- */
- fileHasCreatePermission() {
- return !!(this.fileInfo.permissions & ATOMIC_PERMISSIONS.CREATE)
- },
- },
-
- mounted() {
- // Show the Custom Permissions view on open if the permissions set is not a bundle.
- this.showCustomPermissionsForm = !this.sharePermissionsIsBundle
- },
-
- methods: {
- /**
- * Return whether the share has the exact given permissions.
- *
- * @param {number} permissions - the permissions to check.
- *
- * @return {boolean}
- */
- sharePermissionEqual(permissions) {
- // We use the share's permission without PERMISSION_SHARE as it is not relevant here.
- return (this.share.permissions & ~ATOMIC_PERMISSIONS.SHARE) === permissions
- },
-
- /**
- * Return whether the share has the given permissions.
- *
- * @param {number} permissions - the permissions to check.
- *
- * @return {boolean}
- */
- shareHasPermissions(permissions) {
- return hasPermissions(this.share.permissions, permissions)
- },
-
- /**
- * Set the share permissions to the given permissions.
- *
- * @param {number} permissions - the permissions to set.
- *
- * @return {void}
- */
- setSharePermissions(permissions) {
- this.share.permissions = permissions
- this.queueUpdate('permissions')
- },
-
- /**
- * Return whether some given permissions can be toggled.
- *
- * @param {number} permissionsToToggle - the permissions to toggle.
- *
- * @return {boolean}
- */
- canToggleSharePermissions(permissionsToToggle) {
- return canTogglePermissions(this.share.permissions, permissionsToToggle)
- },
-
- /**
- * Toggle a given permission.
- *
- * @param {number} permissions - the permissions to toggle.
- *
- * @return {void}
- */
- toggleSharePermissions(permissions) {
- this.share.permissions = togglePermissions(this.share.permissions, permissions)
-
- if (!permissionsSetIsValid(this.share.permissions)) {
- return
- }
-
- this.queueUpdate('permissions')
- },
- },
-}
-</script>
-<style lang="scss" scoped>
-.error {
- ::v-deep .action-checkbox__label:before {
- border: 1px solid var(--color-error);
- }
-}
-</style>
diff --git a/apps/files_sharing/src/components/SharingEntry.vue b/apps/files_sharing/src/components/SharingEntry.vue
index 74bff87560a..6417ef0b6ea 100644
--- a/apps/files_sharing/src/components/SharingEntry.vue
+++ b/apps/files_sharing/src/components/SharingEntry.vue
@@ -46,6 +46,7 @@
@open-sharing-details="openShareDetailsForCustomSettings(share)" />
</div>
<NcButton class="sharing-entry__action"
+ data-cy-files-sharing-share-actions
:aria-label="t('files_sharing', 'Open Sharing Details')"
type="tertiary"
@click="openSharingDetails(share)">
diff --git a/apps/files_sharing/src/views/SharingDetailsTab.vue b/apps/files_sharing/src/views/SharingDetailsTab.vue
index 4681e59391d..83e3dc3706f 100644
--- a/apps/files_sharing/src/views/SharingDetailsTab.vue
+++ b/apps/files_sharing/src/views/SharingDetailsTab.vue
@@ -19,6 +19,7 @@
<div ref="quickPermissions" class="sharingTabDetailsView__quick-permissions">
<div>
<NcCheckboxRadioSwitch :button-variant="true"
+ data-cy-files-sharing-share-permissions-bundle="read-only"
:checked.sync="sharingPermission"
:value="bundledPermissions.READ_ONLY.toString()"
name="sharing_permission_radio"
@@ -31,6 +32,7 @@
</template>
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch :button-variant="true"
+ data-cy-files-sharing-share-permissions-bundle="upload-edit"
:checked.sync="sharingPermission"
:value="bundledPermissions.ALL.toString()"
name="sharing_permission_radio"
@@ -48,6 +50,7 @@
</template>
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch v-if="allowsFileDrop"
+ data-cy-files-sharing-share-permissions-bundle="file-drop"
:button-variant="true"
:checked.sync="sharingPermission"
:value="bundledPermissions.FILE_DROP.toString()"
@@ -62,6 +65,7 @@
</template>
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch :button-variant="true"
+ data-cy-files-sharing-share-permissions-bundle="custom"
:checked.sync="sharingPermission"
:value="'custom'"
name="sharing_permission_radio"
@@ -145,7 +149,10 @@
@update:checked="queueUpdate('hideDownload')">
{{ t('files_sharing', 'Hide download') }}
</NcCheckboxRadioSwitch>
- <NcCheckboxRadioSwitch v-if="!isPublicShare" :disabled="!canSetDownload" :checked.sync="canDownload">
+ <NcCheckboxRadioSwitch v-if="!isPublicShare"
+ :disabled="!canSetDownload"
+ :checked.sync="canDownload"
+ data-cy-files-sharing-share-permissions-checkbox="download">
{{ t('files_sharing', 'Allow download') }}
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch :checked.sync="writeNoteToRecipientIsChecked">
@@ -162,21 +169,30 @@
</NcCheckboxRadioSwitch>
<section v-if="setCustomPermissions" class="custom-permissions-group">
<NcCheckboxRadioSwitch :disabled="!allowsFileDrop && share.type === SHARE_TYPES.SHARE_TYPE_LINK"
- :checked.sync="hasRead">
+ :checked.sync="hasRead"
+ data-cy-files-sharing-share-permissions-checkbox="read">
{{ t('files_sharing', 'Read') }}
</NcCheckboxRadioSwitch>
- <NcCheckboxRadioSwitch v-if="isFolder" :disabled="!canSetCreate" :checked.sync="canCreate">
+ <NcCheckboxRadioSwitch v-if="isFolder"
+ :disabled="!canSetCreate"
+ :checked.sync="canCreate"
+ data-cy-files-sharing-share-permissions-checkbox="create">
{{ t('files_sharing', 'Create') }}
</NcCheckboxRadioSwitch>
- <NcCheckboxRadioSwitch :disabled="!canSetEdit" :checked.sync="canEdit">
+ <NcCheckboxRadioSwitch :disabled="!canSetEdit"
+ :checked.sync="canEdit"
+ data-cy-files-sharing-share-permissions-checkbox="update">
{{ t('files_sharing', 'Edit') }}
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch v-if="config.isResharingAllowed && share.type !== SHARE_TYPES.SHARE_TYPE_LINK"
:disabled="!canSetReshare"
- :checked.sync="canReshare">
+ :checked.sync="canReshare"
+ data-cy-files-sharing-share-permissions-checkbox="share">
{{ t('files_sharing', 'Share') }}
</NcCheckboxRadioSwitch>
- <NcCheckboxRadioSwitch :disabled="!canSetDelete" :checked.sync="canDelete">
+ <NcCheckboxRadioSwitch :disabled="!canSetDelete"
+ :checked.sync="canDelete"
+ data-cy-files-sharing-share-permissions-checkbox="delete">
{{ t('files_sharing', 'Delete') }}
</NcCheckboxRadioSwitch>
</section>
@@ -199,10 +215,13 @@
<div class="sharingTabDetailsView__footer">
<div class="button-group">
- <NcButton @click="$emit('close-sharing-details')">
+ <NcButton data-cy-files-sharing-share-editor-action="cancel"
+ @click="$emit('close-sharing-details')">
{{ t('files_sharing', 'Cancel') }}
</NcButton>
- <NcButton type="primary" @click="saveShare">
+ <NcButton type="primary"
+ data-cy-files-sharing-share-editor-action="save"
+ @click="saveShare">
{{ shareButtonText }}
<template v-if="creating" #icon>
<NcLoadingIcon />
diff --git a/apps/files_versions/src/components/Version.vue b/apps/files_versions/src/components/Version.vue
index 690ef7d5f78..694d10e1032 100644
--- a/apps/files_versions/src/components/Version.vue
+++ b/apps/files_versions/src/components/Version.vue
@@ -19,7 +19,7 @@
<NcListItem class="version"
:name="versionLabel"
:force-display-actions="true"
- data-files-versions-version
+ :data-files-versions-version="version.fileVersion"
@click="click">
<!-- Icon -->
<template #icon>
@@ -52,6 +52,7 @@
<!-- Actions -->
<template #actions>
<NcActionButton v-if="enableLabeling && hasUpdatePermissions"
+ data-cy-files-versions-version-action="label"
:close-after-click="true"
@click="labelUpdate">
<template #icon>
@@ -60,6 +61,7 @@
{{ version.label === '' ? t('files_versions', 'Name this version') : t('files_versions', 'Edit version name') }}
</NcActionButton>
<NcActionButton v-if="!isCurrent && canView && canCompare"
+ data-cy-files-versions-version-action="compare"
:close-after-click="true"
@click="compareVersion">
<template #icon>
@@ -68,6 +70,7 @@
{{ t('files_versions', 'Compare to current version') }}
</NcActionButton>
<NcActionButton v-if="!isCurrent && hasUpdatePermissions"
+ data-cy-files-versions-version-action="restore"
:close-after-click="true"
@click="restoreVersion">
<template #icon>
@@ -76,6 +79,7 @@
{{ t('files_versions', 'Restore version') }}
</NcActionButton>
<NcActionLink v-if="isDownloadable"
+ data-cy-files-versions-version-action="download"
:href="downloadURL"
:close-after-click="true"
:download="downloadURL">
@@ -85,6 +89,7 @@
{{ t('files_versions', 'Download version') }}
</NcActionLink>
<NcActionButton v-if="!isCurrent && enableDeletion && hasDeletePermissions"
+ data-cy-files-versions-version-action="delete"
:close-after-click="true"
@click="deleteVersion">
<template #icon>
@@ -266,7 +271,11 @@ export default defineComponent({
this.$emit('restore', this.version)
},
- deleteVersion() {
+ async deleteVersion() {
+ // Let @nc-vue properly remove the popover before we delete the version.
+ // This prevents @nc-vue from throwing a error.
+ await this.$nextTick()
+ await this.$nextTick()
this.$emit('delete', this.version)
},