mirror of
https://github.com/langgenius/dify.git
synced 2026-05-02 23:28:51 +08:00
update model provider list after plugin installed
This commit is contained in:
parent
788f9de843
commit
386ee7b07b
@ -222,7 +222,7 @@ const ModelProviderPage = ({ searchText }: Props) => {
|
|||||||
{!collapse && !isPluginsLoading && (
|
{!collapse && !isPluginsLoading && (
|
||||||
<div className='grid grid-cols-2 gap-2'>
|
<div className='grid grid-cols-2 gap-2'>
|
||||||
{plugins.map(plugin => (
|
{plugins.map(plugin => (
|
||||||
<ProviderCard key={plugin.plugin_id} payload={plugin} onSuccess={updateModelProviders} />
|
<ProviderCard key={plugin.plugin_id} payload={plugin} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -1,11 +1,13 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import type { FC } from 'react'
|
import type { FC } from 'react'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import type { Plugin, PluginDeclaration, PluginManifestInMarket } from '../../types'
|
import { useTranslation } from 'react-i18next'
|
||||||
import Card from '../../card'
|
import Card from '../../card'
|
||||||
import Button from '@/app/components/base/button'
|
import Button from '@/app/components/base/button'
|
||||||
|
import { useUpdateModelProviders } from '@/app/components/header/account-setting/model-provider-page/hooks'
|
||||||
|
import { PluginType } from '../../types'
|
||||||
|
import type { Plugin, PluginDeclaration, PluginManifestInMarket } from '../../types'
|
||||||
import { pluginManifestInMarketToPluginProps, pluginManifestToCardPluginProps } from '../utils'
|
import { pluginManifestInMarketToPluginProps, pluginManifestToCardPluginProps } from '../utils'
|
||||||
import { useTranslation } from 'react-i18next'
|
|
||||||
import Badge, { BadgeState } from '@/app/components/base/badge/index'
|
import Badge, { BadgeState } from '@/app/components/base/badge/index'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@ -24,6 +26,13 @@ const Installed: FC<Props> = ({
|
|||||||
onCancel,
|
onCancel,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
const updateModelProviders = useUpdateModelProviders()
|
||||||
|
|
||||||
|
const handleClose = () => {
|
||||||
|
onCancel()
|
||||||
|
if (payload?.category === PluginType.model)
|
||||||
|
updateModelProviders()
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className='flex flex-col px-6 py-3 justify-center items-start gap-4 self-stretch'>
|
<div className='flex flex-col px-6 py-3 justify-center items-start gap-4 self-stretch'>
|
||||||
@ -45,7 +54,7 @@ const Installed: FC<Props> = ({
|
|||||||
<Button
|
<Button
|
||||||
variant='primary'
|
variant='primary'
|
||||||
className='min-w-[72px]'
|
className='min-w-[72px]'
|
||||||
onClick={onCancel}
|
onClick={handleClose}
|
||||||
>
|
>
|
||||||
{t('common.operation.close')}
|
{t('common.operation.close')}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@ -19,13 +19,11 @@ import { useBoolean } from 'ahooks'
|
|||||||
type Props = {
|
type Props = {
|
||||||
className?: string
|
className?: string
|
||||||
payload: Plugin
|
payload: Plugin
|
||||||
onSuccess: () => void
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const ProviderCard: FC<Props> = ({
|
const ProviderCard: FC<Props> = ({
|
||||||
className,
|
className,
|
||||||
payload,
|
payload,
|
||||||
onSuccess,
|
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const [isShowInstallFromMarketplace, {
|
const [isShowInstallFromMarketplace, {
|
||||||
@ -86,10 +84,7 @@ const ProviderCard: FC<Props> = ({
|
|||||||
manifest={payload as any}
|
manifest={payload as any}
|
||||||
uniqueIdentifier={payload.latest_package_identifier}
|
uniqueIdentifier={payload.latest_package_identifier}
|
||||||
onClose={hideInstallFromMarketplace}
|
onClose={hideInstallFromMarketplace}
|
||||||
onSuccess={() => {
|
onSuccess={() => hideInstallFromMarketplace()}
|
||||||
onSuccess()
|
|
||||||
hideInstallFromMarketplace()
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user