Skip to content

Commit fafcfbe

Browse files
committed
fix(hub-ui): show the built-in Settings dock by default
The Settings view was ported but its dock entry only appeared when a host registered ~settings server-side. hub-ui, as the reference viewer, now owns the ~settings ~builtin dock and injects it into its entries when absent, so Settings is visible in the dock bar and reachable via devframes:open-settings in every consumer. A host that registers its own ~settings still wins the merge, so no duplicate appears.
1 parent e19d38a commit fafcfbe

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 } 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'
@@ -36,20 +36,32 @@ export async function createDocksContext(
3636
const clientDocks = reactive(new Map<string, DevframeDockEntry>())
3737
const entries = computed<DevframeDockEntry[]>(() => {
3838
const server = dockEntries.value
39-
if (clientDocks.size === 0)
40-
return server
41-
const seen = new Set<string>()
42-
const merged: DevframeDockEntry[] = []
43-
for (const entry of server) {
44-
seen.add(entry.id)
45-
// a client dock sharing a server id overrides it in the local merge
46-
merged.push(clientDocks.get(entry.id) ?? entry)
39+
let base: DevframeDockEntry[]
40+
if (clientDocks.size === 0) {
41+
base = server
4742
}
48-
for (const [id, entry] of clientDocks) {
49-
if (!seen.has(id))
50-
merged.push(entry)
43+
else {
44+
const seen = new Set<string>()
45+
const merged: DevframeDockEntry[] = []
46+
for (const entry of server) {
47+
seen.add(entry.id)
48+
// a client dock sharing a server id overrides it in the local merge
49+
merged.push(clientDocks.get(entry.id) ?? entry)
50+
}
51+
for (const [id, entry] of clientDocks) {
52+
if (!seen.has(id))
53+
merged.push(entry)
54+
}
55+
base = merged
5156
}
52-
return merged
57+
// Surface the viewer's own built-in Settings tab by default. hub-ui owns it
58+
// rather than depending on a host to register `~settings` server-side, so
59+
// Settings is always reachable (dock bar + `devframes:open-settings`). A host
60+
// that registered its own `~settings` entry wins — we only add ours when the
61+
// merged list has none.
62+
if (base.some(entry => entry.id === BUILTIN_ENTRY_SETTINGS.id))
63+
return base
64+
return [...base, BUILTIN_ENTRY_SETTINGS]
5365
})
5466

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

0 commit comments

Comments
 (0)