|
1 | 1 | <script setup lang="ts"> |
2 | 2 | import type { DocksContext } from '@devframes/hub/client' |
3 | | -import { computed, useTemplateRef, watch } from 'vue' |
4 | | -import { t } from '../../i18n' |
5 | | -import { getEntryGroup } from '../../state/dock-settings' |
6 | | -import { getEntryPaneKey, useIframePanes } from '../../utils/useIframePanes' |
7 | | -import { useIsRpcTrusted } from '../../utils/useIsRpcTrusted' |
8 | | -import CommandPalette from '../command-palette/CommandPalette.vue' |
9 | | -import Confirm from '../display/Confirm.vue' |
10 | | -import ToastOverlay from '../display/ToastOverlay.vue' |
11 | | -import FloatingElements from '../floating/FloatingElements.vue' |
12 | | -import BrandMark from '../icons/BrandMark.vue' |
13 | | -import ViewBuiltinClientAuthNotice from '../views-builtin/ViewBuiltinClientAuthNotice.vue' |
14 | | -import ViewEntry from '../views/ViewEntry.vue' |
15 | | -import ColorSchemeRoot from './ColorSchemeRoot.vue' |
16 | | -import DockEntriesWithCategories from './DockEntriesWithCategories.vue' |
17 | | -import DockGroupSidebar from './DockGroupSidebar.vue' |
| 3 | +import { ref, watch } from 'vue' |
| 4 | +import DockStandaloneShell from './DockStandaloneShell.vue' |
18 | 5 |
|
19 | | -const props = defineProps<{ |
20 | | - context: DocksContext |
21 | | -}>() |
| 6 | +const props = defineProps<{ context: DocksContext }>() |
22 | 7 |
|
23 | | -const context = props.context |
24 | | -const viewsContainer = useTemplateRef<HTMLElement>('viewsContainer') |
25 | | -const panes = useIframePanes(viewsContainer, context.panel, () => getEntryPaneKey(context.docks.selected)) |
26 | | -
|
27 | | -const isRpcTrusted = useIsRpcTrusted(context, (isTrusted) => { |
28 | | - if (!isTrusted) { |
29 | | - context.docks.switchEntry(null) |
30 | | - } |
31 | | -}) |
32 | | -
|
33 | | -/** Select from the visible dock rail through normal activation, including client scripts and group routing. */ |
34 | | -watch( |
35 | | - [ |
36 | | - () => context.docks.groupedEntries, |
37 | | - isRpcTrusted, |
38 | | - ], |
39 | | - ([groups, trusted]) => { |
40 | | - if (!trusted || context.docks.selectedId) |
41 | | - return |
42 | | - const entry = groups.flatMap(([, entries]) => entries) |
43 | | - .find(entry => entry.type !== 'action' && entry.type !== '~builtin') |
44 | | - if (entry) |
45 | | - void context.docks.switchEntry(entry.id) |
46 | | - }, |
47 | | - { immediate: true }, |
48 | | -) |
49 | | -
|
50 | | -const groupedEntries = computed(() => context.docks.groupedEntries) |
51 | | -const activeGroup = computed(() => getEntryGroup(context.docks.entries, context.docks.selected)) |
52 | | -
|
53 | | -function switchEntry(id: string | undefined) { |
54 | | - if (id) { |
55 | | - context.docks.switchEntry(id) |
56 | | - } |
57 | | -} |
| 8 | +// Panes and trust subscriptions belong to the context that created them. |
| 9 | +const shellKey = ref(0) |
| 10 | +watch(() => props.context, () => shellKey.value++) |
58 | 11 | </script> |
59 | 12 |
|
60 | 13 | <template> |
61 | | - <ColorSchemeRoot> |
62 | | - <main v-if="!isRpcTrusted" class="h-screen w-screen of-hidden"> |
63 | | - <ViewBuiltinClientAuthNotice :context="context" /> |
64 | | - </main> |
65 | | - <div v-else class="h-screen w-screen of-clip grid cols-[max-content_1fr]"> |
66 | | - <nav :aria-label="t('settings.docks')" class="border-r border-base flex flex-col min-h-0"> |
67 | | - <div class="p2 border-b border-base flex"> |
68 | | - <BrandMark class="w-7 h-7 ma" /> |
69 | | - </div> |
70 | | - <div class="transition duration-200 p2 of-y-auto"> |
71 | | - <DockEntriesWithCategories |
72 | | - :context="context" |
73 | | - :groups="groupedEntries" |
74 | | - :is-vertical="false" |
75 | | - :selected="context.docks.selected" |
76 | | - :dim-inactive="false" |
77 | | - @select="(e) => switchEntry(e?.id)" |
78 | | - > |
79 | | - <template #separator> |
80 | | - <div class="border-base border-b w-full my-2" /> |
81 | | - </template> |
82 | | - </DockEntriesWithCategories> |
83 | | - </div> |
84 | | - </nav> |
85 | | - <main class="min-h-0 flex"> |
86 | | - <DockGroupSidebar |
87 | | - v-if="activeGroup" |
88 | | - :context |
89 | | - :group="activeGroup" |
90 | | - :selected-id="context.docks.selected?.id ?? null" |
91 | | - /> |
92 | | - <div class="relative flex-1 min-w-0 min-h-0 of-clip"> |
93 | | - <ViewEntry |
94 | | - v-if="context.docks.selected && panes" |
95 | | - :key="context.docks.selected.id" |
96 | | - :entry="context.docks.selected" |
97 | | - :context |
98 | | - :panes="panes" |
99 | | - /> |
100 | | - <div id="devframes-views-container" ref="viewsContainer" class="pointer-events-auto" /> |
101 | | - </div> |
102 | | - </main> |
103 | | - </div> |
104 | | - <FloatingElements /> |
105 | | - <CommandPalette :context /> |
106 | | - <ToastOverlay :context="props.context" /> |
107 | | - <Confirm /> |
108 | | - </ColorSchemeRoot> |
| 14 | + <DockStandaloneShell :key="shellKey" :context /> |
109 | 15 | </template> |
0 commit comments