summaryrefslogtreecommitdiffhomepage
path: root/src/features/computer/ui/ComputerSelect.svelte
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-25 22:45:51 +0900
committerAdam Malczewski <[email protected]>2026-06-25 22:45:51 +0900
commit1285564f12238b22f6b39b9f3fbcecaca8456911 (patch)
tree9d8ca532969a5a11ee61b5c42135ac6f54159183 /src/features/computer/ui/ComputerSelect.svelte
parentc5ea2232f117adda740c7e3b8366e9f10f14d3cb (diff)
parentcdce5197abcf0f5b0576e847a701d3a317384a65 (diff)
downloaddispatch-web-1285564f12238b22f6b39b9f3fbcecaca8456911.tar.gz
dispatch-web-1285564f12238b22f6b39b9f3fbcecaca8456911.zip
Merge branch 'feature/ssh-support' into dev
# Conflicts: # src/features/workspaces/ui/WorkspaceCard.svelte # src/features/workspaces/ui/WorkspaceCard.test.ts # src/features/workspaces/ui/WorkspacesHome.svelte
Diffstat (limited to 'src/features/computer/ui/ComputerSelect.svelte')
-rw-r--r--src/features/computer/ui/ComputerSelect.svelte39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/features/computer/ui/ComputerSelect.svelte b/src/features/computer/ui/ComputerSelect.svelte
new file mode 100644
index 0000000..d693140
--- /dev/null
+++ b/src/features/computer/ui/ComputerSelect.svelte
@@ -0,0 +1,39 @@
+<script lang="ts">
+ import type { ComputerEntry } from "@dispatch/wire";
+
+ let {
+ value,
+ computers,
+ disabled = false,
+ onSelect,
+ }: {
+ /** The currently selected computer alias, or null for "Local (none)". */
+ value: string | null;
+ /** Discovered computers from `GET /computers` (read-only). */
+ computers: readonly ComputerEntry[];
+ disabled?: boolean;
+ onSelect: (computerId: string | null) => void;
+ } = $props();
+
+ // A `<select>` value is a string; map "" ↔ null (Local). The chosen option's
+ // value is the alias, with "" meaning "clear / local".
+ const selectValue = $derived(value ?? "");
+
+ function onChange(e: Event) {
+ const v = (e.currentTarget as HTMLSelectElement).value;
+ onSelect(v === "" ? null : v);
+ }
+</script>
+
+<select
+ class="select select-bordered select-sm w-full font-mono text-xs"
+ value={selectValue}
+ disabled={disabled}
+ onchange={onChange}
+ aria-label="Computer"
+>
+ <option value="">Local (none)</option>
+ {#each computers as c (c.alias)}
+ <option value={c.alias}>{c.alias}{c.knownHost ? "" : " · new host"}</option>
+ {/each}
+</select>