feat(storepkg,ui): a package can declare a multi-line text setting (#2006)
This commit is contained in:
3 files changed
+6
-2
No files matched your search
@@ -58,6 +58,8 @@ const (
|
||||
SettingDuration SettingType = "duration"
|
||||
SettingList SettingType = "list"
|
||||
SettingSelect SettingType = "select"
|
||||
// SettingText is a string entered over several lines.
|
||||
SettingText SettingType = "text"
|
||||
)
|
||||
|
||||
// Kind returns the setting's type with the default applied.
|
||||
@@ -70,7 +72,7 @@ func (s Setting) Kind() SettingType {
|
||||
|
||||
func (s Setting) validateType() error {
|
||||
switch s.Kind() {
|
||||
case SettingString, SettingNumber, SettingBoolean, SettingDuration, SettingList, SettingSelect:
|
||||
case SettingString, SettingNumber, SettingBoolean, SettingDuration, SettingList, SettingSelect, SettingText:
|
||||
default:
|
||||
return fmt.Errorf("setting %q: unknown type %q", s.Key, s.Type)
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import { computed } from "vue";
|
||||
import { DurationInput } from "@/components/ui/duration-input";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { NumberField, NumberFieldContent, NumberFieldDecrement, NumberFieldIncrement, NumberFieldInput } from "@/components/ui/number-field";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { TagsInput, TagsInputInput, TagsInputItem, TagsInputItemDelete, TagsInputItemText } from "@/components/ui/tags-input";
|
||||
import type { ExtensionSettingSpec } from "@/stores/extensions";
|
||||
@@ -52,5 +53,6 @@ const options = computed(() => (props.spec.options ?? []).map((value) => ({ valu
|
||||
</TagsInput>
|
||||
</div>
|
||||
<OptionSelect v-else-if="spec.type === 'select'" :id="id" :model-value="model" :options="options" @update:model-value="(value) => (model = value)" />
|
||||
<Textarea v-else-if="spec.type === 'text'" :id="id" :model-value="model" rows="6" class="max-w-xl" @update:model-value="(value) => (model = String(value))" />
|
||||
<Input v-else :id="id" v-model="model" class="max-w-md font-mono" />
|
||||
</template>
|
||||
@@ -41,7 +41,7 @@ export interface ExtensionSettingSpec {
|
||||
secret?: boolean;
|
||||
required?: boolean;
|
||||
/** Absent means string. */
|
||||
type?: "string" | "number" | "boolean" | "duration" | "list" | "select";
|
||||
type?: "string" | "number" | "boolean" | "duration" | "list" | "select" | "text";
|
||||
/** Choices for a select. */
|
||||
options?: string[];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user