import { Button } from '@langgenius/dify-ui/button' import { DropdownMenu, DropdownMenuContent, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuRadioItemIndicator, DropdownMenuTrigger, } from '@langgenius/dify-ui/dropdown-menu' import { useState } from 'react' import { useTranslation } from 'react-i18next' import { AUTO_UPDATE_STRATEGY } from './types' const i18nPrefix = 'autoUpdate.strategy' type Props = { value: AUTO_UPDATE_STRATEGY onChange: (value: AUTO_UPDATE_STRATEGY) => void } const StrategyPicker = ({ value, onChange, }: Props) => { const { t } = useTranslation() const [open, setOpen] = useState(false) const options = [ { value: AUTO_UPDATE_STRATEGY.disabled, label: t(`${i18nPrefix}.disabled.name`, { ns: 'plugin' }), description: t(`${i18nPrefix}.disabled.description`, { ns: 'plugin' }), }, { value: AUTO_UPDATE_STRATEGY.fixOnly, label: t(`${i18nPrefix}.fixOnly.name`, { ns: 'plugin' }), description: t(`${i18nPrefix}.fixOnly.description`, { ns: 'plugin' }), }, { value: AUTO_UPDATE_STRATEGY.latest, label: t(`${i18nPrefix}.latest.name`, { ns: 'plugin' }), description: t(`${i18nPrefix}.latest.description`, { ns: 'plugin' }), }, ] const selectedOption = options.find(option => option.value === value) const handleValueChange = (nextValue: string) => { onChange(nextValue as AUTO_UPDATE_STRATEGY) setOpen(false) } return ( }> {selectedOption?.label} {options.map(option => (
{option.label}
{option.description}
))}
) } export default StrategyPicker