'use client' import type { FC } from 'react' import React from 'react' import NoPluginSelected from './no-plugin-selected' import { AUTO_UPDATE_MODE } from './types' import PluginsSelected from './plugins-selected' import Button from '@/app/components/base/button' import { RiAddLine } from '@remixicon/react' import { useTranslation } from 'react-i18next' import { useBoolean } from 'ahooks' import ToolPicker from './tool-picker' const i18nPrefix = 'plugin.autoUpdate' type Props = { updateMode: AUTO_UPDATE_MODE value: string[] // plugin ids onChange: (value: string[]) => void } const PluginsPicker: FC = ({ updateMode, value, onChange, }) => { const { t } = useTranslation() const hasSelected = value.length > 0 const isExcludeMode = updateMode === AUTO_UPDATE_MODE.exclude const handleClear = () => { onChange([]) } const [isShowToolPicker, { set: setToolPicker, }] = useBoolean(false) return (
{hasSelected ? (
{t(`${i18nPrefix}.${isExcludeMode ? 'excludeUpdate' : 'partialUPdate'}`, { num: value.length })}
{t(`${i18nPrefix}.operation.clearAll`)}
) : ( )} {hasSelected && ( )} {t(`${i18nPrefix}.operation.select`)} } value={value} onChange={onChange} isShow={isShowToolPicker} onShowChange={setToolPicker} />
) } export default React.memo(PluginsPicker)