feat(panels): render each panel's state classes from the store

A panel's collapsed, dock-pinned, dock-pinned-top, layout-auto-collapsed
and accordion-collapsed classes are drawn by its root's v-panel-state from
the gev-panel-chrome store. PanelChrome, its restore, the layout
controller, both rails and the side accordion present each panel's state
there instead of writing its classes; the rails call onCollapse(panel,
{collapsed, auto}). The directive applies a change in a synchronous
watcher, since the rails measure a panel in the task that opens or closes
it.

Destroying the chrome inside Cockpit now puts back the panels Cockpit's
entry closed while it can still present them. Without a shell, the voice
tools' set_panel_open reports that there is no panel to open. QA scripts
present the states they set instead of writing the classes.
This commit is contained in:
Sameh Khamis committed 2026-10-31 23:51:47 -07:00
1 parent dd3a2c87f9
commit 95523e09cd
37 files changed
+404 -135

No files matched your search

+29 -13
View File
@@ -8,15 +8,35 @@ import { shallowRef } from 'vue';
*/
/**
* Each panel's disclosure state as its collapse, dock and pin buttons render
* it. PanelChrome owns the panels: it publishes here whenever a panel opens,
* closes or is pinned, and connects the buttons' clicks; the views only render
* and forward clicks.
* @typedef {object} PanelState
* @property {boolean} collapsed Whether the panel is closed, by the person or
* by its layout.
* @property {boolean} pinned A dock tray kept open (`dock-pinned`).
* @property {boolean} pinnedTop The pinned tray drawn on top.
* @property {?('layout'|'accordion')} auto Why a layout closed the panel
* (`layout-auto-collapsed`, `accordion-collapsed`), or null when the
* person's own choice stands.
*/
/** A panel's state before its owner has said otherwise. */
const BLANK = Object.freeze({
collapsed: false,
pinned: false,
pinnedTop: false,
auto: null,
});
/**
* Each panel's disclosure state, which its root (`vPanelState`) and its
* collapse, dock and pin buttons render. PanelChrome owns the panels: it and
* the layouts it runs publish here whenever a panel opens, closes or is
* pinned, and it connects the buttons' clicks; the views only render and
* forward clicks.
*/
export const usePanelChromeStore = defineStore('gev-panel-chrome', () => {
/**
* `{[panelId]: {collapsed, pinned}}`, frozen; a panel is absent until its
* owner first presents it, and its buttons keep their markup until then.
* `{[panelId]: PanelState}`, frozen; a panel is absent until its owner
* first presents it, and it keeps its markup's classes until then.
*/
const panels = shallowRef(Object.freeze({}));
/** @type {{handlers: PanelChromeHandlers}|null} */
@@ -44,17 +64,13 @@ export const usePanelChromeStore = defineStore('gev-panel-chrome', () => {
* unchanged state is not republished.
* @param {object} token
* @param {string} panelId
* @param {{collapsed?: boolean, pinned?: boolean}} patch
* @param {Partial<PanelState>} patch
*/
function publish(token, panelId, patch) {
if (!owns(token) || !panelId) return;
const prior = panels.value[panelId];
const next = { collapsed: false, pinned: false, ...prior, ...patch };
if (
prior &&
prior.collapsed === next.collapsed &&
prior.pinned === next.pinned
)
const next = { ...BLANK, ...prior, ...patch };
if (prior && Object.keys(BLANK).every((key) => prior[key] === next[key]))
return;
panels.value = Object.freeze({
...panels.value,