mirror of https://github.com/langgenius/dify.git
feat: show downgrade warning logic
This commit is contained in:
parent
825fbcc6f8
commit
7ec5816513
|
|
@ -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 && (<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…
Reference in New Issue