feat(ui): add a desktop panel rail to each sidebar

Each side stack hosts a Vue rail listing its panels; selecting one opens it
through PanelChrome. The shell owns one Vue runtime and Pinia instance, and a
panel store mirrors each side's panels from the DOM. The rail hides with its
stack, in Cockpit, clean view and recording, and on phones. Panels without a
catalog entry get a generic item, and Data Layers leaves the rail while the
f shortcut hides it.
This commit is contained in:
Sameh Khamis committed 2026-10-30 16:41:29 -07:00
1 parent eed7657516
commit 3d5d3ef014
29 files changed
+627 -32

No files matched your search

+57
View File
@@ -0,0 +1,57 @@
import { defineStore } from 'pinia';
import { reactive } from 'vue';
/**
* @typedef {object} RailPanel
* @property {string} id Panel element id.
* @property {string} title The panel's translated title.
* @property {boolean} open Whether the panel is expanded.
* @property {boolean} available Whether the panel is offered (not `hidden`).
*/
const samePanels = (a, b) =>
a.length === b.length &&
a.every(
(panel, index) =>
panel.id === b[index].id &&
panel.title === b[index].title &&
panel.open === b[index].open &&
panel.available === b[index].available,
);
/**
* The desktop side panels as the rails present them. Panel disclosure stays
* with PanelChrome; this store publishes each side's panels in order.
*/
export const usePanelStore = defineStore('gev-panels', () => {
/** @type {{left: RailPanel[], right: RailPanel[]}} */
const sides = reactive({ left: [], right: [] });
/**
* Replace one side's panels, keeping the array when nothing changed.
* @param {'left'|'right'} side Sidebar.
* @param {RailPanel[]} panels Panels in display order.
*/
function setSide(side, panels) {
if (!samePanels(sides[side], panels)) sides[side] = panels;
}
/**
* @param {'left'|'right'} side Sidebar.
* @returns {string|null} The open panel's id.
*/
function openPanelId(side) {
return (
sides[side].find((panel) => panel.open && panel.available)?.id ?? null
);
}
/** @param {string} id Panel id. */
function isOpen(id) {
return [...sides.left, ...sides.right].some(
(panel) => panel.id === id && panel.open,
);
}
return { sides, setSide, openPanelId, isOpen };
});
+27
View File
@@ -0,0 +1,27 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { createPinia } from 'pinia';
import { usePanelStore } from './panels.js';
test('the panel store reports each side’s open panel and keeps unchanged sides', () => {
const store = usePanelStore(createPinia());
const left = [
{ id: 'data-panel', open: false, available: true },
{ id: 'scene-panel', open: true, available: true },
];
store.setSide('left', left);
store.setSide('right', [
{ id: 'weather-panel', open: true, available: false },
]);
assert.equal(store.openPanelId('left'), 'scene-panel');
// An open panel that is not offered is not the side's open panel.
assert.equal(store.openPanelId('right'), null);
assert.equal(store.isOpen('scene-panel'), true);
assert.equal(store.isOpen('data-panel'), false);
const published = store.sides.left;
store.setSide(
'left',
left.map((panel) => ({ ...panel })),
);
assert.equal(store.sides.left, published);
});