diff --git a/contracts/api/v2/openapi.json b/contracts/api/v2/openapi.json
index e5929e3cc5..40913861b7 100644
--- a/contracts/api/v2/openapi.json
+++ b/contracts/api/v2/openapi.json
@@ -16879,6 +16879,10 @@
},
"type": "array"
},
+ "ordered": {
+ "description": "The order of a multi-select's values matters. The form shows the chosen values as a list that can be put in order.",
+ "type": "boolean"
+ },
"placeholder": {
"type": "string"
},
@@ -16919,6 +16923,14 @@
"AdminPluginFormSection": {
"additionalProperties": false,
"properties": {
+ "add_group": {
+ "description": "Sections with the same add_group are the slots of one list. The form shows the slots in use and a button that reveals the next.",
+ "type": "string"
+ },
+ "add_label": {
+ "description": "The text of the button that reveals the next slot.",
+ "type": "string"
+ },
"collapsed_default": {
"type": "boolean"
},
diff --git a/go.mod b/go.mod
index 5a058f05ed..517bb734f7 100644
--- a/go.mod
+++ b/go.mod
@@ -175,4 +175,4 @@ require (
replace github.com/zishang520/webtransport-go => ./internal/compat/zishang520-webtransport-go
-replace github.com/Silo-Server/silo-plugin-sdk => github.com/grtn91/silo-plugin-sdk v0.32.2-0.20261111162054-6349f38bd415
+replace github.com/Silo-Server/silo-plugin-sdk => github.com/grtn91/silo-plugin-sdk v0.32.2-0.20261111220705-65c53aada4d3
diff --git a/go.sum b/go.sum
index 99418f9da4..e77ac240ac 100644
--- a/go.sum
+++ b/go.sum
@@ -151,8 +151,8 @@ github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aN
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0 h1:5VipnvEpbqr2gA2VbM+nYVbkIF28c5ZQfqCBQ5g2xfk=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0/go.mod h1:Hyl3n6Twe1hvtd9XUXDec4pTvgMSEixRuQKPTMH2bNs=
-github.com/grtn91/silo-plugin-sdk v0.32.2-0.20261111162054-6349f38bd415 h1:Hd76ckWisVLd+q/+SCyVKACQrq128i+gQS1b+p3IyyE=
-github.com/grtn91/silo-plugin-sdk v0.32.2-0.20261111162054-6349f38bd415/go.mod h1:+r4X2TAiB9Gk22sUj1gFWUj65lll1P1/dMS+Ncvy3Y0=
+github.com/grtn91/silo-plugin-sdk v0.32.2-0.20261111220705-65c53aada4d3 h1:Hm3wz12BcA9RxImughmC1VLmu5fGJ8JAV2gsshyIGUA=
+github.com/grtn91/silo-plugin-sdk v0.32.2-0.20261111220705-65c53aada4d3/go.mod h1:+r4X2TAiB9Gk22sUj1gFWUj65lll1P1/dMS+Ncvy3Y0=
github.com/h2non/bimg v1.1.9 h1:WH20Nxko9l/HFm4kZCA3Phbgu2cbHvYzxwxn9YROEGg=
github.com/h2non/bimg v1.1.9/go.mod h1:R3+UiYwkK4rQl6KVFTOFJHitgLbZXBZNFh2cv3AEbp8=
github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k=
diff --git a/internal/apiv2/admin_plugin_installations.go b/internal/apiv2/admin_plugin_installations.go
index 8b0e3b86b2..a7b1133eff 100644
--- a/internal/apiv2/admin_plugin_installations.go
+++ b/internal/apiv2/admin_plugin_installations.go
@@ -99,6 +99,7 @@ type AdminPluginFormField struct {
ShowWhen []AdminFormCondition `json:"show_when"`
Validation *AdminPluginFormValidation `json:"validation,omitempty"`
ExclusiveGroupField string `json:"exclusive_group_field,omitempty"`
+ Ordered bool `json:"ordered,omitempty" doc:"The order of a multi-select's values matters. The form shows the chosen values as a list that can be put in order."`
}
type AdminPluginFormSection struct {
Key string `json:"key"`
@@ -108,6 +109,8 @@ type AdminPluginFormSection struct {
CollapsedDefault bool `json:"collapsed_default"`
FieldKeys []string `json:"field_keys"`
ShowWhen []AdminFormCondition `json:"show_when"`
+ AddGroup string `json:"add_group,omitempty" doc:"Sections with the same add_group are the slots of one list. The form shows the slots in use and a button that reveals the next."`
+ AddLabel string `json:"add_label,omitempty" doc:"The text of the button that reveals the next slot."`
}
type AdminPluginForm struct {
Fields []AdminPluginFormField `json:"fields"`
@@ -285,7 +288,7 @@ func adminPluginFormOf(f *plugins.AdminFormView) (*AdminPluginForm, error) {
}
out := &AdminPluginForm{Fields: make([]AdminPluginFormField, 0, len(f.Fields)), SubmitLabel: f.SubmitLabel, Sections: make([]AdminPluginFormSection, 0, len(f.Sections))}
for _, fld := range f.Fields {
- item := AdminPluginFormField{Key: fld.Key, Label: fld.Label, Description: fld.Description, Control: fld.Control, Placeholder: fld.Placeholder, Required: fld.Required, Secret: fld.Secret, Multiline: fld.Multiline, Options: make([]AdminFormOption, 0, len(fld.Options)), Rows: fld.Rows, DynamicOptions: fld.DynamicOptions, ShowWhen: adminPluginFormConditionsOf(fld.ShowWhen), ExclusiveGroupField: fld.ExclusiveGroupField}
+ item := AdminPluginFormField{Key: fld.Key, Label: fld.Label, Description: fld.Description, Control: fld.Control, Placeholder: fld.Placeholder, Required: fld.Required, Secret: fld.Secret, Multiline: fld.Multiline, Options: make([]AdminFormOption, 0, len(fld.Options)), Rows: fld.Rows, DynamicOptions: fld.DynamicOptions, ShowWhen: adminPluginFormConditionsOf(fld.ShowWhen), ExclusiveGroupField: fld.ExclusiveGroupField, Ordered: fld.Ordered}
if fld.DefaultValue != nil {
raw, err := json.Marshal(fld.DefaultValue)
if err != nil {
@@ -302,7 +305,7 @@ func adminPluginFormOf(f *plugins.AdminFormView) (*AdminPluginForm, error) {
out.Fields = append(out.Fields, item)
}
for _, s := range f.Sections {
- out.Sections = append(out.Sections, AdminPluginFormSection{Key: s.Key, Title: s.Title, Description: s.Description, Collapsible: s.Collapsible, CollapsedDefault: s.CollapsedDefault, FieldKeys: NonNil(s.FieldKeys), ShowWhen: adminPluginFormConditionsOf(s.ShowWhen)})
+ out.Sections = append(out.Sections, AdminPluginFormSection{Key: s.Key, Title: s.Title, Description: s.Description, Collapsible: s.Collapsible, CollapsedDefault: s.CollapsedDefault, FieldKeys: NonNil(s.FieldKeys), ShowWhen: adminPluginFormConditionsOf(s.ShowWhen), AddGroup: s.AddGroup, AddLabel: s.AddLabel})
}
return out, nil
}
diff --git a/internal/plugins/config_schema_view.go b/internal/plugins/config_schema_view.go
index c788d8807c..a02c8a11b0 100644
--- a/internal/plugins/config_schema_view.go
+++ b/internal/plugins/config_schema_view.go
@@ -39,6 +39,8 @@ type AdminFormFieldView struct {
ShowWhen []AdminFormConditionView `json:"show_when,omitempty"`
Validation *AdminFormValidationView `json:"validation,omitempty"`
ExclusiveGroupField string `json:"exclusive_group_field,omitempty"`
+ // Ordered says the order of a multi-select's values matters.
+ Ordered bool `json:"ordered,omitempty"`
}
type AdminFormOptionView struct {
@@ -70,6 +72,10 @@ type AdminFormSectionView struct {
CollapsedDefault bool `json:"collapsed_default"`
FieldKeys []string `json:"field_keys"`
ShowWhen []AdminFormConditionView `json:"show_when,omitempty"`
+ // AddGroup names the list this section is one slot of, and AddLabel the
+ // button that reveals the next slot. Empty for an ordinary section.
+ AddGroup string `json:"add_group,omitempty"`
+ AddLabel string `json:"add_label,omitempty"`
}
func ConfigSchemaViews(schemas []*pluginv1.ConfigSchema) []ConfigSchemaView {
@@ -122,7 +128,7 @@ func AdminFormViewFromProto(form *pluginv1.AdminFormDescriptor) *AdminFormView {
Placeholder: field.GetPlaceholder(), Required: field.GetRequired(), Secret: field.GetSecret(),
Multiline: field.GetMultiline(), DefaultValue: defaultValue, Options: options, Rows: field.GetRows(),
DynamicOptions: field.GetDynamicOptions(), ShowWhen: adminFormConditionViews(field.GetShowWhen()),
- Validation: validation, ExclusiveGroupField: field.GetExclusiveGroupField(),
+ Validation: validation, ExclusiveGroupField: field.GetExclusiveGroupField(), Ordered: field.GetOrdered(),
})
}
sections := make([]AdminFormSectionView, 0, len(form.GetSections()))
@@ -134,6 +140,7 @@ func AdminFormViewFromProto(form *pluginv1.AdminFormDescriptor) *AdminFormView {
Key: section.GetKey(), Title: section.GetTitle(), Description: section.GetDescription(),
Collapsible: section.GetCollapsible(), CollapsedDefault: section.GetCollapsedDefault(),
FieldKeys: append([]string(nil), section.GetFieldKeys()...), ShowWhen: adminFormConditionViews(section.GetShowWhen()),
+ AddGroup: section.GetAddGroup(), AddLabel: section.GetAddLabel(),
})
}
return &AdminFormView{Fields: fields, SubmitLabel: form.GetSubmitLabel(), Sections: sections}
diff --git a/web/src/api/types.ts b/web/src/api/types.ts
index 179b506527..6a029542f8 100644
--- a/web/src/api/types.ts
+++ b/web/src/api/types.ts
@@ -3935,6 +3935,10 @@ export interface PluginAdminFormSection {
collapsed_default: boolean;
field_keys: string[];
show_when?: PluginAdminFormCondition[];
+ /** Sections with the same add_group are the slots of one list the admin grows. */
+ add_group?: string;
+ /** The text of the button that reveals the next slot. */
+ add_label?: string;
}
export interface PluginAdminFormField {
@@ -3953,6 +3957,8 @@ export interface PluginAdminFormField {
show_when?: PluginAdminFormCondition[];
validation?: PluginAdminFormValidation;
exclusive_group_field?: string;
+ /** The order of a multi-select's values matters; the form lets the admin arrange them. */
+ ordered?: boolean;
/**
* Names a host-known value this field can be populated from in one click.
* Used by autoscan source config so a path field can be filled from Silo's
diff --git a/web/src/api/v2/schema.ts b/web/src/api/v2/schema.ts
index a62d831a87..30860c36dc 100644
--- a/web/src/api/v2/schema.ts
+++ b/web/src/api/v2/schema.ts
@@ -19932,6 +19932,8 @@ export interface components {
label: string;
multiline: boolean;
options: components["schemas"]["AdminFormOption"][];
+ /** @description The order of a multi-select's values matters. The form shows the chosen values as a list that can be put in order. */
+ ordered?: boolean;
placeholder?: string;
required: boolean;
/** Format: int32 */
@@ -19941,6 +19943,10 @@ export interface components {
validation?: components["schemas"]["AdminPluginFormValidation"];
};
AdminPluginFormSection: {
+ /** @description Sections with the same add_group are the slots of one list. The form shows the slots in use and a button that reveals the next. */
+ add_group?: string;
+ /** @description The text of the button that reveals the next slot. */
+ add_label?: string;
collapsed_default: boolean;
collapsible: boolean;
description?: string;
diff --git a/web/src/components/admin/plugins/OrderedMultiSelect.tsx b/web/src/components/admin/plugins/OrderedMultiSelect.tsx
new file mode 100644
index 0000000000..88f87e5a0f
--- /dev/null
+++ b/web/src/components/admin/plugins/OrderedMultiSelect.tsx
@@ -0,0 +1,143 @@
+import { DndContext } from "@dnd-kit/core";
+import { SortableContext, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
+import { CSS } from "@dnd-kit/utilities";
+import { GripVertical, Plus, X } from "lucide-react";
+
+import { Button } from "@/components/ui/button";
+import { useSortableList } from "@/hooks/useSortableList";
+import { useT } from "@/i18n";
+
+import type { SchemaOption } from "./schemaFormUtils";
+
+function identity(value: string): string {
+ return value;
+}
+
+function SortableValue({
+ value,
+ label,
+ position,
+ disabled,
+ onRemove,
+}: {
+ value: string;
+ label: string;
+ position: number;
+ disabled: boolean;
+ onRemove: () => void;
+}) {
+ const t = useT();
+ const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({
+ id: value,
+ disabled,
+ });
+ const style: React.CSSProperties = {
+ transform: CSS.Transform.toString(transform),
+ transition,
+ opacity: isDragging ? 0.4 : 1,
+ };
+ return (
+
+
+ {position}
+ {label}
+
+
+ );
+}
+
+/**
+ * A multi-select whose order matters. The chosen values are a list that can
+ * be put in order by dragging, or with the keyboard on a row's handle; the
+ * options not chosen yet are buttons that add to the end of it.
+ */
+export function OrderedMultiSelect({
+ options,
+ selected,
+ onChange,
+ disabled = false,
+ describedBy,
+}: {
+ options: SchemaOption[];
+ selected: string[];
+ onChange: (next: string[]) => void;
+ disabled?: boolean;
+ describedBy?: string;
+}) {
+ const { sensors, collisionDetection, handleDragEnd } = useSortableList(
+ selected,
+ identity,
+ onChange,
+ );
+ // A chosen value the options no longer list keeps its place, shown as it is stored.
+ const labels = new Map(options.map((option) => [option.value, option.label]));
+ const unchosen = options.filter((option) => !selected.includes(option.value));
+
+ return (
+