mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 01:32:19 +00:00
Make Space Missions an ordinary layer with its own panel
Space Missions no longer runs as a Context mode. The launches layer owns its Satellites dependency, including the rule that a Satellites off asked for after Space Missions was switched on ends it (request order decides), and a small controller connects the layer to its own panel and store. Context no longer isolates, snapshots or restores Space Missions or Satellites, so Contacts and Space Missions run together in either order, and scene playback no longer exits an isolating mode. Settled by the owner: Contacts leaves Satellites as it is, and only a person's or voice Satellites off ends Space Missions; a scene, story, preset or other programmatic off does not. Turning the layer on by hand or by voice, choosing it at first run, or picking a mission on the globe opens the Space Missions panel, and on a phone its Missions sheet. Asking voice to open the panel while the layer is off is refused with a reason, and voice never opens it while the Cockpit owns the screen. With no Context mode on, a voice Context off switches Space Missions off. A failed Satellites restore no longer cuts the layer's teardown short. Mission labels on the globe select their mission. The layer names a failed first index load itself, so the Context toast no longer imports Space Missions code. Also carries the satellites request ordering and DataLayerManager.waitForLayerIdle, the share token for the panel, voice panel ids, Cockpit folding the panel away and the phone tab ellipsis. The panel shares the rail gutters and hover border of the other side panels. On top of the Omnibar: "open space missions panel" reaches the new panel, and Open Context no longer answers to "missions". Co-authored-by: Sameh Khamis <[email protected]>
This commit is contained in:
1 parent
8b2ca602e5
commit
0a6fd5f43f
101 files changed
+2885
-1673
No files matched your search
+25
-17
@@ -62,6 +62,8 @@ import { applyLocaleChoice } from './localePicker.js';
|
||||
import { PanelNavigation } from './panelNavigation.js';
|
||||
import { applicationPinia, createUiRuntime } from './vueRuntime.js';
|
||||
import { useContextStore } from './stores/context.js';
|
||||
import { useSpaceMissionsStore } from './stores/spaceMissions.js';
|
||||
import { SpaceMissionsControls } from './spaceMissionsControls.js';
|
||||
import { useMissionReplayStore } from './stores/missionReplay.js';
|
||||
import { useCelestialRingStore } from './stores/celestialRing.js';
|
||||
import { icrfToFixedAxes } from '../sky/icrf.js';
|
||||
@@ -326,6 +328,7 @@ export class StyleManager extends ShellFacade {
|
||||
readControls: () => ({
|
||||
hud: this.hud,
|
||||
_contextControls: this._contextControls,
|
||||
_spaceMissionsControls: this._spaceMissionsControls,
|
||||
_cctvControls: this._cctvControls,
|
||||
_radioControls: this._radioControls,
|
||||
_streetLevelControls: this._streetLevelControls,
|
||||
@@ -689,6 +692,7 @@ export class StyleManager extends ShellFacade {
|
||||
this._initStreetLevelPanel();
|
||||
this._initWildlifeSightingCard();
|
||||
this._initGlobalContextPanel();
|
||||
this._initSpaceMissionsPanel();
|
||||
this._initLocationBar();
|
||||
this._initMobileShell();
|
||||
this._initShareButton();
|
||||
@@ -1025,17 +1029,12 @@ export class StyleManager extends ShellFacade {
|
||||
}
|
||||
|
||||
_initGlobalContextPanel() {
|
||||
const {
|
||||
radioLayer,
|
||||
militaryInstallationsLayer,
|
||||
militaryAwarenessLayer,
|
||||
rocketLaunchesLayer,
|
||||
} = this.services;
|
||||
const { radioLayer, militaryInstallationsLayer, militaryAwarenessLayer } =
|
||||
this.services;
|
||||
const contextStore = useContextStore(applicationPinia());
|
||||
this._contextControls = new ContextControls({
|
||||
elements: {
|
||||
_globalContextFlightsBtn: this._globalContextFlightsBtn,
|
||||
_globalContextMissionsBtn: this._globalContextMissionsBtn,
|
||||
_installationsSearchBtn: this._installationsSearchBtn,
|
||||
},
|
||||
installations: militaryInstallationsLayer,
|
||||
@@ -1071,13 +1070,24 @@ export class StyleManager extends ShellFacade {
|
||||
militaryAwarenessLayer?.subscribeDirectionOverlay?.((view) =>
|
||||
awarenessDirectionStore.publish(view),
|
||||
);
|
||||
}
|
||||
|
||||
_initSpaceMissionsPanel() {
|
||||
const { rocketLaunchesLayer } = this.services;
|
||||
// The Space Missions layer publishes its roster and selected mission.
|
||||
contextStore.connectMissions(rocketLaunchesLayer);
|
||||
this._missionsPanelUnsubscribe?.();
|
||||
contextStore.publishMissions(null);
|
||||
this._missionsPanelUnsubscribe = rocketLaunchesLayer?.subscribePanel?.(
|
||||
(view) => contextStore.publishMissions(view),
|
||||
);
|
||||
this._spaceMissionsControls?.destroy();
|
||||
this._spaceMissionsControls = new SpaceMissionsControls({
|
||||
layer: rocketLaunchesLayer,
|
||||
store: useSpaceMissionsStore(applicationPinia()),
|
||||
actions: {
|
||||
setPanelCollapsed: (...args) => this.setPanelCollapsed(...args),
|
||||
isCockpitActive: () => Boolean(this.cockpitView?.active),
|
||||
// After the panel has rendered as shown: the phone shell will not
|
||||
// open the Missions sheet over a hidden panel.
|
||||
revealPanel: () =>
|
||||
nextTick(() => this.revealPanel('space-missions-panel')),
|
||||
},
|
||||
});
|
||||
// And its replay vehicle overlay, which the scene chrome renders.
|
||||
const missionReplayStore = useMissionReplayStore(applicationPinia());
|
||||
this._missionReplayUnsubscribe?.();
|
||||
@@ -1955,16 +1965,14 @@ export class StyleManager extends ShellFacade {
|
||||
this._awarenessDirectionUnsubscribe?.();
|
||||
this._awarenessDirectionUnsubscribe = null;
|
||||
useAwarenessDirectionStore(applicationPinia()).publish(null);
|
||||
this._missionsPanelUnsubscribe?.();
|
||||
this._missionsPanelUnsubscribe = null;
|
||||
this._spaceMissionsControls?.destroy();
|
||||
this._spaceMissionsControls = null;
|
||||
this._missionReplayUnsubscribe?.();
|
||||
this._missionReplayUnsubscribe = null;
|
||||
useMissionReplayStore(applicationPinia()).publish(null);
|
||||
const contextStore = useContextStore(applicationPinia());
|
||||
contextStore.connectAwareness(null);
|
||||
contextStore.publishAwareness(null);
|
||||
contextStore.connectMissions(null);
|
||||
contextStore.publishMissions(null);
|
||||
this._cockpitCoordinator.stop();
|
||||
this._visualSettings.stop();
|
||||
this.shareLinkManager?.destroy();
|
||||
|
||||
@@ -4,19 +4,6 @@ import {
|
||||
contextModeWord,
|
||||
} from '../contextModePolicy.js';
|
||||
|
||||
/** Why a Space Missions entry failed: its mission index never loaded, and
|
||||
* the error is no older than `since` (an earlier attempt's is not the cause). */
|
||||
export function spaceMissionsIndexFailure(dataManager, since = 0) {
|
||||
const stats = dataManager?.layers
|
||||
?.get('rocket-launches')
|
||||
?.module?.getStats?.();
|
||||
return stats?.error && stats.lastUpdate == null && stats.errorAt >= since
|
||||
? t(
|
||||
'Space Missions unavailable: the mission index could not load. Try again later.',
|
||||
)
|
||||
: null;
|
||||
}
|
||||
|
||||
export async function _runUserFacingContextAction(
|
||||
operation,
|
||||
message = t('Context could not restore every layer; try again'),
|
||||
@@ -71,7 +58,6 @@ export function getContextModeState() {
|
||||
changing: Boolean(this._contextModeChanging),
|
||||
entering: this._contextModeEntering || null,
|
||||
canContact: !this._contextMode || this._contextMode === 'flights',
|
||||
canMission: !this._contextMode || this._contextMode === 'space-missions',
|
||||
snapshotCaptured: Boolean(this._contextSessionSnapshot),
|
||||
};
|
||||
}
|
||||
@@ -127,7 +113,7 @@ export async function setContextMode(
|
||||
};
|
||||
}
|
||||
const canonical = mode === 'contacts' ? 'flights' : mode;
|
||||
if (!['flights', 'space-missions'].includes(canonical)) {
|
||||
if (canonical !== 'flights') {
|
||||
return {
|
||||
ok: false,
|
||||
action: 'set_context_mode',
|
||||
@@ -222,8 +208,6 @@ export function clearSelectedLayers() {
|
||||
this._contextModeChanging = true;
|
||||
this._contextMode = null;
|
||||
this._contextModeEntering = null;
|
||||
this._contextModeEntryIntent = null;
|
||||
this._contextModeReplacementIntent = null;
|
||||
this._contextSessionSnapshot = null;
|
||||
this._contextRestoreState = null;
|
||||
this._preservePanelStateDuringLayerClear = true;
|
||||
|
||||
@@ -1,28 +1,8 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
import { spaceMissionsIndexFailure } from './contextActions.js';
|
||||
import { translateStatusMessage } from './statusText.js';
|
||||
import { shouldExpandGlobalContextPanel } from '../rightRailPolicy.js';
|
||||
|
||||
export function _initGlobalContextPanel() {
|
||||
const contextTabs = [
|
||||
this._globalContextFlightsBtn,
|
||||
this._globalContextMissionsBtn,
|
||||
].filter(Boolean);
|
||||
contextTabs.forEach((tab, index) =>
|
||||
this.listen(tab, 'keydown', (event) => {
|
||||
let nextIndex = null;
|
||||
if (event.key === 'ArrowRight')
|
||||
nextIndex = (index + 1) % contextTabs.length;
|
||||
else if (event.key === 'ArrowLeft')
|
||||
nextIndex = (index - 1 + contextTabs.length) % contextTabs.length;
|
||||
else if (event.key === 'Home') nextIndex = 0;
|
||||
else if (event.key === 'End') nextIndex = contextTabs.length - 1;
|
||||
if (nextIndex === null) return;
|
||||
event.preventDefault();
|
||||
contextTabs[nextIndex].focus({ preventScroll: true });
|
||||
contextTabs[nextIndex].click();
|
||||
}),
|
||||
);
|
||||
this.listen(this._globalContextFlightsBtn, 'click', () => {
|
||||
if (
|
||||
this.destroyed ||
|
||||
@@ -51,40 +31,6 @@ export function _initGlobalContextPanel() {
|
||||
});
|
||||
});
|
||||
});
|
||||
this.listen(this._globalContextMissionsBtn, 'click', () => {
|
||||
if (
|
||||
this.destroyed ||
|
||||
this._contextModeChanging ||
|
||||
this._clearSelectedLayersPromise
|
||||
)
|
||||
return;
|
||||
const nextMode =
|
||||
this._contextMode === 'space-missions' ? null : 'space-missions';
|
||||
this._claimContextVisualAuthority();
|
||||
const startedAt = Date.now();
|
||||
void this._runUserFacingContextAction(
|
||||
(notificationToken) =>
|
||||
this._selectContextMode(nextMode, { notificationToken }),
|
||||
() =>
|
||||
(nextMode && spaceMissionsIndexFailure(this._dataManager, startedAt)) ||
|
||||
t(
|
||||
'Space Missions could not complete the requested transition; try again',
|
||||
),
|
||||
).then((succeeded) => {
|
||||
if (
|
||||
!this.destroyed &&
|
||||
nextMode &&
|
||||
shouldExpandGlobalContextPanel({
|
||||
action: 'space-missions',
|
||||
explicitUserAction: true,
|
||||
succeeded: succeeded === true,
|
||||
})
|
||||
)
|
||||
this.actions.setPanelCollapsed('global-context-panel', false, {
|
||||
explicit: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
this.listen(this._installationsSearchBtn, 'click', () => {
|
||||
if (
|
||||
this.destroyed ||
|
||||
|
||||
@@ -44,9 +44,6 @@ export class ContextControls {
|
||||
this._contextModeChanging = false;
|
||||
this._contextModeGeneration = 0;
|
||||
this._contextModeEntering = null;
|
||||
this._contextModeEntryIntent = null;
|
||||
this._contextModeReplacementIntent = null;
|
||||
this._contextModeDeferredEntryIntent = null;
|
||||
this._contextSessionSnapshot = null;
|
||||
this._contextRestoreState = null;
|
||||
this._contextLayerReactionPromises = new Set();
|
||||
|
||||
@@ -48,7 +48,6 @@ test('Context starts with an explicit idle snapshot', (t) => {
|
||||
changing: false,
|
||||
entering: null,
|
||||
canContact: true,
|
||||
canMission: true,
|
||||
snapshotCaptured: false,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { setLocale } from '../i18n/index.js';
|
||||
import {
|
||||
contextLayerEnableBlockReason,
|
||||
parseContextLayerBlockReason,
|
||||
} from '../contextModePolicy.js';
|
||||
import {
|
||||
_handleContextLayerChange,
|
||||
localizeVisibilityBlockReason,
|
||||
@@ -18,7 +14,7 @@ function fakeShell() {
|
||||
_userFacingContextNotificationTokens: new Set(),
|
||||
_contextSessionSnapshot: null,
|
||||
_contextModeChanging: false,
|
||||
_contextMode: 'space-missions',
|
||||
_contextMode: null,
|
||||
_contextModeEntering: null,
|
||||
_syncContextModeButtons() {},
|
||||
showToast(message) {
|
||||
@@ -28,41 +24,19 @@ function fakeShell() {
|
||||
};
|
||||
}
|
||||
|
||||
const ENGLISH_GUARD =
|
||||
'Space Missions isolates replay data. Exit the mode to enable Live Flights.';
|
||||
|
||||
test.afterEach(() => setLocale('en'));
|
||||
|
||||
test('the guard reason is English data and parses back to its layer name', () => {
|
||||
const reason = contextLayerEnableBlockReason({
|
||||
contextMode: 'space-missions',
|
||||
change: { layerId: 'flights', enabled: true, origin: 'user' },
|
||||
layerName: 'Live Flights',
|
||||
});
|
||||
assert.equal(reason, ENGLISH_GUARD);
|
||||
assert.deepEqual(parseContextLayerBlockReason(reason), {
|
||||
layer: 'Live Flights',
|
||||
});
|
||||
assert.equal(parseContextLayerBlockReason('Data source unavailable'), null);
|
||||
assert.equal(
|
||||
parseContextLayerBlockReason(
|
||||
'Space Missions isolates replay data. Exit the mode to enable .',
|
||||
),
|
||||
null,
|
||||
);
|
||||
});
|
||||
|
||||
test('en: the toast shows the reason unchanged', () => {
|
||||
setLocale('en');
|
||||
const shell = fakeShell();
|
||||
_handleContextLayerChange.call(shell, {
|
||||
type: 'visibility-blocked',
|
||||
layerId: 'flights',
|
||||
layerId: 'street-level',
|
||||
enabled: true,
|
||||
origin: 'user',
|
||||
reason: ENGLISH_GUARD,
|
||||
reason: 'Data source unavailable',
|
||||
});
|
||||
assert.deepEqual(shell.toasts, [ENGLISH_GUARD]);
|
||||
assert.deepEqual(shell.toasts, ['Data source unavailable']);
|
||||
assert.equal(
|
||||
localizeVisibilityBlockReason('Overpass returned HTTP 503'),
|
||||
'Overpass returned HTTP 503',
|
||||
@@ -70,27 +44,6 @@ test('en: the toast shows the reason unchanged', () => {
|
||||
});
|
||||
|
||||
for (const locale of ['es', 'ru']) {
|
||||
test(`${locale}: the Space Missions block toast is localized with the layer name`, () => {
|
||||
setLocale(locale);
|
||||
const reason = contextLayerEnableBlockReason({
|
||||
contextMode: 'space-missions',
|
||||
change: { layerId: 'flights', enabled: true, origin: 'user' },
|
||||
layerName: 'Live Flights',
|
||||
});
|
||||
const shell = fakeShell();
|
||||
_handleContextLayerChange.call(shell, {
|
||||
type: 'visibility-blocked',
|
||||
layerId: 'flights',
|
||||
enabled: true,
|
||||
origin: 'user',
|
||||
reason,
|
||||
});
|
||||
assert.equal(shell.toasts.length, 1);
|
||||
assert.notEqual(shell.toasts[0], ENGLISH_GUARD, 'toast must be localized');
|
||||
assert.doesNotMatch(shell.toasts[0], /Space Missions isolates/);
|
||||
assert.doesNotMatch(shell.toasts[0], /Live Flights/);
|
||||
});
|
||||
|
||||
test(`${locale}: a known lifecycle reason is looked up in the catalog`, () => {
|
||||
setLocale(locale);
|
||||
const shell = fakeShell();
|
||||
|
||||
+21
-109
@@ -1,28 +1,16 @@
|
||||
import { t, translateKnown } from '../i18n/index.js';
|
||||
import {
|
||||
SPACE_MISSIONS_LAYER_BLOCK_REASON,
|
||||
isExplicitUserIntentOrigin,
|
||||
parseContextLayerBlockReason,
|
||||
recordContextRestoreExplicitChange,
|
||||
recordContextSessionUserChange,
|
||||
shouldExitContextForLayerChange,
|
||||
spaceMissionEntryCancellationDisposition,
|
||||
} from '../contextModePolicy.js';
|
||||
import { localizeLayerName } from './layerNames.js';
|
||||
import { spaceMissionsIndexFailure } from './contextActions.js';
|
||||
|
||||
/**
|
||||
* A blocked-visibility reason in the UI language. Reasons stay English (voice
|
||||
* and tools read them): the Space Missions refusal is rebuilt with the layer
|
||||
* name localized, a known sentence is looked up, anything else passes.
|
||||
* and tools read them): a known sentence is looked up, anything else passes.
|
||||
*/
|
||||
export function localizeVisibilityBlockReason(reason) {
|
||||
if (typeof reason !== 'string' || !reason) return reason;
|
||||
const blocked = parseContextLayerBlockReason(reason);
|
||||
if (blocked)
|
||||
return t(SPACE_MISSIONS_LAYER_BLOCK_REASON, {
|
||||
layer: localizeLayerName(blocked.layer),
|
||||
});
|
||||
return translateKnown(reason);
|
||||
}
|
||||
|
||||
@@ -40,74 +28,12 @@ export function _handleContextLayerChange(change) {
|
||||
this.actions.refreshRadio();
|
||||
}
|
||||
if (change?.type === 'visibility-transition') return;
|
||||
// The effective mode must be read BEFORE the entering flag is cleared:
|
||||
// the entry layer's own enable event is the one that clears it, and the
|
||||
// session bookkeeping below needs to know a mode was being entered.
|
||||
// A mode still being entered counts for the session bookkeeping below.
|
||||
const effectiveContextMode = this._contextModeEntering || this._contextMode;
|
||||
if (change?.type === 'visibility-cancelled') {
|
||||
const cancellationDisposition = spaceMissionEntryCancellationDisposition({
|
||||
change,
|
||||
});
|
||||
if (
|
||||
this._contextModeDeferredEntryIntent?.layerId === change.layerId &&
|
||||
this._contextModeDeferredEntryIntent.intentEpoch === change.intentEpoch
|
||||
) {
|
||||
if (cancellationDisposition !== 'replacement') {
|
||||
this._contextModeDeferredEntryIntent = null;
|
||||
}
|
||||
}
|
||||
if (cancellationDisposition === 'replacement') {
|
||||
this._contextModeEntering = 'space-missions';
|
||||
const entryIntent = this._contextModeEntryIntent;
|
||||
if (
|
||||
entryIntent?.generation === this._contextModeGeneration &&
|
||||
entryIntent.layerId === change.layerId &&
|
||||
entryIntent.intentEpoch === change.intentEpoch
|
||||
) {
|
||||
this._contextModeReplacementIntent = {
|
||||
generation: entryIntent.generation,
|
||||
layerId: change.layerId,
|
||||
intentEpoch: change.successorIntentEpoch,
|
||||
};
|
||||
}
|
||||
} else if (cancellationDisposition === 'restore') {
|
||||
this._contextModeEntering = null;
|
||||
this._contextModeEntryIntent = null;
|
||||
this._contextModeReplacementIntent = null;
|
||||
if (this._contextSessionSnapshot && !this._contextModeChanging) {
|
||||
this._contextMode = null;
|
||||
void this._trackContextLayerReaction(
|
||||
this._runUserFacingContextAction(
|
||||
async (notificationToken) => {
|
||||
await this._restoreContextSessionAfterLayerSettles(
|
||||
change.layerId,
|
||||
{
|
||||
notificationToken,
|
||||
},
|
||||
);
|
||||
return true;
|
||||
},
|
||||
'Space Missions cancellation could not restore the previous layer state', // i18n-ignore: English message; the toast shows localizedMessage
|
||||
{
|
||||
localizedMessage: t(
|
||||
'Space Missions cancellation could not restore the previous layer state',
|
||||
),
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
this._syncContextModeButtons();
|
||||
return;
|
||||
}
|
||||
if (
|
||||
change?.layerId === 'rocket-launches' &&
|
||||
['visibility', 'visibility-blocked', 'visibility-failed'].includes(
|
||||
change.type,
|
||||
)
|
||||
) {
|
||||
this._contextModeEntering = null;
|
||||
}
|
||||
if (change?.type === 'visibility-blocked') {
|
||||
if (
|
||||
!this._userFacingContextNotificationTokens.has(change.notificationToken)
|
||||
@@ -121,10 +47,13 @@ export function _handleContextLayerChange(change) {
|
||||
return;
|
||||
}
|
||||
if (change?.type === 'visibility-failed') {
|
||||
// A layer may name why its own start failed (Space Missions: the
|
||||
// mission index never loaded).
|
||||
const failureMessage =
|
||||
(change.layerId === 'rocket-launches' &&
|
||||
change.enabled &&
|
||||
spaceMissionsIndexFailure(this._dataManager)) ||
|
||||
(change.enabled &&
|
||||
this._dataManager?.layers
|
||||
?.get(change.layerId)
|
||||
?.module?.enableFailureMessage?.()) ||
|
||||
t('{layerId} could not {action} cleanly', {
|
||||
layerId: change.layerId,
|
||||
action: change.enabled ? t('start') : t('stop'),
|
||||
@@ -134,7 +63,7 @@ export function _handleContextLayerChange(change) {
|
||||
// notification for this queue to settle, then reconcile the complete
|
||||
// snapshot, including an uncertain failed shell.
|
||||
const needsDeferredShellRestore =
|
||||
['military-awareness', 'rocket-launches'].includes(change.layerId) &&
|
||||
change.layerId === 'military-awareness' &&
|
||||
change.enabled &&
|
||||
this._contextSessionSnapshot &&
|
||||
!this._contextModeChanging;
|
||||
@@ -212,26 +141,6 @@ export function _handleContextLayerChange(change) {
|
||||
),
|
||||
);
|
||||
}
|
||||
} else if (change.layerId === 'rocket-launches') {
|
||||
const ownsContextEntry =
|
||||
isExplicitUserIntentOrigin(change.origin, change.layerId) ||
|
||||
this._contextMode === 'space-missions' ||
|
||||
effectiveContextMode === 'space-missions';
|
||||
if (!ownsContextEntry) return;
|
||||
this._contextMode = change.enabled
|
||||
? 'space-missions'
|
||||
: this._contextMode === 'space-missions'
|
||||
? null
|
||||
: this._contextMode;
|
||||
if (change.enabled) {
|
||||
this._syncContextModeButtons();
|
||||
} else if (this._contextSessionSnapshot) {
|
||||
void this._trackContextLayerReaction(
|
||||
this._runUserFacingContextAction((notificationToken) =>
|
||||
this._deactivateContextForLayerChange({ notificationToken }),
|
||||
),
|
||||
);
|
||||
}
|
||||
} else if (
|
||||
this._contextMode === 'flights' &&
|
||||
[
|
||||
@@ -254,23 +163,26 @@ export function _handleContextLayerChange(change) {
|
||||
change.enabled &&
|
||||
change.origin === 'user' &&
|
||||
!this.cockpitView?.active &&
|
||||
(change.layerId === 'radio' || change.layerId === 'rocket-launches')
|
||||
change.layerId === 'radio'
|
||||
) {
|
||||
// Context's panel shows its main tab for them (ContextView listens).
|
||||
globalThis.dispatchEvent?.(new Event('gev:context-show-view'));
|
||||
this.actions.setPanelCollapsed('global-context-panel', false, {
|
||||
explicit: true,
|
||||
});
|
||||
if (change.layerId === 'radio')
|
||||
this.actions.setPanelCollapsed('radio-panel', false, { explicit: true });
|
||||
this.actions.setPanelCollapsed('radio-panel', false, { explicit: true });
|
||||
}
|
||||
finishContextLayerChange(this);
|
||||
}
|
||||
|
||||
/** The checks every settled layer change ends with. */
|
||||
function finishContextLayerChange(controls) {
|
||||
// Turning off the layer the view rides ends it; every other layer may be
|
||||
// turned on or off freely during a session.
|
||||
const riddenLayerId = this.cockpitView?.active
|
||||
? this.cockpitView.readSubjectLayerId?.()
|
||||
const riddenLayerId = controls.cockpitView?.active
|
||||
? controls.cockpitView.readSubjectLayerId?.()
|
||||
: null;
|
||||
if (riddenLayerId && !this._dataManager?.isEnabled(riddenLayerId)) {
|
||||
this.cockpitView.exit({ restoreTracking: false });
|
||||
if (riddenLayerId && !controls._dataManager?.isEnabled(riddenLayerId)) {
|
||||
controls.cockpitView.exit({ restoreTracking: false });
|
||||
}
|
||||
this._syncContextModeButtons();
|
||||
controls._syncContextModeButtons();
|
||||
}
|
||||
@@ -22,7 +22,6 @@ function fixture(t) {
|
||||
const controls = new ContextControls({
|
||||
elements: {
|
||||
_globalContextFlightsBtn: $('global-context-flights-btn'),
|
||||
_globalContextMissionsBtn: $('global-context-missions-btn'),
|
||||
_installationsSearchBtn: $('installations-search-btn'),
|
||||
},
|
||||
installations: {},
|
||||
@@ -58,61 +57,41 @@ test('before ContextControls renders, the switch shows its initial markup', (t)
|
||||
'ui-panel panel-collapsible collapsed ui-panel--collapsed',
|
||||
);
|
||||
assert.equal(panel.hasAttribute('data-context-mode'), false);
|
||||
for (const id of [
|
||||
'global-context-flights-btn',
|
||||
'global-context-missions-btn',
|
||||
]) {
|
||||
const tab = $(id);
|
||||
assert.equal(tab.className, 'context-mode-button');
|
||||
assert.equal(tab.getAttribute('aria-selected'), 'false');
|
||||
assert.equal(tab.getAttribute('tabindex'), '0');
|
||||
assert.equal(tab.hasAttribute('aria-busy'), false);
|
||||
}
|
||||
const tab = $('global-context-flights-btn');
|
||||
assert.equal(tab.className, 'context-mode-button');
|
||||
assert.equal(tab.getAttribute('aria-selected'), 'false');
|
||||
assert.equal(tab.getAttribute('tabindex'), '0');
|
||||
assert.equal(tab.hasAttribute('aria-busy'), false);
|
||||
assert.equal($('context-mode-standby').hidden, false);
|
||||
assert.equal($('context-flights-view').hidden, true);
|
||||
assert.equal($('context-missions-view').hidden, true);
|
||||
assert.equal($('global-context-missions-btn'), null);
|
||||
assert.equal($('context-missions-view'), null);
|
||||
assert.equal($('installations-search-btn').hasAttribute('aria-busy'), false);
|
||||
});
|
||||
|
||||
test('a transition keeps focus and Tab on both tabs until it settles', async (t) => {
|
||||
test('a Contacts transition keeps the tab focusable until it settles', async (t) => {
|
||||
const { $, controls, sync } = fixture(t);
|
||||
const contacts = $('global-context-flights-btn');
|
||||
const missions = $('global-context-missions-btn');
|
||||
missions.focus();
|
||||
contacts.focus();
|
||||
controls._contextModeChanging = true;
|
||||
await sync();
|
||||
assert.equal(
|
||||
document.activeElement === missions,
|
||||
true,
|
||||
'busy render keeps focus',
|
||||
);
|
||||
for (const tab of [contacts, missions]) {
|
||||
assert.equal(tab.disabled, false);
|
||||
assert.equal(tab.getAttribute('tabindex'), '0');
|
||||
assert.equal(tab.getAttribute('aria-disabled'), 'true');
|
||||
assert.equal(tab.getAttribute('aria-busy'), 'true');
|
||||
}
|
||||
assert.equal(document.activeElement, contacts);
|
||||
assert.equal(contacts.disabled, false);
|
||||
assert.equal(contacts.getAttribute('tabindex'), '0');
|
||||
assert.equal(contacts.getAttribute('aria-disabled'), 'true');
|
||||
assert.equal(contacts.getAttribute('aria-busy'), 'true');
|
||||
|
||||
controls._contextModeChanging = false;
|
||||
controls._contextMode = 'space-missions';
|
||||
controls._contextMode = 'flights';
|
||||
await sync();
|
||||
assert.equal(
|
||||
document.activeElement === missions,
|
||||
true,
|
||||
'settled render keeps focus',
|
||||
);
|
||||
for (const tab of [contacts, missions]) {
|
||||
assert.equal(tab.disabled, false);
|
||||
assert.equal(tab.getAttribute('aria-disabled'), 'false');
|
||||
assert.equal(tab.getAttribute('aria-busy'), 'false');
|
||||
}
|
||||
assert.equal(missions.classList.contains('active'), true);
|
||||
assert.equal(missions.getAttribute('aria-selected'), 'true');
|
||||
assert.equal(contacts.classList.contains('active'), false);
|
||||
assert.equal(contacts.getAttribute('aria-selected'), 'false');
|
||||
assert.equal(document.activeElement, contacts);
|
||||
assert.equal(contacts.disabled, false);
|
||||
assert.equal(contacts.getAttribute('aria-disabled'), 'false');
|
||||
assert.equal(contacts.getAttribute('aria-busy'), 'false');
|
||||
assert.equal(contacts.classList.contains('active'), true);
|
||||
assert.equal(contacts.getAttribute('aria-selected'), 'true');
|
||||
assert.equal($('context-mode-standby').hidden, true);
|
||||
assert.equal($('context-flights-view').hidden, true);
|
||||
assert.equal($('context-missions-view').hidden, false);
|
||||
assert.equal($('context-flights-view').hidden, false);
|
||||
});
|
||||
|
||||
test('the panel carries the mode beside the classes its chrome writes', async (t) => {
|
||||
|
||||
@@ -12,17 +12,10 @@ export function _syncContextModeButtons() {
|
||||
export function _presentContext() {
|
||||
if (this.destroyed) return;
|
||||
const flightsActive = this._contextMode === 'flights';
|
||||
const missionsActive = this._contextMode === 'space-missions';
|
||||
// Both Context choices stay in the ordinary Tab sequence and are never
|
||||
// native-disabled. Arrow keys still provide tablist navigation, but must
|
||||
// not be the only way to reach Space Missions from the keyboard. Semantic
|
||||
// busy state keeps them perceivable while synchronous click guards prevent
|
||||
// a second transition.
|
||||
this.publish({
|
||||
mode: this._contextMode || 'none',
|
||||
enabled: flightsActive || missionsActive,
|
||||
enabled: flightsActive,
|
||||
flightsActive,
|
||||
missionsActive,
|
||||
busy: Boolean(this._contextModeChanging),
|
||||
installationsBusy: this._installationsSearchBusy,
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
CONTEXT_INDEPENDENT_LAYER_IDS,
|
||||
contextRestoreLayerIds,
|
||||
contextSnapshotLayerIds,
|
||||
mergeContextTransitionErrors,
|
||||
@@ -24,7 +25,8 @@ export async function _waitForContextLayerSettlement() {
|
||||
export function _captureContextSessionSnapshot({ excludeLayerIds = [] } = {}) {
|
||||
if (!this._dataManager || this._contextSessionSnapshot) return;
|
||||
const params = {};
|
||||
for (const layerId of ['military-awareness', 'satellites']) {
|
||||
// Satellites is not Context's: the mission controller owns its parameters.
|
||||
for (const layerId of ['military-awareness']) {
|
||||
const value = this._dataManager.getLayerParams(layerId);
|
||||
if (value) params[layerId] = value;
|
||||
}
|
||||
@@ -93,9 +95,11 @@ export async function _restoreContextSession({
|
||||
restoreState.enabledLayerIds,
|
||||
{
|
||||
origin: 'context-restore',
|
||||
excludeLayerIds: settleContactsCoordinator
|
||||
? [...excludeLayerIds, contactsCoordinatorId]
|
||||
: excludeLayerIds,
|
||||
excludeLayerIds: [
|
||||
...excludeLayerIds,
|
||||
...CONTEXT_INDEPENDENT_LAYER_IDS,
|
||||
...(settleContactsCoordinator ? [contactsCoordinatorId] : []),
|
||||
],
|
||||
notificationToken,
|
||||
...(restoreSignal ? { signal: restoreSignal } : {}),
|
||||
},
|
||||
|
||||
+38
-104
@@ -1,11 +1,8 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
import {
|
||||
contextLayerEnableBlockReason,
|
||||
isExplicitUserIntentOrigin,
|
||||
runWithContextModeChanging,
|
||||
settleContextModeChange,
|
||||
shouldCaptureContextSession,
|
||||
shouldDeferContextEntryDuringClear,
|
||||
} from '../contextModePolicy.js';
|
||||
|
||||
export function connectContextManager(manager) {
|
||||
@@ -28,31 +25,6 @@ export function connectContextManager(manager) {
|
||||
this._captureContextSessionSnapshot({
|
||||
excludeLayerIds: [change.layerId],
|
||||
});
|
||||
if (
|
||||
shouldDeferContextEntryDuringClear({
|
||||
change,
|
||||
clearInFlight: Boolean(this._clearSelectedLayersPromise),
|
||||
})
|
||||
) {
|
||||
this._contextModeDeferredEntryIntent = {
|
||||
layerId: change.layerId,
|
||||
intentEpoch: change.intentEpoch,
|
||||
origin: change.origin,
|
||||
};
|
||||
this._contextModeEntering = 'space-missions';
|
||||
this._syncContextModeButtons();
|
||||
}
|
||||
} else if (
|
||||
change?.layerId === 'rocket-launches' &&
|
||||
change.enabled === false &&
|
||||
isExplicitUserIntentOrigin(change.origin, change.layerId)
|
||||
) {
|
||||
this._contextModeDeferredEntryIntent = null;
|
||||
if (this._clearSelectedLayersPromise) {
|
||||
this._contextSessionSnapshot = null;
|
||||
this._contextModeEntering = null;
|
||||
this._syncContextModeButtons();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -60,88 +32,50 @@ export function connectContextManager(manager) {
|
||||
this._dataManagerVisibilityGuardUnsubscribe =
|
||||
this._dataManager.addVisibilityGuard(async (change) => {
|
||||
if (this.destroyed) return null;
|
||||
const layerName =
|
||||
this._dataManager?.layers?.get(change.layerId)?.module?.name ||
|
||||
change.layerId;
|
||||
const reason = contextLayerEnableBlockReason({
|
||||
contextMode: this._contextModeEntering || this._contextMode,
|
||||
change,
|
||||
layerName,
|
||||
});
|
||||
if (reason) return reason;
|
||||
// A direct Contacts start (the coordinator layer itself, not the
|
||||
// Context chooser) isolates its dependencies like the chooser does.
|
||||
if (
|
||||
change.enabled &&
|
||||
['military-awareness', 'rocket-launches'].includes(change.layerId) &&
|
||||
shouldCaptureContextSession(change) &&
|
||||
(!this._contextModeChanging ||
|
||||
(change.layerId === 'rocket-launches' &&
|
||||
this._contextModeDeferredEntryIntent?.intentEpoch ===
|
||||
change.intentEpoch))
|
||||
) {
|
||||
const entryMode =
|
||||
change.layerId === 'rocket-launches' ? 'space-missions' : null;
|
||||
const deferredClearEntry =
|
||||
this._contextModeDeferredEntryIntent?.intentEpoch ===
|
||||
change.intentEpoch;
|
||||
// A deferred entry owns the state after Clear settles. Restoring
|
||||
// Clear's transient busy flag here would leave Context stuck.
|
||||
const priorChanging = deferredClearEntry
|
||||
? false
|
||||
: this._contextModeChanging;
|
||||
const notificationToken =
|
||||
change.notificationToken || Symbol('direct-context-shell-entry');
|
||||
const ownsNotificationToken = !change.notificationToken;
|
||||
if (ownsNotificationToken) {
|
||||
this._userFacingContextNotificationTokens.add(notificationToken);
|
||||
}
|
||||
this._contextModeEntering = entryMode;
|
||||
this._contextModeChanging = true;
|
||||
!change.enabled ||
|
||||
change.layerId !== 'military-awareness' ||
|
||||
!shouldCaptureContextSession(change) ||
|
||||
this._contextModeChanging
|
||||
)
|
||||
return null;
|
||||
const notificationToken =
|
||||
change.notificationToken || Symbol('direct-context-shell-entry');
|
||||
const ownsNotificationToken = !change.notificationToken;
|
||||
if (ownsNotificationToken) {
|
||||
this._userFacingContextNotificationTokens.add(notificationToken);
|
||||
}
|
||||
this._contextModeEntering = null;
|
||||
this._contextModeChanging = true;
|
||||
try {
|
||||
await this._clearLayersOutsideContextMode(null, {
|
||||
notificationToken,
|
||||
});
|
||||
if (this.destroyed) return false;
|
||||
} catch (error) {
|
||||
console.warn(`[Context] ${change.layerId} isolation failed`, error);
|
||||
try {
|
||||
if (deferredClearEntry) {
|
||||
await this._clearSelectedLayersManagerPromise;
|
||||
if (this.destroyed) return false;
|
||||
if (
|
||||
this._contextModeDeferredEntryIntent?.intentEpoch !==
|
||||
change.intentEpoch
|
||||
)
|
||||
return false;
|
||||
this._contextModeDeferredEntryIntent = null;
|
||||
}
|
||||
await this._clearLayersOutsideContextMode(entryMode, {
|
||||
await this._restoreContextSession({
|
||||
excludeLayerIds: [change.layerId],
|
||||
notificationToken,
|
||||
});
|
||||
if (this.destroyed) return false;
|
||||
} catch (error) {
|
||||
this._contextModeEntering = null;
|
||||
console.warn(`[Context] ${change.layerId} isolation failed`, error);
|
||||
try {
|
||||
await this._restoreContextSession({
|
||||
excludeLayerIds: [change.layerId],
|
||||
notificationToken,
|
||||
});
|
||||
} catch (restoreError) {
|
||||
console.warn(
|
||||
`[Context] ${change.layerId} rollback failed`,
|
||||
restoreError,
|
||||
);
|
||||
}
|
||||
return t(
|
||||
'{mode} could not start because another layer did not stop cleanly',
|
||||
{
|
||||
mode:
|
||||
entryMode === 'space-missions'
|
||||
? t('Space Missions')
|
||||
: t('Context'),
|
||||
},
|
||||
} catch (restoreError) {
|
||||
console.warn(
|
||||
`[Context] ${change.layerId} rollback failed`,
|
||||
restoreError,
|
||||
);
|
||||
} finally {
|
||||
if (ownsNotificationToken) {
|
||||
this._userFacingContextNotificationTokens.delete(
|
||||
notificationToken,
|
||||
);
|
||||
}
|
||||
if (!this.destroyed) settleContextModeChange(this, priorChanging);
|
||||
}
|
||||
return t(
|
||||
'{mode} could not start because another layer did not stop cleanly',
|
||||
{ mode: t('Context') },
|
||||
);
|
||||
} finally {
|
||||
if (ownsNotificationToken) {
|
||||
this._userFacingContextNotificationTokens.delete(notificationToken);
|
||||
}
|
||||
if (!this.destroyed) settleContextModeChange(this, false);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
@@ -13,8 +13,6 @@ export async function _selectContextMode(
|
||||
const generation = ++this._contextModeGeneration;
|
||||
const isCurrent = () =>
|
||||
!this.destroyed && generation === this._contextModeGeneration;
|
||||
this._contextModeEntryIntent = null;
|
||||
this._contextModeReplacementIntent = null;
|
||||
this._contextModeChanging = true;
|
||||
this._syncContextModeButtons();
|
||||
try {
|
||||
@@ -47,9 +45,6 @@ export async function _selectContextMode(
|
||||
this._captureContextSessionSnapshot();
|
||||
this._contextMode = mode;
|
||||
this._syncContextModeButtons();
|
||||
// Replay isolation must settle before Space Missions starts. Contacts
|
||||
// keeps its non-dependency teardown in the background so slow source
|
||||
// shutdown does not delay cockpit entry.
|
||||
try {
|
||||
await this._clearLayersOutsideContextMode(mode, {
|
||||
notificationToken,
|
||||
@@ -82,13 +77,8 @@ export async function _selectContextMode(
|
||||
// Entry is one transaction: isolation succeeded above, so a failed mode
|
||||
// activation must roll the cleared layers back instead of stranding the
|
||||
// user in a half-entered mode with an orphaned snapshot.
|
||||
const entryLayerId =
|
||||
mode === 'flights' ? 'military-awareness' : 'rocket-launches';
|
||||
if (mode === 'flights') {
|
||||
this._dataManager.setLayerParams('military-awareness', {
|
||||
passive: false,
|
||||
});
|
||||
}
|
||||
const entryLayerId = 'military-awareness';
|
||||
this._dataManager.setLayerParams(entryLayerId, { passive: false });
|
||||
let activated = false;
|
||||
let activationError = null;
|
||||
let activationIntent = null;
|
||||
@@ -99,11 +89,6 @@ export async function _selectContextMode(
|
||||
true,
|
||||
{ notificationToken, ...(signal ? { signal } : {}) },
|
||||
);
|
||||
this._contextModeEntryIntent = {
|
||||
generation,
|
||||
layerId: entryLayerId,
|
||||
intentEpoch: activationIntent.intentEpoch,
|
||||
};
|
||||
activated = await activationIntent.promise;
|
||||
terminalIntentOutcome =
|
||||
await this._dataManager._waitForVisibilityIntent?.(
|
||||
@@ -114,46 +99,6 @@ export async function _selectContextMode(
|
||||
activationError = error;
|
||||
}
|
||||
if (!isCurrent()) return false;
|
||||
let replacementIntent =
|
||||
mode === 'space-missions' &&
|
||||
this._contextModeReplacementIntent?.generation === generation &&
|
||||
this._contextModeReplacementIntent.layerId === entryLayerId
|
||||
? this._contextModeReplacementIntent
|
||||
: null;
|
||||
while (replacementIntent) {
|
||||
const outcome = await this._dataManager._waitForVisibilityIntent?.(
|
||||
entryLayerId,
|
||||
replacementIntent.intentEpoch,
|
||||
);
|
||||
terminalIntentOutcome = outcome;
|
||||
if (!isCurrent()) return false;
|
||||
const replacementOwnsMode =
|
||||
outcome?.intentEpoch === replacementIntent.intentEpoch &&
|
||||
outcome.enabled === true &&
|
||||
outcome.succeeded === true;
|
||||
if (replacementOwnsMode) {
|
||||
this._contextModeEntering = null;
|
||||
this._contextModeEntryIntent = null;
|
||||
this._contextModeReplacementIntent = null;
|
||||
this._syncContextModeButtons();
|
||||
return true;
|
||||
}
|
||||
const successorEpoch =
|
||||
outcome?.cancellationReason === 'superseded' &&
|
||||
outcome.successorEnabled === true &&
|
||||
Number.isInteger(outcome.successorIntentEpoch) &&
|
||||
outcome.successorIntentEpoch > replacementIntent.intentEpoch
|
||||
? outcome.successorIntentEpoch
|
||||
: null;
|
||||
replacementIntent =
|
||||
successorEpoch === null
|
||||
? null
|
||||
: {
|
||||
generation,
|
||||
layerId: entryLayerId,
|
||||
intentEpoch: successorEpoch,
|
||||
};
|
||||
}
|
||||
if (
|
||||
activationError ||
|
||||
activated === false ||
|
||||
@@ -182,8 +127,6 @@ export async function _selectContextMode(
|
||||
);
|
||||
}
|
||||
this._contextMode = null;
|
||||
this._contextModeEntryIntent = null;
|
||||
this._contextModeReplacementIntent = null;
|
||||
this._syncContextModeButtons();
|
||||
try {
|
||||
await this._restoreContextSession({
|
||||
@@ -205,7 +148,6 @@ export async function _selectContextMode(
|
||||
// while callers still require literal `true` before expanding Context.
|
||||
return cancelledAndSettled ? null : false;
|
||||
}
|
||||
this._contextModeEntryIntent = null;
|
||||
return true;
|
||||
} finally {
|
||||
if (isCurrent()) {
|
||||
@@ -221,8 +163,6 @@ export async function _deactivateContextForLayerChange({
|
||||
this._contextModeGeneration += 1;
|
||||
this._contextModeChanging = true;
|
||||
this._contextMode = null;
|
||||
this._contextModeEntryIntent = null;
|
||||
this._contextModeReplacementIntent = null;
|
||||
// A layer turned off ends Contacts but not the Cockpit: the view ends only
|
||||
// when the layer it rides goes off (see _handleContextLayerChange).
|
||||
this._syncContextModeButtons();
|
||||
|
||||
@@ -50,6 +50,9 @@ export class LayerBindings {
|
||||
get _contextControls() {
|
||||
return this.readControls()._contextControls;
|
||||
}
|
||||
get _spaceMissionsControls() {
|
||||
return this.readControls()._spaceMissionsControls;
|
||||
}
|
||||
get _cctvControls() {
|
||||
return this.readControls()._cctvControls;
|
||||
}
|
||||
@@ -254,6 +257,7 @@ export class LayerBindings {
|
||||
this._dataManagerUnsubscribe = null;
|
||||
}
|
||||
this._contextControls.connect(this._dataManager);
|
||||
this._spaceMissionsControls?.connect(this._dataManager);
|
||||
if (typeof this._dataManager?.subscribe === 'function') {
|
||||
this._dataManagerUnsubscribe = this._dataManager.subscribe((change) => {
|
||||
this._feedback._loadingFeedbackEvent = change;
|
||||
@@ -319,6 +323,7 @@ export class LayerBindings {
|
||||
this._directionsShellModule?.attachShellServices?.(null);
|
||||
this._directionsShellModule = null;
|
||||
this._dataManager = null;
|
||||
this._spaceMissionsControls?.connect(null);
|
||||
this._connectWeatherCamera();
|
||||
}
|
||||
}
|
||||
@@ -6,14 +6,14 @@ import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createPinia } from 'pinia';
|
||||
import { createApp, h, nextTick } from 'vue';
|
||||
import { useContextStore } from './stores/context.js';
|
||||
import { useSpaceMissionsStore } from './stores/spaceMissions.js';
|
||||
import MissionDetail from './views/panels/MissionDetail.vue';
|
||||
import MissionRoster from './views/panels/MissionRoster.vue';
|
||||
|
||||
function fixture(t) {
|
||||
document.body.replaceChildren();
|
||||
const scroller = document.body.appendChild(document.createElement('div'));
|
||||
scroller.className = 'global-context-panel-inner';
|
||||
scroller.className = 'space-missions-panel-inner';
|
||||
const host = scroller.appendChild(document.createElement('div'));
|
||||
const pinia = createPinia();
|
||||
const app = createApp({
|
||||
@@ -21,13 +21,13 @@ function fixture(t) {
|
||||
}).use(pinia);
|
||||
app.mount(host);
|
||||
t.after(() => app.unmount());
|
||||
const store = useContextStore(pinia);
|
||||
const store = useSpaceMissionsStore(pinia);
|
||||
const calls = [];
|
||||
const record =
|
||||
(name) =>
|
||||
(...args) =>
|
||||
calls.push([name, ...args]);
|
||||
store.connectMissions({
|
||||
store.connect({
|
||||
selectMissionAt: record('select'),
|
||||
selectPreviousMission: record('previous'),
|
||||
selectNextMission: record('next'),
|
||||
@@ -44,7 +44,7 @@ function fixture(t) {
|
||||
});
|
||||
const $ = (selector) => document.querySelector(selector);
|
||||
const publish = async (view) => {
|
||||
store.publishMissions(view);
|
||||
store.publish(view);
|
||||
await nextTick();
|
||||
await nextTick();
|
||||
};
|
||||
@@ -325,7 +325,7 @@ test('the replay controls follow the layer and call its commands', async (t) =>
|
||||
]);
|
||||
});
|
||||
|
||||
test('each newly presented selection returns the Context panel to the top', async (t) => {
|
||||
test('each newly presented selection returns the Space Missions panel to the top', async (t) => {
|
||||
const { publish, scroller } = fixture(t);
|
||||
scroller.scrollTop = 120;
|
||||
await publish({ roster: null, mission: mission({ scrollRequest: 4 }) });
|
||||
|
||||
+23
-2
@@ -30,6 +30,7 @@ export const MOBILE_SHEET_PANELS = Object.freeze({
|
||||
layers: Object.freeze(['data-panel']),
|
||||
cameras: Object.freeze(['cctv-panel', 'street-level-panel']),
|
||||
context: Object.freeze(['global-context-panel']),
|
||||
missions: Object.freeze(['space-missions-panel']),
|
||||
search: Object.freeze(['location-bar']),
|
||||
more: Object.freeze(['control-panel', 'pp-toggles']),
|
||||
});
|
||||
@@ -38,6 +39,11 @@ export const MOBILE_TABS = Object.freeze([
|
||||
Object.freeze({ sheet: 'layers', label: msg('Layers'), icon: 'layers' }),
|
||||
Object.freeze({ sheet: 'cameras', label: msg('Cameras'), icon: 'videocam' }),
|
||||
Object.freeze({ sheet: 'context', label: msg('Context'), icon: 'radar' }),
|
||||
Object.freeze({
|
||||
sheet: 'missions',
|
||||
label: msg('Space Missions'),
|
||||
icon: 'rocket_launch',
|
||||
}),
|
||||
Object.freeze({ sheet: 'search', label: msg('Search'), icon: 'search' }),
|
||||
Object.freeze({ sheet: 'more', label: msg('More'), icon: 'more_horiz' }),
|
||||
]);
|
||||
@@ -142,6 +148,7 @@ export function initMobileShell({
|
||||
.map(element)
|
||||
.filter(Boolean);
|
||||
const dock = element('command-dock');
|
||||
const missionsPanel = element('space-missions-panel');
|
||||
const shown = (node) =>
|
||||
node && globalThis.getComputedStyle?.(node).display !== 'none';
|
||||
|
||||
@@ -254,7 +261,9 @@ export function initMobileShell({
|
||||
const setSheet = (requested) => {
|
||||
swipe = null;
|
||||
if (!body.classList.contains(MOBILE_SHELL_CLASS)) return;
|
||||
const sheet = sheetBlocked(body) ? null : requested;
|
||||
const unavailableMissions =
|
||||
requested === 'missions' && missionsPanel?.hidden;
|
||||
const sheet = sheetBlocked(body) || unavailableMissions ? null : requested;
|
||||
const previous = currentSheetOf(body);
|
||||
if (previous === sheet) return;
|
||||
if (!previous) {
|
||||
@@ -487,9 +496,21 @@ export function initMobileShell({
|
||||
|
||||
if (typeof MutationObserverImpl === 'function') {
|
||||
const observer = new MutationObserverImpl(() => {
|
||||
if (currentSheetOf(body) && sheetBlocked(body)) setSheet(null);
|
||||
const sheet = currentSheetOf(body);
|
||||
if (!sheet) return;
|
||||
if (sheet === 'missions' && missionsPanel?.hidden) {
|
||||
returnFocus = tabFor('layers') ?? returnFocus;
|
||||
setSheet(null);
|
||||
} else if (sheetBlocked(body)) {
|
||||
setSheet(null);
|
||||
}
|
||||
});
|
||||
observer.observe(body, { attributes: true, attributeFilter: ['class'] });
|
||||
if (missionsPanel)
|
||||
observer.observe(missionsPanel, {
|
||||
attributes: true,
|
||||
attributeFilter: ['hidden'],
|
||||
});
|
||||
removers.push(() => observer.disconnect());
|
||||
}
|
||||
|
||||
|
||||
@@ -903,12 +903,11 @@ test('manual Context opens the existing transaction without disabling the tracke
|
||||
}
|
||||
});
|
||||
|
||||
test('manual Context respects Space Missions, busy transitions, missing tracks and disposal', async () => {
|
||||
test('manual Context respects an active mode, busy transitions, missing tracks and disposal', async () => {
|
||||
for (const state of [
|
||||
{ mode: 'space-missions' },
|
||||
{ mode: 'flights' },
|
||||
{ changing: true },
|
||||
{ entering: 'space-missions' },
|
||||
{ entering: 'flights' },
|
||||
{ noTrack: true },
|
||||
{ disposed: true },
|
||||
{ sheet: 'layers' },
|
||||
|
||||
@@ -83,6 +83,12 @@ const PANEL_NAMES = [
|
||||
[/display( panel)?|visual( panel)?/, 'left', 'pp-toggles', msg('Visual')],
|
||||
[/cctv panel|cameras? panel/, 'right', 'cctv-panel', msg('CCTV')],
|
||||
[/street ?level panel/, 'right', 'street-level-panel', msg('Street Level')],
|
||||
[
|
||||
/(space )?missions? panel/,
|
||||
'right',
|
||||
'space-missions-panel',
|
||||
msg('Space Missions'),
|
||||
],
|
||||
[/context( panel)?/, 'right', 'global-context-panel', msg('Context')],
|
||||
];
|
||||
const CLOSE = /\b(collapse|close|hide|minimi[sz]e|dismiss|shut|fold)\b/;
|
||||
|
||||
@@ -123,6 +123,16 @@ test('near-miss lines read as people mean them', () => {
|
||||
]);
|
||||
assert.equal(isPanelText('show earthquake data layer'), false);
|
||||
assert.equal(read('open data layers')[0].item, 'data-panel');
|
||||
assert.equal(
|
||||
read('open space missions panel')[0].item,
|
||||
'space-missions-panel',
|
||||
);
|
||||
assert.equal(
|
||||
read('close the missions panel')[0].item,
|
||||
'space-missions-panel',
|
||||
);
|
||||
// Without "panel" it is the layer, not its panel.
|
||||
assert.equal(isPanelText('show space missions'), false);
|
||||
assert.deepEqual(read('go to trinidad and tobago and show flights'), [
|
||||
{ kind: 'place', place: 'trinidad and tobago' },
|
||||
{ kind: 'layer', id: 'flights', enabled: true },
|
||||
|
||||
+7
-13
@@ -503,19 +503,13 @@ export const COMMANDS = Object.freeze([
|
||||
name: 'Visual',
|
||||
},
|
||||
),
|
||||
cmd(
|
||||
'open-context',
|
||||
msg('Open Context'),
|
||||
'context missions panel open',
|
||||
'radar',
|
||||
{
|
||||
kind: 'panel',
|
||||
action: 'open',
|
||||
side: 'right',
|
||||
item: 'global-context-panel',
|
||||
name: 'Context',
|
||||
},
|
||||
),
|
||||
cmd('open-context', msg('Open Context'), 'context panel open', 'radar', {
|
||||
kind: 'panel',
|
||||
action: 'open',
|
||||
side: 'right',
|
||||
item: 'global-context-panel',
|
||||
name: 'Context',
|
||||
}),
|
||||
cmd('reset', msg('Reset view'), 'home start over reset camera', 'public', {
|
||||
kind: 'camera',
|
||||
act: 'reset',
|
||||
|
||||
@@ -22,6 +22,7 @@ const SHARE_PANEL_STATE_SPECS = Object.freeze([
|
||||
{ id: 'radio-panel' },
|
||||
{ id: 'scene-panel' },
|
||||
{ id: 'global-context-panel' },
|
||||
{ id: 'space-missions-panel' },
|
||||
{ id: 'pp-toggles' },
|
||||
{ id: 'param-slider-panel' },
|
||||
]);
|
||||
@@ -48,6 +49,7 @@ const COCKPIT_ENTRY_COLLAPSE_PANEL_IDS = Object.freeze([
|
||||
'utilities-panel',
|
||||
'pp-toggles',
|
||||
'global-context-panel',
|
||||
'space-missions-panel',
|
||||
'radio-panel',
|
||||
]);
|
||||
|
||||
|
||||
@@ -427,6 +427,31 @@ test('destroying the chrome inside Cockpit puts back the panels its entry closed
|
||||
assert.equal(data.classList.contains('collapsed'), false);
|
||||
});
|
||||
|
||||
test('Cockpit entry folds the Space Missions panel away and exit brings it back', () => {
|
||||
document.body.innerHTML = `<div id="space-missions-panel"></div>`;
|
||||
const store = usePanelChromeStore(createPinia());
|
||||
const chrome = panelChrome(store);
|
||||
const missions = document.getElementById('space-missions-panel');
|
||||
followPanelState(store, 'space-missions-panel', missions);
|
||||
chrome.enterCockpit();
|
||||
assert.equal(missions.classList.contains('collapsed'), true);
|
||||
chrome.exitCockpit();
|
||||
assert.equal(missions.classList.contains('collapsed'), false);
|
||||
chrome.destroy();
|
||||
});
|
||||
|
||||
test('a share link records whether the Space Missions panel is open', () => {
|
||||
document.body.innerHTML = `<div id="space-missions-panel"></div>`;
|
||||
const store = usePanelChromeStore(createPinia());
|
||||
const chrome = panelChrome(store);
|
||||
const state = chrome._buildSharePanelState();
|
||||
assert.deepEqual(
|
||||
state.specs.filter((spec) => spec.id === 'space-missions-panel'),
|
||||
[{ id: 'space-missions-panel', collapsed: false }],
|
||||
);
|
||||
chrome.destroy();
|
||||
});
|
||||
|
||||
test('the accordion closes peers through the real store, and opens them again', () => {
|
||||
document.body.innerHTML = `
|
||||
<div id="data-panel" data-panel-id="data-panel"></div>
|
||||
|
||||
@@ -237,6 +237,7 @@ export class PanelLayoutController {
|
||||
this._recentImageryPanel,
|
||||
this._streetLevelPanel,
|
||||
globalContextPanel,
|
||||
document.getElementById('space-missions-panel'),
|
||||
document.getElementById('radio-panel'),
|
||||
]) {
|
||||
if (panel) this._rightStackResizeObserver.observe(panel);
|
||||
|
||||
@@ -31,6 +31,10 @@ export const PANEL_RAIL_ITEMS = Object.freeze({
|
||||
},
|
||||
'street-level-panel': { icon: 'streetview', label: msg('STREET LEVEL') },
|
||||
'global-context-panel': { icon: 'radar', label: msg('CONTEXT') },
|
||||
'space-missions-panel': {
|
||||
icon: 'rocket_launch',
|
||||
label: msg('Space Missions'),
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@@ -164,6 +164,17 @@ test('the default theme geometry change leaves the base gutters alone', () => {
|
||||
assert.match(display?.body || '', /font-size:\s*12px/);
|
||||
});
|
||||
|
||||
test('Data Layers, Context and Space Missions share the 14px side gutters', () => {
|
||||
const gutters = rules.find(
|
||||
({ selector, body }) =>
|
||||
/:is\(\s*\.data-panel-inner,\s*\.global-context-panel-inner,\s*\.space-missions-panel-inner\s*\)$/.test(
|
||||
selector,
|
||||
) && /padding-left:\s*14px/.test(body),
|
||||
);
|
||||
assert.ok(gutters, 'one rule sets the shared gutters');
|
||||
assert.match(gutters.body, /padding-right:\s*14px/);
|
||||
});
|
||||
|
||||
test('rail titles and dock labels share one set of label tokens', () => {
|
||||
// command-dock-trays.css sets the dock's label type; earlier dock rules
|
||||
// for the same selector are overridden by it.
|
||||
|
||||
@@ -35,9 +35,6 @@ export function readShellElements(document = globalThis.document) {
|
||||
_globalContextFlightsBtn: document.getElementById(
|
||||
'global-context-flights-btn',
|
||||
),
|
||||
_globalContextMissionsBtn: document.getElementById(
|
||||
'global-context-missions-btn',
|
||||
),
|
||||
_installationsSearchBtn: document.getElementById(
|
||||
'installations-search-btn',
|
||||
),
|
||||
|
||||
@@ -1038,15 +1038,16 @@ export class ShellFacade {
|
||||
|
||||
/**
|
||||
* Reads global context mode state for voice/state-sync consumers.
|
||||
* @returns {{mode: 'flights'|'space-missions'|null, active: boolean, changing: boolean, entering: 'flights'|'space-missions'|null, snapshotCaptured: boolean}}
|
||||
* @returns {{mode: 'flights'|null, active: boolean, changing: boolean, entering: 'flights'|null, snapshotCaptured: boolean}}
|
||||
*/
|
||||
getContextModeState(...args) {
|
||||
return this._contextControls?.getContextModeState(...args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets global context mode (Contacts / Space Missions / off) for voice.
|
||||
* @param {'contacts'|'space-missions'|'off'|null} mode - Requested context target.
|
||||
* Sets global context mode (Contacts / off) for voice. Space Missions is
|
||||
* an ordinary layer, not a Context mode.
|
||||
* @param {'contacts'|'off'|null} mode - Requested context target.
|
||||
* @param {object} [options]
|
||||
* @param {string|Symbol|null} [options.notificationToken]
|
||||
* @param {AbortSignal|null} [options.signal]
|
||||
@@ -1056,7 +1057,7 @@ export class ShellFacade {
|
||||
* lane. Cockpit choreography calls this facade INTERNALLY for its own
|
||||
* enter/rollback steps; those transitions are not a Context request by the
|
||||
* operator and must stay inert, so they pass `false`.
|
||||
* @returns {Promise<{ok:boolean, mode:'flights'|'space-missions'|null, active:boolean, action:string, error?:string}>}
|
||||
* @returns {Promise<{ok:boolean, mode:'flights'|null, active:boolean, action:string, error?:string}>}
|
||||
*/
|
||||
setContextMode(...args) {
|
||||
return this._contextControls?.setContextMode(...args);
|
||||
|
||||
@@ -27,7 +27,8 @@ function fixture(theme = 'tactical') {
|
||||
for (const panel of left.children) panel.parentElement = left;
|
||||
const rail = node('rail');
|
||||
const display = node('pp-toggles'), context = node('global-context-panel'), cctv = node('cctv-panel'), radio = node('radio-panel');
|
||||
rail.children = [display, context, cctv];
|
||||
const missions = node('space-missions-panel');
|
||||
rail.children = [display, context, missions, cctv];
|
||||
for (const panel of rail.children) panel.parentElement = rail;
|
||||
context.children = [radio];
|
||||
radio.parentElement = context;
|
||||
@@ -43,7 +44,7 @@ function fixture(theme = 'tactical') {
|
||||
shareLinkManager: { claimRestoreLane: (...args) => claimed.push(args), onPanelStateChange() {} },
|
||||
};
|
||||
owner.setPanelCollapsed = PanelChrome.prototype.setPanelCollapsed.bind(owner);
|
||||
return { layers, scenes, display, context, cctv, radio, owner, saved, claimed,
|
||||
return { layers, scenes, display, context, missions, cctv, radio, owner, saved, claimed,
|
||||
doc: { documentElement: { dataset: { uiTheme: theme } }, getElementById: (id) => nodes.get(id) },
|
||||
};
|
||||
}
|
||||
@@ -71,6 +72,25 @@ test('explicit opening collapses side peers and claims their restoration lanes i
|
||||
}
|
||||
});
|
||||
|
||||
test('the Context and Space Missions panels close each other on desktop', () => {
|
||||
const f = fixture('tactical'), prior = globalThis.document;
|
||||
globalThis.document = f.doc;
|
||||
try {
|
||||
f.owner.setPanelCollapsed('global-context-panel', false, { explicit: true });
|
||||
f.owner.setPanelCollapsed('space-missions-panel', false, { explicit: true });
|
||||
assert.equal(f.missions.classList.contains('collapsed'), false);
|
||||
assert.equal(f.context.classList.contains('collapsed'), true, 'opening Space Missions closes Context');
|
||||
f.owner.setPanelCollapsed('global-context-panel', false, { explicit: true });
|
||||
assert.equal(f.context.classList.contains('collapsed'), false);
|
||||
assert.equal(f.missions.classList.contains('collapsed'), true, 'opening Context closes Space Missions');
|
||||
// Radio lives inside Context, so opening it closes Space Missions too.
|
||||
f.owner.setPanelCollapsed('space-missions-panel', false, { explicit: true });
|
||||
f.owner.setPanelCollapsed('radio-panel', false, { explicit: true });
|
||||
assert.equal(f.context.classList.contains('collapsed'), false);
|
||||
assert.equal(f.missions.classList.contains('collapsed'), true);
|
||||
} finally { globalThis.document = prior; }
|
||||
});
|
||||
|
||||
test('opening already-expanded Radio reveals Context and closes Display', () => {
|
||||
const f = fixture('tactical'), prior = globalThis.document;
|
||||
globalThis.document = f.doc;
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
const LAYER_ID = 'rocket-launches';
|
||||
const PANEL_ID = 'space-missions-panel';
|
||||
|
||||
/**
|
||||
* The Space Missions panel's wiring. Space Missions is an ordinary layer: the
|
||||
* layer owns its data and Satellites dependency, and this connects it to its
|
||||
* panel. The panel shows while the layer is on, and opens when the person
|
||||
* turns the layer on (by hand or by voice) or picks a mission on the globe. Opening it closes the
|
||||
* other right-side panels, Context among them (see setPanelCollapsed).
|
||||
*/
|
||||
export class SpaceMissionsControls {
|
||||
/**
|
||||
* @param {object} options
|
||||
* @param {?object} options.layer The Space Missions layer.
|
||||
* @param {object} options.store The Space Missions store.
|
||||
* @param {object} options.actions
|
||||
* @param {(panelId: string, collapsed: boolean, options?: object) => void} options.actions.setPanelCollapsed
|
||||
* @param {() => boolean} options.actions.isCockpitActive
|
||||
* @param {() => void} [options.actions.revealPanel] Opens the phone sheet that
|
||||
* holds the panel; does nothing on desktop.
|
||||
*/
|
||||
constructor({ layer, store, actions }) {
|
||||
this._layer = layer || null;
|
||||
this._store = store;
|
||||
this._actions = actions;
|
||||
this._manager = null;
|
||||
this._unsubscribeManager = null;
|
||||
this.destroyed = false;
|
||||
store.connect(this._layer);
|
||||
store.publish(null);
|
||||
store.setEnabled(false);
|
||||
this._unsubscribePanel =
|
||||
this._layer?.subscribePanel?.((view) => store.publish(view)) ?? null;
|
||||
this._unsubscribeGlobePick =
|
||||
this._layer?.subscribeGlobePick?.(() => this._reveal()) ?? null;
|
||||
}
|
||||
|
||||
/** Follow a data manager's Space Missions visibility; null disconnects. */
|
||||
connect(manager) {
|
||||
this._unsubscribeManager?.();
|
||||
this._unsubscribeManager = null;
|
||||
this._manager = manager || null;
|
||||
if (this.destroyed) return;
|
||||
this._syncEnabled();
|
||||
this._unsubscribeManager =
|
||||
this._manager?.subscribe?.((change) => this._handleChange(change)) ??
|
||||
null;
|
||||
}
|
||||
|
||||
_syncEnabled() {
|
||||
this._store.setEnabled(Boolean(this._manager?.isEnabled?.(LAYER_ID)));
|
||||
}
|
||||
|
||||
_handleChange(change) {
|
||||
if (this.destroyed || change?.layerId !== LAYER_ID) return;
|
||||
if (!String(change.type || '').startsWith('visibility')) return;
|
||||
this._syncEnabled();
|
||||
if (
|
||||
change.type === 'visibility' &&
|
||||
change.enabled &&
|
||||
(change.origin === 'user' || change.origin === 'voice')
|
||||
)
|
||||
this._reveal();
|
||||
}
|
||||
|
||||
/** Open the panel, unless the Cockpit owns the screen. */
|
||||
_reveal() {
|
||||
if (this.destroyed || this._actions.isCockpitActive?.()) return;
|
||||
this._actions.setPanelCollapsed(PANEL_ID, false, { explicit: true });
|
||||
// A phone shows the rail only as tab sheets: open the Missions sheet too.
|
||||
this._actions.revealPanel?.();
|
||||
}
|
||||
|
||||
destroy() {
|
||||
if (this.destroyed) return;
|
||||
this.destroyed = true;
|
||||
this._unsubscribeManager?.();
|
||||
this._unsubscribeManager = null;
|
||||
this._unsubscribePanel?.();
|
||||
this._unsubscribePanel = null;
|
||||
this._unsubscribeGlobePick?.();
|
||||
this._unsubscribeGlobePick = null;
|
||||
this._store.connect(null);
|
||||
this._store.publish(null);
|
||||
this._store.setEnabled(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
// The Space Missions panel's wiring, apart from Context.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createPinia, setActivePinia } from 'pinia';
|
||||
import { useSpaceMissionsStore } from './stores/spaceMissions.js';
|
||||
import { SpaceMissionsControls } from './spaceMissionsControls.js';
|
||||
|
||||
function layerDouble() {
|
||||
const panelListeners = new Set();
|
||||
const pickListeners = new Set();
|
||||
return {
|
||||
panelListeners,
|
||||
pickListeners,
|
||||
subscribePanel(listener) {
|
||||
panelListeners.add(listener);
|
||||
return () => panelListeners.delete(listener);
|
||||
},
|
||||
subscribeGlobePick(listener) {
|
||||
pickListeners.add(listener);
|
||||
return () => pickListeners.delete(listener);
|
||||
},
|
||||
publish(view) {
|
||||
for (const listener of panelListeners) listener(view);
|
||||
},
|
||||
pick(id) {
|
||||
for (const listener of pickListeners) listener(id);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function managerDouble() {
|
||||
const listeners = new Set();
|
||||
const enabled = new Set();
|
||||
return {
|
||||
listeners,
|
||||
enabled,
|
||||
isEnabled: (id) => enabled.has(id),
|
||||
subscribe(listener) {
|
||||
listeners.add(listener);
|
||||
return () => listeners.delete(listener);
|
||||
},
|
||||
emit(change) {
|
||||
if (change.type === 'visibility') {
|
||||
if (change.enabled) enabled.add(change.layerId);
|
||||
else enabled.delete(change.layerId);
|
||||
}
|
||||
for (const listener of listeners) listener(change);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function rig({ cockpit = false } = {}) {
|
||||
setActivePinia(createPinia());
|
||||
const store = useSpaceMissionsStore();
|
||||
const layer = layerDouble();
|
||||
const manager = managerDouble();
|
||||
const reveals = [];
|
||||
const sheets = [];
|
||||
const state = { cockpit };
|
||||
const controls = new SpaceMissionsControls({
|
||||
layer,
|
||||
store,
|
||||
actions: {
|
||||
setPanelCollapsed: (...args) => reveals.push(args),
|
||||
isCockpitActive: () => state.cockpit,
|
||||
revealPanel: () => sheets.push('space-missions-panel'),
|
||||
},
|
||||
});
|
||||
controls.connect(manager);
|
||||
return { controls, store, layer, manager, reveals, sheets, state };
|
||||
}
|
||||
|
||||
const userOn = {
|
||||
type: 'visibility',
|
||||
layerId: 'rocket-launches',
|
||||
enabled: true,
|
||||
origin: 'user',
|
||||
};
|
||||
|
||||
test('the layer publishes its roster and mission to its own store', () => {
|
||||
const r = rig();
|
||||
assert.equal(r.store.layer, r.layer);
|
||||
assert.equal(r.store.roster, null);
|
||||
const view = { roster: { entries: [] }, mission: { id: 'L1' } };
|
||||
r.layer.publish(view);
|
||||
assert.equal(r.store.roster, view.roster);
|
||||
assert.equal(r.store.mission, view.mission);
|
||||
});
|
||||
|
||||
test('the panel shows while the layer is on', () => {
|
||||
const r = rig();
|
||||
assert.equal(r.store.enabled, false);
|
||||
r.manager.emit({ ...userOn, origin: 'programmatic' });
|
||||
assert.equal(r.store.enabled, true);
|
||||
r.manager.emit({ ...userOn, enabled: false });
|
||||
assert.equal(r.store.enabled, false);
|
||||
// Another layer's change says nothing about Space Missions.
|
||||
r.manager.enabled.add('rocket-launches');
|
||||
r.manager.emit({ ...userOn, layerId: 'satellites' });
|
||||
assert.equal(r.store.enabled, false);
|
||||
});
|
||||
|
||||
test('a person switching the layer on opens its panel; a restore does not', () => {
|
||||
const r = rig();
|
||||
r.manager.emit({ ...userOn, origin: 'share-restore' });
|
||||
r.manager.emit({ ...userOn, type: 'visibility-requested' });
|
||||
assert.deepEqual(r.reveals, []);
|
||||
r.manager.emit(userOn);
|
||||
assert.deepEqual(r.reveals, [
|
||||
['space-missions-panel', false, { explicit: true }],
|
||||
]);
|
||||
// On a phone the rail shows only as tab sheets: the Missions sheet opens too.
|
||||
assert.deepEqual(r.sheets, ['space-missions-panel']);
|
||||
});
|
||||
|
||||
test('a mission picked on the globe opens the panel', () => {
|
||||
const r = rig();
|
||||
r.layer.pick('L1');
|
||||
assert.deepEqual(r.reveals, [
|
||||
['space-missions-panel', false, { explicit: true }],
|
||||
]);
|
||||
assert.deepEqual(r.sheets, ['space-missions-panel']);
|
||||
});
|
||||
|
||||
test('the Cockpit keeps the screen: no reveal while it is on', () => {
|
||||
const r = rig({ cockpit: true });
|
||||
r.layer.pick('L1');
|
||||
r.manager.emit(userOn);
|
||||
r.manager.emit({ ...userOn, origin: 'voice' });
|
||||
assert.deepEqual(r.reveals, []);
|
||||
assert.deepEqual(r.sheets, [], 'no phone sheet over the Cockpit either');
|
||||
r.state.cockpit = false;
|
||||
r.layer.pick('L1');
|
||||
assert.equal(r.reveals.length, 1);
|
||||
});
|
||||
|
||||
test('reconnecting and destroy release every subscription and clear the store', () => {
|
||||
const r = rig();
|
||||
r.controls.connect(r.manager);
|
||||
assert.equal(r.manager.listeners.size, 1, 'no duplicate subscription');
|
||||
r.layer.publish({ roster: { entries: [] }, mission: null });
|
||||
r.manager.emit(userOn);
|
||||
r.controls.destroy();
|
||||
assert.equal(r.manager.listeners.size, 0);
|
||||
assert.equal(r.layer.panelListeners.size, 0);
|
||||
assert.equal(r.layer.pickListeners.size, 0);
|
||||
assert.equal(r.store.layer, null);
|
||||
assert.equal(r.store.roster, null);
|
||||
assert.equal(r.store.enabled, false);
|
||||
r.layer.pick('L1');
|
||||
assert.equal(r.reveals.length, 1, 'a destroyed control reveals nothing');
|
||||
});
|
||||
@@ -5,9 +5,9 @@ import { markRaw, shallowRef } from 'vue';
|
||||
* The Context panel's mode switch as its view renders it. ContextControls
|
||||
* presents the selected mode, the transition busy state and the nearby
|
||||
* sites search (`_presentContext()`) and publishes them here; it
|
||||
* keeps its listeners and transactions. The Contacts and Space Missions
|
||||
* layers publish their panels beside it, and the app connects each layer's
|
||||
* commands.
|
||||
* keeps its listeners and transactions. The Contacts layer publishes its
|
||||
* panel beside it, and the app connects the layer's commands. Space Missions
|
||||
* has its own store (stores/spaceMissions.js).
|
||||
*/
|
||||
export const useContextStore = defineStore('gev-context', () => {
|
||||
/** The presented mode switch; null until the controls first render. */
|
||||
@@ -37,29 +37,6 @@ export const useContextStore = defineStore('gev-context', () => {
|
||||
awarenessLayer.value = layer && markRaw(layer);
|
||||
}
|
||||
|
||||
/** The Space Missions roster; null until the layer first presents it. */
|
||||
const missionRoster = shallowRef(null);
|
||||
|
||||
/** The selected space mission; null while none is selected. */
|
||||
const mission = shallowRef(null);
|
||||
|
||||
/**
|
||||
* @param {?{roster: ?object, mission: ?object}} next The layer's view. The
|
||||
* layer keeps an unchanged roster's object, which re-renders nothing.
|
||||
*/
|
||||
function publishMissions(next) {
|
||||
missionRoster.value = next?.roster ? markRaw(next.roster) : null;
|
||||
mission.value = next?.mission ? markRaw(next.mission) : null;
|
||||
}
|
||||
|
||||
/** The Space Missions layer whose panel commands the components call. */
|
||||
const missionsLayer = shallowRef(null);
|
||||
|
||||
/** @param {?object} layer The Space Missions layer, or null to disconnect. */
|
||||
function connectMissions(layer) {
|
||||
missionsLayer.value = layer && markRaw(layer);
|
||||
}
|
||||
|
||||
return {
|
||||
view,
|
||||
publish,
|
||||
@@ -67,10 +44,5 @@ export const useContextStore = defineStore('gev-context', () => {
|
||||
publishAwareness,
|
||||
awarenessLayer,
|
||||
connectAwareness,
|
||||
missionRoster,
|
||||
mission,
|
||||
publishMissions,
|
||||
missionsLayer,
|
||||
connectMissions,
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,42 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { markRaw, shallowRef } from 'vue';
|
||||
|
||||
/**
|
||||
* The Space Missions panel as its views render it. The Space Missions layer
|
||||
* publishes its roster and selected mission here, and SpaceMissionsControls
|
||||
* publishes whether the layer is on. Nothing here belongs to Context.
|
||||
*/
|
||||
export const useSpaceMissionsStore = defineStore('gev-space-missions', () => {
|
||||
/** Whether the Space Missions layer is on or starting. */
|
||||
const enabled = shallowRef(false);
|
||||
|
||||
/** @param {boolean} next Whether the layer is on or starting. */
|
||||
function setEnabled(next) {
|
||||
enabled.value = Boolean(next);
|
||||
}
|
||||
|
||||
/** The roster; null until the layer first presents it. */
|
||||
const roster = shallowRef(null);
|
||||
|
||||
/** The selected space mission; null while none is selected. */
|
||||
const mission = shallowRef(null);
|
||||
|
||||
/**
|
||||
* @param {?{roster: ?object, mission: ?object}} next The layer's view. The
|
||||
* layer keeps an unchanged roster's object, which re-renders nothing.
|
||||
*/
|
||||
function publish(next) {
|
||||
roster.value = next?.roster ? markRaw(next.roster) : null;
|
||||
mission.value = next?.mission ? markRaw(next.mission) : null;
|
||||
}
|
||||
|
||||
/** The Space Missions layer whose panel commands the components call. */
|
||||
const layer = shallowRef(null);
|
||||
|
||||
/** @param {?object} next The Space Missions layer, or null to disconnect. */
|
||||
function connect(next) {
|
||||
layer.value = next && markRaw(next);
|
||||
}
|
||||
|
||||
return { enabled, setEnabled, roster, mission, publish, layer, connect };
|
||||
});
|
||||
@@ -226,6 +226,7 @@ html:not([lang='en']):not(:lang(zh)):not(:lang(ja))
|
||||
.recent-imagery-panel-inner,
|
||||
.street-level-panel-inner,
|
||||
.global-context-panel-inner,
|
||||
.space-missions-panel-inner,
|
||||
#pp-toggles:not(.collapsed),
|
||||
#pp-toggles.collapsed > .pp-header-row
|
||||
) {
|
||||
@@ -243,6 +244,7 @@ html:not([lang='en']):not(:lang(zh)):not(:lang(ja))
|
||||
.recent-imagery-panel-inner,
|
||||
.street-level-panel-inner,
|
||||
.global-context-panel-inner,
|
||||
.space-missions-panel-inner,
|
||||
#pp-toggles:not(.collapsed),
|
||||
#pp-toggles.collapsed > .pp-header-row
|
||||
):hover {
|
||||
@@ -1175,6 +1177,7 @@ body.ui-clean-view #data-panel,
|
||||
body.ui-clean-view #cctv-panel,
|
||||
body.ui-clean-view #radio-panel,
|
||||
body.ui-clean-view #global-context-panel,
|
||||
body.ui-clean-view #space-missions-panel,
|
||||
body.ui-clean-view #utilities-panel,
|
||||
body.ui-clean-view #scene-panel {
|
||||
opacity: 0 !important;
|
||||
|
||||
+56
-18
@@ -318,21 +318,54 @@ body.recording-mode .gev-panel-rail {
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
#right-context-rail #context-missions-view:not([hidden]),
|
||||
#right-context-rail #space-mission-panel-host,
|
||||
#right-context-rail .space-mission-roster {
|
||||
/* Keep the mission cycler directly beneath its Data Layers entry. */
|
||||
[data-layer-id='rocket-launches'] .data-toggle-controls:not([hidden]) {
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(0, 1fr) auto;
|
||||
gap: 6px;
|
||||
padding: 5px;
|
||||
border: 1px solid var(--glass-border);
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
[data-layer-id='rocket-launches'] .data-toggle-controls-info {
|
||||
grid-column: 2;
|
||||
grid-row: 1;
|
||||
padding-top: 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
[data-layer-id='rocket-launches'] [data-chip-id='next-mission'] {
|
||||
grid-column: 3;
|
||||
grid-row: 1;
|
||||
}
|
||||
|
||||
:root[dir='rtl']
|
||||
[data-layer-id='rocket-launches']
|
||||
.chip-icon
|
||||
.material-symbols-outlined {
|
||||
transform: scaleX(-1);
|
||||
}
|
||||
|
||||
#space-missions-panel {
|
||||
width: min(100%, 330px);
|
||||
min-height: 0;
|
||||
max-height: var(--right-panel-allocated-height, 100%);
|
||||
pointer-events: auto;
|
||||
}
|
||||
#right-context-rail.layout-focus #context-missions-view:not([hidden]),
|
||||
#right-context-rail.layout-focus #space-mission-panel-host,
|
||||
#right-context-rail.layout-focus .space-mission-roster {
|
||||
display: flex;
|
||||
flex: 1 1 auto;
|
||||
flex-direction: column;
|
||||
|
||||
#space-missions-panel[hidden] {
|
||||
display: none;
|
||||
}
|
||||
#right-context-rail.layout-focus .space-mission-roster-list {
|
||||
flex: 1 1 auto;
|
||||
max-height: none;
|
||||
|
||||
.space-missions-panel-inner {
|
||||
max-height: inherit;
|
||||
overflow-y: auto;
|
||||
scrollbar-gutter: stable;
|
||||
}
|
||||
|
||||
#space-missions-panel.collapsed #space-mission-panel-host {
|
||||
display: none;
|
||||
}
|
||||
/* Synchronous intrinsic measurement, independent of focus and allocation.
|
||||
This attribute is not observed by the rail's layout scheduler. */
|
||||
@@ -379,8 +412,6 @@ body.recording-mode .gev-panel-rail {
|
||||
margin-top: 8px;
|
||||
pointer-events: auto;
|
||||
}
|
||||
#space-mission-panel-host:has(#space-mission-panel:not([hidden]))
|
||||
> .context-mode-standby,
|
||||
#space-mission-panel-host:has(#space-mission-panel:not([hidden]))
|
||||
> .space-mission-roster {
|
||||
display: none;
|
||||
@@ -1003,7 +1034,8 @@ body.recording-mode .gev-panel-rail {
|
||||
#global-context-panel .panel-glow {
|
||||
display: none;
|
||||
}
|
||||
.global-context-panel-inner {
|
||||
.global-context-panel-inner,
|
||||
.space-missions-panel-inner {
|
||||
position: relative;
|
||||
display: flex;
|
||||
min-height: 0;
|
||||
@@ -1019,9 +1051,15 @@ body.recording-mode .gev-panel-rail {
|
||||
-webkit-backdrop-filter: blur(24px) saturate(1.4);
|
||||
}
|
||||
|
||||
/* Data Layers and Context share the 14px side padding of the other default
|
||||
theme panels, so every title and toggle sits 19px from its edge. */
|
||||
:root :is(.data-panel-inner, .global-context-panel-inner) {
|
||||
/* Data Layers, Context and Space Missions share the 14px side padding of the
|
||||
other default theme panels, so every title and toggle sits 19px from its
|
||||
edge. */
|
||||
:root
|
||||
:is(
|
||||
.data-panel-inner,
|
||||
.global-context-panel-inner,
|
||||
.space-missions-panel-inner
|
||||
) {
|
||||
padding-right: 14px;
|
||||
padding-left: 14px;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,8 @@ body.mobile-shell #mobile-tab-bar {
|
||||
left: 0;
|
||||
z-index: 170;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, 1fr);
|
||||
grid-auto-flow: column;
|
||||
grid-auto-columns: minmax(0, 1fr);
|
||||
height: var(--mobile-tab-space);
|
||||
padding: 0 max(4px, env(safe-area-inset-right, 0px))
|
||||
var(--mobile-bottom-inset) max(4px, env(safe-area-inset-left, 0px));
|
||||
@@ -62,6 +63,14 @@ body.mobile-shell .mobile-tab {
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
|
||||
/* Long locales clip to one line instead of widening their column. */
|
||||
body.mobile-shell .mobile-tab-label {
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
body.mobile-shell .mobile-tab-icon {
|
||||
font-size: 24px;
|
||||
line-height: 1;
|
||||
@@ -129,6 +138,7 @@ body.mobile-shell #right-context-rail {
|
||||
body.mobile-shell[data-mobile-sheet='layers'] #left-panel-stack,
|
||||
body.mobile-shell[data-mobile-sheet='cameras'] #right-context-rail,
|
||||
body.mobile-shell[data-mobile-sheet='context'] #right-context-rail,
|
||||
body.mobile-shell[data-mobile-sheet='missions'] #right-context-rail,
|
||||
/* Visual opens from the left rail on wider screens, so it lives in the left
|
||||
stack and the More sheet is that stack showing Visual alone. */
|
||||
body.mobile-shell[data-mobile-sheet='more'] #left-panel-stack {
|
||||
@@ -191,6 +201,9 @@ body.mobile-shell[data-mobile-sheet='context']
|
||||
body.mobile-shell[data-mobile-sheet='context']
|
||||
#right-context-rail
|
||||
> #recent-imagery-panel:not([hidden]),
|
||||
body.mobile-shell[data-mobile-sheet='missions']
|
||||
#right-context-rail
|
||||
> #space-missions-panel:not([hidden]),
|
||||
body.mobile-shell[data-mobile-sheet='more'] #left-panel-stack > #pp-toggles {
|
||||
position: relative;
|
||||
inset: auto;
|
||||
|
||||
@@ -14,6 +14,7 @@ body.recording-mode #data-panel,
|
||||
body.recording-mode #cctv-panel,
|
||||
body.recording-mode #radio-panel,
|
||||
body.recording-mode #global-context-panel,
|
||||
body.recording-mode #space-missions-panel,
|
||||
body.recording-mode #gev-voice-control,
|
||||
body.recording-mode #utilities-panel,
|
||||
body.recording-mode #scene-panel {
|
||||
|
||||
@@ -14,8 +14,7 @@ import AwarenessPanel from './panels/AwarenessPanel.vue';
|
||||
import BhoteKoshiPanel from './panels/BhoteKoshiPanel.vue';
|
||||
import EntityCard from './panels/EntityCard.vue';
|
||||
import ViewContext from './panels/ViewContext.vue';
|
||||
import MissionDetail from './panels/MissionDetail.vue';
|
||||
import MissionRoster from './panels/MissionRoster.vue';
|
||||
import SpaceMissionsPanel from './panels/SpaceMissionsPanel.vue';
|
||||
import RadioPanel from './panels/RadioPanel.vue';
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
import { cockpitEntryFace } from '../cockpitPresentation.js';
|
||||
@@ -75,7 +74,7 @@ const setPane = (id) => (el) => {
|
||||
if (target instanceof HTMLElement && target.parentElement !== el) el.appendChild(target);
|
||||
}
|
||||
};
|
||||
// Turning Radio or Launches on asks for the main tab, where they show.
|
||||
// Turning on Radio reveals the Inspector.
|
||||
const showView = () => (activeTab.value = 'view');
|
||||
onMounted(() => {
|
||||
globalThis.addEventListener?.('gev:context-show-view', showView);
|
||||
@@ -221,14 +220,10 @@ watch(
|
||||
<span class="material-symbols-outlined" aria-hidden="true">radar</span>
|
||||
<span>{{ t('CONTACTS') }}</span>
|
||||
</button>
|
||||
<button id="global-context-missions-btn" class="context-mode-button" v-class-toggle="{ active: ctx?.missionsActive }" type="button" role="tab" tabindex="0" :aria-selected="String(ctx?.missionsActive ?? false)" :aria-disabled="ctx && String(ctx.busy)" :aria-busy="ctx && String(ctx.busy)" aria-controls="context-missions-view">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">rocket_launch</span>
|
||||
<span>{{ t('SPACE MISSIONS') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div id="context-mode-standby" class="context-mode-standby" :hidden="ctx?.enabled">
|
||||
<strong>{{ t('SELECT CONTEXT') }}</strong>
|
||||
<span>{{ t('CONTACTS — nearest planes · vessels · sites') }}<br>{{ t('SPACE MISSIONS — launches & orbital assets') }}</span>
|
||||
<span>{{ t('CONTACTS — nearest planes · vessels · sites') }}</span>
|
||||
</div>
|
||||
<section id="context-flights-view" class="context-mode-view" role="tabpanel" aria-labelledby="global-context-flights-btn" :hidden="!ctx?.flightsActive">
|
||||
<div class="global-context-actions" :aria-label="t('Contact Context actions')">
|
||||
@@ -241,12 +236,6 @@ watch(
|
||||
</div>
|
||||
<AwarenessPanel v-if="!contactsMatchCard" />
|
||||
</section>
|
||||
<section id="context-missions-view" class="context-mode-view" role="tabpanel" aria-labelledby="global-context-missions-btn" :hidden="!ctx?.missionsActive">
|
||||
<div id="space-mission-panel-host">
|
||||
<MissionRoster />
|
||||
<MissionDetail />
|
||||
</div>
|
||||
</section>
|
||||
<div v-if="contextOpen" v-show="activeTab === 'view'" id="context-tab-view" role="tabpanel" aria-labelledby="context-tab-btn-view" :class="{ 'context-searching': contextSearchOpen && contextSearchText.trim() }">
|
||||
<EntityCard :with-contacts="contactsMatchCard">
|
||||
<AwarenessPanel v-if="contactsMatchCard" compact />
|
||||
@@ -255,6 +244,7 @@ watch(
|
||||
</div>
|
||||
</div>
|
||||
</RailPanel>
|
||||
<SpaceMissionsPanel />
|
||||
<BhoteKoshiPanel />
|
||||
</aside>
|
||||
|
||||
|
||||
@@ -3,17 +3,17 @@ import { storeToRefs } from 'pinia';
|
||||
import { nextTick, ref, watch } from 'vue';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import UiSlider from '../../kit/UiSlider.js';
|
||||
import { useContextStore } from '../../stores/context.js';
|
||||
import { useSpaceMissionsStore } from '../../stores/spaceMissions.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
|
||||
// The selected space mission inside Context. The launches layer presents it
|
||||
// The selected space mission. The launches layer presents it
|
||||
// and hides the panel while none is selected; the roster beside it hides
|
||||
// while it shows. Buttons call the layer's panel commands.
|
||||
const { mission: m, missionsLayer: layer } = storeToRefs(useContextStore());
|
||||
const { mission: m, layer } = storeToRefs(useSpaceMissionsStore());
|
||||
const root = ref(null);
|
||||
|
||||
// Each newly presented selection returns the Context panel to the top.
|
||||
const SCROLLER = '.global-context-panel-inner';
|
||||
// Each newly presented selection returns the mission panel to the top.
|
||||
const SCROLLER = '.space-missions-panel-inner';
|
||||
watch(
|
||||
() => m.value?.scrollRequest,
|
||||
async (request) => {
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { onBeforeUpdate, onUpdated, ref } from 'vue';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import { useContextStore } from '../../stores/context.js';
|
||||
import { useSpaceMissionsStore } from '../../stores/spaceMissions.js';
|
||||
import UiEmpty from '../../kit/UiEmpty.vue';
|
||||
|
||||
// The Space Missions roster. The launches layer presents it; until it does,
|
||||
// the list shows its loading line. Hover and keyboard focus drive the
|
||||
// layer's preview, and a click selects the mission.
|
||||
const { missionRoster: roster, missionsLayer: layer } = storeToRefs(useContextStore());
|
||||
const { roster, layer } = storeToRefs(useSpaceMissionsStore());
|
||||
const root = ref(null);
|
||||
|
||||
const CONTINUATION = '[data-mission-roster-focus-continuation]';
|
||||
|
||||
@@ -1,19 +1,25 @@
|
||||
<script setup>
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { computed } from 'vue';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import { useDisplayStore } from '../../stores/display.js';
|
||||
import { useSpaceMissionsStore } from '../../stores/spaceMissions.js';
|
||||
|
||||
// The phone shell's tab bar and sheet backdrop. They join the end of the
|
||||
// page when the shell first publishes, after the scene's credits, and leave
|
||||
// it when the shell is destroyed; desktop CSS hides them meanwhile.
|
||||
const { phoneShell: phone } = storeToRefs(useDisplayStore());
|
||||
const { enabled: missionsEnabled } = storeToRefs(useSpaceMissionsStore());
|
||||
const tabs = computed(() =>
|
||||
phone.value?.tabs.filter((tab) => tab.sheet !== 'missions' || missionsEnabled.value),
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport v-if="phone" to="body">
|
||||
<div id="mobile-sheet-backdrop" :hidden="!phone.sheet"></div>
|
||||
<nav id="mobile-tab-bar" :aria-label="t('Panels')" :aria-hidden="String(!phone.enabled)">
|
||||
<button v-for="tab in phone.tabs" :key="tab.sheet" type="button" class="mobile-tab" :data-mobile-sheet="tab.sheet" :aria-expanded="String(phone.sheet === tab.sheet)"><span class="material-symbols-outlined mobile-tab-icon" aria-hidden="true">{{ tab.icon }}</span><span class="mobile-tab-label">{{ t(tab.label) }}</span></button>
|
||||
<button v-for="tab in tabs" :key="tab.sheet" type="button" class="mobile-tab" :data-mobile-sheet="tab.sheet" :aria-expanded="String(phone.sheet === tab.sheet)"><span class="material-symbols-outlined mobile-tab-icon" aria-hidden="true">{{ tab.icon }}</span><span class="mobile-tab-label">{{ t(tab.label) }}</span></button>
|
||||
</nav>
|
||||
</Teleport>
|
||||
</template>
|
||||
@@ -0,0 +1,43 @@
|
||||
<script setup>
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { nextTick, ref, watch } from 'vue';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import RailPanel from '../../rail/RailPanel.vue';
|
||||
import { useSpaceMissionsStore } from '../../stores/spaceMissions.js';
|
||||
import MissionDetail from './MissionDetail.vue';
|
||||
import MissionRoster from './MissionRoster.vue';
|
||||
|
||||
const { enabled, mission } = storeToRefs(useSpaceMissionsStore());
|
||||
const host = ref(null);
|
||||
|
||||
watch(
|
||||
() => Boolean(mission.value),
|
||||
async (selected) => {
|
||||
// Keep keyboard focus in the panel when the selected mission replaces the roster.
|
||||
if (!host.value?.contains(document.activeElement)) return;
|
||||
await nextTick();
|
||||
const control = selected
|
||||
? '[data-mission-close]'
|
||||
: '[data-mission-roster-id]';
|
||||
host.value?.querySelector(control)?.focus();
|
||||
},
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<RailPanel
|
||||
id="space-missions-panel"
|
||||
:title="t('Space Missions')"
|
||||
:hidden="!enabled"
|
||||
:glow="false"
|
||||
start-collapsed
|
||||
sideways
|
||||
scroll
|
||||
rail-scroller
|
||||
>
|
||||
<div id="space-mission-panel-host" ref="host">
|
||||
<MissionRoster />
|
||||
<MissionDetail />
|
||||
</div>
|
||||
</RailPanel>
|
||||
</template>
|
||||
Reference in new issue
Block a user