diff --git a/web/app/components/plugins/plugin-detail-panel/detail-header.tsx b/web/app/components/plugins/plugin-detail-panel/detail-header.tsx
index 7fcbad408c..0f9e2b9ea3 100644
--- a/web/app/components/plugins/plugin-detail-panel/detail-header.tsx
+++ b/web/app/components/plugins/plugin-detail-panel/detail-header.tsx
@@ -77,6 +77,7 @@ const DetailHeader = ({
const [targetVersion, setTargetVersion] = useState({
version: latest_version,
unique_identifier: latest_unique_identifier,
+ isDowngrade: false,
})
const hasNewVersion = useMemo(() => {
if (isFromMarketplace)
@@ -98,8 +99,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
}
@@ -222,6 +233,7 @@ const DetailHeader = ({
setTargetVersion({
version: latest_version,
unique_identifier: latest_unique_identifier,
+ isDowngrade: false,
})
}
handleUpdate()
@@ -316,6 +328,7 @@ const DetailHeader = ({
/>
)
}
+ { isShowDowngradeWarningModal && (
aaa
)}
)
}
diff --git a/web/app/components/plugins/update-plugin/plugin-version-picker.tsx b/web/app/components/plugins/update-plugin/plugin-version-picker.tsx
index 424f76d790..36a4faace1 100644
--- a/web/app/components/plugins/update-plugin/plugin-version-picker.tsx
+++ b/web/app/components/plugins/update-plugin/plugin-version-picker.tsx
@@ -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 = ({
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 = ({
onClick={() => handleSelect({
version: version.version,
unique_identifier: version.unique_identifier,
+ isDowngrade: lt(version.version, currentVersion),
})}
>