chore: node help link (#4795)

This commit is contained in:
zxhlyh
2024-05-30 14:24:53 +08:00
committed by GitHub
parent b10e67be3b
commit 5b2cd8d03a
10 changed files with 174 additions and 15 deletions

View File

@@ -0,0 +1,31 @@
import { memo } from 'react'
import { useTranslation } from 'react-i18next'
import { useNodeHelpLink } from '../hooks/use-node-help-link'
import TooltipPlus from '@/app/components/base/tooltip-plus'
import { BookOpen02 } from '@/app/components/base/icons/src/vender/line/education'
import type { BlockEnum } from '@/app/components/workflow/types'
type HelpLinkProps = {
nodeType: BlockEnum
}
const HelpLink = ({
nodeType,
}: HelpLinkProps) => {
const { t } = useTranslation()
const link = useNodeHelpLink(nodeType)
return (
<TooltipPlus popupContent={t('common.userProfile.helpCenter')}>
<a
href={link}
target='_blank'
className='flex items-center justify-center mr-1 w-6 h-6'
>
<BookOpen02 className='w-4 h-4 text-gray-500' />
</a>
</TooltipPlus>
)
}
export default memo(HelpLink)

View File

@@ -20,6 +20,7 @@ type PanelOperatorProps = {
offset?: OffsetOptions
onOpenChange?: (open: boolean) => void
inNode?: boolean
showHelpLink?: boolean
}
const PanelOperator = ({
id,
@@ -31,6 +32,7 @@ const PanelOperator = ({
},
onOpenChange,
inNode,
showHelpLink = true,
}: PanelOperatorProps) => {
const [open, setOpen] = useState(false)
@@ -65,6 +67,7 @@ const PanelOperator = ({
id={id}
data={data}
onClosePopup={() => setOpen(false)}
showHelpLink={showHelpLink}
/>
</PortalToFollowElemContent>
</PortalToFollowElem>

View File

@@ -4,6 +4,7 @@ import {
} from 'react'
import { useTranslation } from 'react-i18next'
import { useEdges } from 'reactflow'
import { useNodeHelpLink } from '../../hooks/use-node-help-link'
import ChangeBlock from './change-block'
import {
canRunBySingle,
@@ -26,11 +27,13 @@ type PanelOperatorPopupProps = {
id: string
data: Node['data']
onClosePopup: () => void
showHelpLink?: boolean
}
const PanelOperatorPopup = ({
id,
data,
onClosePopup,
showHelpLink,
}: PanelOperatorPopupProps) => {
const { t } = useTranslation()
const language = useGetLanguage()
@@ -77,6 +80,8 @@ const PanelOperatorPopup = ({
const showChangeBlock = data.type !== BlockEnum.Start && !nodesReadOnly && data.type !== BlockEnum.Iteration
const link = useNodeHelpLink(data.type)
return (
<div className='w-[240px] border-[0.5px] border-gray-200 rounded-lg shadow-xl bg-white'>
{
@@ -157,20 +162,22 @@ const PanelOperatorPopup = ({
</>
)
}
<div className='p-1'>
<a
href={
language === 'zh_Hans'
? 'https://docs.dify.ai/v/zh-hans/guides/workflow'
: 'https://docs.dify.ai/features/workflow'
}
target='_blank'
className='flex items-center px-3 h-8 text-sm text-gray-700 rounded-lg cursor-pointer hover:bg-gray-50'
>
{t('workflow.panel.helpLink')}
</a>
</div>
<div className='h-[1px] bg-gray-100'></div>
{
showHelpLink && (
<>
<div className='p-1'>
<a
href={link}
target='_blank'
className='flex items-center px-3 h-8 text-sm text-gray-700 rounded-lg cursor-pointer hover:bg-gray-50'
>
{t('workflow.panel.helpLink')}
</a>
</div>
<div className='h-[1px] bg-gray-100'></div>
</>
)
}
<div className='p-1'>
<div className='px-3 py-2 text-xs text-gray-500'>
<div className='flex items-center mb-1 h-[22px] font-medium'>