Skip to content

Commit

Permalink
Fix #9257
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalwengerter committed Aug 15, 2023
1 parent 50c8945 commit 9df1a3d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
7 changes: 7 additions & 0 deletions changelog/unreleased/bugfix-filter-shares-without-displayname
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: Filter out shares without display name

In rare (legacy) cases, shares can exist without a displayName key, which caused trouble in the sharing sidebar section.
This has been addressed by filtering out shares without a displayName.

https://github.com/owncloud/web/issues/9257
https://github.com/owncloud/web/pull/9504
25 changes: 14 additions & 11 deletions packages/web-app-files/src/components/SideBar/Shares/FileShares.vue
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,20 @@ export default defineComponent({
},
collaborators() {
return [...this.outgoingCollaborators].sort(this.collaboratorsComparator).map((c) => {
const collaborator: typeof c & { key?: string; resharers?: User[] } = { ...c }
collaborator.key = 'collaborator-' + collaborator.id
if (
collaborator.owner.name !== collaborator.fileOwner.name &&
collaborator.owner.name !== this.user.id
) {
collaborator.resharers = [collaborator.owner]
}
return collaborator
})
return [...this.outgoingCollaborators]
.filter((c) => c.collaborator.displayName)
.sort(this.collaboratorsComparator)
.map((c) => {
const collaborator: typeof c & { key?: string; resharers?: User[] } = { ...c }
collaborator.key = 'collaborator-' + collaborator.id
if (
collaborator.owner.name !== collaborator.fileOwner.name &&
collaborator.owner.name !== this.user.id
) {
collaborator.resharers = [collaborator.owner]
}
return collaborator
})
},
displayCollaborators() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,19 @@ describe('FileShares', () => {
expect(wrapper.findAll('#files-collaborators-list li').length).toBe(collaborators.length)
expect(wrapper.html()).toMatchSnapshot()
})
it('filters out collaborator without displayName', () => {
const collaboratorsWithDisallowed = [
...collaborators,
{
...getCollaborator(),
collaborator: { name: 'foo', additionalInfo: 'some' }
}
]
const { wrapper } = getWrapper({ collaborators: collaboratorsWithDisallowed })
expect(wrapper.findAll('#files-collaborators-list li').length).toBe(
collaboratorsWithDisallowed.length - 1
)
})
it('reacts on delete events', async () => {
const spyOnCollaboratorDeleteTrigger = jest
.spyOn((FileShares as any).methods, '$_ocCollaborators_deleteShare_trigger')
Expand Down

0 comments on commit 9df1a3d

Please sign in to comment.