mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 19:04:02 +00:00
feat(ui): render Provider Settings from a store
initKeySetup keeps the setup requests, the ChatGPT OAuth flow, the pasted field values and the dialog's keyboard, and publishes the POWER UP chip, the dialog, its key rows and the status line to the gev-provider-settings store. ProviderSettingsView renders them and sends clicks and typing to the connected owner; in Cyber the chip is teleported into the top toolbar. A successful save renders the rows afresh so no field keeps a key, and the status line announces a repeated message again. The voice action opens and closes the dialog through the same controls.
This commit is contained in:
1 parent
6cb01ff975
commit
fe963a1219
9 files changed
+840
-517
No files matched your search
+12
-15
@@ -9,6 +9,8 @@ import { resolveDeicticArgs } from './deixis.js';
|
||||
export { readLayerLifecycleSummary } from './layerSummary.js';
|
||||
import { defaultGeospatial } from '../search/defaults.js';
|
||||
import { msg } from '../i18n/index.js';
|
||||
import { useProviderSettingsStore } from '../ui/stores/providerSettings.js';
|
||||
import { applicationPinia } from '../ui/vueRuntime.js';
|
||||
import * as Cesium from 'cesium';
|
||||
import { CITY_POIS } from '../cityPois.js';
|
||||
import { greatCircleKm } from '../geoDistance.js';
|
||||
@@ -772,10 +774,9 @@ export function createGevActionRunner({
|
||||
cancelled: true,
|
||||
};
|
||||
const doc = globalThis.document;
|
||||
const panel = doc?.getElementById?.('key-setup');
|
||||
const button = open
|
||||
? doc?.getElementById?.('key-setup-chip')
|
||||
: panel?.querySelector?.('[data-key-setup-close]');
|
||||
// The setup owner (src/keySetup.js) publishes the dialog and takes
|
||||
// its open and close requests.
|
||||
const settings = useProviderSettingsStore(applicationPinia());
|
||||
const concealed =
|
||||
open &&
|
||||
[
|
||||
@@ -784,11 +785,7 @@ export function createGevActionRunner({
|
||||
'cockpit-mode',
|
||||
'scene-playback-mode',
|
||||
].some((mode) => doc?.body?.classList?.contains(mode));
|
||||
if (
|
||||
concealed ||
|
||||
panel?.dataset?.ready !== 'true' ||
|
||||
typeof button?.click !== 'function'
|
||||
) {
|
||||
if (concealed || settings.view?.ready !== true || !settings.controls) {
|
||||
const error = concealed
|
||||
? 'Provider Settings is hidden in the current view. Leave that view before opening it.'
|
||||
: 'Provider Settings is unavailable in this runtime.';
|
||||
@@ -802,11 +799,11 @@ export function createGevActionRunner({
|
||||
say: error,
|
||||
};
|
||||
}
|
||||
button.click();
|
||||
// Opening unhides immediately; closing removes visible before its fade ends.
|
||||
const applied = open
|
||||
? !panel.hidden
|
||||
: !panel.classList.contains('visible');
|
||||
if (open) settings.controls.open();
|
||||
else settings.controls.close();
|
||||
// Opening unhides at once; closing drops visible before its fade ends.
|
||||
const dialog = settings.view.dialog;
|
||||
const applied = open ? !dialog.hidden : !dialog.visible;
|
||||
const say = applied
|
||||
? `Provider Settings is ${open ? 'open' : 'closed'}.`
|
||||
: 'Provider Settings did not change.';
|
||||
@@ -815,7 +812,7 @@ export function createGevActionRunner({
|
||||
action: name,
|
||||
panelId,
|
||||
applied,
|
||||
open: applied ? open : !panel.hidden,
|
||||
open: applied ? open : !dialog.hidden,
|
||||
say,
|
||||
...(!applied ? { error: say } : {}),
|
||||
};
|
||||
|
||||
@@ -681,19 +681,12 @@ test('Provider Settings uses its ready dialog handlers and refuses unavailable o
|
||||
f.run('set_panel_open', { panelId: 'provider-settings', open }, options);
|
||||
assert.equal((await request(true)).unavailable, true);
|
||||
const doc = globalThis.document;
|
||||
const chip = doc.createElement('button');
|
||||
chip.id = 'key-setup-chip';
|
||||
// The setup owner needs only its dialog element; the view is not mounted,
|
||||
// so the published dialog state stands in for it.
|
||||
const panel = doc.createElement('aside');
|
||||
panel.id = 'key-setup';
|
||||
panel.hidden = true;
|
||||
const close = doc.createElement('button');
|
||||
panel.appendChild(close);
|
||||
doc.body.append(chip, panel);
|
||||
const query = panel.querySelector.bind(panel);
|
||||
panel.querySelector = (selector) =>
|
||||
selector === '[data-key-setup-close]' ? close : query(selector);
|
||||
chip.click = () => chip.fire('click');
|
||||
close.click = () => close.fire('click');
|
||||
doc.body.append(panel);
|
||||
const dialog = () => settings.view?.dialog;
|
||||
let frames = 0;
|
||||
const previousFrame = globalThis.requestAnimationFrame;
|
||||
globalThis.requestAnimationFrame = (callback) => {
|
||||
@@ -705,6 +698,10 @@ test('Provider Settings uses its ready dialog handlers and refuses unavailable o
|
||||
else globalThis.requestAnimationFrame = previousFrame;
|
||||
});
|
||||
const { initKeySetup } = await import('../../keySetup.js');
|
||||
const { useProviderSettingsStore } =
|
||||
await import('../../ui/stores/providerSettings.js');
|
||||
const { applicationPinia } = await import('../../ui/vueRuntime.js');
|
||||
const settings = useProviderSettingsStore(applicationPinia());
|
||||
let finishStatus;
|
||||
const pending = initKeySetup({
|
||||
documentRef: doc,
|
||||
@@ -727,7 +724,7 @@ test('Provider Settings uses its ready dialog handlers and refuses unavailable o
|
||||
doc.body.classList.add('cockpit-mode');
|
||||
assert.equal((await request(true)).unavailable, true);
|
||||
assert.equal(
|
||||
panel.hidden,
|
||||
dialog().hidden,
|
||||
true,
|
||||
'a concealed view cannot schedule a later surprise reveal',
|
||||
);
|
||||
@@ -737,16 +734,16 @@ test('Provider Settings uses its ready dialog handlers and refuses unavailable o
|
||||
await assert.rejects(() => request(true, { signal: abort.signal }), {
|
||||
name: 'AbortError',
|
||||
});
|
||||
assert.equal(panel.hidden, true);
|
||||
assert.equal(dialog().hidden, true);
|
||||
assert.equal((await request(true)).ok, true);
|
||||
assert.equal(panel.hidden, false);
|
||||
assert.equal(panel.classList.contains('visible'), true);
|
||||
assert.equal(dialog().hidden, false);
|
||||
assert.equal(dialog().visible, true);
|
||||
assert.equal((await request(true)).ok, true);
|
||||
assert.equal(frames, 1, 'repeated open reuses the dialog');
|
||||
assert.equal((await request(false)).ok, true);
|
||||
assert.equal(panel.classList.contains('visible'), false);
|
||||
assert.equal(dialog().visible, false);
|
||||
t.mock.timers.tick(400);
|
||||
assert.equal(panel.hidden, true);
|
||||
assert.equal(dialog().hidden, true);
|
||||
assert.equal((await request(false)).ok, true);
|
||||
assert.equal(
|
||||
f.state.visual.length,
|
||||
|
||||
Reference in new issue
Block a user