mirror of
https://github.com/langgenius/dify.git
synced 2026-02-13 07:01:23 -05:00
Replace useEffect-based state sync (_pluginInstallLocked/_dimmed) with render-time derived computation in BaseNode, breaking the cycle of effect → node data update → re-render → effect. Extract plugin missing check into a pure utility function for checklist reuse.
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import type { FC } from 'react'
|
|
import type { DataSourceNodeType } from './types'
|
|
import type { NodeProps } from '@/app/components/workflow/types'
|
|
import { memo } from 'react'
|
|
import { useNodePluginInstallation } from '@/app/components/workflow/hooks/use-node-plugin-installation'
|
|
import { InstallPluginButton } from '@/app/components/workflow/nodes/_base/components/install-plugin-button'
|
|
|
|
const Node: FC<NodeProps<DataSourceNodeType>> = ({
|
|
data,
|
|
}) => {
|
|
const {
|
|
isChecking,
|
|
isMissing,
|
|
uniqueIdentifier,
|
|
canInstall,
|
|
onInstallSuccess,
|
|
} = useNodePluginInstallation(data)
|
|
|
|
const showInstallButton = !isChecking && isMissing && canInstall && uniqueIdentifier
|
|
|
|
if (!showInstallButton)
|
|
return null
|
|
|
|
return (
|
|
<div className="relative mb-1 px-3 py-1">
|
|
<div className="pointer-events-auto absolute right-3 top-[-32px] z-40">
|
|
<InstallPluginButton
|
|
size="small"
|
|
extraIdentifiers={[
|
|
data.plugin_id,
|
|
data.provider_name,
|
|
].filter(Boolean) as string[]}
|
|
className="!font-medium !text-text-accent"
|
|
uniqueIdentifier={uniqueIdentifier!}
|
|
onSuccess={onInstallSuccess}
|
|
/>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default memo(Node)
|