fix(ui): egress hosts is a one-host-per-line text area (#1967)

This commit is contained in:
sam committed 2026-11-14 11:33:13 +11:00
1 parent dc4cd29c83
commit 6eea6aaffa
1 file changed
+9 -23
+9 -23
View File
@@ -17,13 +17,7 @@ import {
NumberFieldIncrement,
NumberFieldInput,
} from "@/components/ui/number-field";
import {
TagsInput,
TagsInputInput,
TagsInputItem,
TagsInputItemDelete,
TagsInputItemText,
} from "@/components/ui/tags-input";
import { Textarea } from "@/components/ui/textarea";
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
import { resourcesForPage, useSettingsStore } from "@/stores/settings";
import DraftHint from "./DraftHint.vue";
@@ -91,8 +85,7 @@ const uptimeWarning = computed(() => {
return `Shorter than ${limit}, so containers are killed before a task can finish.`;
});
// A keyboard's clipboard inserts text as typing, not as a paste event, so a
// pasted list arrives as one entry; split it here whatever the input path.
// One host per line; commas and spaces separate too, so a pasted list works.
function splitHosts(values: string[]): string[] {
return [...new Set(values.flatMap((v) => v.split(/[\s,]+/)).filter(Boolean))];
}
@@ -362,21 +355,14 @@ function formatHours(seconds: number): string {
<Field orientation="responsive">
<FieldContent><FieldLabel>Egress hosts</FieldLabel></FieldContent>
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
<TagsInput
:model-value="field.state.value ?? []"
class="font-mono"
<Textarea
:model-value="(field.state.value ?? []).join('\n')"
:rows="6"
class="font-mono text-label"
aria-label="Egress hosts"
add-on-blur
add-on-paste
:delimiter="/[\s,]+/"
@update:model-value="(v) => field.handleChange(splitHosts(v as string[]))"
>
<TagsInputItem v-for="h in field.state.value ?? []" :key="h" :value="h">
<TagsInputItemText />
<TagsInputItemDelete />
</TagsInputItem>
<TagsInputInput placeholder="*.example.com:443" />
</TagsInput>
placeholder="*.example.com:443"
@change="(e: Event) => field.handleChange(splitHosts([(e.target as HTMLTextAreaElement).value]))"
/>
<DraftHint :kind="KIND" path="egress_hosts" />
</div>
</Field>