fix: add sample plugins (#986)
This commit is contained in:
parent
506fae0d9a
commit
e7853c724e
1
packages/app/client/src/plugins/sample-command.ts
Normal file
1
packages/app/client/src/plugins/sample-command.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { default } from '@nocobase/plugin-sample-command/client';
|
1
packages/app/client/src/plugins/sample-custom-block.ts
Normal file
1
packages/app/client/src/plugins/sample-custom-block.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { default } from '@nocobase/plugin-sample-custom-block/client';
|
1
packages/app/client/src/plugins/sample-custom-page.ts
Normal file
1
packages/app/client/src/plugins/sample-custom-page.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { default } from '@nocobase/plugin-sample-custom-page/client';
|
@ -0,0 +1 @@
|
|||||||
|
export { default } from '@nocobase/plugin-sample-custom-signup-page/client';
|
1
packages/app/client/src/plugins/sample-hello.ts
Normal file
1
packages/app/client/src/plugins/sample-hello.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { default } from '@nocobase/plugin-sample-hello/client';
|
1
packages/app/client/src/plugins/sample-ratelimit.ts
Normal file
1
packages/app/client/src/plugins/sample-ratelimit.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { default } from '@nocobase/plugin-sample-ratelimit/client';
|
1
packages/app/client/src/plugins/sample-shop-actions.ts
Normal file
1
packages/app/client/src/plugins/sample-shop-actions.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { default } from '@nocobase/plugin-sample-shop-actions/client';
|
1
packages/app/client/src/plugins/sample-shop-events.ts
Normal file
1
packages/app/client/src/plugins/sample-shop-events.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { default } from '@nocobase/plugin-sample-shop-events/client';
|
1
packages/app/client/src/plugins/sample-shop-i18n.ts
Normal file
1
packages/app/client/src/plugins/sample-shop-i18n.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { default } from '@nocobase/plugin-sample-shop-i18n/client';
|
1
packages/app/client/src/plugins/sample-shop-modeling.ts
Normal file
1
packages/app/client/src/plugins/sample-shop-modeling.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { default } from '@nocobase/plugin-sample-shop-modeling/client';
|
@ -34,7 +34,7 @@ export const PluginManagerLink = () => {
|
|||||||
icon={<AppstoreAddOutlined />}
|
icon={<AppstoreAddOutlined />}
|
||||||
title={t('Plugin manager')}
|
title={t('Plugin manager')}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
history.push('/admin/plugins');
|
history.push('/admin/pm/list');
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</ActionContext.Provider>
|
</ActionContext.Provider>
|
||||||
|
@ -198,7 +198,7 @@ const PluginList = (props) => {
|
|||||||
<Tabs
|
<Tabs
|
||||||
activeKey={tabName}
|
activeKey={tabName}
|
||||||
onChange={(activeKey) => {
|
onChange={(activeKey) => {
|
||||||
history.push(`/admin/plugins/${activeKey}`);
|
history.push(`/admin/pm/list/${activeKey}`);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Tabs.TabPane tab={t('Local')} key={'local'} />
|
<Tabs.TabPane tab={t('Local')} key={'local'} />
|
||||||
@ -348,7 +348,7 @@ export const PMProvider = (props) => {
|
|||||||
routes[1].routes.unshift(
|
routes[1].routes.unshift(
|
||||||
{
|
{
|
||||||
type: 'route',
|
type: 'route',
|
||||||
path: '/admin/plugins/:tabName?',
|
path: '/admin/pm/list/:tabName?',
|
||||||
component: PluginList,
|
component: PluginList,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -52,6 +52,7 @@ export class PluginManagerRepository extends Repository {
|
|||||||
name: item.get('name'),
|
name: item.get('name'),
|
||||||
version: item.get('version'),
|
version: item.get('version'),
|
||||||
enabled: item.get('enabled'),
|
enabled: item.get('enabled'),
|
||||||
|
async: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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) => {
|
this.app.on('beforeInstallPlugin', async (plugin) => {
|
||||||
if (plugin.constructor.name !== 'UsersPlugin') {
|
if (plugin.getName() !== 'users') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const roles = this.app.db.getRepository('roles');
|
const roles = this.app.db.getRepository('roles');
|
||||||
@ -427,26 +451,6 @@ export class PluginACL extends Plugin {
|
|||||||
if (repo) {
|
if (repo) {
|
||||||
await repo.db2cm('roles');
|
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() {
|
async load() {
|
||||||
|
@ -25,6 +25,16 @@
|
|||||||
"@nocobase/plugin-users": "0.8.0-alpha.1",
|
"@nocobase/plugin-users": "0.8.0-alpha.1",
|
||||||
"@nocobase/plugin-verification": "0.8.0-alpha.1",
|
"@nocobase/plugin-verification": "0.8.0-alpha.1",
|
||||||
"@nocobase/plugin-workflow": "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"
|
"@nocobase/server": "0.8.0-alpha.1"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -23,6 +23,19 @@ export class PresetNocoBase extends Plugin {
|
|||||||
builtIn: true,
|
builtIn: true,
|
||||||
installed: 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();
|
await this.app.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "@nocobase/plugin-sample-shop-hooks",
|
"name": "@nocobase/plugin-sample-shop-events",
|
||||||
"version": "0.8.0-alpha.1",
|
"version": "0.8.0-alpha.1",
|
||||||
"main": "lib/server/index.js",
|
"main": "lib/server/index.js",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
Loading…
Reference in New Issue
Block a user