Display statuses editor only for spaces with statuess (#582)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2021-12-08 16:05:19 +07:00 committed by GitHub
parent 983096dbf1
commit 21b2d3e2bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,6 +18,7 @@
import type { Asset, IntlString } from '@anticrm/platform'
import type { Ref, Space, Doc } from '@anticrm/core'
import core from '@anticrm/core'
import type { SpacesNavModel } from '@anticrm/workbench'
import { Action, navigate, getCurrentLocation, location, IconAdd, IconMoreH, IconEdit } from '@anticrm/ui'
@ -65,7 +66,8 @@
}
}
function selectSpace(id: Ref<Space>) {
function selectSpace (id: Ref<Space>) {
const loc = getCurrentLocation()
loc.path[2] = id
loc.path.length = 3
@ -75,12 +77,20 @@
onDestroy(location.subscribe(async (loc) => {
selected = loc.path[2] as Ref<Space>
}))
function getActions (space: Space): Action[] {
const result = [editSpace]
if (client.getHierarchy().isDerived(space._class, core.class.SpaceWithStates)) {
result.push(editStatuses)
}
return result
}
</script>
<div>
<TreeNode label={model.label} actions={[addSpace]}>
{#each spaces as space}
<TreeItem _id={space._id} title={space.name} icon={classIcon(client, space._class)} selected={selected === space._id} actions={[editSpace, editStatuses]} on:click={() => { selectSpace(space._id) }}/>
<TreeItem _id={space._id} title={space.name} icon={classIcon(client, space._class)} selected={selected === space._id} actions={getActions(space)} on:click={() => { selectSpace(space._id) }}/>
{/each}
</TreeNode>
</div>