mirror of
https://github.com/langgenius/dify.git
synced 2026-06-17 14:51:10 +08:00
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: yyh <yuanyouhuilyz@gmail.com> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: hjlarry <hjlarry@163.com> Co-authored-by: fatelei <fatelei@gmail.com> Co-authored-by: Asuka Minato <i@asukaminato.eu.org> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Xiyuan Chen <52963600+GareArc@users.noreply.github.com> Co-authored-by: gigglewang <gigglewang@dify.ai> Co-authored-by: Yunlu Wen <yunlu.wen@dify.ai> Co-authored-by: chariri <w@chariri.moe> Co-authored-by: Evan <2869018789@qq.com> Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com>
56 lines
1.6 KiB
TypeScript
56 lines
1.6 KiB
TypeScript
import { SegmentedControl, SegmentedControlItem } from '@langgenius/dify-ui/segmented-control'
|
|
import { useTranslation } from 'react-i18next'
|
|
import { AUTO_UPDATE_STRATEGY } from './types'
|
|
|
|
const i18nPrefix = 'autoUpdate.strategy'
|
|
|
|
type Props = Readonly<{
|
|
value: AUTO_UPDATE_STRATEGY
|
|
onChange: (value: AUTO_UPDATE_STRATEGY) => void
|
|
}>
|
|
const StrategyPicker = ({
|
|
value,
|
|
onChange,
|
|
}: Props) => {
|
|
const { t } = useTranslation()
|
|
const options = [
|
|
{
|
|
value: AUTO_UPDATE_STRATEGY.disabled,
|
|
label: t(`${i18nPrefix}.disabled.name`, { ns: 'plugin' }),
|
|
},
|
|
{
|
|
value: AUTO_UPDATE_STRATEGY.fixOnly,
|
|
label: t(`${i18nPrefix}.fixOnly.name`, { ns: 'plugin' }),
|
|
},
|
|
{
|
|
value: AUTO_UPDATE_STRATEGY.latest,
|
|
label: t(`${i18nPrefix}.latest.name`, { ns: 'plugin' }),
|
|
},
|
|
]
|
|
|
|
return (
|
|
<SegmentedControl<AUTO_UPDATE_STRATEGY>
|
|
aria-label={t('autoUpdate.automaticUpdates', { ns: 'plugin' })}
|
|
className="w-[326px]"
|
|
value={[value]}
|
|
onValueChange={(nextValue) => {
|
|
const selectedValue = nextValue[0]
|
|
if (selectedValue)
|
|
onChange(selectedValue)
|
|
}}
|
|
>
|
|
{options.map(option => (
|
|
<SegmentedControlItem<AUTO_UPDATE_STRATEGY>
|
|
key={option.value}
|
|
value={option.value}
|
|
className="flex-1 hover:bg-state-base-hover-alt data-pressed:text-text-accent-light-mode-only data-pressed:hover:bg-components-segmented-control-item-active-bg"
|
|
>
|
|
<span className="p-0.5 whitespace-nowrap">{option.label}</span>
|
|
</SegmentedControlItem>
|
|
))}
|
|
</SegmentedControl>
|
|
)
|
|
}
|
|
|
|
export default StrategyPicker
|