aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/src
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2019-10-24 15:51:56 +0200
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2019-10-29 13:20:08 +0100
commit2fd057513a4eafd1282128721fb6dbc443ffdeba (patch)
tree326066a72eb89e7d820baf96ad03dcb2e29ab5e5 /apps/files_sharing/src
parent3331cdd74abb89692c9d37ba503a9d36768ae7d9 (diff)
downloadnextcloud-server-2fd057513a4eafd1282128721fb6dbc443ffdeba.tar.gz
nextcloud-server-2fd057513a4eafd1282128721fb6dbc443ffdeba.zip
Fix current user edit/delete permissions
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files_sharing/src')
-rw-r--r--apps/files_sharing/src/components/SharingEntry.vue127
-rw-r--r--apps/files_sharing/src/components/SharingEntryLink.vue7
-rw-r--r--apps/files_sharing/src/models/Share.js25
3 files changed, 96 insertions, 63 deletions
diff --git a/apps/files_sharing/src/components/SharingEntry.vue b/apps/files_sharing/src/components/SharingEntry.vue
index 857b57adbd0..09d09d607fe 100644
--- a/apps/files_sharing/src/components/SharingEntry.vue
+++ b/apps/files_sharing/src/components/SharingEntry.vue
@@ -30,75 +30,80 @@
<h5>{{ title }}</h5>
</div>
<Actions menu-align="right" class="sharing-entry__actions">
- <!-- edit permission -->
- <ActionCheckbox
- ref="canEdit"
- :checked.sync="canEdit"
- :value="permissionsEdit"
- :disabled="saving">
- {{ t('files_sharing', 'Allow editing') }}
- </ActionCheckbox>
-
- <!-- reshare permission -->
- <ActionCheckbox
- ref="canReshare"
- :checked.sync="canReshare"
- :value="permissionsShare"
- :disabled="saving">
- {{ t('files_sharing', 'Can reshare') }}
- </ActionCheckbox>
-
- <!-- expiration date -->
- <ActionCheckbox :checked.sync="hasExpirationDate"
- :disabled="config.isDefaultExpireDateEnforced || saving"
- @uncheck="onExpirationDisable">
- {{ config.isDefaultExpireDateEnforced
- ? t('files_sharing', 'Expiration date enforced')
- : t('files_sharing', 'Set expiration date') }}
- </ActionCheckbox>
- <ActionInput v-if="hasExpirationDate"
- ref="expireDate"
- v-tooltip.auto="{
- content: errors.expireDate,
- show: errors.expireDate,
- trigger: 'manual'
- }"
- :class="{ error: errors.expireDate}"
- :disabled="saving"
- :first-day-of-week="firstDay"
- :lang="lang"
- :value="share.expireDate"
- icon="icon-calendar-dark"
- type="date"
- :not-before="dateTomorrow"
- :not-after="dateMaxEnforced"
- @update:value="onExpirationChange">
- {{ t('files_sharing', 'Enter a date') }}
- </ActionInput>
-
- <!-- note -->
- <template v-if="canHaveNote">
+ <template v-if="share.canEdit">
+ <!-- edit permission -->
<ActionCheckbox
- :checked.sync="hasNote"
- :disabled="saving"
- @uncheck="queueUpdate('note')">
- {{ t('files_sharing', 'Note to recipient') }}
+ ref="canEdit"
+ :checked.sync="canEdit"
+ :value="permissionsEdit"
+ :disabled="saving">
+ {{ t('files_sharing', 'Allow editing') }}
+ </ActionCheckbox>
+
+ <!-- reshare permission -->
+ <ActionCheckbox
+ ref="canReshare"
+ :checked.sync="canReshare"
+ :value="permissionsShare"
+ :disabled="saving">
+ {{ t('files_sharing', 'Can reshare') }}
+ </ActionCheckbox>
+
+ <!-- expiration date -->
+ <ActionCheckbox :checked.sync="hasExpirationDate"
+ :disabled="config.isDefaultExpireDateEnforced || saving"
+ @uncheck="onExpirationDisable">
+ {{ config.isDefaultExpireDateEnforced
+ ? t('files_sharing', 'Expiration date enforced')
+ : t('files_sharing', 'Set expiration date') }}
</ActionCheckbox>
- <ActionTextEditable v-if="hasNote"
- ref="note"
+ <ActionInput v-if="hasExpirationDate"
+ ref="expireDate"
v-tooltip.auto="{
- content: errors.note,
- show: errors.note,
+ content: errors.expireDate,
+ show: errors.expireDate,
trigger: 'manual'
}"
- :class="{ error: errors.note}"
+ :class="{ error: errors.expireDate}"
:disabled="saving"
- :value.sync="share.note"
- icon="icon-edit"
- @update:value="debounceQueueUpdate('note')" />
+ :first-day-of-week="firstDay"
+ :lang="lang"
+ :value="share.expireDate"
+ icon="icon-calendar-dark"
+ type="date"
+ :not-before="dateTomorrow"
+ :not-after="dateMaxEnforced"
+ @update:value="onExpirationChange">
+ {{ t('files_sharing', 'Enter a date') }}
+ </ActionInput>
+
+ <!-- note -->
+ <template v-if="canHaveNote">
+ <ActionCheckbox
+ :checked.sync="hasNote"
+ :disabled="saving"
+ @uncheck="queueUpdate('note')">
+ {{ t('files_sharing', 'Note to recipient') }}
+ </ActionCheckbox>
+ <ActionTextEditable v-if="hasNote"
+ ref="note"
+ v-tooltip.auto="{
+ content: errors.note,
+ show: errors.note,
+ trigger: 'manual'
+ }"
+ :class="{ error: errors.note}"
+ :disabled="saving"
+ :value.sync="share.note"
+ icon="icon-edit"
+ @update:value="debounceQueueUpdate('note')" />
+ </template>
</template>
- <ActionButton icon="icon-delete" :disabled="saving" @click.prevent="onDelete">
+ <ActionButton v-if="share.canDelete"
+ icon="icon-delete"
+ :disabled="saving"
+ @click.prevent="onDelete">
{{ t('files_sharing', 'Unshare') }}
</ActionButton>
</Actions>
diff --git a/apps/files_sharing/src/components/SharingEntryLink.vue b/apps/files_sharing/src/components/SharingEntryLink.vue
index 4501d67cbbb..6e333be2491 100644
--- a/apps/files_sharing/src/components/SharingEntryLink.vue
+++ b/apps/files_sharing/src/components/SharingEntryLink.vue
@@ -123,7 +123,7 @@
:open.sync="open"
@close="onPasswordSubmit">
<template v-if="share">
- <template v-if="isShareOwner">
+ <template v-if="share.canEdit">
<!-- folder -->
<template v-if="isFolder && fileHasCreatePermission && config.isPublicUploadEnabled">
<ActionRadio :checked="share.permissions === publicUploadRValue"
@@ -256,7 +256,10 @@
{{ name }}
</ActionLink>
- <ActionButton icon="icon-delete" :disabled="saving" @click.prevent="onDelete">
+ <ActionButton v-if="share.canDelete"
+ icon="icon-delete"
+ :disabled="saving"
+ @click.prevent="onDelete">
{{ t('files_sharing', 'Delete share') }}
</ActionButton>
<ActionButton v-if="!isEmailShareType && canReshare"
diff --git a/apps/files_sharing/src/models/Share.js b/apps/files_sharing/src/models/Share.js
index e9d84fb5556..13b68ad68be 100644
--- a/apps/files_sharing/src/models/Share.js
+++ b/apps/files_sharing/src/models/Share.js
@@ -420,6 +420,31 @@ export default class Share {
return !!((this.permissions & OC.PERMISSION_SHARE))
}
+ // PERMISSIONS Shortcuts for the CURRENT USER
+ // ! the permissions above are the share settings,
+ // ! meaning the permissions for the recipient
+ /**
+ * Can the current user EDIT this share ?
+ *
+ * @returns {boolean}
+ * @readonly
+ * @memberof Share
+ */
+ get canEdit() {
+ return this.#share.can_edit === true
+ }
+
+ /**
+ * Can the current user DELETE this share ?
+ *
+ * @returns {boolean}
+ * @readonly
+ * @memberof Share
+ */
+ get canDelete() {
+ return this.#share.can_delete === true
+ }
+
// TODO: SORT THOSE PROPERTIES
get label() {
return this.#share.label