mirror of
https://github.com/langgenius/dify.git
synced 2026-04-29 20:48:01 +08:00
method selector
This commit is contained in:
parent
f04daf056d
commit
3371989572
@ -1,10 +1,7 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import {
|
|
||||||
RiAddLine,
|
|
||||||
} from '@remixicon/react'
|
|
||||||
import Tooltip from '@/app/components/base/tooltip'
|
import Tooltip from '@/app/components/base/tooltip'
|
||||||
import ActionButton from '@/app/components/base/action-button'
|
import MethodSelector from './method-selector'
|
||||||
|
|
||||||
const i18nPrefix = 'workflow.nodes.humanInput'
|
const i18nPrefix = 'workflow.nodes.humanInput'
|
||||||
|
|
||||||
@ -21,11 +18,9 @@ const DeliveryMethod: React.FC = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className='flex items-center px-1'>
|
<div className='flex items-center px-1'>
|
||||||
<ActionButton
|
<MethodSelector
|
||||||
onClick={() => { /* Add new user action logic here */ }}
|
onEdit={() => { /* Add edit action logic here */ }}
|
||||||
>
|
/>
|
||||||
<RiAddLine className='h-4 w-4' />
|
|
||||||
</ActionButton>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className='system-xs-regular flex items-center justify-center rounded-[10px] bg-background-section p-3 text-text-tertiary'>{t(`${i18nPrefix}.deliveryMethod.emptyTip`)}</div>
|
<div className='system-xs-regular flex items-center justify-center rounded-[10px] bg-background-section p-3 text-text-tertiary'>{t(`${i18nPrefix}.deliveryMethod.emptyTip`)}</div>
|
||||||
|
|||||||
@ -0,0 +1,83 @@
|
|||||||
|
'use client'
|
||||||
|
import type { FC } from 'react'
|
||||||
|
import React, { useCallback, useRef, useState } from 'react'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import {
|
||||||
|
RiAddLine,
|
||||||
|
RiMailSendFill,
|
||||||
|
RiRobot2Fill,
|
||||||
|
} from '@remixicon/react'
|
||||||
|
import ActionButton from '@/app/components/base/action-button'
|
||||||
|
import {
|
||||||
|
PortalToFollowElem,
|
||||||
|
PortalToFollowElemContent,
|
||||||
|
PortalToFollowElemTrigger,
|
||||||
|
} from '@/app/components/base/portal-to-follow-elem'
|
||||||
|
import cn from '@/utils/classnames'
|
||||||
|
|
||||||
|
const i18nPrefix = 'workflow.nodes.humanInput'
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
onEdit: () => void
|
||||||
|
}
|
||||||
|
|
||||||
|
const MethodSelector: FC<Props> = ({
|
||||||
|
onEdit,
|
||||||
|
}) => {
|
||||||
|
const { t } = useTranslation()
|
||||||
|
const [open, doSetOpen] = useState(false)
|
||||||
|
const openRef = useRef(open)
|
||||||
|
const setOpen = useCallback((v: boolean) => {
|
||||||
|
doSetOpen(v)
|
||||||
|
openRef.current = v
|
||||||
|
}, [doSetOpen])
|
||||||
|
|
||||||
|
const handleTrigger = useCallback(() => {
|
||||||
|
setOpen(!openRef.current)
|
||||||
|
}, [setOpen])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PortalToFollowElem
|
||||||
|
open={open}
|
||||||
|
onOpenChange={setOpen}
|
||||||
|
placement='bottom-end'
|
||||||
|
offset={{
|
||||||
|
mainAxis: 4,
|
||||||
|
crossAxis: 12,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<PortalToFollowElemTrigger onClick={handleTrigger}>
|
||||||
|
<div>
|
||||||
|
<ActionButton className={cn(open && 'bg-state-base-hover')}>
|
||||||
|
<RiAddLine className='h-4 w-4' />
|
||||||
|
</ActionButton>
|
||||||
|
</div>
|
||||||
|
</PortalToFollowElemTrigger>
|
||||||
|
<PortalToFollowElemContent className='z-50'>
|
||||||
|
<div className='w-[360px] rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg-blur shadow-lg backdrop-blur-sm'>
|
||||||
|
<div className='p-1'>
|
||||||
|
<div className='relative flex cursor-pointer items-center gap-1 rounded-lg p-1 pl-3 hover:bg-state-base-hover'>
|
||||||
|
<div className='rounded-[4px] border border-divider-regular bg-components-icon-bg-indigo-solid p-0.5'>
|
||||||
|
<RiRobot2Fill className='h-3.5 w-3.5 text-text-primary-on-surface' />
|
||||||
|
</div>
|
||||||
|
<div className='p-1'>
|
||||||
|
<div className='system-sm-medium mb-0.5 truncate text-text-primary'>{t(`${i18nPrefix}.deliveryMethod.types.webapp.title`)}</div>
|
||||||
|
<div className='system-xs-regular truncate text-text-tertiary'>{t(`${i18nPrefix}.deliveryMethod.types.webapp.description`)}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className='relative flex cursor-pointer items-center gap-1 rounded-lg p-1 pl-3 hover:bg-state-base-hover'>
|
||||||
|
<div className='rounded-[4px] border border-divider-regular bg-components-icon-bg-indigo-solid p-0.5'>
|
||||||
|
<RiMailSendFill className='h-3.5 w-3.5 text-text-primary-on-surface' />
|
||||||
|
</div>
|
||||||
|
<div className='p-1'>
|
||||||
|
<div className='system-sm-medium mb-0.5 truncate text-text-primary'>{t(`${i18nPrefix}.deliveryMethod.types.email.title`)}</div>
|
||||||
|
<div className='system-xs-regular truncate text-text-tertiary'>{t(`${i18nPrefix}.deliveryMethod.types.email.description`)}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</PortalToFollowElemContent>
|
||||||
|
</PortalToFollowElem>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
export default React.memo(MethodSelector)
|
||||||
@ -909,6 +909,21 @@ const translation = {
|
|||||||
title: 'Delivery Method',
|
title: 'Delivery Method',
|
||||||
tooltip: 'How the human input form is delivered to the user.',
|
tooltip: 'How the human input form is delivered to the user.',
|
||||||
emptyTip: 'No delivery method added, the operation cannot be triggered.',
|
emptyTip: 'No delivery method added, the operation cannot be triggered.',
|
||||||
|
types: {
|
||||||
|
webapp: {
|
||||||
|
title: 'Webapp',
|
||||||
|
description: 'Display to end-user in webapp',
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
title: 'Email',
|
||||||
|
description: 'Send request for input via email',
|
||||||
|
},
|
||||||
|
slack: {
|
||||||
|
title: 'Slack',
|
||||||
|
description: 'Send request for input via Slack',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
added: 'Added',
|
||||||
},
|
},
|
||||||
formContent: 'form content',
|
formContent: 'form content',
|
||||||
userActions: {
|
userActions: {
|
||||||
|
|||||||
@ -910,6 +910,21 @@ const translation = {
|
|||||||
title: '提交方式',
|
title: '提交方式',
|
||||||
tooltip: '人类输入表单如何传递给用户。',
|
tooltip: '人类输入表单如何传递给用户。',
|
||||||
emptyTip: '未添加提交方式,无法触发操作。',
|
emptyTip: '未添加提交方式,无法触发操作。',
|
||||||
|
types: {
|
||||||
|
webapp: {
|
||||||
|
title: 'Webapp',
|
||||||
|
description: '在 Web 应用中显示给最终用户',
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
title: 'Email',
|
||||||
|
description: '通过电子邮件发送输入请求',
|
||||||
|
},
|
||||||
|
slack: {
|
||||||
|
title: 'Slack',
|
||||||
|
description: '通过 Slack 发送输入请求',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
added: '已添加',
|
||||||
},
|
},
|
||||||
formContent: '表单内容',
|
formContent: '表单内容',
|
||||||
userActions: {
|
userActions: {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user