feat: show downgrade warning logic

pull/19758/head
Joel 8 months ago committed by Junyan Qin
parent dcf26ba912
commit 86579cd35e
No known key found for this signature in database
GPG Key ID: 22FE3AFADC710CEB

@ -93,6 +93,7 @@ const DetailHeader = ({
const [targetVersion, setTargetVersion] = useState({
version: latest_version,
unique_identifier: latest_unique_identifier,
isDowngrade: false,
})
const hasNewVersion = useMemo(() => {
if (isFromMarketplace)
@ -114,8 +115,18 @@ const DetailHeader = ({
setFalse: hideUpdateModal,
}] = useBoolean(false)
const isAutoUpgradeEnabled = true // toeo
const [isShowDowngradeWarningModal, {
setTrue: showDowngradeWarningModal,
setFalse: hideDowngradeWarningModal,
}] = useBoolean(false)
const handleUpdate = async () => {
if (isFromMarketplace) {
if(isAutoUpgradeEnabled && targetVersion.isDowngrade) {
showDowngradeWarningModal()
return
}
showUpdateModal()
return
}
@ -238,6 +249,7 @@ const DetailHeader = ({
setTargetVersion({
version: latest_version,
unique_identifier: latest_unique_identifier,
isDowngrade: false,
})
}
handleUpdate()
@ -351,6 +363,7 @@ const DetailHeader = ({
/>
)
}
{ isShowDowngradeWarningModal && (<div>aaa</div>)}
</div>
)
}

@ -15,6 +15,7 @@ import type {
import { useVersionListOfPlugin } from '@/service/use-plugins'
import useTimestamp from '@/hooks/use-timestamp'
import cn from '@/utils/classnames'
import { lt } from 'semver'
type Props = {
disabled?: boolean
@ -28,9 +29,11 @@ type Props = {
onSelect: ({
version,
unique_identifier,
isDowngrade,
}: {
version: string
unique_identifier: string
isDowngrade: boolean
}) => void
}
@ -59,13 +62,14 @@ const PluginVersionPicker: FC<Props> = ({
const { data: res } = useVersionListOfPlugin(pluginID)
const handleSelect = useCallback(({ version, unique_identifier }: {
const handleSelect = useCallback(({ version, unique_identifier, isDowngrade }: {
version: string
unique_identifier: string
isDowngrade: boolean
}) => {
if (currentVersion === version)
return
onSelect({ version, unique_identifier })
onSelect({ version, unique_identifier, isDowngrade })
onShowChange(false)
}, [currentVersion, onSelect, onShowChange])
@ -99,6 +103,7 @@ const PluginVersionPicker: FC<Props> = ({
onClick={() => handleSelect({
version: version.version,
unique_identifier: version.unique_identifier,
isDowngrade: lt(version.version, currentVersion),
})}
>
<div className='flex grow items-center'>

Loading…
Cancel
Save