@@ -15,6 +15,7 @@ import { apiHelper } from '@/lib/api';
1515import PluginDetailInfo from './PluginDetailInfo' ;
1616import { Tooltip , TooltipContent , TooltipProvider , TooltipTrigger } from "@/components/ui/tooltip" ;
1717import { useAppStore } from '@/stores/appStore' ;
18+ import { shouldShowField } from '@/lib/pluginSettingsUtils' ;
1819
1920function JsonEditorDialog ( { initialValue, onSave, onCancel } ) {
2021 const [ jsonString , setJsonString ] = useState ( '' ) ;
@@ -201,6 +202,29 @@ function SettingField({ settingKey, config, value, onChange, readOnly }) {
201202 { config . description && < p className = "text-sm text-muted-foreground" > { config . description } </ p > }
202203 </ div >
203204 ) ;
205+ case 'select' :
206+ return (
207+ < div className = "space-y-2" >
208+ < Label htmlFor = { id } > { config . label } </ Label >
209+ < Select value = { value ?? config . default ?? '' } onValueChange = { readOnly ? undefined : ( ( newValue ) => onChange ( settingKey , newValue ) ) } disabled = { readOnly } >
210+ < SelectTrigger id = { id } >
211+ < SelectValue placeholder = "Выберите значение" />
212+ </ SelectTrigger >
213+ < SelectContent >
214+ { ( config . options || [ ] ) . map ( ( option ) => {
215+ const optionValue = typeof option === 'string' ? option : option . value ;
216+ const optionLabel = typeof option === 'string' ? option : option . label ;
217+ return (
218+ < SelectItem key = { optionValue } value = { optionValue } >
219+ { optionLabel }
220+ </ SelectItem >
221+ ) ;
222+ } ) }
223+ </ SelectContent >
224+ </ Select >
225+ { config . description && < p className = "text-sm text-muted-foreground" > { config . description } </ p > }
226+ </ div >
227+ ) ;
204228 case 'json_file' :
205229 return (
206230 < div className = "space-y-2" >
@@ -372,16 +396,19 @@ export default function PluginSettingsDialog({ bot, plugin, onOpenChange, onSave
372396 < AccordionItem key = { categoryKey } value = { categoryKey } className = "border rounded-lg bg-muted/20 px-4" >
373397 < AccordionTrigger className = "text-base font-semibold hover:no-underline" > { categoryConfig . label } </ AccordionTrigger >
374398 < AccordionContent className = "pt-4 border-t space-y-4" >
375- { Object . entries ( categoryConfig ) . filter ( ( [ key ] ) => key !== 'label' ) . map ( ( [ key , config ] ) => (
376- < SettingField
377- key = { key }
378- settingKey = { key }
379- config = { config }
380- value = { settings [ key ] }
381- onChange = { handleSettingChange }
382- readOnly = { readOnly }
383- />
384- ) ) }
399+ { Object . entries ( categoryConfig )
400+ . filter ( ( [ key ] ) => key !== 'label' )
401+ . filter ( ( [ key , config ] ) => shouldShowField ( key , settings ?. actionsPreset ) )
402+ . map ( ( [ key , config ] ) => (
403+ < SettingField
404+ key = { key }
405+ settingKey = { key }
406+ config = { config }
407+ value = { settings [ key ] }
408+ onChange = { handleSettingChange }
409+ readOnly = { readOnly }
410+ />
411+ ) ) }
385412 </ AccordionContent >
386413 </ AccordionItem >
387414 ) ) }
@@ -391,16 +418,18 @@ export default function PluginSettingsDialog({ bot, plugin, onOpenChange, onSave
391418
392419 return (
393420 < div className = "space-y-4" >
394- { Object . entries ( manifestSettings ) . map ( ( [ key , config ] ) => (
395- < SettingField
396- key = { key }
397- settingKey = { key }
398- config = { config }
399- value = { settings [ key ] }
400- onChange = { handleSettingChange }
401- readOnly = { readOnly }
402- />
403- ) ) }
421+ { Object . entries ( manifestSettings )
422+ . filter ( ( [ key , config ] ) => shouldShowField ( key , settings ?. actionsPreset ) )
423+ . map ( ( [ key , config ] ) => (
424+ < SettingField
425+ key = { key }
426+ settingKey = { key }
427+ config = { config }
428+ value = { settings [ key ] }
429+ onChange = { handleSettingChange }
430+ readOnly = { readOnly }
431+ />
432+ ) ) }
404433 </ div >
405434 ) ;
406435 } ;
0 commit comments