@@ -1980,35 +1984,65 @@ export function ChannelMutateDrawer({
...
@@ -1980,35 +1984,65 @@ export function ChannelMutateDrawer({
<FormItem>
<FormItem>
<FormLabel>{t('Task plugin *')}</FormLabel>
<FormLabel>{t('Task plugin *')}</FormLabel>
{canBindTaskPlugin?(
{canBindTaskPlugin?(
<FormControl><Combobox
<FormControl>
value={field.value}
<Combobox
onValueChange={(value)=>{
value={field.value}
field.onChange(value)
onValueChange={(value)=>{
constplugin=
constoptions=
taskPluginOptionsQuery.data?.find(
taskPluginOptionsQuery.data??[]
(item)=>item.key===value
constpreviousPlugin=options.find(
(item)=>item.key===field.value
)
)
if(plugin?.models?.length){
field.onChange(value)
form.setValue(
constplugin=options.find(
'models',
(item)=>item.key===value
formatModelsArray(plugin.models),
{
shouldDirty:true,
}
)
)
}
if(plugin?.models?.length){
}}
form.setValue(
options={(
'models',
taskPluginOptionsQuery.data??[]
formatModelsArray(plugin.models),
).map((plugin)=>({
{
value:plugin.key,
shouldDirty:true,
label:`${plugin.name} (${plugin.key})`,
}
}))}
)
className='w-full'
}
placeholder={t(
constprefilledBaseUrl=
'Select task plugin'
nextTaskPluginBaseUrl(
)}
form.getValues('base_url'),
/></FormControl>
previousPlugin?.baseUrl,
plugin?.baseUrl
)
if(prefilledBaseUrl!==null){
form.setValue(
'base_url',
prefilledBaseUrl,
{
shouldDirty:true,
shouldValidate:true,
}
)
}
}}
options={(
taskPluginOptionsQuery.data??[]
).map((plugin)=>({
value:plugin.key,
label:`${plugin.name} (${plugin.key})`,
icon:(
<PluginIcon
plugin={{
...plugin,
hasIcon:plugin.hasIcon,
}}
size={16}
/>
),
}))}
className='w-full'
placeholder={t('Select task plugin')}
showSelectedIcon
/>
</FormControl>
):(
):(
<FormControl>
<FormControl>
<Input
<Input
...
@@ -2020,7 +2054,7 @@ placeholder={t(
...
@@ -2020,7 +2054,7 @@ placeholder={t(
)}
)}
<FormDescription>
<FormDescription>
{t(
{t(
'Selecting a plugin fills its declared models.'
'Selecting a plugin fills its declared models and default base URL.'
)}
)}
</FormDescription>
</FormDescription>
<FormMessage/>
<FormMessage/>
...
@@ -2792,12 +2826,74 @@ placeholder={t(
...
@@ -2792,12 +2826,74 @@ placeholder={t(
{...field}
{...field}
/>
/>
</FormControl>
</FormControl>
<FormDescription>
{currentType!==
{t(
CHANNEL_TYPE_TASK_PLUGIN&&(
'Custom API base URL. For official channels, New API has built-in addresses. Only fill this for third-party proxy sites or special endpoints. Do not add /v1 or trailing slash.'
<FormDescription>
{t(
'Custom API base URL. For official channels, New API has built-in addresses. Only fill this for third-party proxy sites or special endpoints. Do not add /v1 or trailing slash.'
)}
</FormDescription>
)}
{currentType===CHANNEL_TYPE_TASK_PLUGIN&&
!boundTaskPlugin?.baseUrl&&(
<FormDescription>
{t(
'The upstream address this plugin sends requests to. The plugin declares no default, so it must be filled in.'