mirror of
https://github.com/langgenius/dify.git
synced 2026-04-28 20:17:29 +08:00
feat: show downgrade warning logic
This commit is contained in:
parent
825fbcc6f8
commit
7ec5816513
@ -77,6 +77,7 @@ const DetailHeader = ({
|
|||||||
const [targetVersion, setTargetVersion] = useState({
|
const [targetVersion, setTargetVersion] = useState({
|
||||||
version: latest_version,
|
version: latest_version,
|
||||||
unique_identifier: latest_unique_identifier,
|
unique_identifier: latest_unique_identifier,
|
||||||
|
isDowngrade: false,
|
||||||
})
|
})
|
||||||
const hasNewVersion = useMemo(() => {
|
const hasNewVersion = useMemo(() => {
|
||||||
if (isFromMarketplace)
|
if (isFromMarketplace)
|
||||||
@ -98,8 +99,18 @@ const DetailHeader = ({
|
|||||||
setFalse: hideUpdateModal,
|
setFalse: hideUpdateModal,
|
||||||
}] = useBoolean(false)
|
}] = useBoolean(false)
|
||||||
|
|
||||||
|
const isAutoUpgradeEnabled = true // toeo
|
||||||
|
const [isShowDowngradeWarningModal, {
|
||||||
|
setTrue: showDowngradeWarningModal,
|
||||||
|
setFalse: hideDowngradeWarningModal,
|
||||||
|
}] = useBoolean(false)
|
||||||
|
|
||||||
const handleUpdate = async () => {
|
const handleUpdate = async () => {
|
||||||
if (isFromMarketplace) {
|
if (isFromMarketplace) {
|
||||||
|
if(isAutoUpgradeEnabled && targetVersion.isDowngrade) {
|
||||||
|
showDowngradeWarningModal()
|
||||||
|
return
|
||||||
|
}
|
||||||
showUpdateModal()
|
showUpdateModal()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -222,6 +233,7 @@ const DetailHeader = ({
|
|||||||
setTargetVersion({
|
setTargetVersion({
|
||||||
version: latest_version,
|
version: latest_version,
|
||||||
unique_identifier: latest_unique_identifier,
|
unique_identifier: latest_unique_identifier,
|
||||||
|
isDowngrade: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
handleUpdate()
|
handleUpdate()
|
||||||
@ -316,6 +328,7 @@ const DetailHeader = ({
|
|||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
{ isShowDowngradeWarningModal && (<div>aaa</div>)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,7 @@ import type {
|
|||||||
import { useVersionListOfPlugin } from '@/service/use-plugins'
|
import { useVersionListOfPlugin } from '@/service/use-plugins'
|
||||||
import useTimestamp from '@/hooks/use-timestamp'
|
import useTimestamp from '@/hooks/use-timestamp'
|
||||||
import cn from '@/utils/classnames'
|
import cn from '@/utils/classnames'
|
||||||
|
import { lt } from 'semver'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
@ -28,9 +29,11 @@ type Props = {
|
|||||||
onSelect: ({
|
onSelect: ({
|
||||||
version,
|
version,
|
||||||
unique_identifier,
|
unique_identifier,
|
||||||
|
isDowngrade,
|
||||||
}: {
|
}: {
|
||||||
version: string
|
version: string
|
||||||
unique_identifier: string
|
unique_identifier: string
|
||||||
|
isDowngrade: boolean
|
||||||
}) => void
|
}) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,13 +62,14 @@ const PluginVersionPicker: FC<Props> = ({
|
|||||||
|
|
||||||
const { data: res } = useVersionListOfPlugin(pluginID)
|
const { data: res } = useVersionListOfPlugin(pluginID)
|
||||||
|
|
||||||
const handleSelect = useCallback(({ version, unique_identifier }: {
|
const handleSelect = useCallback(({ version, unique_identifier, isDowngrade }: {
|
||||||
version: string
|
version: string
|
||||||
unique_identifier: string
|
unique_identifier: string
|
||||||
|
isDowngrade: boolean
|
||||||
}) => {
|
}) => {
|
||||||
if (currentVersion === version)
|
if (currentVersion === version)
|
||||||
return
|
return
|
||||||
onSelect({ version, unique_identifier })
|
onSelect({ version, unique_identifier, isDowngrade })
|
||||||
onShowChange(false)
|
onShowChange(false)
|
||||||
}, [currentVersion, onSelect, onShowChange])
|
}, [currentVersion, onSelect, onShowChange])
|
||||||
|
|
||||||
@ -99,6 +103,7 @@ const PluginVersionPicker: FC<Props> = ({
|
|||||||
onClick={() => handleSelect({
|
onClick={() => handleSelect({
|
||||||
version: version.version,
|
version: version.version,
|
||||||
unique_identifier: version.unique_identifier,
|
unique_identifier: version.unique_identifier,
|
||||||
|
isDowngrade: lt(version.version, currentVersion),
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<div className='flex grow items-center'>
|
<div className='flex grow items-center'>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user