From 1913a4f30b14f18109f9f24c7062d8d13c830d24 Mon Sep 17 00:00:00 2001 From: shuai Date: Tue, 17 Oct 2023 15:35:13 +0800 Subject: [PATCH 1/3] fix: default http code 400 confirm btn text change to ok --- i18n/en_US.yaml | 1 + ui/src/components/Modal/Modal.tsx | 4 +++- ui/src/utils/request.ts | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/i18n/en_US.yaml b/i18n/en_US.yaml index 464b601c..3a627625 100644 --- a/i18n/en_US.yaml +++ b/i18n/en_US.yaml @@ -1128,6 +1128,7 @@ ui: unsuspend: Unsuspend close: Close reopen: Reopen + ok: OK search: title: Search Results keywords: Keywords diff --git a/ui/src/components/Modal/Modal.tsx b/ui/src/components/Modal/Modal.tsx index 16517fcb..4efe906e 100644 --- a/ui/src/components/Modal/Modal.tsx +++ b/ui/src/components/Modal/Modal.tsx @@ -71,7 +71,9 @@ const Index: FC = ({ }} id="ok_button" disabled={confirmBtnDisabled}> - {confirmText || t('btns.confirm')} + {confirmText === 'OK' + ? t('btns.ok') + : confirmText || t('btns.confirm')} )} diff --git a/ui/src/utils/request.ts b/ui/src/utils/request.ts index 7132099d..ad57946f 100644 --- a/ui/src/utils/request.ts +++ b/ui/src/utils/request.ts @@ -117,6 +117,8 @@ class Request { // default error msg will show modal Modal.confirm({ content: msg, + showCancel: false, + confirmText: 'OK', }); return Promise.reject(false); } From 7dfdf4d7e4238b42a43a156d1f93fd3b7fda7ead Mon Sep 17 00:00:00 2001 From: shuai Date: Tue, 17 Oct 2023 16:18:30 +0800 Subject: [PATCH 2/3] fix: add test log --- ui/src/components/PluginRender/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/src/components/PluginRender/index.tsx b/ui/src/components/PluginRender/index.tsx index b3a8efb8..99792c35 100644 --- a/ui/src/components/PluginRender/index.tsx +++ b/ui/src/components/PluginRender/index.tsx @@ -29,7 +29,9 @@ const Index: FC = ({ const pluginSlice: Plugin[] = []; const plugins = PluginKit.getPlugins().filter((plugin) => plugin.activated); + console.log('default list', plugins); plugins.forEach((plugin) => { + console.log('plugininfo ====', plugin); if (type && slug_name) { if (plugin.info.slug_name === slug_name && plugin.info.type === type) { pluginSlice.push(plugin); @@ -49,7 +51,7 @@ const Index: FC = ({ * TODO: Rendering control for non-builtin plug-ins * ps: Logic such as version compatibility determination can be placed here */ - + console.log('plugininfo ====', 111); if (pluginSlice.length === 0) { if (type === 'editor') { return
{children}
; From f8adcb3fa412cd6f9f162f9bee9ac6929d6071ee Mon Sep 17 00:00:00 2001 From: shuai Date: Wed, 18 Oct 2023 11:11:14 +0800 Subject: [PATCH 3/3] feat: add pre-install script for support workspace folder --- ui/package.json | 2 +- ui/scripts/plugin.js | 2 +- ui/src/pages/Admin/Plugins/Installed/index.tsx | 2 ++ ui/src/utils/pluginKit/index.ts | 7 +++++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ui/package.json b/ui/package.json index bd1f0953..a422095c 100644 --- a/ui/package.json +++ b/ui/package.json @@ -8,7 +8,7 @@ "build": "react-app-rewired build", "lint": "eslint . --cache --fix --ext .ts,.tsx", "prettier": "prettier --write \"src/**/*.{js,jsx,ts,tsx,json,css,scss,md}\"", - "preinstall": "node ./scripts/preinstall.js", + "pre-install": "node ./scripts/preinstall.js && pnpm install", "prepare": "pnpm build:packages", "pre-commit": "lint-staged", "build:packages": "pnpm -r --filter=./src/plugins/* run build", diff --git a/ui/scripts/plugin.js b/ui/scripts/plugin.js index 823b6b6b..c62da0b4 100644 --- a/ui/scripts/plugin.js +++ b/ui/scripts/plugin.js @@ -15,7 +15,7 @@ pluginFolders.forEach((folder) => { // add plugin to package.json const packageJson = require(path.join(pluginFolder, 'package.json')); const packageName = packageJson.name; - const packageJsonPath = path.join(__dirname, 'package.json'); + const packageJsonPath = path.join(__dirname, '..', 'package.json'); const packageJsonContent = require(packageJsonPath); packageJsonContent.dependencies[packageName] = 'workspace:*'; diff --git a/ui/src/pages/Admin/Plugins/Installed/index.tsx b/ui/src/pages/Admin/Plugins/Installed/index.tsx index b55e7eb3..216d8378 100644 --- a/ui/src/pages/Admin/Plugins/Installed/index.tsx +++ b/ui/src/pages/Admin/Plugins/Installed/index.tsx @@ -8,6 +8,7 @@ import classNames from 'classnames'; import { Empty, QueryGroup, Icon } from '@/components'; import * as Type from '@/common/interface'; import { useQueryPlugins, updatePluginStatus } from '@/services'; +import PluginKit from '@/utils/pluginKit'; const InstalledPluginsFilterKeys: Type.InstalledPluginsFilterBy[] = [ 'all', @@ -46,6 +47,7 @@ const Users: FC = () => { plugin_slug_name: plugin.slug_name, }).then(() => { updatePlugins(); + PluginKit.changePluginActiveStatus(plugin.slug_name, !plugin.enabled); if (plugin.have_config) { emitPluginChange('refreshConfigurablePlugins'); } diff --git a/ui/src/utils/pluginKit/index.ts b/ui/src/utils/pluginKit/index.ts index fea12d7c..01d9bdbf 100644 --- a/ui/src/utils/pluginKit/index.ts +++ b/ui/src/utils/pluginKit/index.ts @@ -104,6 +104,13 @@ class Plugins { }); } + changePluginActiveStatus(slug_name: string, active: boolean) { + const plugin = this.getPlugin(slug_name); + if (plugin) { + plugin.activated = active; + } + } + getPlugin(slug_name: string) { return this.plugins.find((p) => p.info.slug_name === slug_name); }