Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/1.2.0/UI #571

Merged
merged 3 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions i18n/en_US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,7 @@ ui:
unsuspend: Unsuspend
close: Close
reopen: Reopen
ok: OK
search:
title: Search Results
keywords: Keywords
Expand Down
2 changes: 1 addition & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion ui/scripts/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:*';

Expand Down
4 changes: 3 additions & 1 deletion ui/src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ const Index: FC<Props> = ({
}}
id="ok_button"
disabled={confirmBtnDisabled}>
{confirmText || t('btns.confirm')}
{confirmText === 'OK'
? t('btns.ok')
: confirmText || t('btns.confirm')}
</Button>
)}
</Modal.Footer>
Expand Down
4 changes: 3 additions & 1 deletion ui/src/components/PluginRender/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ const Index: FC<Props> = ({
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);
Expand All @@ -49,7 +51,7 @@ const Index: FC<Props> = ({
* 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 <div className={className}>{children}</div>;
Expand Down
2 changes: 2 additions & 0 deletions ui/src/pages/Admin/Plugins/Installed/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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');
}
Expand Down
7 changes: 7 additions & 0 deletions ui/src/utils/pluginKit/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions ui/src/utils/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ class Request {
// default error msg will show modal
Modal.confirm({
content: msg,
showCancel: false,
confirmText: 'OK',
});
return Promise.reject(false);
}
Expand Down