From 4365c3ea4a98beb68fe27dda147fadd1f50716ca Mon Sep 17 00:00:00 2001 From: chenos Date: Sat, 7 Sep 2024 17:02:25 +0800 Subject: [PATCH] feat: plugins can also be enabled when the plugin dependency version is inconsistent (#5225) --- packages/core/client/src/locale/en_US.json | 4 +++- packages/core/client/src/locale/zh-CN.json | 4 +++- packages/core/client/src/pm/PluginCard.tsx | 17 +++++++++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/packages/core/client/src/locale/en_US.json b/packages/core/client/src/locale/en_US.json index cbfdf6fdb1..6ba6e86e55 100644 --- a/packages/core/client/src/locale/en_US.json +++ b/packages/core/client/src/locale/en_US.json @@ -838,5 +838,7 @@ "Open in new window": "Open in new window", "Sorry, the page you visited does not exist.": "Sorry, the page you visited does not exist.", "is none of": "is none of", - "is any of": "is any of" + "is any of": "is any of", + "Plugin dependency version mismatch": "Plugin dependency version mismatch", + "The current dependency version of the plugin does not match the version of the application and may not work properly. Are you sure you want to continue enabling the plugin?": "The current dependency version of the plugin does not match the version of the application and may not work properly. Are you sure you want to continue enabling the plugin?" } diff --git a/packages/core/client/src/locale/zh-CN.json b/packages/core/client/src/locale/zh-CN.json index 64271b1928..1771db3f99 100644 --- a/packages/core/client/src/locale/zh-CN.json +++ b/packages/core/client/src/locale/zh-CN.json @@ -972,5 +972,7 @@ "Sorry, the page you visited does not exist.": "抱歉,你访问的页面不存在。", "Set Template Engine": "设置模板引擎", "Skip getting the total number of table records during paging to speed up loading. It is recommended to enable this option for data tables with a large amount of data": "在分页时跳过获取表记录总数,以加快加载速度,建议对有大量数据的数据表开启此选项", - "The current user only has the UI configuration permission, but don't have view permission for collection \"{{name}}\"": "当前用户只有 UI 配置权限,但没有数据表 \"{{name}}\" 查看权限。" + "The current user only has the UI configuration permission, but don't have view permission for collection \"{{name}}\"": "当前用户只有 UI 配置权限,但没有数据表 \"{{name}}\" 查看权限。", + "Plugin dependency version mismatch": "插件依赖版本不一致", + "The current dependency version of the plugin does not match the version of the application and may not work properly. Are you sure you want to continue enabling the plugin?": "当前插件的依赖版本与应用的版本不一致,可能无法正常工作。您确定要继续激活插件吗?" } diff --git a/packages/core/client/src/pm/PluginCard.tsx b/packages/core/client/src/pm/PluginCard.tsx index 4ee053ac05..45b0c42db0 100644 --- a/packages/core/client/src/pm/PluginCard.tsx +++ b/packages/core/client/src/pm/PluginCard.tsx @@ -7,7 +7,7 @@ * For more information, please refer to: https://www.nocobase.com/agreement. */ -import { App, Card, Divider, Popconfirm, Space, Switch, Typography, message } from 'antd'; +import { App, Card, Divider, Popconfirm, Space, Switch, Typography } from 'antd'; import classnames from 'classnames'; import React, { FC, useState } from 'react'; import { useTranslation } from 'react-i18next'; @@ -157,7 +157,20 @@ function PluginInfo(props: IPluginInfo) { onChange={async (checked, e) => { e.stopPropagation(); if (!isCompatible && checked) { - message.error(t("Dependencies check failed, can't enable.")); + modal.confirm({ + title: t('Plugin dependency version mismatch'), + content: t( + 'The current dependency version of the plugin does not match the version of the application and may not work properly. Are you sure you want to continue enabling the plugin?', + ), + onOk: async () => { + await api.request({ + url: `pm:enable`, + params: { + filterByTk: name, + }, + }); + }, + }); return; } if (!checked) {