Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix space member panel issues #8300

Merged
merged 3 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Collaborator Author

@JammingBen JammingBen Jan 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again it makes it so much more complicated that the sidebar sometimes uses the highlightedFile for showing and mutating resources, sometimes we use the provided displayedItem, and now sometimes the spaceResource. It would be so nice to have that reduced to one provided prop (either via provide or via props).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fully agree 😕 I'm in favour of provide/inject for the data context of the sidebar. With props it'd be a pretty heavy cascade in some cases.

}
},
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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Distinction by shareType would be ideal, but I don't know if we need the server to adjust as well. Because the server currently handles space user- and group-shares via the same shareType: 7.

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