Skip to content

Commit 52e8ea3

Browse files
committed
refactor(hub): simplify iframe address bar options
1 parent 719b6ed commit 52e8ea3

4 files changed

Lines changed: 10 additions & 12 deletions

File tree

docs/content/8.references/6.hub-api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ The built-in variants of the open dock union (`DevframeDockEntryRegistry`, `@dev
137137

138138
| Type | The hub UI provider renders |
139139
|---|---|
140-
| `iframe` | the entry's `url` in a kept-alive iframe (per `frameId` when shared); honor `subTabs` soft nav; force the existing address bar with `showAddressBar`; override Back, Reload, and Open externally visibility with `controls.back`, `controls.reload`, and `controls.openExternal` |
140+
| `iframe` | the entry's `url` in a kept-alive iframe (per `frameId` when shared); honor `subTabs` soft nav; show the existing address bar with `addressBar: true`, or configure Back, Reload, and Open externally by passing an `addressBar` object |
141141
| `action` | a dock-rail button; activating runs its client script |
142142
| `custom-render` | a container its client script mounts into |
143143
| `launcher` | a launch call-to-action reflecting `launcher.status` |

packages/hub-ui/src/client/components/views/ViewIframe.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ const props = defineProps<{
2020
2121
const settings = useSettings(props.context)
2222
const isEdgeMode = computed(() => props.context.panel.store.mode === 'edge')
23-
const showAddressBar = computed(() => settings.value.showIframeAddressBar || props.entry.showAddressBar === true)
23+
const addressBarControls = computed(() => typeof props.entry.addressBar === 'object' ? props.entry.addressBar : undefined)
24+
const showAddressBar = computed(() => settings.value.showIframeAddressBar || Boolean(props.entry.addressBar))
2425
2526
const ADDRESS_BAR_HEIGHT = 40
2627
@@ -83,9 +84,9 @@ const isCrossOrigin = computed(() => {
8384
return true // Assume cross-origin if URL parsing fails
8485
}
8586
})
86-
const showBack = computed(() => props.entry.controls?.back ?? !isCrossOrigin.value)
87-
const showReload = computed(() => props.entry.controls?.reload ?? !isCrossOrigin.value)
88-
const showOpenExternal = computed(() => props.entry.controls?.openExternal ?? false)
87+
const showBack = computed(() => addressBarControls.value?.back ?? !isCrossOrigin.value)
88+
const showReload = computed(() => addressBarControls.value?.reload ?? !isCrossOrigin.value)
89+
const showOpenExternal = computed(() => addressBarControls.value?.openExternal ?? false)
8990
9091
// Display URL - hides host if same as current page. The remote connection
9192
// descriptor is stripped so its auth token can't be read (or copied) out of the

packages/hub/src/types/docks.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,13 @@ declare module 'devframe/types' {
203203
export interface DevframeViewIframe extends DevframeDockEntryBase {
204204
type: 'iframe'
205205
url: string
206-
/** Request the address bar for this iframe dock. The user's global always-show setting forces it on for every iframe. */
207-
showAddressBar?: boolean
208-
/** Optional address-bar controls. Omitted values retain the existing origin-based behavior. */
209-
controls?: {
206+
/** Request the address bar for this iframe dock. Pass an object to configure its controls. The user's global always-show setting forces it on for every iframe. */
207+
addressBar?: boolean | {
210208
/** Override Back visibility. Cross-origin history access may still be blocked by the browser. */
211209
back?: boolean
212210
/** Override Reload visibility. */
213211
reload?: boolean
214-
/** Override the built-in action that opens the displayed HTTP(S) URL in a new tab. */
212+
/** Override Open externally visibility. */
215213
openExternal?: boolean
216214
}
217215
/**

tests/__snapshots__/tsnapi/@devframes/hub/index.snapshot.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,7 @@ export interface DevframeViewGroup extends DevframeDockEntryBase {
293293
export interface DevframeViewIframe extends DevframeDockEntryBase {
294294
type: 'iframe';
295295
url: string;
296-
showAddressBar?: boolean;
297-
controls?: {
296+
addressBar?: boolean | {
298297
back?: boolean;
299298
reload?: boolean;
300299
openExternal?: boolean;

0 commit comments

Comments
 (0)