Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cancelling custom permissions #8340

Merged
merged 1 commit into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/unreleased/bugfix-cancel-custom-permissions
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Cancel custom permissions

We've fixed a bug where cancelling the custom permissions on a share would remove all permissions.

https://github.com/owncloud/web/pull/8340
https://github.com/owncloud/web/issues/8335
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,14 @@
>
<oc-button
size="small"
class="files-recipient-custom-permissions-drop-cancel"
@click="cancelCustomPermissions"
v-text="$gettext('Cancel')"
/><oc-button
size="small"
variation="primary"
appearance="filled"
class="oc-ml-s"
class="files-recipient-custom-permissions-drop-confirm oc-ml-s"
@click="confirmCustomPermissions"
v-text="$gettext('Apply')"
/>
Expand All @@ -103,7 +104,6 @@
</template>

<script lang="ts">
import { mapState } from 'vuex'
import get from 'lodash-es/get'
import RoleItem from '../Shared/RoleItem.vue'
import {
Expand Down Expand Up @@ -149,6 +149,7 @@ export default defineComponent({
required: true
}
},
emits: ['optionChange'],
setup() {
const store = useStore()
return {
Expand All @@ -164,8 +165,6 @@ export default defineComponent({
}
},
computed: {
...mapState('Files', ['sharesTree']),

roleButtonId() {
if (this.domSelector) {
return `files-collaborators-role-button-${this.domSelector}-${uuid.v4()}`
Expand All @@ -181,9 +180,8 @@ export default defineComponent({
} else if (this.selectedRole.permissions().includes(SharePermissions.denied)) {
return this.$gettext('Deny access')
} else {
return this.$gettextInterpolate(this.$gettext('Invite as %{ name }'), {
name: this.$gettext(this.selectedRole.inlineLabel) || ''
})
const name = this.$gettext(this.selectedRole.inlineLabel) || ''
return this.$gettext('Invite as %{ name }', { name })
}
},
customPermissionsRole() {
Expand Down Expand Up @@ -217,10 +215,12 @@ export default defineComponent({
},
resourceIsSpace() {
return this.resource.type === 'space'
},
defaultCustomPermissions() {
return [...this.selectedRole.permissions(this.allowSharePermission)]
}
},

emits: ['optionChange'],
created() {
this.applyRoleAndPermissions()
},
Expand All @@ -230,7 +230,6 @@ export default defineComponent({
},

mounted() {
this.applyRoleAndPermissions()
window.addEventListener('keydown', this.cycleRoles)
},

Expand All @@ -249,11 +248,9 @@ export default defineComponent({
)[0]
}

if (this.selectedRole.hasCustomPermissions) {
this.customPermissions = this.existingPermissions
} else {
this.customPermissions = [...this.selectedRole.permissions(this.allowSharePermission)]
}
this.customPermissions = this.selectedRole.hasCustomPermissions
? this.existingPermissions
: this.defaultCustomPermissions
},

publishChange() {
Expand Down Expand Up @@ -293,7 +290,9 @@ export default defineComponent({
},

cancelCustomPermissions() {
this.customPermissions = this.existingPermissions
this.customPermissions = this.existingPermissions.length
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI this is the important change here. The rest is just refactoring/cleaning outdated stuff,.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

? this.existingPermissions
: this.defaultCustomPermissions
this.$refs.customPermissionsDrop.hide()
this.$refs.rolesDrop.show()
},
Expand Down
Loading