mirror of
https://github.com/langgenius/dify.git
synced 2026-05-04 16:37:15 +08:00
feat: select tool template
This commit is contained in:
parent
93a560ee54
commit
1ff5969b92
@ -7,6 +7,8 @@ import PluginsSelected from './plugins-selected'
|
|||||||
import Button from '@/app/components/base/button'
|
import Button from '@/app/components/base/button'
|
||||||
import { RiAddLine } from '@remixicon/react'
|
import { RiAddLine } from '@remixicon/react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { useBoolean } from 'ahooks'
|
||||||
|
import ToolPicker from './tool-picker'
|
||||||
|
|
||||||
const i18nPrefix = 'plugin.autoUpdate'
|
const i18nPrefix = 'plugin.autoUpdate'
|
||||||
|
|
||||||
@ -27,6 +29,10 @@ const PluginsPicker: FC<Props> = ({
|
|||||||
const handleClear = () => {
|
const handleClear = () => {
|
||||||
onChange([])
|
onChange([])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const [isShowToolPicker, {
|
||||||
|
set: setToolPicker,
|
||||||
|
}] = useBoolean(false)
|
||||||
return (
|
return (
|
||||||
<div className='mt-2 rounded-[10px] bg-background-section-burn p-2.5'>
|
<div className='mt-2 rounded-[10px] bg-background-section-burn p-2.5'>
|
||||||
{hasSelected ? (
|
{hasSelected ? (
|
||||||
@ -45,10 +51,18 @@ const PluginsPicker: FC<Props> = ({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Button className='mt-2 w-full' size='small' variant='secondary-accent'>
|
<ToolPicker
|
||||||
<RiAddLine className='size-3.5' />
|
trigger={
|
||||||
{t(`${i18nPrefix}.operation.select`)}
|
<Button className='mt-2 w-[350px]' size='small' variant='secondary-accent'>
|
||||||
</Button>
|
<RiAddLine className='size-3.5' />
|
||||||
|
{t(`${i18nPrefix}.operation.select`)}
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
value={value}
|
||||||
|
onChange={onChange}
|
||||||
|
isShow={isShowToolPicker}
|
||||||
|
onShowChange={setToolPicker}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,47 @@
|
|||||||
|
'use client'
|
||||||
|
import type { FC } from 'react'
|
||||||
|
import React, { useCallback } from 'react'
|
||||||
|
import {
|
||||||
|
PortalToFollowElem,
|
||||||
|
PortalToFollowElemContent,
|
||||||
|
PortalToFollowElemTrigger,
|
||||||
|
} from '@/app/components/base/portal-to-follow-elem'
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
trigger: React.ReactNode
|
||||||
|
value: string[]
|
||||||
|
onChange: (value: string[]) => void
|
||||||
|
isShow: boolean
|
||||||
|
onShowChange: (isShow: boolean) => void
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const ToolPicker: FC<Props> = ({
|
||||||
|
trigger,
|
||||||
|
value,
|
||||||
|
onChange,
|
||||||
|
isShow,
|
||||||
|
onShowChange,
|
||||||
|
}) => {
|
||||||
|
const toggleShowPopup = useCallback(() => {
|
||||||
|
onShowChange(!isShow)
|
||||||
|
}, [onShowChange, isShow])
|
||||||
|
return (
|
||||||
|
<PortalToFollowElem
|
||||||
|
placement='top-start'
|
||||||
|
offset={0}
|
||||||
|
open={isShow}
|
||||||
|
onOpenChange={onShowChange}
|
||||||
|
>
|
||||||
|
<PortalToFollowElemTrigger
|
||||||
|
onClick={toggleShowPopup}
|
||||||
|
>
|
||||||
|
{trigger}
|
||||||
|
</PortalToFollowElemTrigger>
|
||||||
|
<PortalToFollowElemContent className='z-[1000]'>
|
||||||
|
<div>aafdf</div>
|
||||||
|
</PortalToFollowElemContent>
|
||||||
|
</PortalToFollowElem>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
export default React.memo(ToolPicker)
|
||||||
Loading…
Reference in New Issue
Block a user