Skip to content

Commit

Permalink
Merge pull request #8300 from owncloud/fix-space-member-panel-issues
Browse files Browse the repository at this point in the history
Fix space member panel issues
  • Loading branch information
kulmann authored Jan 24, 2023
2 parents ce491a5 + aa4e094 commit 983865b
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 30 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/bugfix-re-loading-space-members
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Re-loading space members panel

We've fixed a bug where re-loading the members panel for a space would remove recently added members in the UI.

https://github.com/owncloud/web/pull/8300
https://github.com/owncloud/web/issues/8298
2 changes: 2 additions & 0 deletions changelog/unreleased/enhancement-share-group-members
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ In detail it contains:
* All users / groups who only have access on a share level inside a sub-resource of a space can not see all groups which are regular members of the space

https://github.com/owncloud/web/pull/8161
https://github.com/owncloud/web/pull/8300
https://github.com/owncloud/web/issues/8160
https://github.com/owncloud/web/issues/8177
https://github.com/owncloud/web/issues/8299
6 changes: 5 additions & 1 deletion packages/web-app-files/src/components/SideBar/SideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
/>
<space-info
v-if="isSingleResource && highlightedFileIsSpace"
:space-resource="spaceResource"
class="sidebar-panel__space_info"
/>
</template>
Expand Down Expand Up @@ -219,6 +220,9 @@ export default defineComponent({
this.isSharedWithOthersLocation ||
this.isSharedViaLinkLocation
)
},
spaceResource() {
return this.spaces.find((s) => s.id === this.highlightedFile.id)
}
},
watch: {
Expand All @@ -238,7 +242,7 @@ export default defineComponent({
}
if (isProjectSpaceResource(this.highlightedFile)) {
this.loadSpaceMembers({ graphClient: this.graphClient, space: this.highlightedFile })
this.loadSpaceMembers({ graphClient: this.graphClient, space: this.spaceResource })
}
if (this.isShareLocation || !noChanges) {
Expand Down
18 changes: 4 additions & 14 deletions packages/web-pkg/src/components/sideBar/Spaces/SpaceInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,20 @@
<div class="oc-mr-s">
<oc-icon
name="layout-grid"
:size="space.description ? 'large' : 'medium'"
:size="spaceResource.description ? 'large' : 'medium'"
class="oc-display-block"
/>
</div>
<div>
<h3 data-testid="space-info-name" v-text="space.name" />
<span data-testid="space-info-subtitle" v-text="space.description" />
<h3 data-testid="space-info-name" v-text="spaceResource.name" />
<span data-testid="space-info-subtitle" v-text="spaceResource.description" />
</div>
</div>
</div>
</template>

<script lang="ts">
import { defineComponent } from 'vue'
import { mapGetters } from 'vuex'
import { PropType } from 'vue'
import { defineComponent, PropType } from 'vue'
import { SpaceResource } from 'web-client'
export default defineComponent({
Expand All @@ -30,13 +27,6 @@ export default defineComponent({
type: Object as PropType<SpaceResource>,
required: false
}
},
computed: {
...mapGetters('Files', ['highlightedFile']),
space() {
return this.spaceResource || this.highlightedFile
}
}
})
</script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import SpaceInfo from 'web-pkg/src/components/sideBar/Spaces/SpaceInfo.vue'
import {
createStore,
defaultPlugins,
shallowMount,
defaultStoreMockOptions
} from 'web-test-helpers'
import { defaultPlugins, shallowMount } from 'web-test-helpers'

const spaceMock = {
type: 'space',
Expand All @@ -31,14 +26,11 @@ describe('SpaceInfo', () => {
})

function createWrapper(spaceResource) {
const storeOptions = { ...defaultStoreMockOptions }
storeOptions.modules.Files.getters.highlightedFile.mockImplementation(() => spaceResource)
const store = createStore(storeOptions)

return {
wrapper: shallowMount(SpaceInfo, {
props: { spaceResource },
global: {
plugins: [...defaultPlugins(), store]
plugins: [...defaultPlugins()]
}
})
}
Expand Down
11 changes: 7 additions & 4 deletions packages/web-runtime/src/store/spaces.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { buildSpace, isProjectSpaceResource, SpaceResource } from 'web-client/src/helpers'
import { Ref } from 'vue'
import { Ref, unref } from 'vue'
import { set, has } from 'lodash-es'
import { unref } from 'vue'
import { buildSpaceShare } from 'web-client/src/helpers/share'
import { sortSpaceMembers } from '../helpers/space/sortMembers'

Expand Down Expand Up @@ -88,8 +87,10 @@ const mutations = {
state.spaceMembers = members
},
UPSERT_SPACE_MEMBERS(state, member) {
// group shares don't have the name prop... distinguish by shareType
const checkAttr = member.collaborator.name ? 'name' : 'displayName'
const memberIndex = state.spaceMembers.findIndex((s) => {
return member.id === s.id && member.collaborator.name === s.collaborator.name
return member.id === s.id && member.collaborator[checkAttr] === s.collaborator[checkAttr]
})

if (memberIndex >= 0) {
Expand All @@ -100,8 +101,10 @@ const mutations = {
}
},
REMOVE_SPACE_MEMBER(state, member) {
// group shares don't have the name prop... distinguish by shareType
const checkAttr = member.collaborator.name ? 'name' : 'displayName'
state.spaceMembers = state.spaceMembers.filter(
(s) => member.id === s.id && member.collaborator.name !== s.collaborator.name
(s) => member.id === s.id && member.collaborator[checkAttr] !== s.collaborator[checkAttr]
)
}
}
Expand Down

0 comments on commit 983865b

Please sign in to comment.