mirror of
https://github.com/jambonz/jambonz-webapp.git
synced 2025-12-19 05:37:43 +00:00
appEnvs should support enum dropdown (#532)
This commit is contained in:
@@ -810,6 +810,7 @@ export interface AppEnvProperty {
|
|||||||
default?: string | number | boolean;
|
default?: string | number | boolean;
|
||||||
obscure?: boolean;
|
obscure?: boolean;
|
||||||
uiHint?: "input" | "textarea" | "filepicker";
|
uiHint?: "input" | "textarea" | "filepicker";
|
||||||
|
enum?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AppEnv {
|
export interface AppEnv {
|
||||||
|
|||||||
@@ -845,7 +845,9 @@ export const ApplicationForm = ({ application }: ApplicationFormProps) => {
|
|||||||
? String(defaultValue)
|
? String(defaultValue)
|
||||||
: "",
|
: "",
|
||||||
onChange: (
|
onChange: (
|
||||||
e: React.ChangeEvent<HTMLInputElement>,
|
e: React.ChangeEvent<
|
||||||
|
HTMLInputElement | HTMLSelectElement
|
||||||
|
>,
|
||||||
) => {
|
) => {
|
||||||
// Convert to proper type based on schema
|
// Convert to proper type based on schema
|
||||||
let newValue;
|
let newValue;
|
||||||
@@ -870,6 +872,11 @@ export const ApplicationForm = ({ application }: ApplicationFormProps) => {
|
|||||||
type: isNumber ? "number" : "text",
|
type: isNumber ? "number" : "text",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isDropdown =
|
||||||
|
webhook.webhookEnv![key].type === "string" &&
|
||||||
|
(webhook.webhookEnv![key].enum?.length || 0) >
|
||||||
|
0;
|
||||||
|
|
||||||
const textAreaSpecificProps = {
|
const textAreaSpecificProps = {
|
||||||
rows: 6,
|
rows: 6,
|
||||||
cols: 61,
|
cols: 61,
|
||||||
@@ -880,6 +887,19 @@ export const ApplicationForm = ({ application }: ApplicationFormProps) => {
|
|||||||
.obscure
|
.obscure
|
||||||
? ObscureInput
|
? ObscureInput
|
||||||
: webhook.webhookEnv![key].uiHint || "input";
|
: webhook.webhookEnv![key].uiHint || "input";
|
||||||
|
if (isDropdown) {
|
||||||
|
return (
|
||||||
|
<Selector
|
||||||
|
{...commonProps}
|
||||||
|
options={webhook.webhookEnv![
|
||||||
|
key
|
||||||
|
].enum!.map((option) => ({
|
||||||
|
name: option,
|
||||||
|
value: option,
|
||||||
|
}))}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
if (componentType === "filepicker") {
|
if (componentType === "filepicker") {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
Reference in New Issue
Block a user