Skip to content

Commit

Permalink
fix failing linter steps
Browse files Browse the repository at this point in the history
fix FileShares snapshots
fix failing FileShares acceptance tests
  • Loading branch information
fschade committed Jan 2, 2023
1 parent 5d41616 commit a705861
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ import {
shareInviteCollaboratorHelp,
shareInviteCollaboratorHelpCern
} from '../../../helpers/contextualHelpers'
import { defineComponent, PropType } from 'vue'
import { computed, defineComponent, PropType } from 'vue'
import { isProjectSpaceResource, SpaceResource } from 'web-client/src/helpers'
import { createFileRouteOptions } from 'web-pkg/src/helpers/router'
Expand All @@ -103,9 +103,19 @@ export default defineComponent({
setup() {
const store = useStore()
const sharesListCollapsed = !store.getters.configuration.options.sidebar.shares.showAllOnLoad
const currentUserIsMemberOfSpace = computed(() => {
const userId = store.getters.user?.id
if (!userId) {
return false
}
return store.getters['runtime/spaces/spaceMembers'].some(
(member) => member.collaborator?.name === userId
)
})
return {
sharesListCollapsed,
currentUserIsMemberOfSpace,
hasProjectSpaces: useCapabilityProjectSpacesEnabled(),
hasShareJail: useCapabilityShareJailEnabled(),
hasResharing: useCapabilityFilesSharingResharing()
Expand Down Expand Up @@ -224,7 +234,7 @@ export default defineComponent({
return (
this.space?.driveType === 'project' &&
this.highlightedFile.type !== 'space' &&
this.space?.isMember(this.user)
this.currentUserIsMemberOfSpace
)
}
},
Expand Down Expand Up @@ -336,18 +346,23 @@ export default defineComponent({
return null
},
// fixMe: head-breaking logic
isShareModifiable(collaborator) {
const isSharableResource = this.space && isProjectSpaceResource(this.space)
const isPersonalSpaceShare = !isProjectSpaceResource(this.space)
const isPersonalMember = this.currentUserIsMemberOfSpace
const isIndirectPersonalCollaborator = collaborator.indirect
const isProjectSpaceShare = !isPersonalSpaceShare
const isManager = this.space?.isManager(this.user)
if (!isSharableResource) {
return false
if (isPersonalSpaceShare && isPersonalMember && isManager) {
return true
}
if (this.space?.isManager(this.user)) {
if (isPersonalSpaceShare && !isIndirectPersonalCollaborator) {
return true
}
if (collaborator.indirect) {
if (isProjectSpaceShare && isManager) {
return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,7 @@ describe('FileShares', () => {
it('loads space members if a space is given and the current user is member', () => {
const user = { id: '1' }
const space = mockDeep<SpaceResource>({ driveType: 'project' })
const spaceMembers = [
{ collaborator: { name: user.id } },
{ collaborator: { name: 2 } }
]
const spaceMembers = [{ collaborator: { name: user.id } }, { collaborator: { name: 2 } }]
const collaborator = getCollaborator()
collaborator.collaborator = { ...collaborator.collaborator, name: user.id }
const { wrapper } = getWrapper({ space, collaborators: [collaborator], user, spaceMembers })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ exports[`FileShares collaborators list renders sharedWithLabel and sharee list 1
</div>
<ul aria-label="Share receivers" class="oc-list oc-list-divider oc-overflow-hidden oc-m-rm" id="files-collaborators-list">
<li>
<collaborator-list-item-stub share="[object Object]"></collaborator-list-item-stub>
<collaborator-list-item-stub modifiable="true" share="[object Object]"></collaborator-list-item-stub>
</li>
<li>
<collaborator-list-item-stub share="[object Object]"></collaborator-list-item-stub>
<collaborator-list-item-stub modifiable="true" share="[object Object]"></collaborator-list-item-stub>
</li>
<li>
<collaborator-list-item-stub share="[object Object]"></collaborator-list-item-stub>
<collaborator-list-item-stub modifiable="true" share="[object Object]"></collaborator-list-item-stub>
</li>
<li>
<collaborator-list-item-stub share="[object Object]"></collaborator-list-item-stub>
<collaborator-list-item-stub modifiable="true" share="[object Object]"></collaborator-list-item-stub>
</li>
</ul>
<div class="oc-flex oc-flex-center">
Expand All @@ -61,12 +61,21 @@ exports[`FileShares current space loads space members if a space is given and th
<div class="avatars-wrapper oc-flex oc-flex-middle oc-flex-between">
<h4 class="oc-text-bold oc-my-rm">Shared with</h4>
</div>
<ul aria-label="Share receivers" class="oc-list oc-list-divider oc-overflow-hidden oc-m-rm" id="files-collaborators-list">
<ul aria-label="Share receivers" class="oc-list oc-list-divider oc-overflow-hidden oc-mb-l" id="files-collaborators-list">
<li>
<collaborator-list-item-stub share="[object Object]"></collaborator-list-item-stub>
</li>
</ul>
<!---->
<h4 class="oc-text-bold oc-my-s">Space members</h4>
<ul aria-label="Space members" class="oc-list oc-list-divider oc-overflow-hidden oc-m-rm" id="space-collaborators-list">
<li>
<collaborator-list-item-stub share="[object Object]"></collaborator-list-item-stub>
</li>
<li>
<collaborator-list-item-stub share="[object Object]"></collaborator-list-item-stub>
</li>
</ul>
<!---->
</div>
`;
1 change: 0 additions & 1 deletion packages/web-client/src/helpers/resource/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export interface Resource {
isMounted?(): boolean

getDomSelector?(): string

matchingSpace?: any

resourceOwner?: User
Expand Down

0 comments on commit a705861

Please sign in to comment.