mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-23 08:48:01 +00:00
UBER-880 Use space presenter for starred spaces (#3717)
Signed-off-by: Alexander Onnikov <alexander.onnikov@xored.com>
This commit is contained in:
parent
7e0fe4e91f
commit
fd5436536d
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
// Copyright © 2022 Hardcore Engineering Inc.
|
// Copyright © 2022, 2023 Hardcore Engineering Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License. You may
|
// you may not use this file except in compliance with the License. You may
|
||||||
@ -162,7 +162,15 @@
|
|||||||
on:select={(res) => (menuSelection = res.detail)}
|
on:select={(res) => (menuSelection = res.detail)}
|
||||||
/>
|
/>
|
||||||
{#if starred.length}
|
{#if starred.length}
|
||||||
<StarredNav label={preference.string.Starred} spaces={starred} on:space {currentSpace} />
|
<StarredNav
|
||||||
|
label={preference.string.Starred}
|
||||||
|
spaces={starred}
|
||||||
|
models={model.spaces}
|
||||||
|
on:space
|
||||||
|
{currentSpace}
|
||||||
|
{currentSpecial}
|
||||||
|
deselect={menuSelection}
|
||||||
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#each model.spaces as m, i (m.label)}
|
{#each model.spaces as m, i (m.label)}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<!--
|
<!--
|
||||||
// Copyright © 2020 Anticrm Platform Contributors.
|
// Copyright © 2020 Anticrm Platform Contributors.
|
||||||
|
// Copyright © 2023 Hardcore Engineering Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License. You may
|
// you may not use this file except in compliance with the License. You may
|
||||||
@ -13,7 +14,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { Class, Doc, Ref, Space } from '@hcengineering/core'
|
import type { Doc, Ref, Space } from '@hcengineering/core'
|
||||||
import core from '@hcengineering/core'
|
import core from '@hcengineering/core'
|
||||||
import { DocUpdates } from '@hcengineering/notification'
|
import { DocUpdates } from '@hcengineering/notification'
|
||||||
import { NotificationClientImpl } from '@hcengineering/notification-resources'
|
import { NotificationClientImpl } from '@hcengineering/notification-resources'
|
||||||
@ -23,7 +24,6 @@
|
|||||||
import {
|
import {
|
||||||
Action,
|
Action,
|
||||||
AnyComponent,
|
AnyComponent,
|
||||||
AnySvelteComponent,
|
|
||||||
IconAdd,
|
IconAdd,
|
||||||
IconEdit,
|
IconEdit,
|
||||||
IconSearch,
|
IconSearch,
|
||||||
@ -31,12 +31,11 @@
|
|||||||
navigate,
|
navigate,
|
||||||
showPopup
|
showPopup
|
||||||
} from '@hcengineering/ui'
|
} from '@hcengineering/ui'
|
||||||
import view from '@hcengineering/view'
|
|
||||||
import { NavLink, TreeItem, TreeNode, getActions as getContributedActions } from '@hcengineering/view-resources'
|
import { NavLink, TreeItem, TreeNode, getActions as getContributedActions } from '@hcengineering/view-resources'
|
||||||
import { SpacesNavModel } from '@hcengineering/workbench'
|
import { SpacesNavModel } from '@hcengineering/workbench'
|
||||||
import { createEventDispatcher } from 'svelte'
|
import { createEventDispatcher } from 'svelte'
|
||||||
import plugin from '../../plugin'
|
import plugin from '../../plugin'
|
||||||
import { classIcon, getSpaceName } from '../../utils'
|
import { classIcon, getSpaceName, getSpacePresenter } from '../../utils'
|
||||||
import TreeSeparator from './TreeSeparator.svelte'
|
import TreeSeparator from './TreeSeparator.svelte'
|
||||||
|
|
||||||
export let model: SpacesNavModel
|
export let model: SpacesNavModel
|
||||||
@ -100,7 +99,6 @@
|
|||||||
|
|
||||||
const notificationClient = NotificationClientImpl.getClient()
|
const notificationClient = NotificationClientImpl.getClient()
|
||||||
const docUpdates = notificationClient.docUpdatesStore
|
const docUpdates = notificationClient.docUpdatesStore
|
||||||
const hierarchy = client.getHierarchy()
|
|
||||||
|
|
||||||
function isChanged (space: Space, docUpdates: Map<Ref<Doc>, DocUpdates>): boolean {
|
function isChanged (space: Space, docUpdates: Map<Ref<Doc>, DocUpdates>): boolean {
|
||||||
const update = docUpdates.get(space._id)
|
const update = docUpdates.get(space._id)
|
||||||
@ -116,13 +114,6 @@
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getPresenter (_class: Ref<Class<Doc>>): Promise<AnySvelteComponent | undefined> {
|
|
||||||
const value = hierarchy.classHierarchyMixin(_class, view.mixin.SpacePresenter)
|
|
||||||
if (value?.presenter !== undefined) {
|
|
||||||
return await getResource(value.presenter)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let visibleIf: ((space: Space) => Promise<boolean>) | undefined
|
let visibleIf: ((space: Space) => Promise<boolean>) | undefined
|
||||||
|
|
||||||
$: if (model.visibleIf) {
|
$: if (model.visibleIf) {
|
||||||
@ -157,7 +148,7 @@
|
|||||||
shortDropbox={model.specials !== undefined}
|
shortDropbox={model.specials !== undefined}
|
||||||
>
|
>
|
||||||
{#each filteredSpaces as space, i (space._id)}
|
{#each filteredSpaces as space, i (space._id)}
|
||||||
{#await getPresenter(space._class) then presenter}
|
{#await getSpacePresenter(client, space._class) then presenter}
|
||||||
{#if separate && model.specials && i !== 0}<TreeSeparator line />{/if}
|
{#if separate && model.specials && i !== 0}<TreeSeparator line />{/if}
|
||||||
{#if model.specials && presenter}
|
{#if model.specials && presenter}
|
||||||
<svelte:component this={presenter} {space} {model} {currentSpace} {currentSpecial} {getActions} {deselect} />
|
<svelte:component this={presenter} {space} {model} {currentSpace} {currentSpecial} {getActions} {deselect} />
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
// Copyright © 2022 Hardcore Engineering Inc.
|
// Copyright © 2022, 2023 Hardcore Engineering Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License. You may
|
// you may not use this file except in compliance with the License. You may
|
||||||
@ -23,11 +23,16 @@
|
|||||||
import { Action, IconEdit } from '@hcengineering/ui'
|
import { Action, IconEdit } from '@hcengineering/ui'
|
||||||
import view from '@hcengineering/view'
|
import view from '@hcengineering/view'
|
||||||
import { NavLink, TreeItem, TreeNode, getActions as getContributedActions } from '@hcengineering/view-resources'
|
import { NavLink, TreeItem, TreeNode, getActions as getContributedActions } from '@hcengineering/view-resources'
|
||||||
import { classIcon, getSpaceName } from '../../utils'
|
import { SpacesNavModel } from '@hcengineering/workbench'
|
||||||
|
import { classIcon, getSpaceName, getSpacePresenter } from '../../utils'
|
||||||
|
|
||||||
export let label: IntlString
|
export let label: IntlString
|
||||||
export let currentSpace: Ref<Space> | undefined
|
|
||||||
export let spaces: Space[]
|
export let spaces: Space[]
|
||||||
|
export let models: SpacesNavModel[]
|
||||||
|
export let currentSpace: Ref<Space> | undefined
|
||||||
|
export let currentSpecial: string | undefined
|
||||||
|
export let deselect: boolean = false
|
||||||
|
|
||||||
const client = getClient()
|
const client = getClient()
|
||||||
|
|
||||||
const unStarSpace: Action = {
|
const unStarSpace: Action = {
|
||||||
@ -85,6 +90,11 @@
|
|||||||
|
|
||||||
<TreeNode {label} parent actions={async () => [unStarAll]}>
|
<TreeNode {label} parent actions={async () => [unStarAll]}>
|
||||||
{#each spaces as space (space._id)}
|
{#each spaces as space (space._id)}
|
||||||
|
{@const model = models.find((p) => p.spaceClass === space._class)}
|
||||||
|
{#await getSpacePresenter(client, space._class) then presenter}
|
||||||
|
{#if presenter && model}
|
||||||
|
<svelte:component this={presenter} {space} {model} {currentSpace} {currentSpecial} {getActions} {deselect} />
|
||||||
|
{:else}
|
||||||
{#await getSpaceName(client, space) then name}
|
{#await getSpaceName(client, space) then name}
|
||||||
<NavLink space={space._id}>
|
<NavLink space={space._id}>
|
||||||
<TreeItem
|
<TreeItem
|
||||||
@ -98,5 +108,7 @@
|
|||||||
/>
|
/>
|
||||||
</NavLink>
|
</NavLink>
|
||||||
{/await}
|
{/await}
|
||||||
|
{/if}
|
||||||
|
{/await}
|
||||||
{/each}
|
{/each}
|
||||||
</TreeNode>
|
</TreeNode>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright © 2020, 2021 Anticrm Platform Contributors.
|
// Copyright © 2020, 2021 Anticrm Platform Contributors.
|
||||||
// Copyright © 2021 Hardcore Engineering Inc.
|
// Copyright © 2021, 2023 Hardcore Engineering Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License. You may
|
// you may not use this file except in compliance with the License. You may
|
||||||
@ -22,6 +22,7 @@ import { getResource, setMetadata } from '@hcengineering/platform'
|
|||||||
import preference from '@hcengineering/preference'
|
import preference from '@hcengineering/preference'
|
||||||
import { closeClient, getClient } from '@hcengineering/presentation'
|
import { closeClient, getClient } from '@hcengineering/presentation'
|
||||||
import {
|
import {
|
||||||
|
AnySvelteComponent,
|
||||||
closePanel,
|
closePanel,
|
||||||
fetchMetadataLocalStorage,
|
fetchMetadataLocalStorage,
|
||||||
getCurrentLocation,
|
getCurrentLocation,
|
||||||
@ -205,3 +206,13 @@ export function signOut (): void {
|
|||||||
void closeClient()
|
void closeClient()
|
||||||
navigate({ path: [loginId] })
|
navigate({ path: [loginId] })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getSpacePresenter (
|
||||||
|
client: Client,
|
||||||
|
_class: Ref<Class<Doc>>
|
||||||
|
): Promise<AnySvelteComponent | undefined> {
|
||||||
|
const value = client.getHierarchy().classHierarchyMixin(_class, view.mixin.SpacePresenter)
|
||||||
|
if (value?.presenter !== undefined) {
|
||||||
|
return await getResource(value.presenter)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user