fix: prevent client-side crashes from null/undefined plugin data in workflow (#23154) (#23182)

This commit is contained in:
lyzno1
2025-07-31 10:03:33 +08:00
committed by GitHub
parent 646900b00c
commit 1b2046da3f
9 changed files with 260 additions and 14 deletions

View File

@@ -26,7 +26,8 @@ export type SwitchPluginVersionProps = {
export const SwitchPluginVersion: FC<SwitchPluginVersionProps> = (props) => {
const { uniqueIdentifier, tooltip, onChange, className } = props
const [pluginId] = uniqueIdentifier.split(':')
const [pluginId] = uniqueIdentifier?.split(':') || ['']
const [isShow, setIsShow] = useState(false)
const [isShowUpdateModal, { setTrue: showUpdateModal, setFalse: hideUpdateModal }] = useBoolean(false)
const [target, setTarget] = useState<{
@@ -60,6 +61,11 @@ export const SwitchPluginVersion: FC<SwitchPluginVersionProps> = (props) => {
})
}
const { t } = useTranslation()
// Guard against null/undefined uniqueIdentifier to prevent app crash
if (!uniqueIdentifier || !pluginId)
return null
return <Tooltip popupContent={!isShow && !isShowUpdateModal && tooltip} triggerMethod='hover'>
<div className={cn('flex w-fit items-center justify-center', className)} onClick={e => e.stopPropagation()}>
{isShowUpdateModal && pluginDetail && <PluginMutationModel