fix: prevent show error when data is not ready

pull/12547/head
AkaraChen 1 year ago
parent b450c6f976
commit 4042c1f6c4

@ -18,6 +18,7 @@ export const ToolIcon = memo(({ providerName }: ToolIconProps) => {
const { data: buildInTools } = useAllBuiltInTools() const { data: buildInTools } = useAllBuiltInTools()
const { data: customTools } = useAllCustomTools() const { data: customTools } = useAllCustomTools()
const { data: workflowTools } = useAllWorkflowTools() const { data: workflowTools } = useAllWorkflowTools()
const isDataReady = !!buildInTools && !!customTools && !!workflowTools
const currentProvider = useMemo(() => { const currentProvider = useMemo(() => {
const mergedTools = [...(buildInTools || []), ...(customTools || []), ...(workflowTools || [])] const mergedTools = [...(buildInTools || []), ...(customTools || []), ...(workflowTools || [])]
return mergedTools.find((toolWithProvider) => { return mergedTools.find((toolWithProvider) => {
@ -33,10 +34,11 @@ export const ToolIcon = memo(({ providerName }: ToolIconProps) => {
return iconFromMarketPlace return iconFromMarketPlace
}, [author, currentProvider, name]) }, [author, currentProvider, name])
const status: Status = useMemo(() => { const status: Status = useMemo(() => {
if (!isDataReady) return undefined
if (!currentProvider) return 'not-installed' if (!currentProvider) return 'not-installed'
if (currentProvider.is_team_authorization === false) return 'not-authorized' if (currentProvider.is_team_authorization === false) return 'not-authorized'
return undefined return undefined
}, [currentProvider]) }, [currentProvider, isDataReady])
const indicator = status === 'not-installed' ? 'red' : status === 'not-authorized' ? 'yellow' : undefined const indicator = status === 'not-installed' ? 'red' : status === 'not-authorized' ? 'yellow' : undefined
const notSuccess = (['not-installed', 'not-authorized'] as Array<Status>).includes(status) const notSuccess = (['not-installed', 'not-authorized'] as Array<Status>).includes(status)
const { t } = useTranslation() const { t } = useTranslation()

@ -67,14 +67,20 @@ const AgentNode: FC<NodeProps<AgentNodeType>> = (props) => {
{inputs.agent_strategy_name {inputs.agent_strategy_name
? <SettingItem ? <SettingItem
label={t('workflow.nodes.agent.strategy.shortLabel')} label={t('workflow.nodes.agent.strategy.shortLabel')}
status={!currentStrategyStatus?.isExistInPlugin ? 'error' : undefined} status={
currentStrategyStatus && !currentStrategyStatus.isExistInPlugin
? 'error'
: undefined
}
tooltip={ tooltip={
!currentStrategyStatus?.isExistInPlugin ? t('workflow.nodes.agent.strategyNotInstallTooltip', { (currentStrategyStatus && !currentStrategyStatus.isExistInPlugin)
? t('workflow.nodes.agent.strategyNotInstallTooltip', {
plugin: pluginDetail?.declaration.label plugin: pluginDetail?.declaration.label
? renderI18nObject(pluginDetail?.declaration.label) ? renderI18nObject(pluginDetail?.declaration.label)
: undefined, : undefined,
strategy: inputs.agent_strategy_label, strategy: inputs.agent_strategy_label,
}) : undefined })
: undefined
} }
> >
{inputs.agent_strategy_label} {inputs.agent_strategy_label}

Loading…
Cancel
Save