Merge branch 'feat/mcp-frontend' into deploy/dev

pull/22036/head
Joel 11 months ago
commit ff630b6dc5

@ -74,17 +74,16 @@ type IndexBarProps = {
letters: string[] letters: string[]
itemRefs: RefObject<{ [key: string]: HTMLElement | null }> itemRefs: RefObject<{ [key: string]: HTMLElement | null }>
className?: string className?: string
hasScrollBar: boolean
} }
const IndexBar: FC<IndexBarProps> = ({ letters, itemRefs, className, hasScrollBar }) => { const IndexBar: FC<IndexBarProps> = ({ letters, itemRefs, className }) => {
const handleIndexClick = (letter: string) => { const handleIndexClick = (letter: string) => {
const element = itemRefs.current?.[letter] const element = itemRefs.current?.[letter]
if (element) if (element)
element.scrollIntoView({ behavior: 'smooth' }) element.scrollIntoView({ behavior: 'smooth' })
} }
return ( return (
<div className={classNames('index-bar absolute right-0 top-36 flex flex-col items-center w-6 justify-center text-xs font-medium text-text-quaternary', hasScrollBar && 'right-3', className)}> <div className={classNames('index-bar sticky top-[20px] flex h-full w-6 flex-col items-center justify-center text-xs font-medium text-text-quaternary', className)}>
<div className={classNames('absolute left-0 top-0 h-full w-px bg-[linear-gradient(270deg,rgba(255,255,255,0)_0%,rgba(16,24,40,0.08)_30%,rgba(16,24,40,0.08)_50%,rgba(16,24,40,0.08)_70.5%,rgba(255,255,255,0)_100%)]')}></div> <div className={classNames('absolute left-0 top-0 h-full w-px bg-[linear-gradient(270deg,rgba(255,255,255,0)_0%,rgba(16,24,40,0.08)_30%,rgba(16,24,40,0.08)_50%,rgba(16,24,40,0.08)_70.5%,rgba(255,255,255,0)_100%)]')}></div>
{letters.map(letter => ( {letters.map(letter => (
<div className="cursor-pointer hover:text-text-secondary" key={letter} onClick={() => handleIndexClick(letter)}> <div className="cursor-pointer hover:text-text-secondary" key={letter} onClick={() => handleIndexClick(letter)}>

@ -11,6 +11,7 @@ import { useMemo } from 'react'
type Props = { type Props = {
payload: ToolWithProvider[] payload: ToolWithProvider[]
isShowLetterIndex: boolean isShowLetterIndex: boolean
indexBar: React.ReactNode
hasSearchText: boolean hasSearchText: boolean
onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void
canNotSelectMultiple?: boolean canNotSelectMultiple?: boolean
@ -25,6 +26,7 @@ const ToolViewFlatView: FC<Props> = ({
letters, letters,
payload, payload,
isShowLetterIndex, isShowLetterIndex,
indexBar,
hasSearchText, hasSearchText,
onSelect, onSelect,
canNotSelectMultiple, canNotSelectMultiple,
@ -43,7 +45,8 @@ const ToolViewFlatView: FC<Props> = ({
return res return res
}, [payload, letters]) }, [payload, letters])
return ( return (
<div> <div className='flex w-full'>
<div className='mr-1 grow'>
{payload.map(tool => ( {payload.map(tool => (
<div <div
key={tool.id} key={tool.id}
@ -56,7 +59,6 @@ const ToolViewFlatView: FC<Props> = ({
<Tool <Tool
payload={tool} payload={tool}
viewType={ViewType.flat} viewType={ViewType.flat}
isShowLetterIndex={isShowLetterIndex}
hasSearchText={hasSearchText} hasSearchText={hasSearchText}
onSelect={onSelect} onSelect={onSelect}
canNotSelectMultiple={canNotSelectMultiple} canNotSelectMultiple={canNotSelectMultiple}
@ -67,6 +69,8 @@ const ToolViewFlatView: FC<Props> = ({
</div> </div>
))} ))}
</div> </div>
{isShowLetterIndex && indexBar}
</div>
) )
} }

@ -21,7 +21,6 @@ type Props = {
className?: string className?: string
payload: ToolWithProvider payload: ToolWithProvider
viewType: ViewType viewType: ViewType
isShowLetterIndex: boolean
hasSearchText: boolean hasSearchText: boolean
onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void
canNotSelectMultiple?: boolean canNotSelectMultiple?: boolean
@ -34,7 +33,6 @@ const Tool: FC<Props> = ({
className, className,
payload, payload,
viewType, viewType,
isShowLetterIndex,
hasSearchText, hasSearchText,
onSelect, onSelect,
canNotSelectMultiple, canNotSelectMultiple,
@ -145,7 +143,7 @@ const Tool: FC<Props> = ({
return ( return (
<div <div
key={payload.id} key={payload.id}
className={cn('mb-1 last-of-type:mb-0', isShowLetterIndex && 'mr-6')} className={cn('mb-1 last-of-type:mb-0')}
ref={ref} ref={ref}
> >
<div className={cn(className)}> <div className={cn(className)}>

@ -43,7 +43,6 @@ const Blocks = ({
indexBarClassName, indexBarClassName,
selectedTools, selectedTools,
canChooseMCPTool, canChooseMCPTool,
hasScrollBar,
}: ToolsProps) => { }: ToolsProps) => {
// const tools: any = [] // const tools: any = []
const { t } = useTranslation() const { t } = useTranslation()
@ -127,6 +126,7 @@ const Blocks = ({
onSelectMultiple={onSelectMultiple} onSelectMultiple={onSelectMultiple}
selectedTools={selectedTools} selectedTools={selectedTools}
canChooseMCPTool={canChooseMCPTool} canChooseMCPTool={canChooseMCPTool}
indexBar={<IndexBar letters={letters} itemRefs={toolRefs} className={indexBarClassName} />}
/> />
) : ( ) : (
<ToolListTreeView <ToolListTreeView
@ -140,8 +140,6 @@ const Blocks = ({
/> />
) )
)} )}
{isShowLetterIndex && <IndexBar hasScrollBar={!!hasScrollBar} letters={letters} itemRefs={toolRefs} className={indexBarClassName} />}
</div> </div>
) )
} }

Loading…
Cancel
Save