Merge branch '@hera/main' into @hera/dev
This commit is contained in:
commit
afc79d633f
2
.github/workflows/build-pro-image.yml
vendored
2
.github/workflows/build-pro-image.yml
vendored
@ -33,7 +33,7 @@ jobs:
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: nocobase/pro-plugins
|
||||
ref: feat/dataSource-manager
|
||||
ref: main
|
||||
path: packages/pro-plugins
|
||||
ssh-key: ${{ secrets.SUBMODULE_SSH_KEY }}
|
||||
- name: rm .git
|
||||
|
42
CHANGELOG.md
42
CHANGELOG.md
@ -7,6 +7,48 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
||||
|
||||
## [v0.20.0-alpha.7](https://github.com/nocobase/nocobase/compare/v0.20.0-alpha.6...v0.20.0-alpha.7) - 2024-03-08
|
||||
|
||||
### Merged
|
||||
|
||||
- fix: view collection interface missing [`#3658`](https://github.com/nocobase/nocobase/pull/3658)
|
||||
- fix: getCollection bug [`#3656`](https://github.com/nocobase/nocobase/pull/3656)
|
||||
|
||||
### Commits
|
||||
|
||||
- chore(versions): 😊 publish v0.20.0-alpha.7 [`63d1a8d`](https://github.com/nocobase/nocobase/commit/63d1a8d90ca30056f7dd48bc012c30590b727cb8)
|
||||
- chore: update changelog [`12ba7cd`](https://github.com/nocobase/nocobase/commit/12ba7cd9d0c48dc7b7048ebb73bb93be79e41ac8)
|
||||
- chore(ci): change branch of pro image [`8dbae24`](https://github.com/nocobase/nocobase/commit/8dbae24489a8f2dcb3fd055a89225454394501e7)
|
||||
|
||||
## [v0.20.0-alpha.6](https://github.com/nocobase/nocobase/compare/v0.20.0-alpha.5...v0.20.0-alpha.6) - 2024-03-08
|
||||
|
||||
### Merged
|
||||
|
||||
- fix: parse association field in acl [`#3655`](https://github.com/nocobase/nocobase/pull/3655)
|
||||
- chore: update menu name of plugin-localization [`#3653`](https://github.com/nocobase/nocobase/pull/3653)
|
||||
- chore(pm): set plugin-sms-auth as local plugin, close T-3323 [`#3652`](https://github.com/nocobase/nocobase/pull/3652)
|
||||
- fix(cascadeSelect): cassadeSelect does not dislay data in edit form [`#3649`](https://github.com/nocobase/nocobase/pull/3649)
|
||||
- fix(db): through scope in eager loading & fix(acl): filter reset issue [`#3636`](https://github.com/nocobase/nocobase/pull/3636)
|
||||
- fix: dateTime format configured in table is invalid [`#3630`](https://github.com/nocobase/nocobase/pull/3630)
|
||||
- fix: data source permission role update [`#3643`](https://github.com/nocobase/nocobase/pull/3643)
|
||||
- style: flexWrap in actionBar [`#3635`](https://github.com/nocobase/nocobase/pull/3635)
|
||||
- fix: add displayName [`#3628`](https://github.com/nocobase/nocobase/pull/3628)
|
||||
- fix(customRequestAction): should not support setting icons and colours [`#3632`](https://github.com/nocobase/nocobase/pull/3632)
|
||||
- fix(workflow-action-trigger): change plugin name [`#3631`](https://github.com/nocobase/nocobase/pull/3631)
|
||||
- fix: graph collection postions data missing [`#3627`](https://github.com/nocobase/nocobase/pull/3627)
|
||||
- fix(ActionLink): fix hover style [`#3629`](https://github.com/nocobase/nocobase/pull/3629)
|
||||
- feat(plugin-workflow-form-trigger): add trigger button to all single record action bar [`#3563`](https://github.com/nocobase/nocobase/pull/3563)
|
||||
- fix: sidebar menu text overflow [`#3626`](https://github.com/nocobase/nocobase/pull/3626)
|
||||
- fix(acl-plugin-setting): pluginPermissions for snippets check [`#3622`](https://github.com/nocobase/nocobase/pull/3622)
|
||||
- fix(subTable): fix changing title field invalid [`#3625`](https://github.com/nocobase/nocobase/pull/3625)
|
||||
- fix: fix hover style for sub table [`#3623`](https://github.com/nocobase/nocobase/pull/3623)
|
||||
|
||||
### Commits
|
||||
|
||||
- chore(versions): 😊 publish v0.20.0-alpha.6 [`8b4821e`](https://github.com/nocobase/nocobase/commit/8b4821e2df39958f7befa9aa0abd203cd162bace)
|
||||
- chore: update yarn.lock [`1088756`](https://github.com/nocobase/nocobase/commit/108875600c4baf9824246c43bcbdd858876e5fd1)
|
||||
- chore: update changelog [`f9a10de`](https://github.com/nocobase/nocobase/commit/f9a10de9811b7a35b13f67d9007051487321e993)
|
||||
|
||||
## [v0.20.0-alpha.5](https://github.com/nocobase/nocobase/compare/v0.20.0-alpha.4...v0.20.0-alpha.5) - 2024-03-06
|
||||
|
||||
### Merged
|
||||
|
@ -14,7 +14,7 @@ services:
|
||||
- DB_DIALECT=mysql
|
||||
- DB_HOST=mysql
|
||||
- DB_DATABASE=nocobase
|
||||
- DB_USER=nocobase
|
||||
- DB_USER=root
|
||||
- DB_PASSWORD=nocobase
|
||||
- DB_TIMEZONE=+08:00
|
||||
volumes:
|
||||
@ -30,4 +30,4 @@ services:
|
||||
MYSQL_ROOT_PASSWORD: nocobase
|
||||
restart: always
|
||||
networks:
|
||||
- nocobase
|
||||
- nocobase
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"npmClient": "yarn",
|
||||
"useWorkspaces": true,
|
||||
"npmClientArgs": ["--ignore-engines"],
|
||||
|
@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "@nocobase/acl",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"description": "",
|
||||
"license": "Apache-2.0",
|
||||
"main": "./lib/index.js",
|
||||
"types": "./lib/index.d.ts",
|
||||
"dependencies": {
|
||||
"@nocobase/resourcer": "0.20.0-alpha.5",
|
||||
"@nocobase/utils": "0.20.0-alpha.5",
|
||||
"@nocobase/resourcer": "0.20.0-alpha.7",
|
||||
"@nocobase/utils": "0.20.0-alpha.7",
|
||||
"minimatch": "^5.1.1"
|
||||
},
|
||||
"repository": {
|
||||
|
@ -264,7 +264,7 @@ export class ACL extends EventEmitter {
|
||||
ctx: {
|
||||
state,
|
||||
},
|
||||
$user: async () => state.currentUser,
|
||||
$user: getUser(ctx),
|
||||
$nRole: () => state.currentRole,
|
||||
},
|
||||
});
|
||||
@ -388,3 +388,24 @@ export class ACL extends EventEmitter {
|
||||
return this.availableActions.has(this.resolveActionAlias(actionName));
|
||||
}
|
||||
}
|
||||
|
||||
function getUser(ctx) {
|
||||
return async ({ fields }) => {
|
||||
const userFields = fields.filter((f) => f && ctx.db.getFieldByPath('users.' + f));
|
||||
ctx.logger?.info('filter-parse: ', { userFields });
|
||||
if (!ctx.state.currentUser) {
|
||||
return;
|
||||
}
|
||||
if (!userFields.length) {
|
||||
return;
|
||||
}
|
||||
const user = await ctx.db.getRepository('users').findOne({
|
||||
filterByTk: ctx.state.currentUser.id,
|
||||
fields: userFields,
|
||||
});
|
||||
ctx.logger?.info('filter-parse: ', {
|
||||
$user: user?.toJSON(),
|
||||
});
|
||||
return user;
|
||||
};
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
{
|
||||
"name": "@nocobase/actions",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"description": "",
|
||||
"license": "Apache-2.0",
|
||||
"main": "./lib/index.js",
|
||||
"types": "./lib/index.d.ts",
|
||||
"dependencies": {
|
||||
"@nocobase/cache": "0.20.0-alpha.5",
|
||||
"@nocobase/database": "0.20.0-alpha.5",
|
||||
"@nocobase/resourcer": "0.20.0-alpha.5"
|
||||
"@nocobase/cache": "0.20.0-alpha.7",
|
||||
"@nocobase/database": "0.20.0-alpha.7",
|
||||
"@nocobase/resourcer": "0.20.0-alpha.7"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -1,17 +1,17 @@
|
||||
{
|
||||
"name": "@nocobase/app",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"description": "",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./lib/index.js",
|
||||
"types": "./lib/index.d.ts",
|
||||
"dependencies": {
|
||||
"@nocobase/database": "0.20.0-alpha.5",
|
||||
"@nocobase/preset-nocobase": "0.20.0-alpha.5",
|
||||
"@nocobase/server": "0.20.0-alpha.5"
|
||||
"@nocobase/database": "0.20.0-alpha.7",
|
||||
"@nocobase/preset-nocobase": "0.20.0-alpha.7",
|
||||
"@nocobase/server": "0.20.0-alpha.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nocobase/client": "0.20.0-alpha.5"
|
||||
"@nocobase/client": "0.20.0-alpha.7"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -1,16 +1,16 @@
|
||||
{
|
||||
"name": "@nocobase/auth",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"description": "",
|
||||
"license": "Apache-2.0",
|
||||
"main": "./lib/index.js",
|
||||
"types": "./lib/index.d.ts",
|
||||
"dependencies": {
|
||||
"@nocobase/actions": "0.20.0-alpha.5",
|
||||
"@nocobase/cache": "0.20.0-alpha.5",
|
||||
"@nocobase/database": "0.20.0-alpha.5",
|
||||
"@nocobase/resourcer": "0.20.0-alpha.5",
|
||||
"@nocobase/utils": "0.20.0-alpha.5",
|
||||
"@nocobase/actions": "0.20.0-alpha.7",
|
||||
"@nocobase/cache": "0.20.0-alpha.7",
|
||||
"@nocobase/database": "0.20.0-alpha.7",
|
||||
"@nocobase/resourcer": "0.20.0-alpha.7",
|
||||
"@nocobase/utils": "0.20.0-alpha.7",
|
||||
"@types/jsonwebtoken": "^8.5.8",
|
||||
"jsonwebtoken": "^8.5.1"
|
||||
},
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/build",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"description": "Library build tool based on rollup.",
|
||||
"main": "lib/index.js",
|
||||
"types": "./lib/index.d.ts",
|
||||
|
2
packages/core/cache/package.json
vendored
2
packages/core/cache/package.json
vendored
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/cache",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"description": "",
|
||||
"license": "Apache-2.0",
|
||||
"main": "./lib/index.js",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/cli",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"description": "",
|
||||
"license": "Apache-2.0",
|
||||
"main": "./src/index.js",
|
||||
@ -8,7 +8,7 @@
|
||||
"nocobase": "./bin/index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nocobase/app": "0.20.0-alpha.5",
|
||||
"@nocobase/app": "0.20.0-alpha.7",
|
||||
"@types/fs-extra": "^11.0.1",
|
||||
"@umijs/utils": "3.5.20",
|
||||
"chalk": "^4.1.1",
|
||||
@ -25,7 +25,7 @@
|
||||
"tsx": "^4.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nocobase/devtools": "0.20.0-alpha.5"
|
||||
"@nocobase/devtools": "0.20.0-alpha.7"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/client",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "Apache-2.0",
|
||||
"main": "lib/index.js",
|
||||
"module": "es/index.mjs",
|
||||
@ -26,9 +26,9 @@
|
||||
"@formily/reactive-react": "^2.2.27",
|
||||
"@formily/shared": "^2.2.27",
|
||||
"@formily/validator": "^2.2.27",
|
||||
"@nocobase/evaluators": "0.20.0-alpha.5",
|
||||
"@nocobase/sdk": "0.20.0-alpha.5",
|
||||
"@nocobase/utils": "0.20.0-alpha.5",
|
||||
"@nocobase/evaluators": "0.20.0-alpha.7",
|
||||
"@nocobase/sdk": "0.20.0-alpha.7",
|
||||
"@nocobase/utils": "0.20.0-alpha.7",
|
||||
"ahooks": "^3.7.2",
|
||||
"antd": "^5.12.8",
|
||||
"antd-style": "3.4.5",
|
||||
|
@ -29,6 +29,9 @@ import { transformVariableValue } from '../../variables/utils/transformVariableV
|
||||
import { useBlockRequestContext, useFilterByTk, useParamsFromRecord } from '../BlockProvider';
|
||||
import { useDetailsBlockContext } from '../DetailsBlockProvider';
|
||||
import { TableFieldResource } from '../TableFieldProvider';
|
||||
import { Field, Form } from '@formily/core';
|
||||
import { untracked } from '@formily/reactive';
|
||||
import { isSubMode } from '../../schema-component/antd/association-field/util';
|
||||
|
||||
export * from './useFormActiveFields';
|
||||
export * from './useParsedFilter';
|
||||
@ -222,14 +225,14 @@ export const useCreateActionProps = () => {
|
||||
__parent?.service?.refresh?.();
|
||||
if (!onSuccess?.successMessage) {
|
||||
message.success(t('Saved successfully'));
|
||||
await form.reset(undefined, { forceClear: true });
|
||||
await resetFormCorrectly(form);
|
||||
return;
|
||||
}
|
||||
if (onSuccess?.manualClose) {
|
||||
modal.success({
|
||||
title: compile(onSuccess?.successMessage),
|
||||
onOk: async () => {
|
||||
await form.reset(undefined, { forceClear: true });
|
||||
await resetFormCorrectly(form);
|
||||
if (onSuccess?.redirecting && onSuccess?.redirectTo) {
|
||||
if (isURL(onSuccess.redirectTo)) {
|
||||
window.location.href = onSuccess.redirectTo;
|
||||
@ -241,7 +244,7 @@ export const useCreateActionProps = () => {
|
||||
});
|
||||
} else {
|
||||
message.success(compile(onSuccess?.successMessage));
|
||||
await form.reset(undefined, { forceClear: true });
|
||||
await resetFormCorrectly(form);
|
||||
if (onSuccess?.redirecting && onSuccess?.redirectTo) {
|
||||
if (isURL(onSuccess.redirectTo)) {
|
||||
window.location.href = onSuccess.redirectTo;
|
||||
@ -1280,8 +1283,8 @@ export const useAssociationNames = (dataSource?: string) => {
|
||||
const path = pre + '.' + title.label;
|
||||
appends.add(path);
|
||||
}
|
||||
|
||||
const isTreeCollection = isAssociationField && getCollection(collectionField.target)?.template === 'tree';
|
||||
const isTreeCollection =
|
||||
isAssociationField && getCollection(collectionField.target, dataSource)?.template === 'tree';
|
||||
if (collectionField && (isAssociationField || isAssociationSubfield) && s['x-component'] !== 'TableField') {
|
||||
const fieldPath = !isAssociationField && isAssociationSubfield ? getAssociationPath(s.name) : s.name;
|
||||
const path = prefix === '' || !prefix ? fieldPath : prefix + '.' + fieldPath;
|
||||
@ -1350,3 +1353,20 @@ function getTargetField(obj) {
|
||||
const result = keys.slice(0, index);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 之所以不直接使用 form.reset() 是因为其无法将子表格重置为空
|
||||
* 主要用于修复这个问题:https://nocobase.height.app/T-3106
|
||||
* @param form
|
||||
*/
|
||||
async function resetFormCorrectly(form: Form) {
|
||||
untracked(() => {
|
||||
Object.keys(form.fields).forEach((key) => {
|
||||
if (isSubMode(form.fields[key])) {
|
||||
// 清空子表格或者子表单的初始值,可以确保后面的 reset 会清空子表格或者子表单的值
|
||||
(form.fields[key] as Field).initialValue = null;
|
||||
}
|
||||
});
|
||||
});
|
||||
await form.reset();
|
||||
}
|
||||
|
@ -60,12 +60,12 @@ const PreviewCom = (props) => {
|
||||
const children = collection.fields
|
||||
.filter((v) => !['hasOne', 'hasMany', 'belongsToMany'].includes(v?.type))
|
||||
?.map((v) => {
|
||||
return { value: v.name, key: v.name, label: t(v.uiSchema?.title) };
|
||||
return { value: v.name, key: v.name, label: t(v.uiSchema?.title || v.name) };
|
||||
})
|
||||
.concat(result);
|
||||
data.push({
|
||||
value: item,
|
||||
label: t(collection.title),
|
||||
label: t(collection.title || collection.name),
|
||||
children,
|
||||
});
|
||||
});
|
||||
@ -187,7 +187,7 @@ const PreviewCom = (props) => {
|
||||
{data.map((group) => (
|
||||
<Select.OptGroup key={group.key} label={compile(group.label)}>
|
||||
{group.children.map((item) => (
|
||||
<Select.Option key={item.value} value={item.value}>
|
||||
<Select.Option key={item.value} value={item.name}>
|
||||
{compile(item.label)}
|
||||
</Select.Option>
|
||||
))}
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { createBlockInPage, expect, oneEmptyForm, test } from '@nocobase/test/e2e';
|
||||
import { T3106 } from './templatesOfBug';
|
||||
import { T3106, T3469 } from './templatesOfBug';
|
||||
import { uid } from '@formily/shared';
|
||||
|
||||
test.describe('where creation form block can be added', () => {
|
||||
test('page', async ({ page, mockPage }) => {
|
||||
@ -101,6 +102,38 @@ test.describe('configure actions', () => {
|
||||
).toHaveValue('test name');
|
||||
});
|
||||
|
||||
// https://nocobase.height.app/T-3469
|
||||
test('default values for fields should not be cleared after submission', async ({ page, mockPage }) => {
|
||||
await mockPage(T3469).goto();
|
||||
|
||||
// username 的值不能重复,所以为了避免报错这里随机生成一个值
|
||||
const username = uid();
|
||||
|
||||
// Username 字段没有设置默认值,手动输入一个值
|
||||
await page
|
||||
.getByLabel('block-item-CollectionField-users-form-users.username-Username')
|
||||
.getByRole('textbox')
|
||||
.fill(username);
|
||||
|
||||
// Nickname 字段设置了默认值,应该显示出默认值
|
||||
await expect(
|
||||
page.getByLabel('block-item-CollectionField-users-form-users.nickname-Nickname').getByRole('textbox'),
|
||||
).toHaveValue('Should be cleared after submission');
|
||||
await expect(
|
||||
page.getByLabel('block-item-CollectionField-users-form-users.username-Username').getByRole('textbox'),
|
||||
).toHaveValue(username);
|
||||
|
||||
// 点击提交按钮之后,Nickname 字段的默认值应该依然显示,Username 字段的值应该被清空
|
||||
await page.getByLabel('action-Action-Submit-submit-').click();
|
||||
|
||||
await expect(
|
||||
page.getByLabel('block-item-CollectionField-users-form-users.nickname-Nickname').getByRole('textbox'),
|
||||
).toHaveValue('Should be cleared after submission');
|
||||
await expect(
|
||||
page.getByLabel('block-item-CollectionField-users-form-users.username-Username').getByRole('textbox'),
|
||||
).toHaveValue('');
|
||||
});
|
||||
|
||||
test('customize: save record', async ({ page, mockPage }) => {
|
||||
await mockPage(oneEmptyForm).goto();
|
||||
|
||||
|
@ -1165,7 +1165,7 @@ test.describe('creation form block schema settings', () => {
|
||||
await page.getByRole('menuitem', { name: 'form Form' }).first().hover();
|
||||
await page.getByRole('menuitem', { name: 'Users' }).hover();
|
||||
await page.getByRole('menuitem', { name: 'Duplicate template' }).hover();
|
||||
await page.getByRole('menuitem', { name: 'Users_Form (Fields only)' }).click();
|
||||
await page.getByRole('menuitem', { name: 'Users_Form (Fields only)' }).first().click();
|
||||
await page.mouse.move(300, 0);
|
||||
await expect(page.getByLabel('block-item-CardItem-users-form')).toBeVisible();
|
||||
|
||||
@ -1174,7 +1174,7 @@ test.describe('creation form block schema settings', () => {
|
||||
await page.getByLabel('schema-initializer-Grid-CreateFormBlockInitializers-users').hover();
|
||||
await page.getByRole('menuitem', { name: 'form Form' }).first().hover();
|
||||
await page.getByRole('menuitem', { name: 'Reference template' }).hover();
|
||||
await page.getByRole('menuitem', { name: 'Users_Form (Fields only)' }).click();
|
||||
await page.getByRole('menuitem', { name: 'Users_Form (Fields only)' }).first().click();
|
||||
await page.mouse.move(300, 0);
|
||||
await page.getByLabel('schema-initializer-Grid-CreateFormBlockInitializers-users').hover();
|
||||
await expect(page.locator('.ant-drawer').getByLabel('block-item-CardItem-users-form')).toBeVisible();
|
||||
@ -1185,7 +1185,7 @@ test.describe('creation form block schema settings', () => {
|
||||
await page.getByLabel('schema-initializer-Grid-RecordBlockInitializers-users').click();
|
||||
await page.getByRole('menuitem', { name: 'form Form' }).first().hover();
|
||||
await page.getByRole('menuitem', { name: 'Reference template' }).hover();
|
||||
await page.getByRole('menuitem', { name: 'Users_Form (Fields only)' }).click();
|
||||
await page.getByRole('menuitem', { name: 'Users_Form (Fields only)' }).first().click();
|
||||
await page.mouse.move(300, 0);
|
||||
|
||||
//修改引用模板
|
||||
|
@ -5491,3 +5491,213 @@ export const T3251: PageConfig = {
|
||||
'x-index': 1,
|
||||
},
|
||||
};
|
||||
|
||||
export const T3469: PageConfig = {
|
||||
pageSchema: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Page',
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
'9u463vapg0k': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid',
|
||||
'x-initializer': 'BlockInitializers',
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
isaxpp1w32b: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Row',
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
'5dld0j6dehi': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Col',
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
'96xwhprgfdg': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-acl-action-props': {
|
||||
skipScopeCheck: true,
|
||||
},
|
||||
'x-acl-action': 'users:create',
|
||||
'x-decorator': 'FormBlockProvider',
|
||||
'x-decorator-props': {
|
||||
dataSource: 'main',
|
||||
resource: 'users',
|
||||
collection: 'users',
|
||||
},
|
||||
'x-toolbar': 'BlockSchemaToolbar',
|
||||
'x-settings': 'blockSettings:createForm',
|
||||
'x-component': 'CardItem',
|
||||
'x-component-props': {},
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
'0sj1sfgjoxa': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'FormV2',
|
||||
'x-component-props': {
|
||||
useProps: '{{ useFormBlockProps }}',
|
||||
},
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
grid: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid',
|
||||
'x-initializer': 'FormItemInitializers',
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
e4ke3wqxm2o: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Row',
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
l8uf6qeppmb: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Col',
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
nickname: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'string',
|
||||
'x-toolbar': 'FormItemSchemaToolbar',
|
||||
'x-settings': 'fieldSettings:FormItem',
|
||||
'x-component': 'CollectionField',
|
||||
'x-decorator': 'FormItem',
|
||||
'x-collection-field': 'users.nickname',
|
||||
'x-component-props': {},
|
||||
default: 'Should be cleared after submission',
|
||||
'x-index': 1,
|
||||
'x-uid': 'lpgebrm0gig',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': 'novdv1tcz37',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': 'kzf3dxvr0mb',
|
||||
'x-async': false,
|
||||
},
|
||||
s17cswscq2o: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Row',
|
||||
properties: {
|
||||
oh79jnxzotw: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Col',
|
||||
properties: {
|
||||
username: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'string',
|
||||
'x-toolbar': 'FormItemSchemaToolbar',
|
||||
'x-settings': 'fieldSettings:FormItem',
|
||||
'x-component': 'CollectionField',
|
||||
'x-decorator': 'FormItem',
|
||||
'x-collection-field': 'users.username',
|
||||
'x-component-props': {},
|
||||
'x-uid': 'z9dn5rnc3oi',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': '62vb90prmzk',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'ti5u46epv08',
|
||||
'x-async': false,
|
||||
'x-index': 2,
|
||||
},
|
||||
},
|
||||
'x-uid': 'e365kp0cwm9',
|
||||
'x-async': false,
|
||||
},
|
||||
'7660qws6e4c': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-initializer': 'FormActionInitializers',
|
||||
'x-component': 'ActionBar',
|
||||
'x-component-props': {
|
||||
layout: 'one-column',
|
||||
style: {
|
||||
marginTop: 24,
|
||||
},
|
||||
},
|
||||
'x-index': 2,
|
||||
properties: {
|
||||
'79tmpu1usft': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
title: '{{ t("Submit") }}',
|
||||
'x-action': 'submit',
|
||||
'x-component': 'Action',
|
||||
'x-toolbar': 'ActionSchemaToolbar',
|
||||
'x-settings': 'actionSettings:createSubmit',
|
||||
'x-component-props': {
|
||||
type: 'primary',
|
||||
htmlType: 'submit',
|
||||
useProps: '{{ useCreateActionProps }}',
|
||||
},
|
||||
'x-action-settings': {
|
||||
triggerWorkflows: [],
|
||||
},
|
||||
type: 'void',
|
||||
'x-index': 1,
|
||||
'x-uid': '96sageysorb',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': 'nnn377hn4o4',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': 'j5qpwo8d6su',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': 'rlcmlnna7k8',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': 'b6n82zkmrsh',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': 'agdpemeoz1v',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': 'dn5nok8na2g',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': 'lb8hlm9oyv8',
|
||||
'x-async': true,
|
||||
},
|
||||
};
|
||||
|
@ -175,7 +175,6 @@ export const SubTable: any = observer(
|
||||
onClick={() => {
|
||||
field.value = field.value || [];
|
||||
field.value.push(markRecordAsNew({}));
|
||||
field.onInput(field.value);
|
||||
}}
|
||||
>
|
||||
{t('Add new')}
|
||||
|
@ -5,6 +5,7 @@ import { Tag } from 'antd';
|
||||
import dayjs from 'dayjs';
|
||||
import React from 'react';
|
||||
import { CollectionFieldOptions_deprecated, useCollectionManager_deprecated } from '../../../collection-manager';
|
||||
import { Field } from '@formily/core';
|
||||
|
||||
export const useLabelUiSchemaV2 = () => {
|
||||
const { getCollectionJoinField } = useCollectionManager_deprecated();
|
||||
@ -102,6 +103,7 @@ export function isShowFilePicker(labelUiSchema) {
|
||||
/**
|
||||
* 当前字段的模式是否是 `子表格` 或者 `子表单`
|
||||
*/
|
||||
export function isSubMode(fieldSchema: Schema) {
|
||||
return ['Nester', 'SubTable', 'PopoverNester'].includes(fieldSchema['x-component-props']?.mode);
|
||||
export function isSubMode(field: any) {
|
||||
const mode = field['x-component-props']?.mode || (field as Field).componentProps?.mode;
|
||||
return ['Nester', 'SubTable', 'PopoverNester'].includes(mode);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "create-nocobase-app",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"main": "src/index.js",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
|
@ -1,16 +1,16 @@
|
||||
{
|
||||
"name": "@nocobase/data-source-manager",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"description": "",
|
||||
"license": "Apache-2.0",
|
||||
"main": "./lib/index.js",
|
||||
"types": "./lib/index.d.ts",
|
||||
"dependencies": {
|
||||
"@nocobase/actions": "0.20.0-alpha.5",
|
||||
"@nocobase/cache": "0.20.0-alpha.5",
|
||||
"@nocobase/database": "0.20.0-alpha.5",
|
||||
"@nocobase/resourcer": "0.20.0-alpha.5",
|
||||
"@nocobase/utils": "0.20.0-alpha.5",
|
||||
"@nocobase/actions": "0.20.0-alpha.7",
|
||||
"@nocobase/cache": "0.20.0-alpha.7",
|
||||
"@nocobase/database": "0.20.0-alpha.7",
|
||||
"@nocobase/resourcer": "0.20.0-alpha.7",
|
||||
"@nocobase/utils": "0.20.0-alpha.7",
|
||||
"@types/jsonwebtoken": "^8.5.8",
|
||||
"jsonwebtoken": "^8.5.1"
|
||||
},
|
||||
|
@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "@nocobase/database",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"description": "",
|
||||
"main": "./lib/index.js",
|
||||
"types": "./lib/index.d.ts",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@nocobase/logger": "0.20.0-alpha.5",
|
||||
"@nocobase/utils": "0.20.0-alpha.5",
|
||||
"@nocobase/logger": "0.20.0-alpha.7",
|
||||
"@nocobase/utils": "0.20.0-alpha.7",
|
||||
"async-mutex": "^0.3.2",
|
||||
"chalk": "^4.1.1",
|
||||
"cron-parser": "4.4.0",
|
||||
|
@ -34,7 +34,7 @@ describe('view inference', function () {
|
||||
|
||||
await db.sync();
|
||||
|
||||
const viewName = 'user_posts';
|
||||
const viewName = 'test_view';
|
||||
|
||||
const dropViewSQL = `DROP VIEW IF EXISTS ${viewName}`;
|
||||
await db.sequelize.query(dropViewSQL);
|
||||
|
@ -153,10 +153,14 @@ export default class PostgresQueryInterface extends QueryInterface {
|
||||
|
||||
// handle column alias
|
||||
const from = ast[0].from;
|
||||
const findAs = from.find((from) => from.as === columnExprTable);
|
||||
if (columnExprTable === null && column.expr.type === 'column_ref') {
|
||||
columnExprTable = from[0].table;
|
||||
} else {
|
||||
const findAs = from.find((from) => from.as === columnExprTable);
|
||||
|
||||
if (findAs) {
|
||||
columnExprTable = findAs.table;
|
||||
if (findAs) {
|
||||
columnExprTable = findAs.table;
|
||||
}
|
||||
}
|
||||
|
||||
return columnUsage.column_name === column.expr.column && columnUsage.table_name === columnExprTable;
|
||||
|
@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "@nocobase/devtools",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"description": "",
|
||||
"license": "Apache-2.0",
|
||||
"main": "./src/index.js",
|
||||
"dependencies": {
|
||||
"@nocobase/build": "0.20.0-alpha.5",
|
||||
"@nocobase/client": "0.20.0-alpha.5",
|
||||
"@nocobase/test": "0.20.0-alpha.5",
|
||||
"@nocobase/build": "0.20.0-alpha.7",
|
||||
"@nocobase/client": "0.20.0-alpha.7",
|
||||
"@nocobase/test": "0.20.0-alpha.7",
|
||||
"@types/koa": "^2.13.4",
|
||||
"@types/koa-bodyparser": "^4.3.4",
|
||||
"@types/lodash": "^4.14.177",
|
||||
|
@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "@nocobase/evaluators",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"description": "",
|
||||
"main": "./lib/index.js",
|
||||
"types": "./lib/index.d.ts",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@formulajs/formulajs": "4.2.0",
|
||||
"@nocobase/utils": "0.20.0-alpha.5",
|
||||
"@nocobase/utils": "0.20.0-alpha.7",
|
||||
"mathjs": "^10.6.0"
|
||||
},
|
||||
"repository": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/logger",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"description": "nocobase logging library",
|
||||
"license": "Apache-2.0",
|
||||
"main": "./lib/index.js",
|
||||
|
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@nocobase/resourcer",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"description": "",
|
||||
"main": "./lib/index.js",
|
||||
"types": "./lib/index.d.ts",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@nocobase/utils": "0.20.0-alpha.5",
|
||||
"@nocobase/utils": "0.20.0-alpha.7",
|
||||
"deepmerge": "^4.2.2",
|
||||
"koa-compose": "^4.1.0",
|
||||
"lodash": "^4.17.21",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/sdk",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "Apache-2.0",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/server",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"main": "lib/index.js",
|
||||
"types": "./lib/index.d.ts",
|
||||
"license": "Apache-2.0",
|
||||
@ -10,18 +10,18 @@
|
||||
"@koa/cors": "^3.1.0",
|
||||
"@koa/multer": "^3.0.2",
|
||||
"@koa/router": "^9.4.0",
|
||||
"@nocobase/acl": "0.20.0-alpha.5",
|
||||
"@nocobase/actions": "0.20.0-alpha.5",
|
||||
"@nocobase/auth": "0.20.0-alpha.5",
|
||||
"@nocobase/cache": "0.20.0-alpha.5",
|
||||
"@nocobase/data-source-manager": "0.20.0-alpha.5",
|
||||
"@nocobase/database": "0.20.0-alpha.5",
|
||||
"@nocobase/evaluators": "0.20.0-alpha.5",
|
||||
"@nocobase/logger": "0.20.0-alpha.5",
|
||||
"@nocobase/resourcer": "0.20.0-alpha.5",
|
||||
"@nocobase/sdk": "0.20.0-alpha.5",
|
||||
"@nocobase/telemetry": "0.20.0-alpha.5",
|
||||
"@nocobase/utils": "0.20.0-alpha.5",
|
||||
"@nocobase/acl": "0.20.0-alpha.7",
|
||||
"@nocobase/actions": "0.20.0-alpha.7",
|
||||
"@nocobase/auth": "0.20.0-alpha.7",
|
||||
"@nocobase/cache": "0.20.0-alpha.7",
|
||||
"@nocobase/data-source-manager": "0.20.0-alpha.7",
|
||||
"@nocobase/database": "0.20.0-alpha.7",
|
||||
"@nocobase/evaluators": "0.20.0-alpha.7",
|
||||
"@nocobase/logger": "0.20.0-alpha.7",
|
||||
"@nocobase/resourcer": "0.20.0-alpha.7",
|
||||
"@nocobase/sdk": "0.20.0-alpha.7",
|
||||
"@nocobase/telemetry": "0.20.0-alpha.7",
|
||||
"@nocobase/utils": "0.20.0-alpha.7",
|
||||
"@types/decompress": "4.2.4",
|
||||
"@types/ini": "^1.3.31",
|
||||
"@types/koa-send": "^4.1.3",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/telemetry",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"description": "nocobase telemetry library",
|
||||
"license": "Apache-2.0",
|
||||
"main": "./lib/index.js",
|
||||
@ -11,7 +11,7 @@
|
||||
"directory": "packages/telemetry"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nocobase/utils": "0.20.0-alpha.5",
|
||||
"@nocobase/utils": "0.20.0-alpha.7",
|
||||
"@opentelemetry/api": "^1.7.0",
|
||||
"@opentelemetry/instrumentation": "^0.46.0",
|
||||
"@opentelemetry/resources": "^1.19.0",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/test",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"main": "lib/index.js",
|
||||
"module": "./src/index.ts",
|
||||
"types": "./lib/index.d.ts",
|
||||
@ -40,7 +40,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@faker-js/faker": "8.1.0",
|
||||
"@nocobase/server": "0.20.0-alpha.5",
|
||||
"@nocobase/server": "0.20.0-alpha.7",
|
||||
"@playwright/test": "^1.42.1",
|
||||
"@testing-library/react": "^14.0.0",
|
||||
"@testing-library/user-event": "^14.4.3",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/utils",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"main": "lib/index.js",
|
||||
"types": "./lib/index.d.ts",
|
||||
"license": "Apache-2.0",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "权限控制",
|
||||
"description": "Based on roles, resources, and actions, access control can precisely manage interface configuration permissions, data operation permissions, menu access permissions, and plugin permissions.",
|
||||
"description.zh-CN": "基于角色、资源和操作的权限控制,可以精确控制界面配置权限、数据操作权限、菜单访问权限、插件权限。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/acl",
|
||||
|
@ -34,6 +34,137 @@ describe('actions', () => {
|
||||
await app.destroy();
|
||||
});
|
||||
|
||||
it('should set scope with user associations', async () => {
|
||||
await app.db.getCollection('collections').repository.create({
|
||||
values: {
|
||||
name: 'sites',
|
||||
autoGenId: false,
|
||||
fields: [
|
||||
{
|
||||
name: 'id',
|
||||
type: 'bigInt',
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
{
|
||||
type: 'string',
|
||||
name: 'name',
|
||||
},
|
||||
],
|
||||
},
|
||||
context: {},
|
||||
});
|
||||
|
||||
// create site
|
||||
const site = await db.getRepository('sites').create({
|
||||
values: {
|
||||
name: 'testSite',
|
||||
},
|
||||
});
|
||||
|
||||
const site2 = await db.getRepository('sites').create({
|
||||
values: {
|
||||
name: 'site2',
|
||||
},
|
||||
});
|
||||
|
||||
await app.db.getCollection('fields').repository.create({
|
||||
values: {
|
||||
collectionName: 'users',
|
||||
name: 'site',
|
||||
type: 'belongsTo',
|
||||
foreignKey: 'siteId',
|
||||
targetKey: 'id',
|
||||
},
|
||||
context: {},
|
||||
});
|
||||
|
||||
const testUser = await db.getRepository('users').create({
|
||||
values: {
|
||||
username: 'testUser',
|
||||
site: site.get('id'),
|
||||
},
|
||||
});
|
||||
|
||||
await db.getRepository('roles').create({
|
||||
values: {
|
||||
name: 'testRole',
|
||||
users: [
|
||||
{
|
||||
id: testUser.get('id'),
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
await app.db.getCollection('collections').repository.create({
|
||||
values: {
|
||||
name: 'items',
|
||||
fields: [
|
||||
{
|
||||
type: 'string',
|
||||
name: 'name',
|
||||
},
|
||||
{
|
||||
name: 'site',
|
||||
type: 'belongsTo',
|
||||
foreignKey: 'siteId',
|
||||
targetKey: 'id',
|
||||
},
|
||||
],
|
||||
},
|
||||
context: {},
|
||||
});
|
||||
|
||||
const scope = await app.db.getCollection('dataSourcesRolesResourcesScopes').repository.create({
|
||||
values: {
|
||||
name: 'items-own-site',
|
||||
actions: ['view'],
|
||||
fields: ['name'],
|
||||
scope: { $and: [{ site: { id: { $eq: '{{$user.site.id}}' } } }] },
|
||||
resourceName: 'items',
|
||||
},
|
||||
});
|
||||
|
||||
// create acl resource
|
||||
const createResourcesResp = await adminAgent.resource('roles.resources', 'testRole').create({
|
||||
values: {
|
||||
name: 'items',
|
||||
usingActionsConfig: true,
|
||||
actions: [
|
||||
{
|
||||
name: 'view',
|
||||
scope: scope.get('id'),
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
expect(createResourcesResp.status).toBe(200);
|
||||
|
||||
const item = await db.getRepository('items').create({
|
||||
values: {
|
||||
name: 'testItem',
|
||||
site: site.get('id'),
|
||||
},
|
||||
});
|
||||
|
||||
await db.getRepository('items').create({
|
||||
values: {
|
||||
name: 'item2',
|
||||
site: site2.get('id'),
|
||||
},
|
||||
});
|
||||
|
||||
// list with user
|
||||
const userAgent: any = app.agent().login(testUser).set('x-role', 'testRole');
|
||||
|
||||
const listResp = await userAgent.resource('items').list({});
|
||||
expect(listResp.status).toBe(200);
|
||||
const data = listResp.body.data;
|
||||
expect(data.length).toBe(1);
|
||||
});
|
||||
|
||||
it('update profile with roles', async () => {
|
||||
const res2 = await adminAgent.resource('users').updateProfile({
|
||||
filterByTk: adminUser.id,
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/plugin-action-bulk-edit",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"main": "dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/action-bulk-edit",
|
||||
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/action-bulk-edit",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/plugin-action-bulk-update",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"main": "dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/action-bulk-update",
|
||||
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/action-bulk-update",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/plugin-action-duplicate",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"main": "dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/action-duplicate",
|
||||
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/action-duplicate",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/plugin-action-print",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"main": "dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/action-print",
|
||||
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/action-print",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/plugin-api-doc",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"displayName": "API documentation",
|
||||
"displayName.zh-CN": "API 文档",
|
||||
"description": "An OpenAPI documentation generator for NocoBase HTTP API.",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "认证:API 密钥",
|
||||
"description": "Allows users to use API key to access application's HTTP API",
|
||||
"description.zh-CN": "允许用户使用 API 密钥访问应用的 HTTP API",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/api-keys",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/plugin-audit-logs",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"displayName": "Audit logs (deprecated)",
|
||||
"displayName.zh-CN": "审计日志(废弃)",
|
||||
"description": "This plugin is deprecated. There will be a new audit log plugin in the future.",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/plugin-auth",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/auth",
|
||||
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/auth",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "应用的备份与还原",
|
||||
"description": "Backup and restore applications for scenarios such as application replication, migration, and upgrades.",
|
||||
"description.zh-CN": "备份和还原应用,可用于应用的复制、迁移、升级等场景。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/backup-restore",
|
||||
|
@ -73,7 +73,7 @@ export class Dumper extends AppMigrator {
|
||||
if (backupFileStat.isFile()) {
|
||||
return {
|
||||
name: fileName,
|
||||
createdAt: backupFileStat.birthtime,
|
||||
createdAt: backupFileStat.ctime,
|
||||
fileSize: humanFileSize(backupFileStat.size),
|
||||
status: 'ok',
|
||||
} as BackUpStatusOk;
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/plugin-calendar",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"displayName": "Calendar",
|
||||
"displayName.zh-CN": "日历",
|
||||
"description": "Provides callendar collection template and block for managing date data, typically for date/time related information such as events, appointments, tasks, and so on.",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "认证:CAS",
|
||||
"description": "CAS authentication.",
|
||||
"description.zh-CN": "通过 CAS 协议认证身份。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/auth-cas",
|
||||
|
@ -2,12 +2,10 @@ import { Context, Next } from '@nocobase/actions';
|
||||
import { CASAuth } from '../auth';
|
||||
|
||||
export const login = async (ctx: Context, next: Next) => {
|
||||
const { authenticator, redirect = '' } = ctx.action.params;
|
||||
const { authenticator, redirect = '/admin' } = ctx.action.params;
|
||||
const auth = (await ctx.app.authManager.get(authenticator, ctx)) as CASAuth;
|
||||
const { casUrl, serviceUrl } = auth.getOptions();
|
||||
const service = encodeURIComponent(
|
||||
`${serviceUrl}?authenticator=${authenticator}&__appName=${ctx.app.name}&redirect=${redirect}`,
|
||||
);
|
||||
const { casUrl } = auth.getOptions();
|
||||
const service = auth.getService(authenticator, ctx.app.name, redirect);
|
||||
ctx.redirect(`${casUrl}/login?service=${service}`);
|
||||
next();
|
||||
};
|
||||
|
@ -11,21 +11,33 @@ export class CASAuth extends BaseAuth {
|
||||
});
|
||||
}
|
||||
|
||||
getOptions() {
|
||||
getOptions(): {
|
||||
casUrl?: string;
|
||||
serviceUrl?: string;
|
||||
autoSignup?: boolean;
|
||||
} {
|
||||
const opts = this.options || {};
|
||||
return {
|
||||
...opts,
|
||||
serviceUrl: `${opts.serviceDomain}/api/cas:service`,
|
||||
} as {
|
||||
casUrl?: string;
|
||||
serviceUrl?: string;
|
||||
autoSignup?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
getService(authenticator: string, appName: string, redirect: string) {
|
||||
const { serviceUrl } = this.getOptions();
|
||||
return encodeURIComponent(`${serviceUrl}?authenticator=${authenticator}&__appName=${appName}&redirect=${redirect}`);
|
||||
}
|
||||
|
||||
async serviceValidate(ticket: string) {
|
||||
const { casUrl, serviceUrl } = this.getOptions();
|
||||
const url = `${casUrl}/serviceValidate?ticket=${ticket}&service=${serviceUrl}`;
|
||||
const { casUrl } = this.getOptions();
|
||||
const { authenticator, __appName: appName, redirect = '/admin' } = this.ctx.action.params;
|
||||
const service = this.getService(authenticator, appName, redirect);
|
||||
const url = `${casUrl}/serviceValidate?ticket=${ticket}&service=${service}`;
|
||||
this.ctx.logger.debug(`serviceValidate url: ${url}`, {
|
||||
module: 'auth',
|
||||
submodule: 'cas',
|
||||
method: 'serviceValidate',
|
||||
});
|
||||
try {
|
||||
const res = await axios.get(url);
|
||||
return res;
|
||||
@ -42,6 +54,7 @@ export class CASAuth extends BaseAuth {
|
||||
throw new Error('Missing ticket');
|
||||
}
|
||||
const res = await this.serviceValidate(ticket);
|
||||
ctx.logger.debug(res?.data, { module: 'auth', submodule: 'cas', method: 'validate' });
|
||||
const pattern = /<(?:cas|sso):user>(.*?)<\/(?:cas|sso):user>/;
|
||||
const username = res?.data.match(pattern)?.[1];
|
||||
if (!username) {
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "图表(废弃)",
|
||||
"description": "The plugin has been deprecated, please use the data visualization plugin instead.",
|
||||
"description.zh-CN": "已废弃插件,请使用数据可视化插件代替。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"main": "./dist/server/index.js",
|
||||
"license": "AGPL-3.0",
|
||||
"devDependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/plugin-china-region",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"displayName": "Administrative divisions of China",
|
||||
"displayName.zh-CN": "中国行政区划",
|
||||
"description": "Provides data and field type for administrative divisions of China.",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "WEB 客户端",
|
||||
"description": "Provides a client interface for the NocoBase server",
|
||||
"description.zh-CN": "为 NocoBase 服务端提供客户端界面",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"main": "./dist/server/index.js",
|
||||
"license": "AGPL-3.0",
|
||||
"devDependencies": {
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "数据源:主数据库",
|
||||
"description": "NocoBase main database, supports relational databases such as MySQL, PostgreSQL, SQLite and so on.",
|
||||
"description.zh-CN": "NocoBase 主数据库,支持 MySQL、PostgreSQL、SQLite 等关系型数据库。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/data-source-main",
|
||||
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/data-source-main",
|
||||
|
@ -0,0 +1,142 @@
|
||||
import Database, { Collection as DBCollection } from '@nocobase/database';
|
||||
import Application from '@nocobase/server';
|
||||
import { createApp } from '..';
|
||||
|
||||
describe('destroy', () => {
|
||||
let db: Database;
|
||||
let app: Application;
|
||||
let Collection: DBCollection;
|
||||
let Field: DBCollection;
|
||||
|
||||
beforeEach(async () => {
|
||||
app = await createApp({
|
||||
database: {
|
||||
tablePrefix: '',
|
||||
},
|
||||
});
|
||||
db = app.db;
|
||||
Collection = db.getCollection('collections');
|
||||
Field = db.getCollection('fields');
|
||||
|
||||
await Collection.repository.create({
|
||||
values: {
|
||||
name: 'a',
|
||||
fields: [
|
||||
{
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
},
|
||||
context: {},
|
||||
});
|
||||
|
||||
await Collection.repository.create({
|
||||
values: {
|
||||
name: 'b',
|
||||
fields: [
|
||||
{
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
},
|
||||
context: {},
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await app.destroy();
|
||||
});
|
||||
|
||||
describe('destroy field', () => {
|
||||
it('should remove field in model when field destroyed', async () => {
|
||||
const collection = await Collection.repository.create({
|
||||
values: {
|
||||
name: 'test',
|
||||
fields: [
|
||||
{ name: 'f1', type: 'string' },
|
||||
{
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
},
|
||||
context: {},
|
||||
});
|
||||
|
||||
expect(db.getCollection('test').model.rawAttributes.name).toBeDefined();
|
||||
|
||||
await Field.repository.destroy({
|
||||
filter: {
|
||||
name: 'name',
|
||||
collectionName: 'test',
|
||||
},
|
||||
context: {},
|
||||
});
|
||||
|
||||
expect(db.getCollection('test').model.rawAttributes.name).toBeUndefined();
|
||||
expect(db.getCollection('test').model.rawAttributes.f1).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('destroy foreign key', () => {
|
||||
it('should destroy association field when foreign key field destroyed', async () => {
|
||||
await Field.repository.create({
|
||||
values: {
|
||||
name: 'b',
|
||||
type: 'hasOne',
|
||||
target: 'b',
|
||||
collectionName: 'a',
|
||||
foreignKey: 'a_id',
|
||||
interface: 'oho',
|
||||
},
|
||||
context: {},
|
||||
});
|
||||
|
||||
// should create association field
|
||||
expect(
|
||||
await Field.repository.findOne({
|
||||
filter: {
|
||||
collectionName: 'a',
|
||||
name: 'b',
|
||||
},
|
||||
}),
|
||||
).toBeTruthy();
|
||||
|
||||
const foreignKeyField = await Field.repository.findOne({
|
||||
filter: {
|
||||
name: 'a_id',
|
||||
collectionName: 'b',
|
||||
},
|
||||
});
|
||||
|
||||
// should create foreign key
|
||||
expect(foreignKeyField).toBeTruthy();
|
||||
|
||||
expect(db.getCollection('b').model.rawAttributes.a_id).toBeTruthy();
|
||||
|
||||
// destroy foreign key field
|
||||
await Field.repository.destroy({
|
||||
filter: {
|
||||
name: 'a_id',
|
||||
collectionName: 'b',
|
||||
},
|
||||
context: {},
|
||||
});
|
||||
|
||||
// should remove association field
|
||||
expect(
|
||||
await Field.repository.findOne({
|
||||
filter: {
|
||||
collectionName: 'a',
|
||||
name: 'b',
|
||||
},
|
||||
}),
|
||||
).toBeFalsy();
|
||||
|
||||
// should remove foreign key
|
||||
expect(db.getCollection('b').model.rawAttributes.a_id).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/plugin-custom-request",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"main": "dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/action-custom-request",
|
||||
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/action-custom-request",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/plugin-data-source-manager",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"main": "dist/server/index.js",
|
||||
"displayName": "Data source manager",
|
||||
"displayName.zh-CN": "数据源管理",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/plugin-data-visualization",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"displayName": "Data visualization",
|
||||
"displayName.zh-CN": "数据可视化",
|
||||
"description": "Provides data visualization feature, including chart block and chart filter block, support line charts, area charts, bar charts and more than a dozen kinds of charts, you can also extend more chart types.",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/plugin-disable-pm-add",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"main": "./dist/server/index.js",
|
||||
"peerDependencies": {
|
||||
"@nocobase/client": "0.x",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "错误处理器",
|
||||
"description": "Handling application errors and exceptions.",
|
||||
"description.zh-CN": "处理应用程序中的错误和异常。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
"devDependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/plugin-excel-formula-field",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"description": "",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "操作:导出记录",
|
||||
"description": "Export filtered records to excel, you can configure which fields to export.",
|
||||
"description.zh-CN": "导出筛选后的记录到 Excel 中,可以配置导出哪些字段。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/action-export",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/plugin-file-manager",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"displayName": "File manager",
|
||||
"displayName.zh-CN": "文件管理器",
|
||||
"description": "Provides files storage services with files collection template and attachment field.",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "数据表字段:公式",
|
||||
"description": "Configure and store the results of calculations between multiple field values in the same record, supporting both Math.js and Excel formula functions.",
|
||||
"description.zh-CN": "可以配置并存储同一条记录的多字段值之间的计算结果,支持 Math.js 和 Excel formula functions 两种引擎",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/field-formula",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/plugin-gantt",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"displayName": "Block: Gantt",
|
||||
"displayName.zh-CN": "区块:甘特图",
|
||||
"description": "Provides Gantt block.",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "可视化数据表管理",
|
||||
"description": "An ER diagram-like tool. Currently only the Master database is supported.",
|
||||
"description.zh-CN": "类似 ER 图的工具,目前只支持主数据库。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/graph-collection-manager",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "区块:iframe",
|
||||
"description": "Create an iframe block on the page to embed and display external web pages or content.",
|
||||
"description.zh-CN": "在页面上创建和管理iframe,用于嵌入和展示外部网页或内容。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/block-iframe",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "操作:导入记录",
|
||||
"description": "Import records using excel templates. You can configure which fields to import and templates will be generated automatically.",
|
||||
"description.zh-CN": "使用 Excel 模板导入数据,可以配置导入哪些字段,自动生成模板。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/action-import",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/plugin-kanban",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"main": "dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/block-kanban",
|
||||
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/block-kanban",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/plugin-localization-management",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"main": "dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/localization-management",
|
||||
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/localization-management",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "日志",
|
||||
"description": "Server-side logs, mainly including API request logs and system runtime logs, and allows to package and download log files.",
|
||||
"description.zh-CN": "服务端日志,主要包括接口请求日志和系统运行日志,并支持打包和下载日志文件。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/logger",
|
||||
|
@ -2,7 +2,7 @@
|
||||
"name": "@nocobase/plugin-map",
|
||||
"displayName": "Block: Map",
|
||||
"displayName.zh-CN": "区块:地图",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"description": "Map block, support Gaode map and Google map, you can also extend more map types.",
|
||||
"description.zh-CN": "地图区块,支持高德地图和 Google 地图,你也可以扩展更多地图类型。",
|
||||
"license": "AGPL-3.0",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "数学公式字段",
|
||||
"description": "A powerful mathematical formula field plugin designed to provide flexible mathematical and formula calculation capabilities for databases or data management systems. It seamlessly integrates with various database systems such as MySQL, PostgreSQL, and offers an intuitive user interface for defining and executing mathematical formula fields.",
|
||||
"description.zh-CN": "一个功能强大的数学公式字段插件,旨在为数据库或数据管理系统提供灵活的数学计算和公式计算功能。它可以与各种数据库系统(如MySQL、PostgreSQL)无缝集成,并提供直观的用户界面来定义和执行数学公式字段。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
"devDependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/plugin-mobile-client",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/mobile-client",
|
||||
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/mobile-client",
|
||||
|
@ -2,7 +2,7 @@
|
||||
"name": "@nocobase/plugin-mock-collections",
|
||||
"displayName": "mock-collections",
|
||||
"description": "mock-collections",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"main": "./dist/server/index.js",
|
||||
"license": "AGPL-3.0",
|
||||
"peerDependencies": {
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "多应用管理器",
|
||||
"description": "Dynamically create multiple apps without separate deployments.",
|
||||
"description.zh-CN": "无需单独部署即可动态创建多个应用。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/multi-app-manager",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "多应用数据表共享",
|
||||
"description": "",
|
||||
"description.zh-CN": "",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"main": "./dist/server/index.js",
|
||||
"devDependencies": {
|
||||
"@formily/react": "2.x",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/plugin-notifications",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"description": "",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "认证:OIDC",
|
||||
"description": "OIDC (OpenID Connect) authentication.",
|
||||
"description.zh-CN": "通过 OIDC (OpenID Connect) 协议认证身份。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/auth-oidc",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "认证:SAML 2.0",
|
||||
"description": "SAML 2.0 authentication.",
|
||||
"description.zh-CN": "通过 SAML 2.0 协议认证身份。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/auth-saml",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/plugin-sample-hello",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"main": "./dist/server/index.js",
|
||||
"displayName": "Hello",
|
||||
"displayName.zh-CN": "Hello",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "数据表字段:自动编码",
|
||||
"description": "Automatically generate codes based on configured rules, supporting combinations of dates, numbers, and text.",
|
||||
"description.zh-CN": "根据配置的规则自动生成编码,支持日期、数字、文本的组合。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/field-sequence",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "认证:短信",
|
||||
"description": "SMS authentication.",
|
||||
"description.zh-CN": "通过短信验证码认证身份。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/auth-sms",
|
||||
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/auth-sms",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "数据表字段:关系快照",
|
||||
"description": "When adding a new record, create a snapshot for its relational record and save in the new record. The snapshot will not be updated when the relational record is updated.",
|
||||
"description.zh-CN": "在添加数据时,为它的关系数据创建快照,并保存在当前的数据中。关系数据更新时,快照不会更新。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/field-snapshot",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "系统设置",
|
||||
"description": "Used to adjust the system title, logo, language, etc.",
|
||||
"description.zh-CN": "用于调整系统的标题、LOGO、语言等。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/system-settings",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nocobase/plugin-theme-editor",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"main": "dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/theme-editor",
|
||||
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/theme-editor",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "路由管理",
|
||||
"description": "manage the routes of nocobase",
|
||||
"description.zh-CN": "管理页面路由。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
"devDependencies": {
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "UI schema 存储服务",
|
||||
"description": "Provides centralized UI schema storage service.",
|
||||
"description.zh-CN": "提供中心化的 UI schema 存储服务。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/ui-schema-storage",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "用户",
|
||||
"description": "Provides basic user model, as well as created by and updated by fields.",
|
||||
"description.zh-CN": "提供了基础的用户模型,以及创建人和最后更新人字段。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/users",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "验证码",
|
||||
"description": "verification setting.",
|
||||
"description.zh-CN": "验证码配置。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/verification",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "工作流:数据操作触发器",
|
||||
"description": "Bind action buttons to trigger workflow events when clicked.",
|
||||
"description.zh-CN": "可对数据操作按钮绑定,在点击后触发对应的工作流事件。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/plugins/workflow-action-trigger",
|
||||
|
@ -1,9 +1,14 @@
|
||||
import { get } from 'lodash';
|
||||
import { BelongsTo, HasOne } from 'sequelize';
|
||||
import { Model, modelAssociationByKey } from '@nocobase/database';
|
||||
import { DefaultContext } from '@nocobase/server';
|
||||
import { ActionContext } from '@nocobase/resourcer';
|
||||
import { Next } from '@nocobase/actions';
|
||||
|
||||
import WorkflowPlugin, { Trigger, WorkflowModel, toJSON } from '@nocobase/plugin-workflow';
|
||||
|
||||
interface Context extends ActionContext, DefaultContext {}
|
||||
|
||||
export default class extends Trigger {
|
||||
constructor(workflow: WorkflowPlugin) {
|
||||
super(workflow);
|
||||
@ -11,7 +16,7 @@ export default class extends Trigger {
|
||||
workflow.app.resourcer.use(this.middleware);
|
||||
}
|
||||
|
||||
async triggerAction(context, next) {
|
||||
async triggerAction(context: Context, next: Next) {
|
||||
const { triggerWorkflows } = context.action.params;
|
||||
|
||||
if (!triggerWorkflows) {
|
||||
@ -24,7 +29,7 @@ export default class extends Trigger {
|
||||
this.trigger(context);
|
||||
}
|
||||
|
||||
middleware = async (context, next) => {
|
||||
middleware = async (context: Context, next: Next) => {
|
||||
const {
|
||||
resourceName,
|
||||
actionName,
|
||||
@ -48,7 +53,7 @@ export default class extends Trigger {
|
||||
return this.trigger(context);
|
||||
};
|
||||
|
||||
private async trigger(context) {
|
||||
private async trigger(context: Context) {
|
||||
const { triggerWorkflows = '', values } = context.action.params;
|
||||
|
||||
const { currentUser, currentRole } = context.state;
|
||||
@ -59,17 +64,20 @@ export default class extends Trigger {
|
||||
|
||||
const triggers = triggerWorkflows.split(',').map((trigger) => trigger.split('!'));
|
||||
const workflowRepo = this.workflow.db.getRepository('workflows');
|
||||
const workflows = await workflowRepo.find({
|
||||
filter: {
|
||||
key: triggers.map((trigger) => trigger[0]),
|
||||
current: true,
|
||||
type: 'action',
|
||||
enabled: true,
|
||||
},
|
||||
});
|
||||
const workflows = (
|
||||
await workflowRepo.find({
|
||||
filter: {
|
||||
key: triggers.map((trigger) => trigger[0]),
|
||||
current: true,
|
||||
type: 'action',
|
||||
enabled: true,
|
||||
},
|
||||
})
|
||||
).filter((workflow) => Boolean(workflow.config.collection));
|
||||
const syncGroup = [];
|
||||
const asyncGroup = [];
|
||||
for (const workflow of workflows) {
|
||||
const { collection, appends = [] } = workflow.config;
|
||||
const trigger = triggers.find((trigger) => trigger[0] == workflow.key);
|
||||
const event = [workflow];
|
||||
if (context.action.resourceName !== 'workflows') {
|
||||
@ -90,7 +98,6 @@ export default class extends Trigger {
|
||||
}
|
||||
}
|
||||
}
|
||||
const { collection, appends = [] } = workflow.config;
|
||||
const model = payload.constructor;
|
||||
if (payload instanceof Model) {
|
||||
if (collection !== model.collection.name) {
|
||||
@ -107,7 +114,15 @@ export default class extends Trigger {
|
||||
event.push({ data: toJSON(payload), ...userInfo });
|
||||
}
|
||||
} else {
|
||||
const data = trigger[1] ? get(values, trigger[1]) : values;
|
||||
const { model, repository } = context.db.getCollection(collection);
|
||||
let data = trigger[1] ? get(values, trigger[1]) : values;
|
||||
const pk = get(data, model.primaryKeyAttribute);
|
||||
if (appends.length && pk != null) {
|
||||
data = await repository.findOne({
|
||||
filterByTk: pk,
|
||||
appends,
|
||||
});
|
||||
}
|
||||
// this.workflow.trigger(workflow, {
|
||||
// data,
|
||||
// ...userInfo,
|
||||
|
@ -214,6 +214,7 @@ describe('workflow > action-trigger', () => {
|
||||
type: 'action',
|
||||
config: {
|
||||
collection: 'posts',
|
||||
appends: ['createdBy'],
|
||||
},
|
||||
});
|
||||
|
||||
@ -238,6 +239,7 @@ describe('workflow > action-trigger', () => {
|
||||
const [e2] = await workflow.getExecutions();
|
||||
expect(e2.status).toBe(EXECUTION_STATUS.RESOLVED);
|
||||
expect(e2.context.data).toHaveProperty('title', 't2');
|
||||
expect(e2.context.data).toHaveProperty('createdBy');
|
||||
});
|
||||
});
|
||||
|
||||
@ -281,7 +283,7 @@ describe('workflow > action-trigger', () => {
|
||||
});
|
||||
|
||||
describe('directly trigger', () => {
|
||||
it('trigger data', async () => {
|
||||
it('no collection configured should not be triggered', async () => {
|
||||
const workflow = await WorkflowModel.create({
|
||||
enabled: true,
|
||||
type: 'action',
|
||||
@ -295,20 +297,78 @@ describe('workflow > action-trigger', () => {
|
||||
|
||||
await sleep(500);
|
||||
|
||||
const e1s = await workflow.getExecutions();
|
||||
expect(e1s.length).toBe(0);
|
||||
});
|
||||
|
||||
it('trigger on form data', async () => {
|
||||
const workflow = await WorkflowModel.create({
|
||||
enabled: true,
|
||||
type: 'action',
|
||||
config: {
|
||||
collection: 'posts',
|
||||
appends: ['createdBy'],
|
||||
},
|
||||
});
|
||||
|
||||
const res1 = await userAgents[0].resource('workflows').trigger({
|
||||
values: { title: 't1' },
|
||||
triggerWorkflows: `${workflow.key}`,
|
||||
});
|
||||
expect(res1.status).toBe(202);
|
||||
|
||||
await sleep(500);
|
||||
|
||||
const [e1] = await workflow.getExecutions();
|
||||
expect(e1.status).toBe(EXECUTION_STATUS.RESOLVED);
|
||||
expect(e1.context.data).toMatchObject({ title: 't1' });
|
||||
expect(e1.context.data.createdBy).toBeUndefined();
|
||||
});
|
||||
|
||||
it('trigger on record data', async () => {
|
||||
const workflow = await WorkflowModel.create({
|
||||
enabled: true,
|
||||
type: 'action',
|
||||
config: {
|
||||
collection: 'posts',
|
||||
appends: ['createdBy'],
|
||||
},
|
||||
});
|
||||
|
||||
const post = await PostRepo.create({
|
||||
values: { title: 't1', createdBy: users[0].id },
|
||||
});
|
||||
|
||||
const res1 = await userAgents[0].resource('workflows').trigger({
|
||||
values: post.toJSON(),
|
||||
triggerWorkflows: `${workflow.key}`,
|
||||
});
|
||||
expect(res1.status).toBe(202);
|
||||
|
||||
await sleep(500);
|
||||
|
||||
const [e1] = await workflow.getExecutions();
|
||||
expect(e1.status).toBe(EXECUTION_STATUS.RESOLVED);
|
||||
expect(e1.context.data).toMatchObject({ title: 't1' });
|
||||
expect(e1.context.data).toHaveProperty('createdBy');
|
||||
expect(e1.context.data.createdBy.id).toBe(users[0].id);
|
||||
});
|
||||
|
||||
it('multi trigger', async () => {
|
||||
const w1 = await WorkflowModel.create({
|
||||
enabled: true,
|
||||
type: 'action',
|
||||
config: {
|
||||
collection: 'posts',
|
||||
},
|
||||
});
|
||||
|
||||
const w2 = await WorkflowModel.create({
|
||||
enabled: true,
|
||||
type: 'action',
|
||||
config: {
|
||||
collection: 'posts',
|
||||
},
|
||||
});
|
||||
|
||||
const res1 = await userAgents[0].resource('workflows').trigger({
|
||||
@ -358,6 +418,9 @@ describe('workflow > action-trigger', () => {
|
||||
const workflow = await WorkflowModel.create({
|
||||
enabled: true,
|
||||
type: 'action',
|
||||
config: {
|
||||
collection: 'posts',
|
||||
},
|
||||
});
|
||||
|
||||
const res1 = await userAgents[0].resource('workflows').trigger({
|
||||
@ -377,6 +440,9 @@ describe('workflow > action-trigger', () => {
|
||||
const workflow = await WorkflowModel.create({
|
||||
enabled: true,
|
||||
type: 'action',
|
||||
config: {
|
||||
collection: 'posts',
|
||||
},
|
||||
});
|
||||
|
||||
const res1 = await userAgents[0].resource('workflows').trigger({
|
||||
@ -398,6 +464,9 @@ describe('workflow > action-trigger', () => {
|
||||
const w1 = await WorkflowModel.create({
|
||||
enabled: true,
|
||||
type: 'action',
|
||||
config: {
|
||||
collection: 'posts',
|
||||
},
|
||||
});
|
||||
|
||||
const res1 = await userAgents[0].resource('workflows').trigger({
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Migration } from '@nocobase/server';
|
||||
|
||||
export default class extends Migration {
|
||||
appVersion = '<0.20.0-alpha.6';
|
||||
appVersion = '<0.20.0-alpha.7';
|
||||
on = 'afterSync';
|
||||
async up() {
|
||||
const { db } = this.context;
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "工作流:聚合查询节点",
|
||||
"description": "Used to aggregate data against the database in workflow, such as: statistics, sum, average, etc.",
|
||||
"description.zh-CN": "可用于在工作流中对数据库进行聚合查询,如:统计数量、求和、平均值等。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/workflow-aggregate",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "工作流:延时节点",
|
||||
"description": "Could be used in workflow parallel branch for waiting other branches.",
|
||||
"description.zh-CN": "可用于工作流并行分支中等待其他分支执行完成。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/workflow-delay",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "工作流:动态表达式计算节点",
|
||||
"description": "Useful plugin for doing dynamic calculation based on expression collection records in workflow.",
|
||||
"description.zh-CN": "用于在工作流中进行基于数据行的动态表达式计算。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/workflow-dynamic-calculation",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "工作流:循环节点",
|
||||
"description": "Used to repeat the sub-process processing of each value in an array, and can also be used for fixed times of sub-process processing.",
|
||||
"description.zh-CN": "用于对一个数组中的每个值进行重复的子流程处理,也可用于固定次数的重复子流程处理。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/workflow-loop",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "工作流:人工处理节点",
|
||||
"description": "Could be used for workflows which some of decisions are made by users.",
|
||||
"description.zh-CN": "用于人工控制部分决策的流程。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/workflow-manual",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"displayName.zh-CN": "工作流:并行分支节点",
|
||||
"description": "Could be used for parallel execution of branch processes in the workflow.",
|
||||
"description.zh-CN": "用于在工作流中需要并行执行的分支流程。",
|
||||
"version": "0.20.0-alpha.5",
|
||||
"version": "0.20.0-alpha.7",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/workflow-parallel",
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user