Skip to content

Commit

Permalink
Optional roles' share permission when resharing enable
Browse files Browse the repository at this point in the history
  • Loading branch information
diocas committed Nov 14, 2022
1 parent 560e99b commit 2ac7321
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ import {
useCapabilityFilesSharingAllowCustomPermissions,
useCapabilityFilesSharingCanDenyAccess,
useCapabilityFilesSharingResharing,
useCapabilityFilesSharingResharingDefault,
useCapabilityShareJailEnabled,
useStore
} from 'web-pkg/src/composables'
Expand Down Expand Up @@ -123,6 +124,7 @@ export default defineComponent({
const store = useStore()
return {
hasResharing: useCapabilityFilesSharingResharing(store),
resharingDefault: useCapabilityFilesSharingResharingDefault(store),
hasShareJail: useCapabilityShareJailEnabled(store),
hasRoleCustomPermissions: useCapabilityFilesSharingAllowCustomPermissions(store),
hasRoleDenyAccess: useCapabilityFilesSharingCanDenyAccess(store),
Expand Down Expand Up @@ -305,7 +307,9 @@ export default defineComponent({
const bitmask = this.selectedRole.hasCustomPermissions
? SharePermissions.permissionsToBitmask(this.customPermissions)
: SharePermissions.permissionsToBitmask(
this.selectedRole.permissions(this.hasResharing || this.resourceIsSpace)
this.selectedRole.permissions(
(this.hasResharing && this.resharingDefault) || this.resourceIsSpace
)
)
let path = this.highlightedFile.path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ import { DateTime } from 'luxon'
import EditDropdown from './EditDropdown.vue'
import RoleDropdown from './RoleDropdown.vue'
import { SharePermissions, ShareTypes } from 'web-client/src/helpers/share'
import { useCapabilityFilesSharingResharing } from 'web-pkg/src/composables'
import {
useCapabilityFilesSharingResharing,
useCapabilityFilesSharingResharingDefault
} from 'web-pkg/src/composables'
import { extractDomSelector } from 'web-client/src/helpers/resource'
import { defineComponent } from '@vue/composition-api'
import * as uuid from 'uuid'
Expand Down Expand Up @@ -138,6 +141,7 @@ export default defineComponent({
setup() {
return {
hasResharing: useCapabilityFilesSharingResharing(),
resharingDefault: useCapabilityFilesSharingResharingDefault(),
...useGraphClient()
}
},
Expand Down Expand Up @@ -361,7 +365,9 @@ export default defineComponent({
saveShareChanges({ role, permissions, expirationDate }) {
const bitmask = role.hasCustomPermissions
? SharePermissions.permissionsToBitmask(permissions)
: SharePermissions.permissionsToBitmask(role.permissions(this.hasResharing || this.isSpace))
: SharePermissions.permissionsToBitmask(
role.permissions((this.hasResharing && this.resharingDefault) || this.isSpace)
)
const changeMethod = this.isSpace ? this.changeSpaceMember : this.changeShare
changeMethod({
client: this.$client,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
>
<span class="oc-flex oc-flex-middle">
<oc-icon :name="role.icon" class="oc-pl-s oc-pr-m" />
<role-item :role="role" :allow-share-permission="allowSharePermission" />
<role-item
:role="role"
:allow-share-permission="allowSharePermission && resharingDefault"
/>
</span>
<span class="oc-flex">
<oc-icon v-if="isSelectedRole(role)" name="check" />
Expand Down Expand Up @@ -118,6 +121,7 @@ import { PropType } from '@vue/composition-api'
import {
useCapabilityFilesSharingAllowCustomPermissions,
useCapabilityFilesSharingCanDenyAccess,
useCapabilityFilesSharingResharingDefault,
useStore
} from 'web-pkg/src/composables'
Expand Down Expand Up @@ -154,7 +158,8 @@ export default defineComponent({
const store = useStore()
return {
hasRoleDenyAccess: useCapabilityFilesSharingCanDenyAccess(store),
hasRoleCustomPermissions: useCapabilityFilesSharingAllowCustomPermissions(store)
hasRoleCustomPermissions: useCapabilityFilesSharingAllowCustomPermissions(store),
resharingDefault: useCapabilityFilesSharingResharingDefault(store)
}
},
data() {
Expand Down Expand Up @@ -253,7 +258,9 @@ export default defineComponent({
if (this.selectedRole.hasCustomPermissions) {
this.customPermissions = this.existingPermissions
} else {
this.customPermissions = [...this.selectedRole.permissions(this.allowSharePermission)]
this.customPermissions = [
...this.selectedRole.permissions(this.allowSharePermission && this.resharingDefault)
]
}
},
Expand All @@ -270,7 +277,7 @@ export default defineComponent({
return
}
this.selectedRole = role
this.customPermissions = role.permissions(this.allowSharePermission)
this.customPermissions = role.permissions(this.allowSharePermission && this.resharingDefault)
this.publishChange()
},
Expand All @@ -288,7 +295,7 @@ export default defineComponent({
this.selectedRole = PeopleShareRoles.getByBitmask(
bitmask,
this.resource.isFolder,
this.allowSharePermission
this.allowSharePermission && this.resharingDefault
)
this.publishChange()
},
Expand Down
5 changes: 4 additions & 1 deletion packages/web-app-files/src/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import { WebDAV } from 'web-client/src/webdav'
import { ClientService } from 'web-pkg/src/services'

const allowSharePermissions = (getters) => {
return get(getters, `capabilities.files_sharing.resharing`, true)
return (
get(getters, `capabilities.files_sharing.resharing`, true) &&
get(getters, `capabilities.files_sharing.resharing_default`, true)
)
}

export default {
Expand Down
4 changes: 4 additions & 0 deletions packages/web-pkg/src/composables/capability/useCapability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export const useCapabilityFilesSharingResharing = createCapabilityComposable(
'files_sharing.resharing',
true
)
export const useCapabilityFilesSharingResharingDefault = createCapabilityComposable(
'files_sharing.resharing_default',
true
)

export const useCapabilitySpacesEnabled = createCapabilityComposable('spaces.enabled', false)
export const useCapabilityProjectSpacesEnabled = createCapabilityComposable(
Expand Down

0 comments on commit 2ac7321

Please sign in to comment.