From 6b759795d5f28d287e4698a13de8689bc1d890da Mon Sep 17 00:00:00 2001 From: Joel Date: Fri, 15 Nov 2024 13:09:19 +0800 Subject: [PATCH] feat: can install github --- .../(commonLayout)/plugins/test/card/page.tsx | 24 +++++++++---------- .../steps/install-by-dsl-list.tsx | 7 ++++-- .../install-bundle/steps/install.tsx | 7 +++--- web/service/use-plugins.ts | 2 +- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/web/app/(commonLayout)/plugins/test/card/page.tsx b/web/app/(commonLayout)/plugins/test/card/page.tsx index 1d7817a982..5c53f1e653 100644 --- a/web/app/(commonLayout)/plugins/test/card/page.tsx +++ b/web/app/(commonLayout)/plugins/test/card/page.tsx @@ -13,12 +13,12 @@ const PluginList = () => { return (
{ }} fromDSLPayload={[ - { - type: 'marketplace', - value: { - plugin_unique_identifier: 'langgenius/google:0.0.2@dcb354c9d0fee60e6e9c9eb996e1e485bbef343ba8cd545c0cfb3ec80970f6f1', - }, - }, + // { + // type: 'marketplace', + // value: { + // plugin_unique_identifier: 'langgenius/google:0.0.2@dcb354c9d0fee60e6e9c9eb996e1e485bbef343ba8cd545c0cfb3ec80970f6f1', + // }, + // }, { type: 'github', value: { @@ -28,12 +28,12 @@ const PluginList = () => { github_plugin_unique_identifier: 'yixiao0/test:0.0.1@3592166c87afcf944b4f13f27467a5c8f9e00bd349cb42033a072734a37431b4', }, }, - { - type: 'marketplace', - value: { - plugin_unique_identifier: 'langgenius/openai:0.0.1@f88fdb98d104466db16a425bfe3af8c1bcad45047a40fb802d98a989ac57a5a3', - }, - }, + // { + // type: 'marketplace', + // value: { + // plugin_unique_identifier: 'langgenius/openai:0.0.1@f88fdb98d104466db16a425bfe3af8c1bcad45047a40fb802d98a989ac57a5a3', + // }, + // }, ]} />
{/*

Dify Plugin list

*/} 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 8442c0a13d..1d1fe4e67c 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 @@ -26,9 +26,12 @@ const InstallByDSLList: FC = ({ const [plugins, setPlugins, getPlugins] = useGetState([]) const handlePlugInFetched = useCallback((index: number) => { return (p: Plugin) => { - setPlugins(plugins.map((item, i) => i === index ? p : item)) + const nextPlugins = produce(plugins, (draft) => { + draft[index] = p + }) + setPlugins(nextPlugins) } - }, [plugins]) + }, [plugins, setPlugins]) const marketPlaceInDSLIndex = useMemo(() => { const res: number[] = [] 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 1ac7f95746..72908abce8 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 @@ -35,15 +35,16 @@ const Install: FC = ({ const nextSelectedIndexes = isSelected ? selectedIndexes.filter(i => i !== selectedIndex) : [...selectedIndexes, selectedIndex] setSelectedIndexes(nextSelectedIndexes) } + const [canInstall, setCanInstall] = React.useState(false) const handleLoadedAllPlugin = useCallback(() => { setCanInstall(true) - }, [selectedPlugins, selectedIndexes]) + }, []) // Install from marketplace and github const { mutate: installFromMarketplaceAndGitHub, isPending: isInstalling } = useInstallFromMarketplaceAndGitHub({ - onSuccess: () => { - console.log('success!') + onSuccess: (res: { success: boolean }[]) => { + console.log(res) }, }) console.log(canInstall, !isInstalling, selectedPlugins.length === 0) diff --git a/web/service/use-plugins.ts b/web/service/use-plugins.ts index 6697948877..fcbd5a01d7 100644 --- a/web/service/use-plugins.ts +++ b/web/service/use-plugins.ts @@ -97,7 +97,7 @@ export const useUploadGitHub = (payload: { export const useInstallFromMarketplaceAndGitHub = ({ onSuccess, }: { - onSuccess?: () => void + onSuccess?: (res: { success: boolean }[]) => void }) => { return useMutation({ mutationFn: (payload: Dependency[]) => {