mirror of
https://github.com/jambonz/jambonz-webapp.git
synced 2026-01-25 02:08:19 +00:00
fix app envs does not take default value and filepicker is required even value is available (#529)
This commit is contained in:
@@ -53,7 +53,12 @@ import type {
|
|||||||
AppEnv,
|
AppEnv,
|
||||||
} from "src/api/types";
|
} from "src/api/types";
|
||||||
import { MSG_REQUIRED_FIELDS, MSG_WEBHOOK_FIELDS } from "src/constants";
|
import { MSG_REQUIRED_FIELDS, MSG_WEBHOOK_FIELDS } from "src/constants";
|
||||||
import { hasLength, isUserAccountScope, useRedirect } from "src/utils";
|
import {
|
||||||
|
hasLength,
|
||||||
|
hasValue,
|
||||||
|
isUserAccountScope,
|
||||||
|
useRedirect,
|
||||||
|
} from "src/utils";
|
||||||
import { setAccountFilter, setLocation } from "src/store/localStore";
|
import { setAccountFilter, setLocation } from "src/store/localStore";
|
||||||
import SpeechProviderSelection from "./speech-selection";
|
import SpeechProviderSelection from "./speech-selection";
|
||||||
import ObscureInput from "src/components/obscure-input";
|
import ObscureInput from "src/components/obscure-input";
|
||||||
@@ -595,6 +600,18 @@ export const ApplicationForm = ({ application }: ApplicationFormProps) => {
|
|||||||
getAppEnvSchema(callWebhook.url)
|
getAppEnvSchema(callWebhook.url)
|
||||||
.then(({ json }) => {
|
.then(({ json }) => {
|
||||||
setAppEnv(json);
|
setAppEnv(json);
|
||||||
|
const defaultEnvVars = Object.keys(json).reduce((acc, key) => {
|
||||||
|
const value = json[key];
|
||||||
|
if (value?.default) {
|
||||||
|
return { ...acc, [key]: value.default };
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
|
||||||
|
setEnvVars((prev) => ({
|
||||||
|
...defaultEnvVars,
|
||||||
|
...(prev || {}),
|
||||||
|
}));
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
setMessage(error.msg);
|
setMessage(error.msg);
|
||||||
@@ -886,7 +903,8 @@ export const ApplicationForm = ({ application }: ApplicationFormProps) => {
|
|||||||
}}
|
}}
|
||||||
placeholder="Choose a file"
|
placeholder="Choose a file"
|
||||||
required={
|
required={
|
||||||
webhook.webhookEnv![key].required
|
webhook.webhookEnv![key].required &&
|
||||||
|
!hasValue(envVars?.[key])
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{React.createElement("textarea", {
|
{React.createElement("textarea", {
|
||||||
|
|||||||
Reference in New Issue
Block a user