diff options
| author | Adam Malczewski <[email protected]> | 2026-06-25 22:45:51 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-06-25 22:45:51 +0900 |
| commit | 306f28a7732e11e3de1c6d0c4d26cadb92b25d3e (patch) | |
| tree | a9584c44cf71031aa20b50e43ef5cf534536bb16 /src/features/computer/ui/ComputerSelect.svelte | |
| parent | 84c07718aaa4224953cf7f6cf986e825c8900cd5 (diff) | |
| parent | b54f026f5a1eeae697954ffe0a0ea2b4f5efe085 (diff) | |
| download | dispatch-web-306f28a7732e11e3de1c6d0c4d26cadb92b25d3e.tar.gz dispatch-web-306f28a7732e11e3de1c6d0c4d26cadb92b25d3e.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.svelte | 39 |
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> |
