mirror of https://github.com/langgenius/dify.git
chore: parse marketplace bundle new api
This commit is contained in:
parent
26288e71d3
commit
498222371c
|
|
@ -89,17 +89,17 @@ const InstallByDSLList: FC<Props> = ({
|
|||
}, [isFetchingMarketplaceDataFromDSL])
|
||||
|
||||
useEffect(() => {
|
||||
if (!isFetchingMarketplaceDataFromLocal && marketplaceResFromLocalRes?.data.versions) {
|
||||
const payloads = marketplaceResFromLocalRes?.data.versions
|
||||
if (!isFetchingMarketplaceDataFromLocal && marketplaceResFromLocalRes?.data.list) {
|
||||
const payloads = marketplaceResFromLocalRes?.data.list
|
||||
const failedIndex: number[] = []
|
||||
const nextPlugins = produce(getPlugins(), (draft) => {
|
||||
marketPlaceInDSLIndex.forEach((index, i) => {
|
||||
if (payloads[i]) {
|
||||
const item = payloads[i]
|
||||
draft[index] = { // TODO: wait for api change
|
||||
name: 'xxx',
|
||||
plugin_id: item.unique_identifier,
|
||||
} as Plugin
|
||||
draft[index] = {
|
||||
...item.plugin,
|
||||
plugin_id: item.version.unique_identifier,
|
||||
}
|
||||
}
|
||||
else {
|
||||
failedIndex.push(index)
|
||||
|
|
|
|||
|
|
@ -311,10 +311,13 @@ export type PluginsFromMarketplaceResponse = {
|
|||
plugins: Plugin[]
|
||||
}
|
||||
export type PluginsFromMarketplaceByInfoResponse = {
|
||||
versions: {
|
||||
plugin_name: string
|
||||
plugin_org: string
|
||||
unique_identifier: string
|
||||
list: {
|
||||
plugin: Plugin
|
||||
version: {
|
||||
plugin_name: string
|
||||
plugin_org: string
|
||||
unique_identifier: string
|
||||
}
|
||||
}[]
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,11 +22,13 @@ import {
|
|||
PortalToFollowElemTrigger,
|
||||
} from '@/app/components/base/portal-to-follow-elem'
|
||||
import Input from '@/app/components/base/input'
|
||||
import SearchBox from '@/app/components/plugins/marketplace/search-box'
|
||||
|
||||
import {
|
||||
Plus02,
|
||||
} from '@/app/components/base/icons/src/vender/line/general'
|
||||
|
||||
interface NodeSelectorProps {
|
||||
type NodeSelectorProps = {
|
||||
open?: boolean
|
||||
onOpenChange?: (open: boolean) => void
|
||||
onSelect: OnSelectBlock
|
||||
|
|
@ -60,6 +62,7 @@ const NodeSelector: FC<NodeSelectorProps> = ({
|
|||
}) => {
|
||||
const { t } = useTranslation()
|
||||
const [searchText, setSearchText] = useState('')
|
||||
const [tags, setTags] = useState<string[]>([])
|
||||
const [localOpen, setLocalOpen] = useState(false)
|
||||
const open = openFromProps === undefined ? localOpen : openFromProps
|
||||
const handleOpenChange = useCallback((newOpen: boolean) => {
|
||||
|
|
@ -127,15 +130,28 @@ const NodeSelector: FC<NodeSelectorProps> = ({
|
|||
<PortalToFollowElemContent className='z-[1000]'>
|
||||
<div className={`rounded-lg border-[0.5px] border-gray-200 bg-white shadow-lg ${popupClassName}`}>
|
||||
<div className='px-2 pt-2' onClick={e => e.stopPropagation()}>
|
||||
<Input
|
||||
showLeftIcon
|
||||
showClearIcon
|
||||
autoFocus
|
||||
value={searchText}
|
||||
placeholder={searchPlaceholder}
|
||||
onChange={e => setSearchText(e.target.value)}
|
||||
onClear={() => setSearchText('')}
|
||||
/>
|
||||
{activeTab === TabsEnum.Blocks && (
|
||||
<Input
|
||||
showLeftIcon
|
||||
showClearIcon
|
||||
autoFocus
|
||||
value={searchText}
|
||||
placeholder={searchPlaceholder}
|
||||
onChange={e => setSearchText(e.target.value)}
|
||||
onClear={() => setSearchText('')}
|
||||
/>
|
||||
)}
|
||||
{activeTab === TabsEnum.Tools && (
|
||||
<SearchBox
|
||||
search={searchText}
|
||||
onSearchChange={setSearchText}
|
||||
tags={tags}
|
||||
onTagsChange={setTags}
|
||||
size='small'
|
||||
placeholder={t('plugin.searchTools')!}
|
||||
/>
|
||||
)}
|
||||
|
||||
</div>
|
||||
<Tabs
|
||||
activeTab={activeTab}
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ export const useFetchPluginsInMarketPlaceByIds = (unique_identifiers: string[])
|
|||
export const useFetchPluginsInMarketPlaceByInfo = (infos: Record<string, any>[]) => {
|
||||
return useQuery({
|
||||
queryKey: [NAME_SPACE, 'fetchPluginsInMarketPlaceByInfo', infos],
|
||||
queryFn: () => postMarketplace<{ data: PluginsFromMarketplaceByInfoResponse }>('/plugins/versions', {
|
||||
queryFn: () => postMarketplace<{ data: PluginsFromMarketplaceByInfoResponse }>('/plugins/versions/batch', {
|
||||
body: {
|
||||
plugin_tuples: infos.map(info => ({
|
||||
org: info.organization,
|
||||
|
|
|
|||
Loading…
Reference in New Issue