mirror of
https://github.com/langgenius/dify.git
synced 2026-05-01 16:08:04 +08:00
chore: choose tools show
This commit is contained in:
@ -277,6 +277,7 @@ const AllTools = ({
|
||||
viewType={isSupportGroupView ? activeView : ViewType.flat}
|
||||
hasSearchText={hasSearchText}
|
||||
selectedTools={selectedTools}
|
||||
hideSelectedInfo={hideFeaturedTool}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
@ -18,6 +18,7 @@ type Props = {
|
||||
letters: string[]
|
||||
toolRefs: any
|
||||
selectedTools?: ToolValue[]
|
||||
hideSelectedInfo?: boolean
|
||||
}
|
||||
|
||||
const ToolViewFlatView: FC<Props> = ({
|
||||
@ -31,6 +32,7 @@ const ToolViewFlatView: FC<Props> = ({
|
||||
onSelectMultiple,
|
||||
toolRefs,
|
||||
selectedTools,
|
||||
hideSelectedInfo,
|
||||
}) => {
|
||||
const firstLetterToolIds = useMemo(() => {
|
||||
const res: Record<string, string> = {}
|
||||
@ -61,6 +63,7 @@ const ToolViewFlatView: FC<Props> = ({
|
||||
canNotSelectMultiple={canNotSelectMultiple}
|
||||
onSelectMultiple={onSelectMultiple}
|
||||
selectedTools={selectedTools}
|
||||
hideSelectedInfo={hideSelectedInfo}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
|
||||
@ -14,6 +14,7 @@ type Props = {
|
||||
canNotSelectMultiple?: boolean
|
||||
onSelectMultiple?: (type: BlockEnum, tools: ToolDefaultValue[]) => void
|
||||
selectedTools?: ToolValue[]
|
||||
hideSelectedInfo?: boolean
|
||||
}
|
||||
|
||||
const Item: FC<Props> = ({
|
||||
@ -24,6 +25,7 @@ const Item: FC<Props> = ({
|
||||
canNotSelectMultiple,
|
||||
onSelectMultiple,
|
||||
selectedTools,
|
||||
hideSelectedInfo,
|
||||
}) => {
|
||||
return (
|
||||
<div>
|
||||
@ -41,6 +43,7 @@ const Item: FC<Props> = ({
|
||||
canNotSelectMultiple={canNotSelectMultiple}
|
||||
onSelectMultiple={onSelectMultiple}
|
||||
selectedTools={selectedTools}
|
||||
hideSelectedInfo={hideSelectedInfo}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@ -15,6 +15,7 @@ type Props = {
|
||||
canNotSelectMultiple?: boolean
|
||||
onSelectMultiple?: (type: BlockEnum, tools: ToolDefaultValue[]) => void
|
||||
selectedTools?: ToolValue[]
|
||||
hideSelectedInfo?: boolean
|
||||
}
|
||||
|
||||
const ToolListTreeView: FC<Props> = ({
|
||||
@ -24,6 +25,7 @@ const ToolListTreeView: FC<Props> = ({
|
||||
canNotSelectMultiple,
|
||||
onSelectMultiple,
|
||||
selectedTools,
|
||||
hideSelectedInfo,
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
const getI18nGroupName = useCallback((name: string) => {
|
||||
@ -54,6 +56,7 @@ const ToolListTreeView: FC<Props> = ({
|
||||
canNotSelectMultiple={canNotSelectMultiple}
|
||||
onSelectMultiple={onSelectMultiple}
|
||||
selectedTools={selectedTools}
|
||||
hideSelectedInfo={hideSelectedInfo}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@ -40,6 +40,7 @@ type Props = {
|
||||
onSelectMultiple?: (type: BlockEnum, tools: ToolDefaultValue[]) => void
|
||||
selectedTools?: ToolValue[]
|
||||
isShowLetterIndex?: boolean
|
||||
hideSelectedInfo?: boolean
|
||||
}
|
||||
|
||||
const Tool: FC<Props> = ({
|
||||
@ -51,6 +52,7 @@ const Tool: FC<Props> = ({
|
||||
canNotSelectMultiple,
|
||||
onSelectMultiple,
|
||||
selectedTools,
|
||||
hideSelectedInfo,
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
const { allowed: isMCPToolAllowed } = useMCPToolAvailability()
|
||||
@ -226,7 +228,7 @@ const Tool: FC<Props> = ({
|
||||
</div>
|
||||
|
||||
<div className="ml-2 flex items-center">
|
||||
{!isShowCanNotChooseMCPTip && !canNotSelectMultiple && (notShowProvider ? notShowProviderSelectInfo : selectedInfo)}
|
||||
{!isShowCanNotChooseMCPTip && !canNotSelectMultiple && (notShowProvider ? notShowProviderSelectInfo : (!hideSelectedInfo && selectedInfo))}
|
||||
{isShowCanNotChooseMCPTip && <McpToolNotSupportTooltip />}
|
||||
{hasAction && (
|
||||
<FoldIcon className={cn('h-4 w-4 shrink-0 text-text-tertiary group-hover/item:text-text-tertiary', isFold && 'text-text-quaternary')} />
|
||||
|
||||
@ -21,6 +21,7 @@ type ToolsProps = {
|
||||
className?: string
|
||||
indexBarClassName?: string
|
||||
selectedTools?: ToolValue[]
|
||||
hideSelectedInfo?: boolean
|
||||
}
|
||||
const Tools = ({
|
||||
onSelect,
|
||||
@ -34,6 +35,7 @@ const Tools = ({
|
||||
className,
|
||||
indexBarClassName,
|
||||
selectedTools,
|
||||
hideSelectedInfo,
|
||||
}: ToolsProps) => {
|
||||
// const tools: any = []
|
||||
const language = useGetLanguage()
|
||||
@ -107,6 +109,7 @@ const Tools = ({
|
||||
canNotSelectMultiple={canNotSelectMultiple}
|
||||
onSelectMultiple={onSelectMultiple}
|
||||
selectedTools={selectedTools}
|
||||
hideSelectedInfo={hideSelectedInfo}
|
||||
indexBar={<IndexBar letters={letters} itemRefs={toolRefs} className={indexBarClassName} />}
|
||||
/>
|
||||
)
|
||||
@ -118,6 +121,7 @@ const Tools = ({
|
||||
canNotSelectMultiple={canNotSelectMultiple}
|
||||
onSelectMultiple={onSelectMultiple}
|
||||
selectedTools={selectedTools}
|
||||
hideSelectedInfo={hideSelectedInfo}
|
||||
/>
|
||||
)
|
||||
)}
|
||||
|
||||
@ -395,6 +395,10 @@ const ToolBlockComponent: FC<ToolBlockComponentProps> = ({
|
||||
setToolValue(prev => (prev ? { ...prev, credential_id: id } : prev))
|
||||
}
|
||||
|
||||
const needAuthorization = useMemo(() => {
|
||||
return !(!currentProvider || currentProvider.type !== CollectionType.builtIn || !currentProvider.allow_delete)
|
||||
}, [currentProvider])
|
||||
|
||||
const toolSettingsContent = currentProvider && currentTool && toolValue && (
|
||||
<>
|
||||
<ToolHeader
|
||||
@ -404,18 +408,24 @@ const ToolBlockComponent: FC<ToolBlockComponentProps> = ({
|
||||
description={toolDescriptionText}
|
||||
onClose={() => setIsSettingOpen(false)}
|
||||
/>
|
||||
<ToolAuthorizationSection
|
||||
currentProvider={currentProvider}
|
||||
credentialId={toolValue.credential_id}
|
||||
onAuthorizationItemClick={handleAuthorizationItemClick}
|
||||
/>
|
||||
<ToolSettingsSection
|
||||
currentProvider={currentProvider}
|
||||
currentTool={currentTool}
|
||||
value={toolValue}
|
||||
onChange={handleToolValueChange}
|
||||
nodeId={undefined}
|
||||
/>
|
||||
{needAuthorization && (
|
||||
<>
|
||||
<ToolAuthorizationSection
|
||||
currentProvider={currentProvider}
|
||||
credentialId={toolValue.credential_id}
|
||||
onAuthorizationItemClick={handleAuthorizationItemClick}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
{!needAuthorization && (
|
||||
<ToolSettingsSection
|
||||
currentProvider={currentProvider}
|
||||
currentTool={currentTool}
|
||||
value={toolValue}
|
||||
onChange={handleToolValueChange}
|
||||
nodeId={undefined}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user