From 5947e38ea04be93720cea7bd026be99018430d7e Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 19 Nov 2024 18:32:17 +0800 Subject: [PATCH] feat: install by local bundle change --- web/app/(commonLayout)/plugins/test/card/page.tsx | 4 ++-- .../install-plugin/install-bundle/item/github-item.tsx | 4 ++-- .../install-plugin/install-bundle/steps/install-multi.tsx | 2 +- .../install-plugin/install-from-local-package/index.tsx | 2 +- web/app/components/plugins/types.ts | 4 ++-- web/config/index.ts | 2 +- web/service/use-plugins.ts | 5 +++-- 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/web/app/(commonLayout)/plugins/test/card/page.tsx b/web/app/(commonLayout)/plugins/test/card/page.tsx index 02e80d8563..c41f5ac27d 100644 --- a/web/app/(commonLayout)/plugins/test/card/page.tsx +++ b/web/app/(commonLayout)/plugins/test/card/page.tsx @@ -30,7 +30,7 @@ const PluginList = () => { type: 'github', value: { repo: 'YIXIAO0/test', - version: '1.11.5', + release: '1.11.5', package: 'test.difypkg', github_plugin_unique_identifier: 'yixiao0/test:0.0.1@3592166c87afcf944b4f13f27467a5c8f9e00bd349cb42033a072734a37431b4', }, @@ -40,7 +40,7 @@ const PluginList = () => { value: { package: 'dify-test.difypkg', repo: 'WTW0313/dify-test', - version: '0.0.5-beta.2', + release: '0.0.5-beta.2', github_plugin_unique_identifier: 'wtw0313/dify-test:0.0.1@1633daa043b47155d4228e2db7734245fd6d3e20ba812e5c02ce69fc1e3038f4', }, }, diff --git a/web/app/components/plugins/install-plugin/install-bundle/item/github-item.tsx b/web/app/components/plugins/install-plugin/install-bundle/item/github-item.tsx index cfbe05ca5d..9d50d41343 100644 --- a/web/app/components/plugins/install-plugin/install-bundle/item/github-item.tsx +++ b/web/app/components/plugins/install-plugin/install-bundle/item/github-item.tsx @@ -25,8 +25,8 @@ const Item: FC = ({ const info = dependency.value const { data, error } = useUploadGitHub({ repo: info.repo!, - version: info.version!, - package: info.package!, + version: info.release!, + package: info.packages!, }) const [payload, setPayload] = React.useState(null) useEffect(() => { diff --git a/web/app/components/plugins/install-plugin/install-bundle/steps/install-multi.tsx b/web/app/components/plugins/install-plugin/install-bundle/steps/install-multi.tsx index 50cf5b7dc9..27e7cca7ad 100644 --- a/web/app/components/plugins/install-plugin/install-bundle/steps/install-multi.tsx +++ b/web/app/components/plugins/install-plugin/install-bundle/steps/install-multi.tsx @@ -23,7 +23,7 @@ const InstallByDSLList: FC = ({ onLoadedAllPlugin, }) => { const { isLoading: isFetchingMarketplaceData, data: marketplaceRes } = useFetchPluginsInMarketPlaceByIds(allPlugins.filter(d => d.type === 'marketplace').map(d => (d as GitHubItemAndMarketPlaceDependency).value.plugin_unique_identifier!)) - + console.log(allPlugins) const [plugins, setPlugins, getPlugins] = useGetState<(Plugin | undefined)[]>((() => { const hasLocalPackage = allPlugins.some(d => d.type === 'package') if (!hasLocalPackage) diff --git a/web/app/components/plugins/install-plugin/install-from-local-package/index.tsx b/web/app/components/plugins/install-plugin/install-from-local-package/index.tsx index bbafcf2033..611a1ad5a1 100644 --- a/web/app/components/plugins/install-plugin/install-from-local-package/index.tsx +++ b/web/app/components/plugins/install-plugin/install-from-local-package/index.tsx @@ -28,7 +28,7 @@ const InstallFromLocalPackage: React.FC = ({ const [uniqueIdentifier, setUniqueIdentifier] = useState(null) const [manifest, setManifest] = useState(null) const [errorMsg, setErrorMsg] = useState(null) - const isBundle = file.name.endsWith('.bundle') + const isBundle = file.name.endsWith('.difybndl') const [dependencies, setDependencies] = useState([]) const getTitle = useCallback(() => { diff --git a/web/app/components/plugins/types.ts b/web/app/components/plugins/types.ts index 645ee1a7a2..0a85cbf0cb 100644 --- a/web/app/components/plugins/types.ts +++ b/web/app/components/plugins/types.ts @@ -315,8 +315,8 @@ export type GitHubItemAndMarketPlaceDependency = { type: 'github' | 'marketplace' | 'package' value: { repo?: string - version?: string - package?: string + release?: string + packages?: string github_plugin_unique_identifier?: string marketplace_plugin_unique_identifier?: string plugin_unique_identifier?: string diff --git a/web/config/index.ts b/web/config/index.ts index 6e8c4a630c..c3f03c1235 100644 --- a/web/config/index.ts +++ b/web/config/index.ts @@ -274,4 +274,4 @@ export const DISABLE_UPLOAD_IMAGE_AS_ICON = process.env.NEXT_PUBLIC_DISABLE_UPLO export const GITHUB_ACCESS_TOKEN = process.env.NEXT_PUBLIC_GITHUB_ACCESS_TOKEN || globalThis.document?.body?.getAttribute('data-public-github-access-token') || '' -export const SUPPORT_INSTALL_LOCAL_FILE_EXTENSIONS = '.difypkg,.bundle' +export const SUPPORT_INSTALL_LOCAL_FILE_EXTENSIONS = '.difypkg,.difybndl' diff --git a/web/service/use-plugins.ts b/web/service/use-plugins.ts index def7b42ec2..1007b116f4 100644 --- a/web/service/use-plugins.ts +++ b/web/service/use-plugins.ts @@ -125,8 +125,8 @@ export const useInstallFromMarketplaceAndGitHub = ({ await post('/workspaces/current/plugin/install/github', { body: { repo: data.value.repo!, - version: data.value.version!, - package: data.value.package!, + version: data.value.release!, + package: data.value.packages!, plugin_unique_identifier: data.value.github_plugin_unique_identifier!, }, }) @@ -231,6 +231,7 @@ export const useFetchPluginsInMarketPlaceByIds = (unique_identifiers: string[]) unique_identifiers, }, }), + enabled: unique_identifiers.filter(i => !!i).length > 0, // loaded then fetch }) }