mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 03:32:23 +08:00
endpoint card databing
This commit is contained in:
parent
5e077e4ce8
commit
0279bd8c75
|
@ -1,55 +1,74 @@
|
||||||
import React from 'react'
|
import React, { useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { RiLoginCircleLine } from '@remixicon/react'
|
import { RiDeleteBinLine, RiEditLine, RiLoginCircleLine } from '@remixicon/react'
|
||||||
|
import type { EndpointListItem } from '../types'
|
||||||
|
import ActionButton from '@/app/components/base/action-button'
|
||||||
import CopyBtn from '@/app/components/base/copy-btn'
|
import CopyBtn from '@/app/components/base/copy-btn'
|
||||||
import Indicator from '@/app/components/header/indicator'
|
import Indicator from '@/app/components/header/indicator'
|
||||||
import Switch from '@/app/components/base/switch'
|
import Switch from '@/app/components/base/switch'
|
||||||
|
|
||||||
const EndpointCard = () => {
|
type Props = {
|
||||||
|
data: EndpointListItem
|
||||||
|
}
|
||||||
|
|
||||||
|
const EndpointCard = ({
|
||||||
|
data,
|
||||||
|
}: Props) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
const [active, setActive] = useState(data.enabled)
|
||||||
|
|
||||||
|
const handleSwitch = () => {
|
||||||
|
setActive(!active)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='p-0.5 bg-background-section-burn rounded-xl'>
|
<div className='p-0.5 bg-background-section-burn rounded-xl'>
|
||||||
<div className='p-2.5 pl-3 bg-components-panel-on-panel-item-bg rounded-[10px] border-[0.5px] border-components-panel-border'>
|
<div className='group p-2.5 pl-3 bg-components-panel-on-panel-item-bg rounded-[10px] border-[0.5px] border-components-panel-border'>
|
||||||
<div className='mb-1 h-6 flex items-center gap-1 text-text-secondary system-md-semibold'>
|
<div className='flex items-center'>
|
||||||
<RiLoginCircleLine className='w-4 h-4' />
|
<div className='grow mb-1 h-6 flex items-center gap-1 text-text-secondary system-md-semibold'>
|
||||||
<div>Endpoint for Unreal workspace</div>
|
<RiLoginCircleLine className='w-4 h-4' />
|
||||||
</div>
|
<div>{data.name}</div>
|
||||||
<div className='h-6 flex items-center'>
|
</div>
|
||||||
<div className='shrink-0 w-24 text-text-tertiary system-xs-regular'>Start Callback</div>
|
<div className='hidden group-hover:flex items-center'>
|
||||||
<div className='group grow flex items-center text-text-secondary system-xs-regular truncate'>
|
<ActionButton>
|
||||||
<div className='truncate'>https://extension.dify.ai/a1b2c3d4/onStart</div>
|
<RiEditLine className='w-4 h-4' />
|
||||||
<CopyBtn
|
</ActionButton>
|
||||||
className='hidden shrink-0 ml-2 group-hover:block'
|
<ActionButton className='hover:bg-state-destructive-hover text-text-tertiary hover:text-text-destructive'>
|
||||||
value={'https://extension.dify.ai/a1b2c3d4/onStart'}
|
<RiDeleteBinLine className='w-4 h-4' />
|
||||||
isPlain
|
</ActionButton>
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className='h-6 flex items-center'>
|
{data.declaration.endpoints.map((endpoint, index) => (
|
||||||
<div className='shrink-0 w-24 text-text-tertiary system-xs-regular'>Finish Callback</div>
|
<div key={index} className='h-6 flex items-center'>
|
||||||
<div className='group grow flex items-center text-text-secondary system-xs-regular truncate'>
|
<div className='shrink-0 w-12 text-text-tertiary system-xs-regular'>{endpoint.method}</div>
|
||||||
<div className='truncate'>https://extension.dify.ai/a1b2c3d4/onFinish</div>
|
<div className='group/item grow flex items-center text-text-secondary system-xs-regular truncate'>
|
||||||
<CopyBtn
|
<div className='truncate'>{`${data.url}${endpoint.path}`}</div>
|
||||||
className='hidden shrink-0 ml-2 group-hover:block'
|
<CopyBtn
|
||||||
value={'https://extension.dify.ai/a1b2c3d4/onFinish'}
|
className='hidden shrink-0 ml-2 group-hover/item:block'
|
||||||
isPlain
|
value={`${data.url}${endpoint.path}`}
|
||||||
/>
|
isPlain
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
))}
|
||||||
</div>
|
</div>
|
||||||
<div className='px-3 py-2 flex items-center justify-between'>
|
<div className='p-2 pl-3 flex items-center justify-between'>
|
||||||
<div className='flex items-center gap-1 system-xs-semibold-uppercase text-util-colors-green-green-600'>
|
{active && (
|
||||||
<Indicator color='green' />
|
<div className='flex items-center gap-1 system-xs-semibold-uppercase text-util-colors-green-green-600'>
|
||||||
{t('plugin.detailPanel.serviceOk')}
|
<Indicator color='green' />
|
||||||
</div>
|
{t('plugin.detailPanel.serviceOk')}
|
||||||
{/* <div className='flex items-center gap-1 system-xs-semibold-uppercase text-text-tertiary'>
|
</div>
|
||||||
<Indicator color='gray' />
|
)}
|
||||||
{t('plugin.detailPanel.disabled')}
|
{!active && (
|
||||||
</div> */}
|
<div className='flex items-center gap-1 system-xs-semibold-uppercase text-text-tertiary'>
|
||||||
|
<Indicator color='gray' />
|
||||||
|
{t('plugin.detailPanel.disabled')}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<Switch
|
<Switch
|
||||||
className='ml-3'
|
className='ml-3'
|
||||||
defaultValue={true}
|
defaultValue={active}
|
||||||
onChange={() => {}}
|
onChange={handleSwitch}
|
||||||
size='sm'
|
size='sm'
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { RiAddLine } from '@remixicon/react'
|
import { RiAddLine } from '@remixicon/react'
|
||||||
|
import type { EndpointListItem, PluginEndpointDeclaration } from '../types'
|
||||||
import EndpointCard from './endpoint-card'
|
import EndpointCard from './endpoint-card'
|
||||||
import ActionButton from '@/app/components/base/action-button'
|
import ActionButton from '@/app/components/base/action-button'
|
||||||
import Tooltip from '@/app/components/base/tooltip'
|
import Tooltip from '@/app/components/base/tooltip'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
declaration: any
|
declaration: PluginEndpointDeclaration
|
||||||
list: any[]
|
list: EndpointListItem[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const EndpointList = ({
|
const EndpointList = ({
|
||||||
|
@ -22,11 +23,7 @@ const EndpointList = ({
|
||||||
{t('plugin.detailPanel.endpoints')}
|
{t('plugin.detailPanel.endpoints')}
|
||||||
<Tooltip
|
<Tooltip
|
||||||
popupContent={
|
popupContent={
|
||||||
<div className='w-[180px]'>
|
<div className='w-[180px]'>TODO</div>
|
||||||
{t('appDebug.voice.voiceSettings.resolutionTooltip').split('\n').map(item => (
|
|
||||||
<div key={item}>{item}</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -39,7 +36,10 @@ const EndpointList = ({
|
||||||
)}
|
)}
|
||||||
<div className='flex flex-col gap-2'>
|
<div className='flex flex-col gap-2'>
|
||||||
{list.map((item, index) => (
|
{list.map((item, index) => (
|
||||||
<EndpointCard key={index} />
|
<EndpointCard
|
||||||
|
key={index}
|
||||||
|
data={item}
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -8,7 +8,6 @@ import EndpointList from './endpoint-list'
|
||||||
import ActionList from './action-list'
|
import ActionList from './action-list'
|
||||||
import ModelList from './model-list'
|
import ModelList from './model-list'
|
||||||
import Drawer from '@/app/components/base/drawer'
|
import Drawer from '@/app/components/base/drawer'
|
||||||
// import Loading from '@/app/components/base/loading'
|
|
||||||
import cn from '@/utils/classnames'
|
import cn from '@/utils/classnames'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
@ -39,7 +38,6 @@ const PluginDetailPanel: FC<Props> = ({
|
||||||
positionCenter={false}
|
positionCenter={false}
|
||||||
panelClassname={cn('justify-start mt-[64px] mr-2 mb-2 !w-[420px] !max-w-[420px] !p-0 !bg-components-panel-bg rounded-2xl border-[0.5px] border-components-panel-border shadow-xl')}
|
panelClassname={cn('justify-start mt-[64px] mr-2 mb-2 !w-[420px] !max-w-[420px] !p-0 !bg-components-panel-bg rounded-2xl border-[0.5px] border-components-panel-border shadow-xl')}
|
||||||
>
|
>
|
||||||
{/* {loading && <Loading type='area' />} */}
|
|
||||||
{pluginDetail && (
|
{pluginDetail && (
|
||||||
<>
|
<>
|
||||||
<DetailHeader
|
<DetailHeader
|
||||||
|
|
Loading…
Reference in New Issue
Block a user