Skip to content

Commit

Permalink
feat: add secure viewer to space roles
Browse files Browse the repository at this point in the history
  • Loading branch information
JammingBen committed May 16, 2024
1 parent 87852bc commit 6cbeaa6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
<h3 class="oc-text-bold oc-text-medium" v-text="$gettext('Viewers')" />
<members-role-section :members="filteredSpaceViewers" />
</div>
<div
v-if="filteredSpaceSecureViewers.length"
class="oc-mb-m"
data-testid="space-members-role-secure-viewers"
>
<h3 class="oc-text-bold oc-text-medium" v-text="$gettext('Secure viewers')" />
<members-role-section :members="filteredSpaceSecureViewers" />
</div>
</div>
</div>
</template>
Expand Down Expand Up @@ -74,6 +82,10 @@ export default defineComponent({
...unref(resource).spaceRoles.viewer.map((r) => ({
...r,
roleType: 'viewer'
})),
...unref(resource).spaceRoles['secure-viewer'].map((r) => ({
...r,
roleType: 'secure-viewer'
}))
].sort((a, b) => a.displayName.localeCompare(b.displayName))
})
Expand All @@ -90,6 +102,9 @@ export default defineComponent({
const filteredSpaceViewers = computed(() => {
return unref(filteredSpaceMembers).filter((m) => m.roleType === 'viewer')
})
const filteredSpaceSecureViewers = computed(() => {
return unref(filteredSpaceMembers).filter((m) => m.roleType === 'secure-viewer')
})
watch(filterTerm, () => {
if (unref(membersListRef)) {
Expand All @@ -108,6 +123,7 @@ export default defineComponent({
filteredSpaceManagers,
filteredSpaceEditors,
filteredSpaceViewers,
filteredSpaceSecureViewers,
membersListRef
}
}
Expand Down
6 changes: 1 addition & 5 deletions packages/web-app-files/src/views/spaces/Projects.vue
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,7 @@ export default defineComponent({
return formatFileSize(space.spaceQuota.remaining, currentLanguage)
}
const getMemberCount = (space: SpaceResource) => {
return (
space.spaceRoles.manager.length +
space.spaceRoles.editor.length +
space.spaceRoles.viewer.length
)
return Object.values(space.spaceRoles).flat().length
}
onMounted(async () => {
Expand Down
5 changes: 4 additions & 1 deletion packages/web-client/src/helpers/space/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export function buildSpace(
): SpaceResource {
let spaceImageData: DriveItem, spaceReadmeData: DriveItem
let disabled = false
const spaceRoles: SpaceRoles = { viewer: [], editor: [], manager: [] }
const spaceRoles: SpaceRoles = { viewer: [], editor: [], manager: [], 'secure-viewer': [] }

if (data.special) {
spaceImageData = data.special.find((el) => el.specialFolder.name === 'image')
Expand Down Expand Up @@ -285,6 +285,9 @@ export function buildSpace(
isManager(user: User): boolean {
return this.spaceRoles.manager.map((r) => r.isMember(user)).some(Boolean)
},
isSecureViewer(user: User): boolean {
return this.spaceRoles['secure-viewer'].map((r) => r.isMember(user)).some(Boolean)
},
isMember(user: User): boolean {
return this.isViewer(user) || this.isEditor(user) || this.isManager(user)
},
Expand Down
1 change: 1 addition & 0 deletions packages/web-client/src/helpers/space/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface SpaceRoles {
viewer: SpaceRole[]
editor: SpaceRole[]
manager: SpaceRole[]
'secure-viewer': SpaceRole[]
}

export interface SpaceResource extends Resource {
Expand Down

0 comments on commit 6cbeaa6

Please sign in to comment.