fix: add sample plugins (#986)

This commit is contained in:
chenos 2022-10-29 14:07:51 +08:00 committed by GitHub
parent 506fae0d9a
commit e7853c724e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 63 additions and 25 deletions

View File

@ -0,0 +1 @@
export { default } from '@nocobase/plugin-sample-command/client';

View File

@ -0,0 +1 @@
export { default } from '@nocobase/plugin-sample-custom-block/client';

View File

@ -0,0 +1 @@
export { default } from '@nocobase/plugin-sample-custom-page/client';

View File

@ -0,0 +1 @@
export { default } from '@nocobase/plugin-sample-custom-signup-page/client';

View File

@ -0,0 +1 @@
export { default } from '@nocobase/plugin-sample-hello/client';

View File

@ -0,0 +1 @@
export { default } from '@nocobase/plugin-sample-ratelimit/client';

View File

@ -0,0 +1 @@
export { default } from '@nocobase/plugin-sample-shop-actions/client';

View File

@ -0,0 +1 @@
export { default } from '@nocobase/plugin-sample-shop-events/client';

View File

@ -0,0 +1 @@
export { default } from '@nocobase/plugin-sample-shop-i18n/client';

View File

@ -0,0 +1 @@
export { default } from '@nocobase/plugin-sample-shop-modeling/client';

View File

@ -34,7 +34,7 @@ export const PluginManagerLink = () => {
icon={<AppstoreAddOutlined />}
title={t('Plugin manager')}
onClick={() => {
history.push('/admin/plugins');
history.push('/admin/pm/list');
}}
/>
</ActionContext.Provider>

View File

@ -198,7 +198,7 @@ const PluginList = (props) => {
<Tabs
activeKey={tabName}
onChange={(activeKey) => {
history.push(`/admin/plugins/${activeKey}`);
history.push(`/admin/pm/list/${activeKey}`);
}}
>
<Tabs.TabPane tab={t('Local')} key={'local'} />
@ -348,7 +348,7 @@ export const PMProvider = (props) => {
routes[1].routes.unshift(
{
type: 'route',
path: '/admin/plugins/:tabName?',
path: '/admin/pm/list/:tabName?',
component: PluginList,
},
{

View File

@ -52,6 +52,7 @@ export class PluginManagerRepository extends Repository {
name: item.get('name'),
version: item.get('version'),
enabled: item.get('enabled'),
async: true,
});
}
}

View File

@ -285,8 +285,32 @@ export class PluginACL extends Plugin {
}
});
this.app.on('afterInstallPlugin', async (plugin) => {
if (plugin.getName() !== 'users') {
return;
}
const User = this.db.getCollection('users');
await User.repository.update({
values: {
roles: ['root', 'admin', 'member'],
},
forceUpdate: true,
});
const RolesUsers = this.db.getCollection('rolesUsers');
await RolesUsers.repository.update({
filter: {
userId: 1,
roleName: 'root',
},
values: {
default: true,
},
});
});
this.app.on('beforeInstallPlugin', async (plugin) => {
if (plugin.constructor.name !== 'UsersPlugin') {
if (plugin.getName() !== 'users') {
return;
}
const roles = this.app.db.getRepository('roles');
@ -427,26 +451,6 @@ export class PluginACL extends Plugin {
if (repo) {
await repo.db2cm('roles');
}
const User = this.db.getCollection('users');
await User.repository.update({
values: {
roles: ['root', 'admin', 'member'],
},
forceUpdate: true,
});
const RolesUsers = this.db.getCollection('rolesUsers');
await RolesUsers.repository.update({
filter: {
userId: 1,
roleName: 'root',
},
values: {
default: true,
},
});
}
async load() {

View File

@ -25,6 +25,16 @@
"@nocobase/plugin-users": "0.8.0-alpha.1",
"@nocobase/plugin-verification": "0.8.0-alpha.1",
"@nocobase/plugin-workflow": "0.8.0-alpha.1",
"@nocobase/plugin-sample-command": "0.8.0-alpha.1",
"@nocobase/plugin-sample-custom-block": "0.8.0-alpha.1",
"@nocobase/plugin-sample-custom-page": "0.8.0-alpha.1",
"@nocobase/plugin-sample-custom-signup-page": "0.8.0-alpha.1",
"@nocobase/plugin-sample-hello": "0.8.0-alpha.1",
"@nocobase/plugin-sample-ratelimit": "0.8.0-alpha.1",
"@nocobase/plugin-sample-shop-actions": "0.8.0-alpha.1",
"@nocobase/plugin-sample-shop-events": "0.8.0-alpha.1",
"@nocobase/plugin-sample-shop-i18n": "0.8.0-alpha.1",
"@nocobase/plugin-sample-shop-modeling": "0.8.0-alpha.1",
"@nocobase/server": "0.8.0-alpha.1"
},
"repository": {

View File

@ -23,6 +23,19 @@ export class PresetNocoBase extends Plugin {
builtIn: true,
installed: true,
});
const samples = [
'sample-command',
'sample-custom-block',
'sample-custom-page',
'sample-custom-signup-page',
'sample-hello',
'sample-ratelimit',
'sample-shop-actions',
'sample-shop-events',
'sample-shop-i18n',
'sample-shop-modeling',
];
await this.app.pm.add(samples, {});
await this.app.reload();
}

View File

@ -1,5 +1,5 @@
{
"name": "@nocobase/plugin-sample-shop-hooks",
"name": "@nocobase/plugin-sample-shop-events",
"version": "0.8.0-alpha.1",
"main": "lib/server/index.js",
"devDependencies": {