Allow child classes in navigator model (#5275)

Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
Alexander Onnikov 2024-04-10 02:20:49 +07:00 committed by GitHub
parent 38ac81d6c1
commit 9d414439b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 7 deletions

View File

@ -18,7 +18,7 @@ import { NotificationGroup, NotificationType } from '@hcengineering/notification
import type { Asset, Plugin, Resource } from '@hcengineering/platform'
import { IntlString, plugin } from '@hcengineering/platform'
import type { AnyComponent, Location, ResolvedLocation } from '@hcengineering/ui'
import { Action, Viewlet } from '@hcengineering/view'
import { Action } from '@hcengineering/view'
import { Document, DocumentEmbedding, DocumentSnapshot, SavedDocument, Teamspace } from './types'
/**
@ -75,9 +75,6 @@ export const documentPlugin = plugin(documentId, {
DocumentNotificationGroup: '' as Ref<NotificationGroup>,
ContentNotification: '' as Ref<NotificationType>
},
viewlet: {
TableBranches: '' as Ref<Viewlet>
},
descriptor: {
TeamspaceType: '' as Ref<SpaceTypeDescriptor>
},

View File

@ -42,10 +42,11 @@
let shownSpaces: Space[] = []
$: if (model) {
const classes = getSpecialSpaceClass(model).flatMap((c) => hierarchy.getDescendants(c))
query.query(
core.class.Space,
{
_class: { $in: getSpecialSpaceClass(model) }
_class: { $in: classes }
// temp disabled, need way for default spaces
// members: getCurrentAccount()._id
},

View File

@ -13,7 +13,7 @@
// limitations under the License.
-->
<script lang="ts">
import type { Doc, Ref, Space } from '@hcengineering/core'
import type { Class, Doc, Ref, Space } from '@hcengineering/core'
import core from '@hcengineering/core'
import { DocNotifyContext, InboxNotification } from '@hcengineering/notification'
import { InboxNotificationsClientImpl } from '@hcengineering/notification-resources'
@ -86,6 +86,16 @@
return result
}
function getSpaceModel (space: Ref<Class<Space>>): SpacesNavModel | undefined {
const hierarchy = client.getHierarchy()
const ancestors = [space, ...[...hierarchy.getAncestors(space)].reverse()]
for (const clazz of ancestors) {
const model = models.find((p) => p.spaceClass === clazz)
if (model !== undefined) return model
}
return undefined
}
const inboxClient = InboxNotificationsClientImpl.getClient()
const notifyContextByDocStore = inboxClient.contextByDoc
const inboxNotificationsByContextStore = inboxClient.inboxNotificationsByContext
@ -103,7 +113,7 @@
<TreeNode _id={'tree-stared'} {label} node actions={async () => [unStarAll]}>
{#each spaces as space (space._id)}
{@const model = models.find((p) => p.spaceClass === space._class)}
{@const model = getSpaceModel(space._class)}
{#await getSpacePresenter(client, space._class) then presenter}
{#if presenter && model}
<svelte:component