From 6f5e010db54a6c8e388031b4d140835a4b110aba Mon Sep 17 00:00:00 2001 From: Joel Date: Thu, 14 Nov 2024 18:31:10 +0800 Subject: [PATCH] chore: handle uploaded selected --- .../install-bundle/item/loaded-item.tsx | 2 +- .../install-bundle/steps/install-by-dsl-list.tsx | 4 ++-- .../install-bundle/steps/install.tsx | 16 +++++++--------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/web/app/components/plugins/install-plugin/install-bundle/item/loaded-item.tsx b/web/app/components/plugins/install-plugin/install-bundle/item/loaded-item.tsx index 94a9071dae..ef083b6924 100644 --- a/web/app/components/plugins/install-plugin/install-bundle/item/loaded-item.tsx +++ b/web/app/components/plugins/install-plugin/install-bundle/item/loaded-item.tsx @@ -27,7 +27,7 @@ const LoadedItem: FC = ({ {payload.version}} + titleLeft={payload.version ? {payload.version} : null} /> ) diff --git a/web/app/components/plugins/install-plugin/install-bundle/steps/install-by-dsl-list.tsx b/web/app/components/plugins/install-plugin/install-bundle/steps/install-by-dsl-list.tsx index eae9394dc1..a7ab97ab6a 100644 --- a/web/app/components/plugins/install-plugin/install-bundle/steps/install-by-dsl-list.tsx +++ b/web/app/components/plugins/install-plugin/install-bundle/steps/install-by-dsl-list.tsx @@ -65,14 +65,14 @@ const InstallByDSLList: FC = ({ d.type === 'github' ? p.plugin_id === d.value.plugin_unique_identifier)} + checked={!!selectedPlugins.find(p => p.plugin_id === plugins[index]?.plugin_id)} onCheckedChange={handleSelect} dependency={d} onFetchedPayload={handlePlugInFetched(index)} /> : p.plugin_id === d.value.plugin_unique_identifier)} + checked={!!selectedPlugins.find(p => p.plugin_id === plugins[index]?.plugin_id)} onCheckedChange={handleSelect} payload={plugins[index] as Plugin} /> diff --git a/web/app/components/plugins/install-plugin/install-bundle/steps/install.tsx b/web/app/components/plugins/install-plugin/install-bundle/steps/install.tsx index 1423e399b8..e3610f6d98 100644 --- a/web/app/components/plugins/install-plugin/install-bundle/steps/install.tsx +++ b/web/app/components/plugins/install-plugin/install-bundle/steps/install.tsx @@ -23,15 +23,13 @@ const Install: FC = ({ const selectedPluginsNum = selectedPlugins.length const handleSelect = (plugin: Plugin) => { - return () => { - const isSelected = !!selectedPlugins.find(p => p.plugin_id === plugin.plugin_id) - let nextSelectedPlugins - if (isSelected) - nextSelectedPlugins = selectedPlugins.filter(p => p.plugin_id !== plugin.plugin_id) - else - nextSelectedPlugins = [...selectedPlugins, plugin] - setSelectedPlugins(nextSelectedPlugins) - } + const isSelected = !!selectedPlugins.find(p => p.plugin_id === plugin.plugin_id) + let nextSelectedPlugins + if (isSelected) + nextSelectedPlugins = selectedPlugins.filter(p => p.plugin_id !== plugin.plugin_id) + else + nextSelectedPlugins = [...selectedPlugins, plugin] + setSelectedPlugins(nextSelectedPlugins) } const [canInstall, setCanInstall] = React.useState(false) const handleLoadedAllPlugin = useCallback(() => {