feat: plugins picker holder

This commit is contained in:
Joel 2025-06-19 18:13:56 +08:00
parent 3061280f7a
commit 01cdffaa08
2 changed files with 63 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import TimePicker from '@/app/components/base/date-and-time-picker/time-picker'
import type { Dayjs } from 'dayjs'
import dayjs from 'dayjs'
import OptionCard from '@/app/components/workflow/nodes/_base/components/option-card'
import PluginsPicker from './plugins-picker'
const i18nPrefix = 'plugin.autoUpdate'
@ -38,6 +39,8 @@ const AutoUpdateSetting: FC<Props> = ({
strategy_setting,
upgrade_time_of_day,
upgrade_mode,
exclude_plugins,
include_plugins,
} = payload
const strategyDescription = useMemo(() => {
switch (strategy_setting) {
@ -49,6 +52,32 @@ const AutoUpdateSetting: FC<Props> = ({
return ''
}
}, [strategy_setting, t])
const plugins = useMemo(() => {
switch (upgrade_mode) {
case AUTO_UPDATE_MODE.partial:
return include_plugins
case AUTO_UPDATE_MODE.exclude:
return exclude_plugins
default:
return []
}
}, [upgrade_mode, exclude_plugins, include_plugins])
const handlePluginsChange = useCallback((newPlugins: string[]) => {
if (upgrade_mode === AUTO_UPDATE_MODE.partial) {
onChange({
...payload,
include_plugins: newPlugins,
})
}
else if (upgrade_mode === AUTO_UPDATE_MODE.exclude) {
onChange({
...payload,
exclude_plugins: newPlugins,
})
}
}, [payload, upgrade_mode, onChange])
const handleChange = useCallback((key: keyof AutoUpdateConfig) => {
return (value: AutoUpdateConfig[keyof AutoUpdateConfig]) => {
onChange({
@ -94,6 +123,11 @@ const AutoUpdateSetting: FC<Props> = ({
/>
))}
</div>
<PluginsPicker
value={plugins}
onChange={handlePluginsChange}
/>
</div>
</>
)}

View File

@ -0,0 +1,29 @@
'use client'
import type { FC } from 'react'
import React from 'react'
type Props = {
value: string[] // plugin ids
onChange: (value: string[]) => void
}
const PluginsPicker: FC<Props> = ({
value,
onChange,
}) => {
const hasSelected = value.length > 0
return (
<div className='rounded-xl'>
{hasSelected ? (
<div className='flex justify-between'>
<div>Selected plugins will not auto-update</div>
</div>
) : (
<div className='system-xs-regular text-center text-text-tertiary'>
Only selected plugins will auto-update. No plugins are currently selected, so no plugins will auto-update.
</div>
)}
</div>
)
}
export default React.memo(PluginsPicker)