blob: 2619a39b9215740b3942cef46c856a2966b76375 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
<script lang="ts">
import type { InvokeMessage } from "@dispatch/ui-contract";
import { SurfaceView } from "../features/surface-host";
import type { AppStore } from "./store.svelte";
let { store }: { store: AppStore } = $props();
function handleSelect(surfaceId: string) {
store.select(surfaceId);
}
function handleInvoke(msg: InvokeMessage) {
store.invoke(msg.surfaceId, msg.actionId, msg.payload);
}
</script>
<main>
<h1>Dispatch</h1>
{#if store.lastError}
<div role="alert">
<strong>Error:</strong>
{store.lastError.message}
</div>
{/if}
<section>
<h2>Surfaces</h2>
{#if store.catalog.length === 0}
<p>No surfaces available</p>
{:else}
<ul>
{#each store.catalog as entry (entry.id)}
<li>
<button
aria-current={entry.id === store.selectedId ? "true" : undefined}
onclick={() => handleSelect(entry.id)}
>
{entry.title}
<span>({entry.region})</span>
</button>
</li>
{/each}
</ul>
{/if}
</section>
{#if store.selectedSpec}
<section>
<SurfaceView spec={store.selectedSpec} onInvoke={handleInvoke} />
</section>
{/if}
</main>
|