feat: can install github

This commit is contained in:
Joel 2024-11-15 13:09:19 +08:00
parent bba80f465b
commit 6b759795d5
4 changed files with 22 additions and 18 deletions

View File

@ -13,12 +13,12 @@ const PluginList = () => {
return (
<div className='pb-3 bg-white'>
<InstallBundle onClose={() => { }} 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',
// },
// },
]} />
<div className='mx-3 '>
{/* <h2 className='my-3'>Dify Plugin list</h2> */}

View File

@ -26,9 +26,12 @@ const InstallByDSLList: FC<Props> = ({
const [plugins, setPlugins, getPlugins] = useGetState<Plugin[]>([])
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[] = []

View File

@ -35,15 +35,16 @@ const Install: FC<Props> = ({
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)

View File

@ -97,7 +97,7 @@ export const useUploadGitHub = (payload: {
export const useInstallFromMarketplaceAndGitHub = ({
onSuccess,
}: {
onSuccess?: () => void
onSuccess?: (res: { success: boolean }[]) => void
}) => {
return useMutation({
mutationFn: (payload: Dependency[]) => {