mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-16 18:45:55 +08:00
Merge branch 'feat/mcp-frontend' into deploy/dev
This commit is contained in:
commit
a4ee06e1be
@ -86,7 +86,6 @@ const MCPDetailContent: FC<Props> = ({
|
|||||||
return
|
return
|
||||||
const res = await authorizeMcp({
|
const res = await authorizeMcp({
|
||||||
provider_id: detail.id,
|
provider_id: detail.id,
|
||||||
server_url: detail.server_url!,
|
|
||||||
})
|
})
|
||||||
if (res.result === 'success')
|
if (res.result === 'success')
|
||||||
handleUpdateTools()
|
handleUpdateTools()
|
||||||
@ -194,7 +193,7 @@ const MCPDetailContent: FC<Props> = ({
|
|||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{detail.is_team_authorization && !isGettingTools && !toolList.length && (
|
{!isUpdating && detail.is_team_authorization && !isGettingTools && !toolList.length && (
|
||||||
<div className='flex h-full w-full flex-col items-center justify-center'>
|
<div className='flex h-full w-full flex-col items-center justify-center'>
|
||||||
<div className='system-sm-regular mb-3 text-text-tertiary'>{t('tools.mcp.toolsEmpty')}</div>
|
<div className='system-sm-regular mb-3 text-text-tertiary'>{t('tools.mcp.toolsEmpty')}</div>
|
||||||
<Button
|
<Button
|
||||||
@ -203,7 +202,7 @@ const MCPDetailContent: FC<Props> = ({
|
|||||||
>{t('tools.mcp.getTools')}</Button>
|
>{t('tools.mcp.getTools')}</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{!isGettingTools && toolList.length > 0 && (
|
{!isUpdating && !isGettingTools && toolList.length > 0 && (
|
||||||
<>
|
<>
|
||||||
<div className='flex shrink-0 justify-between gap-2 px-4 pb-1 pt-2'>
|
<div className='flex shrink-0 justify-between gap-2 px-4 pb-1 pt-2'>
|
||||||
<div className='flex h-6 items-center'>
|
<div className='flex h-6 items-center'>
|
||||||
@ -228,7 +227,7 @@ const MCPDetailContent: FC<Props> = ({
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{!detail.is_team_authorization && (
|
{!isUpdating && !detail.is_team_authorization && (
|
||||||
<div className='flex h-full w-full flex-col items-center justify-center'>
|
<div className='flex h-full w-full flex-col items-center justify-center'>
|
||||||
{!isAuthorizing && <div className='system-md-medium mb-1 text-text-secondary'>{t('tools.mcp.authorizingRequired')}</div>}
|
{!isAuthorizing && <div className='system-md-medium mb-1 text-text-secondary'>{t('tools.mcp.authorizingRequired')}</div>}
|
||||||
{isAuthorizing && <div className='system-md-medium mb-1 text-text-secondary'>{t('tools.mcp.authorizing')}</div>}
|
{isAuthorizing && <div className='system-md-medium mb-1 text-text-secondary'>{t('tools.mcp.authorizing')}</div>}
|
||||||
|
@ -70,7 +70,6 @@ const MCPList = ({
|
|||||||
setCurrentProviderID(provider.id)
|
setCurrentProviderID(provider.id)
|
||||||
await authorizeMcp({
|
await authorizeMcp({
|
||||||
provider_id: provider.id,
|
provider_id: provider.id,
|
||||||
server_url: provider.server_url!,
|
|
||||||
})
|
})
|
||||||
await refetch() // update authorization in list
|
await refetch() // update authorization in list
|
||||||
await updateTools(provider.id)
|
await updateTools(provider.id)
|
||||||
@ -84,7 +83,6 @@ const MCPList = ({
|
|||||||
if (!targetProvider) return
|
if (!targetProvider) return
|
||||||
await updateMCPAuthorizationToken({
|
await updateMCPAuthorizationToken({
|
||||||
provider_id: providerID,
|
provider_id: providerID,
|
||||||
server_url: targetProvider.server_url!,
|
|
||||||
authorization_code: code,
|
authorization_code: code,
|
||||||
})
|
})
|
||||||
await refetch()
|
await refetch()
|
||||||
|
@ -101,7 +101,7 @@ const MCPCard = ({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className='system-xs-regular text-divider-deep'>/</div>
|
<div className='system-xs-regular text-divider-deep'>/</div>
|
||||||
<div className='system-xs-regular truncate text-text-tertiary'>{`${t('tools.mcp.updateTime')} ${formatTimeFromNow(data.updated_at!)}`}</div>
|
<div className='system-xs-regular truncate text-text-tertiary'>{`${t('tools.mcp.updateTime')} ${formatTimeFromNow(data.updated_at! * 1000)}`}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -140,7 +140,7 @@ export const useDeleteMCP = ({
|
|||||||
export const useAuthorizeMCP = () => {
|
export const useAuthorizeMCP = () => {
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationKey: [NAME_SPACE, 'authorize-mcp'],
|
mutationKey: [NAME_SPACE, 'authorize-mcp'],
|
||||||
mutationFn: (payload: { provider_id: string; server_url: string }) => {
|
mutationFn: (payload: { provider_id: string; }) => {
|
||||||
return post<{ result?: string; authorization_url?: string }>('/workspaces/current/tool-provider/mcp/auth', {
|
return post<{ result?: string; authorization_url?: string }>('/workspaces/current/tool-provider/mcp/auth', {
|
||||||
body: payload,
|
body: payload,
|
||||||
})
|
})
|
||||||
@ -151,7 +151,7 @@ export const useAuthorizeMCP = () => {
|
|||||||
export const useUpdateMCPAuthorizationToken = () => {
|
export const useUpdateMCPAuthorizationToken = () => {
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationKey: [NAME_SPACE, 'refresh-mcp-server-code'],
|
mutationKey: [NAME_SPACE, 'refresh-mcp-server-code'],
|
||||||
mutationFn: (payload: { provider_id: string; server_url: string; authorization_code: string }) => {
|
mutationFn: (payload: { provider_id: string; authorization_code: string }) => {
|
||||||
return get<MCPServerDetail>('/workspaces/current/tool-provider/mcp/token', {
|
return get<MCPServerDetail>('/workspaces/current/tool-provider/mcp/token', {
|
||||||
params: {
|
params: {
|
||||||
...payload,
|
...payload,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user