Files
gods-eye-view/src/rightRailPolicy.js
T
Sameh Khamis 2035c767ce feat(ui): keep one side panel open per desktop sidebar in every HUD layout
The Cyber accordion now applies to both sidebars and every HUD layout:
opening a side panel collapses its peers, the layout normalizes restored
state to one owner, and collapsed panels are hidden on desktop. Phones keep
showing several panels per sheet.
2026-10-30 16:28:08 -07:00

36 lines
1.3 KiB
JavaScript

const GLOBAL_CONTEXT_EXPLICIT_ACTIONS = new Set([
'contacts',
'space-missions',
'cockpit',
]);
/**
* Decide whether a completed action should reveal the Global Context panel.
* Expansion belongs only to an explicit, successful owner action. Restoring a
* session or replaying saved state must preserve the saved collapsed state,
* and a failed transition must leave the prior panel state untouched.
*
* Whether an aircraft is already selected is deliberately irrelevant: an
* explicit Cockpit action still reveals the context that supports that track.
*
* @param {object} input Action outcome and coordination state.
* @param {'contacts'|'space-missions'|'cockpit'|string} input.action Completed action.
* @param {boolean} input.explicitUserAction Whether the user directly requested it.
* @param {boolean} input.succeeded Whether the requested transition completed.
* @param {boolean} [input.restoring=false] Whether saved/session state is being restored.
* @returns {boolean} Whether Global Context should be expanded.
*/
export function shouldExpandGlobalContextPanel({
action,
explicitUserAction,
succeeded,
restoring = false,
}) {
return Boolean(
GLOBAL_CONTEXT_EXPLICIT_ACTIONS.has(action) &&
explicitUserAction &&
succeeded &&
!restoring,
);
}