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;
|
||||
obscure?: boolean;
|
||||
uiHint?: "input" | "textarea" | "filepicker";
|
||||
enum?: string[];
|
||||
}
|
||||
|
||||
export interface AppEnv {
|
||||
|
||||
@@ -845,7 +845,9 @@ export const ApplicationForm = ({ application }: ApplicationFormProps) => {
|
||||
? String(defaultValue)
|
||||
: "",
|
||||
onChange: (
|
||||
e: React.ChangeEvent<HTMLInputElement>,
|
||||
e: React.ChangeEvent<
|
||||
HTMLInputElement | HTMLSelectElement
|
||||
>,
|
||||
) => {
|
||||
// Convert to proper type based on schema
|
||||
let newValue;
|
||||
@@ -870,6 +872,11 @@ export const ApplicationForm = ({ application }: ApplicationFormProps) => {
|
||||
type: isNumber ? "number" : "text",
|
||||
};
|
||||
|
||||
const isDropdown =
|
||||
webhook.webhookEnv![key].type === "string" &&
|
||||
(webhook.webhookEnv![key].enum?.length || 0) >
|
||||
0;
|
||||
|
||||
const textAreaSpecificProps = {
|
||||
rows: 6,
|
||||
cols: 61,
|
||||
@@ -880,6 +887,19 @@ export const ApplicationForm = ({ application }: ApplicationFormProps) => {
|
||||
.obscure
|
||||
? ObscureInput
|
||||
: webhook.webhookEnv![key].uiHint || "input";
|
||||
if (isDropdown) {
|
||||
return (
|
||||
<Selector
|
||||
{...commonProps}
|
||||
options={webhook.webhookEnv![
|
||||
key
|
||||
].enum!.map((option) => ({
|
||||
name: option,
|
||||
value: option,
|
||||
}))}
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (componentType === "filepicker") {
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user