Files
windmill/frontend/src/lib/components/hostedPage.ts
T
Diego ImbertandRuben Fiszel ebb3048ca0 feat: mount session list pages in process instead of iframes (#11289)
* feat: mount session list pages in process instead of iframes

* fix: seed filter defaults from the query, not the cached search params

* fix: type trigger list rows from the generated trigger types

* fix: judge hosted lists by the operating workspace's rules and keep role-gated filters

* fix: keep the user folders filter key for every role, hidden where it does not apply

* fix: drop the user folders filter for users it is not offered to

* fix: wait for a known user before dropping the user folders filter

* style: tint trigger rows for every kind and align the schedules footer wording

* fix: stamp edited_at when a schedule is updated

---------

Co-authored-by: Ruben Fiszel <ruben@windmill.dev>
2026-09-24 15:14:59 +02:00

32 lines
1.3 KiB
TypeScript

import { getContext, setContext } from 'svelte'
// A list page mounted somewhere other than its own route — an AI session's preview tab. The
// document URL there belongs to the host, so the page's view (the filters in its query) has to
// live wherever the host keeps it, and its rows and links open where the host decides instead of
// in a drawer or a top-level navigation. Components under such a host read this instead of
// `window.location`; outside one there is none, and they keep to the document.
export type HostedPage = {
/** The page's query, `''` or `?…`. Reactive: the host may re-point it. */
readonly search: string
/** Replace the page's query. */
setSearch(search: string): void
/** Open one of the page's rows, by path. */
openItem(path: string): void
/** Follow an in-app link (base included) the page would otherwise navigate to. */
openLink(href: string): void
}
const KEY = Symbol('hostedPage')
/** Reads context: call during component initialisation. */
export function setHostedPage(host: HostedPage): void {
setContext(KEY, host)
}
/** The host of this page, or undefined on the page's own route. Reads context: call during
* component initialisation. */
export function useHostedPage(): HostedPage | undefined {
return getContext<HostedPage | undefined>(KEY)
}