Skip to content

Commit e478041

Browse files
BykhovDenisArtyomSavchenko
authored andcommitted
Return spaces to card navigator (#10243)
* Return spaces to card navigator Signed-off-by: Denis Bykhov <[email protected]> * Fix formatting Signed-off-by: Denis Bykhov <[email protected]> --------- Signed-off-by: Denis Bykhov <[email protected]>
1 parent 89fbb96 commit e478041

File tree

6 files changed

+41
-30
lines changed

6 files changed

+41
-30
lines changed

models/card/src/index.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ export function createModel (builder: Builder): void {
472472
_class: card.class.Card,
473473
icon: card.icon.All,
474474
label: card.string.AllCards,
475-
defaultViewletDescriptor: card.viewlet.CardFeedDescriptor
475+
defaultViewletDescriptor: view.viewlet.Table
476476
},
477477
position: 'top'
478478
},
@@ -491,7 +491,17 @@ export function createModel (builder: Builder): void {
491491
position: 'top'
492492
}
493493
],
494-
spaces: [],
494+
spaces: [
495+
{
496+
id: 'spaces',
497+
label: core.string.Spaces,
498+
spaceClass: card.class.CardSpace,
499+
addSpaceLabel: core.string.Space,
500+
icon: card.icon.Space,
501+
// intentionally left empty in order to make space presenter working
502+
specials: []
503+
}
504+
],
495505
groups: [
496506
{
497507
id: 'types',
@@ -503,14 +513,12 @@ export function createModel (builder: Builder): void {
503513
{
504514
id: 'type',
505515
label: card.string.Cards,
506-
component: card.component.Main,
507-
componentProps: {
508-
defaultViewletDescriptor: card.viewlet.CardFeedDescriptor
509-
}
516+
component: card.component.Main
510517
}
511518
]
512519
}
513-
]
520+
],
521+
hideStarred: true
514522
},
515523
navHeaderActions: card.component.CardHeaderButton
516524
},

plugins/card-resources/src/components/Favorites.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,5 @@
2626
_class={card.class.FavoriteCard}
2727
icon={view.icon.Star}
2828
label={preference.string.Starred}
29-
defaultViewletDescriptor={view.viewlet.List}
3029
baseQuery={{ application }}
3130
/>

plugins/card-resources/src/components/Main.svelte

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
-->
1515
<script lang="ts">
1616
import { MasterTag } from '@hcengineering/card'
17-
import { Class, Doc, Ref } from '@hcengineering/core'
17+
import { Class, Doc, Ref, Space } from '@hcengineering/core'
1818
import { IntlString } from '@hcengineering/platform'
1919
import { createQuery } from '@hcengineering/presentation'
2020
import { location } from '@hcengineering/ui'
@@ -23,11 +23,12 @@
2323
import card from '../plugin'
2424
2525
let _class: Ref<Class<Doc>> | undefined
26+
let space: Ref<Space> | undefined
2627
2728
onDestroy(
2829
location.subscribe((loc) => {
29-
const isTypeSpecified = loc.path[3] === 'type'
30-
_class = isTypeSpecified ? loc.path[4] : card.class.Card
30+
space = loc.path[3] === 'type' ? undefined : loc.path[3]
31+
_class = loc.path[4]
3132
})
3233
)
3334
@@ -38,7 +39,7 @@
3839
allClasses = res.filter((it) => it.removed !== true)
3940
})
4041
41-
$: clazz = allClasses.find((it) => it._id === _class)
42+
$: clazz = allClasses.find((it) => it._id === _class) ?? allClasses.find((it) => it._id === card.class.Card)
4243
4344
$: label = getLabel(clazz)
4445
@@ -50,8 +51,9 @@
5051
{#if clazz !== undefined && label !== undefined}
5152
<SpecialView
5253
_class={clazz._id}
53-
defaultViewletDescriptor={card.viewlet.CardFeedDescriptor}
54+
baseQuery={space !== undefined ? { space } : {}}
55+
{space}
5456
{label}
55-
icon={card.icon.Card}
57+
icon={clazz.icon ?? card.icon.Card}
5658
/>
5759
{/if}

plugins/card-resources/src/components/navigator/TypesNavigator.svelte

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
-->
1515
<script lang="ts">
1616
import { FavoriteType, MasterTag } from '@hcengineering/card'
17-
import core, { Class, Doc, getCurrentAccount, Ref } from '@hcengineering/core'
17+
import core, { Class, Doc, getCurrentAccount, Ref, Space } from '@hcengineering/core'
1818
import preference from '@hcengineering/preference'
1919
import { createQuery, getClient } from '@hcengineering/presentation'
2020
import { Action, getCurrentLocation, location as locationStore, navigate } from '@hcengineering/ui'
@@ -25,6 +25,7 @@
2525
import TagHierarchy from './TagHierarchy.svelte'
2626
2727
export let model: GroupsNavModel
28+
export let currentSpace: Ref<Space> | undefined
2829
2930
let classes: MasterTag[] = []
3031
let _class: Ref<Class<Doc>> | undefined
@@ -116,7 +117,7 @@
116117
$: empty = rootClasses === undefined || rootClasses.length === 0
117118
</script>
118119

119-
<div class="flex-col w-full">
120+
<div class="flex-col w-full flex-no-shrink">
120121
{#if favoriteRootClasses.length > 0}
121122
<TreeNode
122123
_id={'tree-favorites-' + model.id}
@@ -130,7 +131,7 @@
130131
allClasses={classes}
131132
{_class}
132133
space={undefined}
133-
currentSpace={undefined}
134+
{currentSpace}
134135
{getItemActions}
135136
on:select={(e) => {
136137
selectType(e.detail)
@@ -152,7 +153,7 @@
152153
allClasses={classes}
153154
{_class}
154155
space={undefined}
155-
currentSpace={undefined}
156+
{currentSpace}
156157
{getItemActions}
157158
excludedClasses={favoriteTypes}
158159
on:select={(e) => {

plugins/workbench-resources/src/components/Navigator.svelte

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@
8181
8282
let requestIndex = 0
8383
async function update (model: NavigatorModel, spaces: Space[], preferences: Map<Ref<Doc>, SpacePreference>) {
84-
shownSpaces = spaces.filter((sp) => !sp.archived && !preferences.has(sp._id))
85-
starred = spaces.filter((sp) => preferences.has(sp._id))
84+
shownSpaces = spaces.filter((sp) => !sp.archived && (model.hideStarred || !preferences.has(sp._id)))
85+
starred = model.hideStarred ? [] : spaces.filter((sp) => preferences.has(sp._id))
8686
if (model.specials !== undefined) {
8787
const [sp, resIndex] = await updateSpecials(model.specials, spaces, ++requestIndex)
8888
if (resIndex !== requestIndex) return
@@ -173,7 +173,7 @@
173173
<div class="min-h-3 flex-no-shrink" />
174174

175175
<SavedView alias={currentApplication?.alias} on:select={(res) => (menuSelection = res.detail)} />
176-
{#if starred.length}
176+
{#if starred.length > 0 && !model.hideStarred}
177177
<StarredNav
178178
label={preference.string.Starred}
179179
spaces={starred}
@@ -186,6 +186,15 @@
186186
/>
187187
{/if}
188188

189+
{#if model.groups && model.groups.length > 0}
190+
<div class="min-h-3 flex-no-shrink" />
191+
{#each model.groups as group (group.id)}
192+
{#if group.component}
193+
<Component is={group.component} props={{ model: group, currentSpace }} />
194+
{/if}
195+
{/each}
196+
{/if}
197+
189198
{#each model.spaces as m (m.label)}
190199
<SpacesNav
191200
spaces={shownSpaces.filter((it) => hierarchy.isDerived(it._class, m.spaceClass))}
@@ -198,14 +207,5 @@
198207
deselect={menuSelection || starred.some((s) => s._id === currentSpace)}
199208
/>
200209
{/each}
201-
202-
{#if model.groups && model.groups.length > 0}
203-
<div class="min-h-3 flex-no-shrink" />
204-
{#each model.groups as group (group.id)}
205-
{#if group.component}
206-
<Component is={group.component} props={{ model: group }} />
207-
{/if}
208-
{/each}
209-
{/if}
210210
</Scroller>
211211
{/if}

plugins/workbench/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ export interface NavigatorModel {
159159
spaces: SpacesNavModel[]
160160
specials?: SpecialNavModel[]
161161
groups?: GroupsNavModel[]
162+
hideStarred?: boolean
162163
}
163164

164165
/** @public */

0 commit comments

Comments
 (0)