mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-28 21:27:14 +00:00
fix(bots): move adapter debugger to configuration
This commit is contained in:
@@ -22,6 +22,7 @@ import { Agent, Bot } from '@/app/infra/entities/api';
|
||||
import { getAdapterDocUrl } from '@/app/infra/entities/adapter-docs';
|
||||
import { ExternalLink, ChevronDown, ChevronRight } from 'lucide-react';
|
||||
import EventBindingsEditor from './EventBindingsEditor';
|
||||
import AdapterEventDebugDialog from './AdapterEventDebugDialog';
|
||||
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { useForm } from 'react-hook-form';
|
||||
@@ -687,6 +688,27 @@ const BotForm = forwardRef<BotFormHandle, BotFormProps>(function BotForm(
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
{currentAdapter && initBotId && (
|
||||
<div className="flex flex-col gap-3 border-t pt-4 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div className="min-w-0">
|
||||
<p className="text-sm font-medium">
|
||||
{t('bots.adapterConfigurationTest')}
|
||||
</p>
|
||||
<p className="mt-1 text-sm text-muted-foreground">
|
||||
{t('bots.adapterConfigurationTestDescription')}
|
||||
</p>
|
||||
</div>
|
||||
<AdapterEventDebugDialog
|
||||
botId={initBotId}
|
||||
adapterLabel={
|
||||
adapterNameList.find(
|
||||
(adapter) => adapter.value === currentAdapter,
|
||||
)?.label ?? currentAdapter
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
@@ -703,11 +725,6 @@ const BotForm = forwardRef<BotFormHandle, BotFormProps>(function BotForm(
|
||||
<EventBindingsEditor
|
||||
form={form}
|
||||
botId={initBotId}
|
||||
adapterLabel={
|
||||
adapterNameList.find(
|
||||
(adapter) => adapter.value === currentAdapter,
|
||||
)?.label ?? currentAdapter
|
||||
}
|
||||
supportedEvents={adapterSupportedEvents[currentAdapter] || []}
|
||||
agentOptions={agentNameList}
|
||||
/>
|
||||
|
||||
@@ -120,7 +120,6 @@ import {
|
||||
groupEventPatterns,
|
||||
} from '@/app/home/components/event-patterns/event-pattern-groups';
|
||||
import EventSelectOptionContent from '@/app/home/components/event-patterns/EventSelectOptionContent';
|
||||
import AdapterEventDebugDialog from './AdapterEventDebugDialog';
|
||||
|
||||
export const PIPELINE_DISCARD = '__discard__';
|
||||
|
||||
@@ -129,7 +128,6 @@ export const PIPELINE_DISCARD = '__discard__';
|
||||
interface EventBindingsEditorProps {
|
||||
form: UseFormReturn<any>;
|
||||
botId?: string;
|
||||
adapterLabel: string;
|
||||
supportedEvents: string[];
|
||||
agentOptions: Agent[];
|
||||
}
|
||||
@@ -1428,7 +1426,6 @@ function SortableBindingCard({
|
||||
export default function EventBindingsEditor({
|
||||
form,
|
||||
botId,
|
||||
adapterLabel,
|
||||
supportedEvents,
|
||||
agentOptions,
|
||||
}: EventBindingsEditorProps) {
|
||||
@@ -1800,7 +1797,6 @@ export default function EventBindingsEditor({
|
||||
eventOptions={dryRunEventOptions}
|
||||
agentOptions={agentOptions}
|
||||
/>
|
||||
<AdapterEventDebugDialog botId={botId} adapterLabel={adapterLabel} />
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
|
||||
@@ -471,6 +471,9 @@ const enUS = {
|
||||
adapterEventNeedsSavedBot:
|
||||
'Save the bot before listening for platform events.',
|
||||
adapterEventCurrentPlatform: 'the current platform',
|
||||
adapterConfigurationTest: 'Test adapter configuration',
|
||||
adapterConfigurationTestDescription:
|
||||
'Trigger an event on the platform to confirm these settings work.',
|
||||
refreshRouteStatus: 'Refresh status',
|
||||
routeStatusIdle: 'No run yet',
|
||||
routeStatusRefreshFailed: 'Failed to refresh route status.',
|
||||
|
||||
@@ -478,6 +478,9 @@ const jaJP = {
|
||||
adapterEventNeedsSavedBot:
|
||||
'プラットフォームイベントを監視する前にボットを保存してください。',
|
||||
adapterEventCurrentPlatform: '現在のプラットフォーム',
|
||||
adapterConfigurationTest: 'アダプター設定をテスト',
|
||||
adapterConfigurationTestDescription:
|
||||
'プラットフォームでイベントを発生させ、この設定が動作することを確認します。',
|
||||
refreshRouteStatus: '状態を更新',
|
||||
routeStatusIdle: '実行記録なし',
|
||||
routeStatusRefreshFailed: 'ルート状態の更新に失敗しました。',
|
||||
|
||||
@@ -448,6 +448,9 @@ const zhHans = {
|
||||
adapterEventData: '查看事件数据',
|
||||
adapterEventNeedsSavedBot: '请先保存机器人后再监听平台事件。',
|
||||
adapterEventCurrentPlatform: '当前平台',
|
||||
adapterConfigurationTest: '适配器测试',
|
||||
adapterConfigurationTestDescription:
|
||||
'在当前平台触发事件,确认这组配置是否已经生效。',
|
||||
refreshRouteStatus: '刷新状态',
|
||||
routeStatusIdle: '暂无运行记录',
|
||||
routeStatusRefreshFailed: '刷新路由状态失败。',
|
||||
|
||||
@@ -445,6 +445,9 @@ test.describe('bot advanced flows', () => {
|
||||
const routingCard = page
|
||||
.locator('[data-slot="card"]')
|
||||
.filter({ has: page.getByText('Event Routing', { exact: true }) });
|
||||
const adapterCard = page.locator('[data-slot="card"]').filter({
|
||||
has: page.getByText('Adapter Configuration', { exact: true }),
|
||||
});
|
||||
const dangerCard = page
|
||||
.locator('[data-slot="card"]')
|
||||
.filter({ has: page.getByText('Danger Zone', { exact: true }) });
|
||||
@@ -532,7 +535,13 @@ test.describe('bot advanced flows', () => {
|
||||
expect(dialogBox!.height).toBeLessThan(500);
|
||||
|
||||
await routeDialog.getByRole('button', { name: 'Close' }).first().click();
|
||||
await routingCard
|
||||
await expect(
|
||||
routingCard.getByRole('button', { name: 'Listen for platform events' }),
|
||||
).toHaveCount(0);
|
||||
await expect(
|
||||
adapterCard.getByText('Test adapter configuration'),
|
||||
).toBeVisible();
|
||||
await adapterCard
|
||||
.getByRole('button', { name: 'Listen for platform events' })
|
||||
.click();
|
||||
const adapterDialog = page.getByRole('dialog');
|
||||
|
||||
Reference in New Issue
Block a user