Skip to content

Commit

Permalink
Move filtering for collaborator displayName in outgoingShares to useS…
Browse files Browse the repository at this point in the history
…hares composable
  • Loading branch information
pascalwengerter committed Aug 15, 2023
1 parent 9df1a3d commit d8d609d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 29 deletions.
25 changes: 11 additions & 14 deletions packages/web-app-files/src/components/SideBar/Shares/FileShares.vue
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,17 @@ export default defineComponent({
},
collaborators() {
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
})
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
})
},
displayCollaborators() {
Expand Down
4 changes: 2 additions & 2 deletions packages/web-app-files/src/composables/shares/useShares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { useStore } from 'web-pkg/src/composables'
export function useShares() {
const store = useStore()
const outgoingLinks: Ref<Share[]> = computed(() => store.getters['Files/outgoingLinks'])
const outgoingCollaborators: Ref<Share[]> = computed(
() => store.getters['Files/outgoingCollaborators']
const outgoingCollaborators: Ref<Share[]> = computed(() =>
store.getters['Files/outgoingCollaborators'].filter((s) => s.collaborator.displayName)
)
return { outgoingCollaborators, outgoingLinks }
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,6 @@ 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 d8d609d

Please sign in to comment.