fix: switch version plugin
This commit is contained in:
parent
5e4d2f9501
commit
fa83f2e2fa
@ -23,7 +23,10 @@ export const SwitchPluginVersion: FC<SwitchPluginVersionProps> = (props) => {
|
|||||||
const [pluginId] = uniqueIdentifier.split(':')
|
const [pluginId] = uniqueIdentifier.split(':')
|
||||||
const [isShow, setIsShow] = useState(false)
|
const [isShow, setIsShow] = useState(false)
|
||||||
const [isShowUpdateModal, { setTrue: showUpdateModal, setFalse: hideUpdateModal }] = useBoolean(false)
|
const [isShowUpdateModal, { setTrue: showUpdateModal, setFalse: hideUpdateModal }] = useBoolean(false)
|
||||||
const [targetVersion, setTargetVersion] = useState<string>()
|
const [target, setTarget] = useState<{
|
||||||
|
version: string,
|
||||||
|
pluginUniqueIden: string;
|
||||||
|
}>()
|
||||||
const pluginDetails = useCheckInstalled({
|
const pluginDetails = useCheckInstalled({
|
||||||
pluginIds: [pluginId],
|
pluginIds: [pluginId],
|
||||||
enabled: true,
|
enabled: true,
|
||||||
@ -33,13 +36,8 @@ export const SwitchPluginVersion: FC<SwitchPluginVersionProps> = (props) => {
|
|||||||
const handleUpdatedFromMarketplace = useCallback(() => {
|
const handleUpdatedFromMarketplace = useCallback(() => {
|
||||||
hideUpdateModal()
|
hideUpdateModal()
|
||||||
pluginDetails.refetch()
|
pluginDetails.refetch()
|
||||||
onChange?.(targetVersion!)
|
onChange?.(target!.version)
|
||||||
}, [hideUpdateModal, onChange, pluginDetails, targetVersion])
|
}, [hideUpdateModal, onChange, pluginDetails, target])
|
||||||
|
|
||||||
const targetUniqueIdentifier = (() => {
|
|
||||||
if (!targetVersion || !pluginDetail) return uniqueIdentifier
|
|
||||||
return uniqueIdentifier.replaceAll(pluginDetail.version, targetVersion)
|
|
||||||
})()
|
|
||||||
return <Tooltip popupContent={!isShow && !isShowUpdateModal && tooltip} triggerMethod='hover'>
|
return <Tooltip popupContent={!isShow && !isShowUpdateModal && tooltip} triggerMethod='hover'>
|
||||||
<div className={cn('w-fit', className)}>
|
<div className={cn('w-fit', className)}>
|
||||||
{isShowUpdateModal && pluginDetail && <UpdateFromMarketplace
|
{isShowUpdateModal && pluginDetail && <UpdateFromMarketplace
|
||||||
@ -49,8 +47,8 @@ export const SwitchPluginVersion: FC<SwitchPluginVersionProps> = (props) => {
|
|||||||
payload: pluginDetail.declaration,
|
payload: pluginDetail.declaration,
|
||||||
},
|
},
|
||||||
targetPackageInfo: {
|
targetPackageInfo: {
|
||||||
id: targetUniqueIdentifier,
|
id: target!.pluginUniqueIden,
|
||||||
version: targetVersion!,
|
version: target!.version,
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
onCancel={hideUpdateModal}
|
onCancel={hideUpdateModal}
|
||||||
@ -62,7 +60,10 @@ export const SwitchPluginVersion: FC<SwitchPluginVersionProps> = (props) => {
|
|||||||
pluginID={pluginId}
|
pluginID={pluginId}
|
||||||
currentVersion={pluginDetail.version}
|
currentVersion={pluginDetail.version}
|
||||||
onSelect={(state) => {
|
onSelect={(state) => {
|
||||||
setTargetVersion(state.version)
|
setTarget({
|
||||||
|
pluginUniqueIden: state.unique_identifier,
|
||||||
|
version: state.version,
|
||||||
|
})
|
||||||
showUpdateModal()
|
showUpdateModal()
|
||||||
}}
|
}}
|
||||||
trigger={
|
trigger={
|
||||||
|
Loading…
Reference in New Issue
Block a user