Skip to content

Commit 78470d2

Browse files
authored
fix(hub-ui): show the built-in Settings dock by default (#198)
1 parent 369cb55 commit 78470d2

2 files changed

Lines changed: 43 additions & 13 deletions

File tree

‎packages/hub-ui/src/client/constants.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,26 @@ export const BUILTIN_ENTRY_CLIENT_AUTH_NOTICE: DevframeViewBuiltin = Object.free
3838
icon: 'ph:warning-duotone',
3939
})
4040

41+
/**
42+
* The viewer's own Settings view. hub-ui owns this `~builtin` dock rather than
43+
* leaning on a host to register it server-side — so the Settings tab is visible
44+
* by default in every consumer of the reference UI (the standalone viewer and
45+
* the embedded dock alike). A `~builtin` view defaults its category to
46+
* `~builtin`, so it groups and sorts last on the bar. A host that registers its
47+
* own `~settings` dock (node-side, into `devframe:docks`) still wins the merge;
48+
* this entry only fills the gap when none is present.
49+
*/
50+
export const BUILTIN_ENTRY_SETTINGS: DevframeViewBuiltin = Object.freeze({
51+
type: '~builtin',
52+
category: '~builtin',
53+
id: '~settings',
54+
title: 'Settings',
55+
icon: 'ph:gear-duotone',
56+
})
57+
4158
export const BUILTIN_ENTRIES: readonly DevframeViewBuiltin[] = Object.freeze([
4259
BUILTIN_ENTRY_CLIENT_AUTH_NOTICE,
60+
BUILTIN_ENTRY_SETTINGS,
4361
])
4462

4563
export { DEFAULT_CATEGORIES_ORDER } from '@devframes/hub/constants'

‎packages/hub-ui/src/client/state/context.ts‎

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { HubDocksUserSettings } from './dock-settings'
77
import { attachFrameNavClient } from '@devframes/hub/client'
88
import { DEFAULT_STATE_USER_SETTINGS, DOCK_RENDERERS_STATE_KEY } from '@devframes/hub/constants'
99
import { computed, markRaw, reactive, ref, toRefs, watch, watchEffect } from 'vue'
10-
import { BUILTIN_ENTRIES, HUB_UI_HIDE_EVENT } from '../constants'
10+
import { BUILTIN_ENTRIES, BUILTIN_ENTRY_SETTINGS, HUB_UI_HIDE_EVENT } from '../constants'
1111
import { useBranding } from './branding'
1212
import { createCommandsContext } from './commands'
1313
import { docksGroupByCategories, getCategoryLabel, getGroupMembers, getGroupMembersGrouped, getRegisteredGroupIds, resolveCommandIcon, resolveGroupDefaultChild } from './dock-settings'
@@ -45,20 +45,32 @@ export async function createDocksContext(
4545
const clientDocks = reactive(new Map<string, DevframeDockEntry>())
4646
const entries = computed<DevframeDockEntry[]>(() => {
4747
const server = dockEntries.value
48-
if (clientDocks.size === 0)
49-
return server
50-
const seen = new Set<string>()
51-
const merged: DevframeDockEntry[] = []
52-
for (const entry of server) {
53-
seen.add(entry.id)
54-
// a client dock sharing a server id overrides it in the local merge
55-
merged.push(clientDocks.get(entry.id) ?? entry)
48+
let base: DevframeDockEntry[]
49+
if (clientDocks.size === 0) {
50+
base = server
5651
}
57-
for (const [id, entry] of clientDocks) {
58-
if (!seen.has(id))
59-
merged.push(entry)
52+
else {
53+
const seen = new Set<string>()
54+
const merged: DevframeDockEntry[] = []
55+
for (const entry of server) {
56+
seen.add(entry.id)
57+
// a client dock sharing a server id overrides it in the local merge
58+
merged.push(clientDocks.get(entry.id) ?? entry)
59+
}
60+
for (const [id, entry] of clientDocks) {
61+
if (!seen.has(id))
62+
merged.push(entry)
63+
}
64+
base = merged
6065
}
61-
return merged
66+
// Surface the viewer's own built-in Settings tab by default. hub-ui owns it
67+
// rather than depending on a host to register `~settings` server-side, so
68+
// Settings is always reachable (dock bar + `devframes:open-settings`). A host
69+
// that registered its own `~settings` entry wins — we only add ours when the
70+
// merged list has none.
71+
if (base.some(entry => entry.id === BUILTIN_ENTRY_SETTINGS.id))
72+
return base
73+
return [...base, BUILTIN_ENTRY_SETTINGS]
6274
})
6375

6476
const selectedId = ref<string | null>(null)

0 commit comments

Comments
 (0)