/** * P1EditorHeader * * Top chrome bar for the PDS v2 editor theme. * Renders: P1 branding, site label, WorkstreamSwitcher, page selector button, * collaborator presence, Zappy toggle, and the user avatar with account menu. */ import React from 'react'; import type { ActorPresence, Branch, DocumentLiveState } from '@pantheon-systems/css-client'; import type { Template, TemplateSummary } from '../../features/content-type-templates/types.js'; import type { WorkstreamSwitcherHandle } from './WorkstreamSwitcher.js'; import type { PageNavigatorDocument } from './PageNavigator.js'; import type { LocaleFieldOption } from './LocaleField.js'; export type { PageNavigatorDocument }; export declare const BEFORE_NAVIGATE_TIMEOUT_MS = 8000; export interface CurrentUser { id: string; name?: string; email?: string; avatar?: string; } export interface SiteMenuItem { label: string; iconName?: string; callback: () => void; } export interface P1EditorHeaderProps { documents: PageNavigatorDocument[]; currentDocument: PageNavigatorDocument | null; selectedDocumentPath?: string | null; currentUser?: CurrentUser; collaborators?: ActorPresence[]; siteName: string; siteId?: string; dashboardUrl?: string; /** Custom logo image URL. When provided, replaces the default PantheonLogo. */ logoUrl?: string; /** Called (and awaited) before the logo link navigates — use to flush pending saves. */ onBeforeLogoNavigate?: () => Promise; onSelectDocument: (doc: PageNavigatorDocument) => void; onCreateDocument?: (path: string, template?: TemplateSummary | null, title?: string, locale?: string) => Promise; onGenerateWithAI?: (brief: string, page: { path: string; title: string; }) => void; isPathTaken?: (path: string) => Promise; onLogout: () => void | Promise; /** * Set when a logout attempt failed. Rendered in the header rather than the * user menu, which closes on click before the attempt resolves. */ logoutError?: string | null; /** True while a logout is in flight; disables the menu item. */ isLoggingOut?: boolean; templates?: TemplateSummary[]; templatesLoading?: boolean; /** Data sources (built-in + user) for the modal's collection builder. */ datasources?: { id: string; label: string; inputs?: string[]; }[]; /** Show the Zappy AI Assistant toggle. Pass the same flag that gates the chat plugin. */ showAIPanelToggle?: boolean; /** * Whether the right rail (inspector panel) is currently visible. Zappy only counts as * showing when the AI panel is open *and* this is true — Puck doesn't mount the panel's * `fields` override at all while the rail is collapsed. Omit outside Puck, where there is * no rail to hide; the toggle then treats the rail as always visible. */ rightRailVisible?: boolean; /** * Reveal the right rail. Called when opening Zappy (via the toggle or "Generate with AI") * while the rail is collapsed, so the panel that's about to open is actually visible. */ onRevealRail?: () => void; /** Branches to show in the workstream switcher. When omitted the switcher is hidden. */ branches?: Branch[]; /** The branch currently open in the editor. */ currentBranch?: Branch | null; /** Called when the user switches to a different branch in the switcher. */ onSwitchBranch?: (branchId: string) => void; /** Called with the name entered in the switcher's "New workstream" form. */ onCreateWorkstream?: (name: string) => void | Promise; /** Lets another control open the switcher's "New workstream" form. */ workstreamSwitcherRef?: React.Ref; /** * Called every time the workstream switcher dropdown opens. Wire this to a * branch-list refetch so workstreams created elsewhere — another tab, the * dashboard, or an API call — show up without a page refresh. */ onOpenWorkstreamSwitcher?: () => void; /** Create a new template from the modal's "New template" flow. */ onCreateTemplate?: (params: { name: string; label: string; description?: string; defaultUrlPattern?: string; }) => Promise