mirror of https://github.com/langgenius/dify.git
fix: prevent show error when data is not ready
This commit is contained in:
parent
b450c6f976
commit
4042c1f6c4
|
|
@ -18,6 +18,7 @@ export const ToolIcon = memo(({ providerName }: ToolIconProps) => {
|
|||
const { data: buildInTools } = useAllBuiltInTools()
|
||||
const { data: customTools } = useAllCustomTools()
|
||||
const { data: workflowTools } = useAllWorkflowTools()
|
||||
const isDataReady = !!buildInTools && !!customTools && !!workflowTools
|
||||
const currentProvider = useMemo(() => {
|
||||
const mergedTools = [...(buildInTools || []), ...(customTools || []), ...(workflowTools || [])]
|
||||
return mergedTools.find((toolWithProvider) => {
|
||||
|
|
@ -33,10 +34,11 @@ export const ToolIcon = memo(({ providerName }: ToolIconProps) => {
|
|||
return iconFromMarketPlace
|
||||
}, [author, currentProvider, name])
|
||||
const status: Status = useMemo(() => {
|
||||
if (!isDataReady) return undefined
|
||||
if (!currentProvider) return 'not-installed'
|
||||
if (currentProvider.is_team_authorization === false) return 'not-authorized'
|
||||
return undefined
|
||||
}, [currentProvider])
|
||||
}, [currentProvider, isDataReady])
|
||||
const indicator = status === 'not-installed' ? 'red' : status === 'not-authorized' ? 'yellow' : undefined
|
||||
const notSuccess = (['not-installed', 'not-authorized'] as Array<Status>).includes(status)
|
||||
const { t } = useTranslation()
|
||||
|
|
|
|||
|
|
@ -67,14 +67,20 @@ const AgentNode: FC<NodeProps<AgentNodeType>> = (props) => {
|
|||
{inputs.agent_strategy_name
|
||||
? <SettingItem
|
||||
label={t('workflow.nodes.agent.strategy.shortLabel')}
|
||||
status={!currentStrategyStatus?.isExistInPlugin ? 'error' : undefined}
|
||||
status={
|
||||
currentStrategyStatus && !currentStrategyStatus.isExistInPlugin
|
||||
? 'error'
|
||||
: undefined
|
||||
}
|
||||
tooltip={
|
||||
!currentStrategyStatus?.isExistInPlugin ? t('workflow.nodes.agent.strategyNotInstallTooltip', {
|
||||
plugin: pluginDetail?.declaration.label
|
||||
? renderI18nObject(pluginDetail?.declaration.label)
|
||||
: undefined,
|
||||
strategy: inputs.agent_strategy_label,
|
||||
}) : undefined
|
||||
(currentStrategyStatus && !currentStrategyStatus.isExistInPlugin)
|
||||
? t('workflow.nodes.agent.strategyNotInstallTooltip', {
|
||||
plugin: pluginDetail?.declaration.label
|
||||
? renderI18nObject(pluginDetail?.declaration.label)
|
||||
: undefined,
|
||||
strategy: inputs.agent_strategy_label,
|
||||
})
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
{inputs.agent_strategy_label}
|
||||
|
|
|
|||
Loading…
Reference in New Issue