Skip to content

Commit

Permalink
Merge pull request #1311 from nextcloud/feat/1128
Browse files Browse the repository at this point in the history
feat: share Application with groups
  • Loading branch information
blizzz authored Sep 12, 2024
2 parents 52846ad + 1bafa65 commit cb086b3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/modules/modals/EditContext.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export default {
},
getContextReceivers(context) {
let sharing = Object.values(context.sharing)
sharing = sharing.filter((share) => getCurrentUser().uid !== share.receiver)
sharing = sharing.filter((share) => !(getCurrentUser().uid === share.receiver && share.receiver_type === 'user'))
const receivers = sharing.map((share) => {
return {
id: share.receiver,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div>
<ResourceForm :resources="localResources" data-cy="contextResourceForm" @add="addResource" />
<ResourceList :resources="localResources" data-cy="contextResourceList" @remove="removeResource" />
<ResourceSharees :select-users="true" :select-groups="false" :receivers="localReceivers" data-cy="contextResourceShare" @update="updateReceivers" />
<ResourceSharees :select-users="true" :select-groups="true" :receivers="localReceivers" data-cy="contextResourceShare" @update="updateReceivers" />
<ResourceSharePermissions :resources="localResources" data-cy="contextResourcePerms" @update="updateResourcePermissions" />
</div>
</div>
Expand Down
27 changes: 22 additions & 5 deletions src/shared/components/ncContextResource/ResourceSharees.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ export default {
data() {
return {
preExistingSharees: [...this.receivers],
localSharees: this.receivers.map(userObject => userObject.id),
localSharees: this.receivers.map(obj => ({
id: obj.id,
displayName: obj.displayName,
icon: obj.icon,
isUser: obj.isUser,
key: obj.key,
})),
}
},
Expand All @@ -64,7 +70,13 @@ export default {
return this.localSharees
},
set(v) {
this.localSharees = v.map(userObject => userObject.id)
this.localSharees = v.map(obj => ({
id: obj.id,
displayName: obj.displayName,
icon: obj.icon,
isUser: obj.isUser,
key: obj.key,
}))
this.$emit('update', v)
},
},
Expand All @@ -77,10 +89,15 @@ export default {
filterOutUnwantedItems(items) {
// Filter out existing items
items = items.filter((item) => !(item.isUser && this.localSharees.includes(item.id)))
const filteredItems = []
items.forEach((item) => {
const alreadyExists = this.localSharees.find((localItem) => item.id === localItem.id && item.isUser === localItem.isUser)
if (!alreadyExists) {
filteredItems.push(item)
}
})
// Filter out current user
return items.filter((item) => !(item.isUser && item.id === this.currentUserId))
return filteredItems.filter((item) => !(item.isUser && item.id === this.currentUserId))
},
formatResult(autocompleteResult) {
Expand Down

0 comments on commit cb086b3

Please sign in to comment.