feat: can install github

pull/12372/head
Joel 1 year ago
parent bba80f465b
commit 6b759795d5

@ -13,12 +13,12 @@ const PluginList = () => {
return ( return (
<div className='pb-3 bg-white'> <div className='pb-3 bg-white'>
<InstallBundle onClose={() => { }} fromDSLPayload={[ <InstallBundle onClose={() => { }} fromDSLPayload={[
{ // {
type: 'marketplace', // type: 'marketplace',
value: { // value: {
plugin_unique_identifier: 'langgenius/google:0.0.2@dcb354c9d0fee60e6e9c9eb996e1e485bbef343ba8cd545c0cfb3ec80970f6f1', // plugin_unique_identifier: 'langgenius/google:0.0.2@dcb354c9d0fee60e6e9c9eb996e1e485bbef343ba8cd545c0cfb3ec80970f6f1',
}, // },
}, // },
{ {
type: 'github', type: 'github',
value: { value: {
@ -28,12 +28,12 @@ const PluginList = () => {
github_plugin_unique_identifier: 'yixiao0/test:0.0.1@3592166c87afcf944b4f13f27467a5c8f9e00bd349cb42033a072734a37431b4', github_plugin_unique_identifier: 'yixiao0/test:0.0.1@3592166c87afcf944b4f13f27467a5c8f9e00bd349cb42033a072734a37431b4',
}, },
}, },
{ // {
type: 'marketplace', // type: 'marketplace',
value: { // value: {
plugin_unique_identifier: 'langgenius/openai:0.0.1@f88fdb98d104466db16a425bfe3af8c1bcad45047a40fb802d98a989ac57a5a3', // plugin_unique_identifier: 'langgenius/openai:0.0.1@f88fdb98d104466db16a425bfe3af8c1bcad45047a40fb802d98a989ac57a5a3',
}, // },
}, // },
]} /> ]} />
<div className='mx-3 '> <div className='mx-3 '>
{/* <h2 className='my-3'>Dify Plugin list</h2> */} {/* <h2 className='my-3'>Dify Plugin list</h2> */}

@ -26,9 +26,12 @@ const InstallByDSLList: FC<Props> = ({
const [plugins, setPlugins, getPlugins] = useGetState<Plugin[]>([]) const [plugins, setPlugins, getPlugins] = useGetState<Plugin[]>([])
const handlePlugInFetched = useCallback((index: number) => { const handlePlugInFetched = useCallback((index: number) => {
return (p: Plugin) => { 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 marketPlaceInDSLIndex = useMemo(() => {
const res: number[] = [] const res: number[] = []

@ -35,15 +35,16 @@ const Install: FC<Props> = ({
const nextSelectedIndexes = isSelected ? selectedIndexes.filter(i => i !== selectedIndex) : [...selectedIndexes, selectedIndex] const nextSelectedIndexes = isSelected ? selectedIndexes.filter(i => i !== selectedIndex) : [...selectedIndexes, selectedIndex]
setSelectedIndexes(nextSelectedIndexes) setSelectedIndexes(nextSelectedIndexes)
} }
const [canInstall, setCanInstall] = React.useState(false) const [canInstall, setCanInstall] = React.useState(false)
const handleLoadedAllPlugin = useCallback(() => { const handleLoadedAllPlugin = useCallback(() => {
setCanInstall(true) setCanInstall(true)
}, [selectedPlugins, selectedIndexes]) }, [])
// Install from marketplace and github // Install from marketplace and github
const { mutate: installFromMarketplaceAndGitHub, isPending: isInstalling } = useInstallFromMarketplaceAndGitHub({ const { mutate: installFromMarketplaceAndGitHub, isPending: isInstalling } = useInstallFromMarketplaceAndGitHub({
onSuccess: () => { onSuccess: (res: { success: boolean }[]) => {
console.log('success!') console.log(res)
}, },
}) })
console.log(canInstall, !isInstalling, selectedPlugins.length === 0) console.log(canInstall, !isInstalling, selectedPlugins.length === 0)

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

Loading…
Cancel
Save