mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-22 19:11:33 +03:00
uberf-7764: improve space permissions query (#6236)
Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com>
This commit is contained in:
parent
7c1a1619e8
commit
c675f45491
@ -1495,9 +1495,21 @@ export const permissionsStore = writable<PermissionsStore>({
|
|||||||
ap: {},
|
ap: {},
|
||||||
whitelist: new Set()
|
whitelist: new Set()
|
||||||
})
|
})
|
||||||
const permissionsQuery = createQuery(true)
|
|
||||||
|
|
||||||
permissionsQuery.query(core.class.Space, {}, (res) => {
|
const spaceTypesQuery = createQuery(true)
|
||||||
|
const permissionsQuery = createQuery(true)
|
||||||
|
type TargetClassesProjection = Record<Ref<Class<Space>>, number>
|
||||||
|
|
||||||
|
spaceTypesQuery.query(core.class.SpaceType, {}, (types) => {
|
||||||
|
const targetClasses = types.reduce<TargetClassesProjection>((acc, st) => {
|
||||||
|
acc[st.targetClass] = 1
|
||||||
|
return acc
|
||||||
|
}, {})
|
||||||
|
|
||||||
|
permissionsQuery.query(
|
||||||
|
core.class.Space,
|
||||||
|
{},
|
||||||
|
(res) => {
|
||||||
const whitelistedSpaces = new Set<Ref<Space>>()
|
const whitelistedSpaces = new Set<Ref<Space>>()
|
||||||
const permissionsBySpace: PermissionsBySpace = {}
|
const permissionsBySpace: PermissionsBySpace = {}
|
||||||
const accountsByPermission: AccountsByPermission = {}
|
const accountsByPermission: AccountsByPermission = {}
|
||||||
@ -1548,6 +1560,15 @@ permissionsQuery.query(core.class.Space, {}, (res) => {
|
|||||||
ap: accountsByPermission,
|
ap: accountsByPermission,
|
||||||
whitelist: whitelistedSpaces
|
whitelist: whitelistedSpaces
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
{
|
||||||
|
projection: {
|
||||||
|
_id: 1,
|
||||||
|
type: 1,
|
||||||
|
...targetClasses
|
||||||
|
} as any
|
||||||
|
}
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
export function getCollaborationUser (): CollaborationUser {
|
export function getCollaborationUser (): CollaborationUser {
|
||||||
|
Loading…
Reference in New Issue
Block a user