mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-11-05 07:12:02 +08:00
fix(web): hide duplicate connection mode control
This commit is contained in:
@@ -552,6 +552,14 @@ const BotForm = forwardRef<BotFormHandle, BotFormProps>(function BotForm(
|
||||
[adapterNameToDynamicConfigMap, currentAdapter],
|
||||
);
|
||||
|
||||
const connectionModeControllerNames = useMemo(() => {
|
||||
if (supportedConnectionModes.length <= 1) return [];
|
||||
const webhookField = dynamicFormConfigList.find(
|
||||
(item) => item.type === DynamicFormItemType.WEBHOOK_URL,
|
||||
);
|
||||
return webhookField?.show_if?.field ? [webhookField.show_if.field] : [];
|
||||
}, [dynamicFormConfigList, supportedConnectionModes.length]);
|
||||
|
||||
const botGuideSteps = useMemo<GuidedTourStep[]>(() => {
|
||||
const steps: GuidedTourStep[] = [];
|
||||
|
||||
@@ -1140,6 +1148,7 @@ const BotForm = forwardRef<BotFormHandle, BotFormProps>(function BotForm(
|
||||
<div data-guide="bot-adapter-parameters">
|
||||
<DynamicFormComponent
|
||||
itemConfigList={dynamicFormConfigList}
|
||||
hiddenItemNames={connectionModeControllerNames}
|
||||
initialValues={currentAdapterConfig}
|
||||
onSubmit={(values) => {
|
||||
form.setValue('adapter_config', values, {
|
||||
|
||||
@@ -441,6 +441,7 @@ export default function DynamicFormComponent({
|
||||
systemContext,
|
||||
onValidate,
|
||||
renderItem,
|
||||
hiddenItemNames,
|
||||
}: {
|
||||
itemConfigList: IDynamicFormItemSchema[];
|
||||
onSubmit?: (val: object) => unknown;
|
||||
@@ -463,6 +464,8 @@ export default function DynamicFormComponent({
|
||||
formValues: Record<string, unknown>;
|
||||
setFormValue: (name: string, value: unknown) => void;
|
||||
}) => ReactNode | undefined;
|
||||
/** Fields retained in form state but omitted from the rendered form. */
|
||||
hiddenItemNames?: readonly string[];
|
||||
}) {
|
||||
const isInitialMount = useRef(true);
|
||||
const previousInitialValues = useRef(initialValues);
|
||||
@@ -647,6 +650,8 @@ export default function DynamicFormComponent({
|
||||
/>
|
||||
|
||||
{itemConfigList.map((config, index) => {
|
||||
if (hiddenItemNames?.includes(config.name)) return null;
|
||||
|
||||
// Create a normalized config with type converted to frontend format
|
||||
const normalizedConfig = {
|
||||
...config,
|
||||
|
||||
Reference in New Issue
Block a user