Skip to content

Commit

Permalink
fix FileShares snapshots
Browse files Browse the repository at this point in the history
fix failing FileShares acceptance tests
  • Loading branch information
fschade committed Jan 2, 2023
1 parent 35cda2b commit 3813cf8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 12 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 @@ -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>
`;

0 comments on commit 3813cf8

Please sign in to comment.