From 820352f280abd61ae43c5f29b37db889388ba044 Mon Sep 17 00:00:00 2001 From: Chareice Date: Sun, 17 Mar 2024 09:19:54 +0800 Subject: [PATCH 1/6] fix: console command --- packages/core/server/src/commands/console.ts | 25 +++++++++++--------- packages/core/server/src/commands/index.ts | 4 ++-- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/packages/core/server/src/commands/console.ts b/packages/core/server/src/commands/console.ts index ee80a3c85..1f2ea878d 100644 --- a/packages/core/server/src/commands/console.ts +++ b/packages/core/server/src/commands/console.ts @@ -3,16 +3,19 @@ import Application from '../application'; const REPL = require('repl'); export default (app: Application) => { - app.command('console').action(async () => { - await app.start(); - const repl = (REPL.start('nocobase > ').context.app = app); - repl.on('exit', async function (err) { - if (err) { - console.log(err); - process.exit(1); - } - await app.stop(); - process.exit(0); + app + .command('console') + .preload() + .action(async () => { + await app.start(); + const repl = (REPL.start('nocobase > ').context.app = app); + repl.on('exit', async function (err) { + if (err) { + console.log(err); + process.exit(1); + } + await app.stop(); + process.exit(0); + }); }); - }); }; diff --git a/packages/core/server/src/commands/index.ts b/packages/core/server/src/commands/index.ts index 4a0fd5709..c518ecb8d 100644 --- a/packages/core/server/src/commands/index.ts +++ b/packages/core/server/src/commands/index.ts @@ -11,9 +11,9 @@ import restart from './restart'; import start from './start'; import stop from './stop'; import upgrade from './upgrade'; - +import consoleCommand from './console'; export function registerCli(app: Application) { - // console(app); + consoleCommand(app); dbAuth(app); createMigration(app); dbClean(app); From 4cf560b177d9627e852ec03e40655393b50d2e5c Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Sun, 17 Mar 2024 09:26:35 +0800 Subject: [PATCH 2/6] fix(acl): invalid action permission judgment (#3735) * fix: x-acl-action is missing in action schema * fix: useACLRoleContext * fix: useACLRoleContext * fix: useACLRoleContext --- packages/core/client/src/acl/ACLProvider.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/client/src/acl/ACLProvider.tsx b/packages/core/client/src/acl/ACLProvider.tsx index 4467be742..35698ea8d 100644 --- a/packages/core/client/src/acl/ACLProvider.tsx +++ b/packages/core/client/src/acl/ACLProvider.tsx @@ -151,7 +151,7 @@ const useAllowedActions = () => { const useResourceName = () => { const service = useResourceActionContext(); const result = useBlockRequestContext() || { service }; - return result?.props?.resource || result?.service?.defaultRequest?.resource; + return result?.props?.resource || result?.props?.collection || result?.service?.defaultRequest?.resource; }; export function useACLRoleContext() { From 3be6b7c0c64ff5d41b214bbfd8f2c9684153e597 Mon Sep 17 00:00:00 2001 From: YANG QIA <2013xile@gmail.com> Date: Sun, 17 Mar 2024 15:16:06 +0800 Subject: [PATCH 3/6] fix(data-vi): association fields transform bug (#3737) * fix(data-vi): association fields transform bug * fix: bug --- .../src/client/chart/g2plot/dualAxes.ts | 3 +- .../src/client/chart/g2plot/g2plot.ts | 38 ++++--------------- 2 files changed, 8 insertions(+), 33 deletions(-) diff --git a/packages/plugins/@nocobase/plugin-data-visualization/src/client/chart/g2plot/dualAxes.ts b/packages/plugins/@nocobase/plugin-data-visualization/src/client/chart/g2plot/dualAxes.ts index 58e78f5fd..256948667 100644 --- a/packages/plugins/@nocobase/plugin-data-visualization/src/client/chart/g2plot/dualAxes.ts +++ b/packages/plugins/@nocobase/plugin-data-visualization/src/client/chart/g2plot/dualAxes.ts @@ -76,8 +76,7 @@ export class DualAxes extends G2PlotChart { yField, colorField: () => { const props = fieldProps[yField]; - const transformer = props?.transformer; - return props?.label || (transformer ? transformer(yField) : yField); + return props?.label || yField; }, axis: { y: { diff --git a/packages/plugins/@nocobase/plugin-data-visualization/src/client/chart/g2plot/g2plot.ts b/packages/plugins/@nocobase/plugin-data-visualization/src/client/chart/g2plot/g2plot.ts index fd73f177e..d9a041cad 100644 --- a/packages/plugins/@nocobase/plugin-data-visualization/src/client/chart/g2plot/g2plot.ts +++ b/packages/plugins/@nocobase/plugin-data-visualization/src/client/chart/g2plot/g2plot.ts @@ -1,4 +1,3 @@ -import { transform } from 'lodash'; import { Chart, ChartProps, ChartType, RenderProps } from '../chart'; import configs from './configs'; @@ -25,31 +24,17 @@ export class G2PlotChart extends Chart { }; getProps({ data, general, advanced, fieldProps }: RenderProps) { - const meta = {}; - // Some charts render wrong when the field name contains a dot in G2Plot - const replace = (key: string) => key.replace(/\./g, '_'); - general = Object.entries(general).reduce((obj, [key, value]) => { - obj[key] = value; - if (key.includes('Field')) { - if (Array.isArray(value)) { - obj[key] = value.map((v) => (v?.includes('.') ? replace(v) : v)); - } else if (typeof value === 'string' && value.includes('.')) { - obj[key] = replace(value); - } - } - return obj; - }, {}); const config = { legend: { color: { - itemLabelText: (datnum) => { - const props = fieldProps[datnum.label]; + itemLabelText: (datnum: { label: string }) => { + const props = fieldProps[general.seriesField]; const transformer = props?.transformer; - return props?.label || (transformer ? transformer(datnum.label) : datnum.label); + return transformer ? transformer(datnum.label) : datnum.label; }, }, }, - tooltip: (d, index, data, column) => { + tooltip: (d, index: number, data, column: any) => { const field = column.y.field; const props = fieldProps[field]; const name = props?.label || field; @@ -59,30 +44,21 @@ export class G2PlotChart extends Chart { }, axis: { x: { - labelFormatter: (datnum) => { + labelFormatter: (datnum: any) => { const props = fieldProps[general.xField]; const transformer = props?.transformer; return transformer ? transformer(datnum) : datnum; }, }, y: { - labelFormatter: (datnum) => { + labelFormatter: (datnum: any) => { const props = fieldProps[general.yField]; const transformer = props?.transformer; return transformer ? transformer(datnum) : datnum; }, }, }, - data: data.map((item) => { - const obj = {}; - Object.entries(item).forEach(([key, value]) => { - if (key.includes('.')) { - key = replace(key); - } - obj[key] = value; - }); - return obj; - }), + data, theme: 'classic', animate: { enter: { From 483f45765d52c1fbaf6ac2797b3d72b2d96c303c Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Sun, 17 Mar 2024 16:35:59 +0800 Subject: [PATCH 4/6] refactor: colDivider style improve for draging overing (#3709) * refactor: colDivider style improve for draging overing * refactor: stle improve * style: grid.Col style improve --- .../src/schema-component/antd/grid/Grid.tsx | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/packages/core/client/src/schema-component/antd/grid/Grid.tsx b/packages/core/client/src/schema-component/antd/grid/Grid.tsx index fe2edbfff..bd0adb590 100644 --- a/packages/core/client/src/schema-component/antd/grid/Grid.tsx +++ b/packages/core/client/src/schema-component/antd/grid/Grid.tsx @@ -448,8 +448,7 @@ Grid.Col = observer( } return { width }; }, [cols?.length, schema?.['x-component-props']?.['width']]); - - const { setNodeRef } = useDroppable({ + const { isOver, setNodeRef } = useDroppable({ id: field.address.toString(), data: { insertAdjacent: 'beforeEnd', @@ -457,9 +456,41 @@ Grid.Col = observer( wrapSchema: (s) => s, }, }); + const [active, setActive] = useState(false); + + const droppableStyle = useMemo(() => { + if (!isOver) + return { + height: '100%', + }; + + return { + background: `linear-gradient(to top, ${new TinyColor(token.colorSettings) + .setAlpha(0.1) + .toHex8String()} 20%, transparent 20%)`, + borderTopRightRadius: '10px', + borderTopLeftRadius: '10px', + height: '100%', + }; + }, [active, isOver]); + + useDndMonitor({ + onDragStart(event) { + setActive(true); + }, + onDragMove(event) {}, + onDragOver(event) {}, + onDragEnd(event) { + setActive(false); + }, + onDragCancel(event) { + setActive(false); + }, + }); + return ( -
+
{props.children}
From 93091a92f7cf8b9236e5aa2d0c01056f3ad96646 Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Sun, 17 Mar 2024 17:29:23 +0800 Subject: [PATCH 5/6] test(acl):column action acl e2e (#3738) * test: acl e2e test support new data block * test: acl e2e test support new data block * test: acl e2e test support new data block * test: acl e2e test support new data block --- .../src/client/__e2e__/collection.test.ts | 110 +++- .../plugin-acl/src/client/__e2e__/utils.ts | 570 ++++++++++++++++++ 2 files changed, 677 insertions(+), 3 deletions(-) diff --git a/packages/plugins/@nocobase/plugin-acl/src/client/__e2e__/collection.test.ts b/packages/plugins/@nocobase/plugin-acl/src/client/__e2e__/collection.test.ts index 5404b725b..c23b86510 100644 --- a/packages/plugins/@nocobase/plugin-acl/src/client/__e2e__/collection.test.ts +++ b/packages/plugins/@nocobase/plugin-acl/src/client/__e2e__/collection.test.ts @@ -1,5 +1,5 @@ import { expect, test } from '@nocobase/test/e2e'; -import { oneTableBlock } from './utils'; +import { oneTableBlock, newTableBlock } from './utils'; test.describe('view', () => { test('general permission', async ({ page, mockPage, mockRole, updateRole }) => { @@ -23,8 +23,9 @@ test.describe('view', () => { await page.reload(); await expect(page.getByLabel('block-item-CardItem-general-table')).toBeVisible(); }); - test('individual collection permission', async ({ page, mockPage, mockRole, updateRole }) => { + test('individual collection permission', async ({ page, mockPage, mockRole, mockRecord, updateRole }) => { await mockPage(oneTableBlock).goto(); + await mockRecord('general'); //新建角色并切换到新角色 const roleData = await mockRole({ allowNewMenu: true, @@ -56,6 +57,7 @@ test.describe('view', () => { }); await page.reload(); await expect(page.getByLabel('block-item-CardItem-general-table')).toBeVisible(); + await expect(page.getByLabel('action-Action.Link-View')).toBeVisible(); await expect(page.getByRole('button', { name: 'singleLineText' })).not.toBeVisible(); await expect(page.getByRole('button', { name: 'phone' })).not.toBeVisible(); }); @@ -258,6 +260,54 @@ test.describe('update', () => { await page.reload(); await expect(page.getByLabel('action-Action.Link-Edit')).toBeVisible(); }); + test('individual collection permission support new data block', async ({ + page, + mockPage, + mockRole, + mockRecord, + updateRole, + }) => { + await mockPage(newTableBlock).goto(); + await mockRecord('general'); + //新建角色并切换到新角色 + const roleData = await mockRole({ + allowNewMenu: true, + strategy: { + actions: ['update'], + }, + resources: [ + { + usingActionsConfig: true, + name: 'general', + actions: [{ name: 'view' }], + }, + ], + }); + await page.evaluate((roleData) => { + window.localStorage.setItem('NOCOBASE_ROLE', roleData.name); + }, roleData); + await page.reload(); + await mockPage(newTableBlock).goto(); + await expect(page.getByLabel('block-item-CardItem-general-table')).toBeVisible(); + await expect(page.getByLabel('action-Action.Link-Edit')).not.toBeVisible(); + await updateRole({ + name: roleData.name, + resources: [ + { + usingActionsConfig: true, + name: 'general', + actions: [ + { + name: 'view', + }, + { name: 'update' }, + ], + }, + ], + }); + await page.reload(); + await expect(page.getByLabel('action-Action.Link-Edit')).toBeVisible(); + }); test('individual collection permission with fields', async ({ page, mockPage, mockRole, mockRecord }) => { await mockPage(oneTableBlock).goto(); await mockRecord('general'); @@ -311,7 +361,7 @@ test.describe('destroy', () => { await page.reload(); await expect(page.getByLabel('action-Action-Delete-destroy-general-table')).toBeVisible(); }); - test('individual collection permission', async ({ page, mockPage, mockRole, updateRole }) => { + test('individual collection permission', async ({ page, mockPage, mockRole, mockRecord, updateRole }) => { await mockPage().goto(); //新建角色并切换到新角色 const roleData = await mockRole({ @@ -332,8 +382,11 @@ test.describe('destroy', () => { }, roleData); await page.reload(); await mockPage(oneTableBlock).goto(); + await mockRecord('general'); await expect(page.getByLabel('block-item-CardItem-general-table')).toBeVisible(); await expect(page.getByLabel('action-Action-Delete-destroy-general-table')).not.toBeVisible(); + await expect(page.getByLabel('action-Action.Link-Delete')).not.toBeVisible(); + await updateRole({ name: roleData.name, resources: [ @@ -351,6 +404,57 @@ test.describe('destroy', () => { }); await page.reload(); await expect(page.getByLabel('action-Action-Delete-destroy-general-table')).toBeVisible(); + await expect(page.getByLabel('action-Action.Link-Delete')).toBeVisible(); + }); + test('individual collection permission support new data block', async ({ + page, + mockPage, + mockRole, + mockRecord, + updateRole, + }) => { + await mockPage().goto(); + //新建角色并切换到新角色 + const roleData = await mockRole({ + allowNewMenu: true, + strategy: { + actions: ['destroy'], + }, + resources: [ + { + usingActionsConfig: true, + name: 'general', + actions: [{ name: 'view' }], + }, + ], + }); + await page.evaluate((roleData) => { + window.localStorage.setItem('NOCOBASE_ROLE', roleData.name); + }, roleData); + await page.reload(); + await mockPage(newTableBlock).goto(); + await mockRecord('general'); + await expect(page.getByLabel('block-item-CardItem-general-table')).toBeVisible(); + await expect(page.getByLabel('action-Action-Delete-destroy-general-table')).not.toBeVisible(); + await expect(page.getByLabel('action-Action.Link-Delete-')).not.toBeVisible(); + await updateRole({ + name: roleData.name, + resources: [ + { + usingActionsConfig: true, + name: 'general', + actions: [ + { + name: 'view', + }, + { name: 'destroy' }, + ], + }, + ], + }); + await page.reload(); + await expect(page.getByLabel('action-Action-Delete-destroy-general-table')).toBeVisible(); + await expect(page.getByLabel('action-Action.Link-Delete-')).toBeVisible(); }); }); diff --git a/packages/plugins/@nocobase/plugin-acl/src/client/__e2e__/utils.ts b/packages/plugins/@nocobase/plugin-acl/src/client/__e2e__/utils.ts index d61e9c282..c67278a46 100644 --- a/packages/plugins/@nocobase/plugin-acl/src/client/__e2e__/utils.ts +++ b/packages/plugins/@nocobase/plugin-acl/src/client/__e2e__/utils.ts @@ -2182,6 +2182,34 @@ export const oneTableBlock: PageConfig = { 'x-async': false, 'x-index': 4, }, + k4602nzuf6r: { + _isJSONSchemaObject: true, + version: '2.0', + title: '{{ t("Delete") }}', + 'x-action': 'destroy', + 'x-component': 'Action.Link', + 'x-toolbar': 'ActionSchemaToolbar', + 'x-settings': 'actionSettings:delete', + 'x-component-props': { + icon: 'DeleteOutlined', + confirm: { + title: "{{t('Delete record')}}", + content: "{{t('Are you sure you want to delete it?')}}", + }, + useProps: '{{ useDestroyActionProps }}', + }, + 'x-action-settings': { + triggerWorkflows: [], + }, + 'x-decorator': 'ACLActionProvider', + 'x-designer-props': { + linkageAction: true, + }, + type: 'void', + 'x-uid': 'a6mt7vf9g67', + 'x-async': false, + 'x-index': 5, + }, }, 'x-uid': 'mi05lvz5sj2', 'x-async': false, @@ -2548,3 +2576,545 @@ export const oneTableBlock: PageConfig = { 'x-index': 1, }, }; + +export const newTableBlock: PageConfig = { + collections: general, + pageSchema: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Page', + properties: { + '46txyuq0grs': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid', + 'x-initializer': 'page:addBlock', + properties: { + zahcrjgcnp9: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid.Row', + properties: { + au2rt1euteu: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid.Col', + properties: { + ml4odxr7n6g: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-decorator': 'TableBlockProvider', + 'x-acl-action': 'general:list', + 'x-decorator-props': { + collection: 'general', + dataSource: 'main', + action: 'list', + params: { + pageSize: 20, + }, + rowKey: 'id', + showIndex: true, + dragSort: false, + disableTemplate: false, + }, + 'x-toolbar': 'BlockSchemaToolbar', + 'x-settings': 'blockSettings:table', + 'x-component': 'CardItem', + 'x-filter-targets': [], + properties: { + actions: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-initializer': 'table:configureActions', + 'x-component': 'ActionBar', + 'x-component-props': { + style: { + marginBottom: 'var(--nb-spacing)', + }, + }, + properties: { + slrfnm3niyj: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + title: '{{ t("Bulk update") }}', + 'x-component': 'Action', + 'x-align': 'right', + 'x-acl-action': 'update', + 'x-decorator': 'ACLActionProvider', + 'x-acl-action-props': { + skipScopeCheck: true, + }, + 'x-action': 'customize:bulkUpdate', + 'x-toolbar': 'ActionSchemaToolbar', + 'x-settings': 'actionSettings:bulkUpdate', + 'x-action-settings': { + assignedValues: {}, + updateMode: 'selected', + onSuccess: { + manualClose: true, + redirecting: false, + successMessage: '{{t("Updated successfully")}}', + }, + }, + 'x-component-props': { + icon: 'EditOutlined', + useProps: '{{ useCustomizeBulkUpdateActionProps }}', + }, + 'x-uid': 'n1qxijc21mx', + 'x-async': false, + 'x-index': 1, + }, + '2zkhhoww1fr': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + title: '{{t("Bulk edit")}}', + 'x-component': 'Action', + 'x-action': 'customize:bulkEdit', + 'x-action-settings': { + updateMode: 'selected', + }, + 'x-component-props': { + openMode: 'drawer', + icon: 'EditOutlined', + }, + 'x-align': 'right', + 'x-decorator': 'ACLActionProvider', + 'x-toolbar': 'ActionSchemaToolbar', + 'x-settings': 'actionSettings:bulkEdit', + 'x-acl-action': 'update', + 'x-acl-action-props': { + skipScopeCheck: true, + }, + properties: { + drawer: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + title: '{{t("Bulk edit")}}', + 'x-component': 'Action.Container', + 'x-component-props': { + className: 'nb-action-popup', + }, + properties: { + tabs: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Tabs', + 'x-component-props': {}, + 'x-initializer': 'TabPaneInitializersForBulkEditFormBlock', + properties: { + tab1: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + title: '{{t("Bulk edit")}}', + 'x-component': 'Tabs.TabPane', + 'x-designer': 'Tabs.Designer', + 'x-component-props': {}, + properties: { + grid: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid', + 'x-initializer': 'popup:bulkEdit:addBlock', + 'x-uid': '8nuffbe34bb', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': '4oldm9wc10s', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': '194thgnvcpy', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': '1x3ly7atx00', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': '75x1gquc69a', + 'x-async': false, + 'x-index': 2, + }, + huteob4p7ua: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-action': 'create', + 'x-acl-action': 'create', + title: "{{t('Add new')}}", + 'x-toolbar': 'ActionSchemaToolbar', + 'x-settings': 'actionSettings:addNew', + 'x-component': 'Action', + 'x-decorator': 'ACLActionProvider', + 'x-component-props': { + openMode: 'drawer', + type: 'primary', + component: 'CreateRecordAction', + icon: 'PlusOutlined', + }, + 'x-align': 'right', + 'x-acl-action-props': { + skipScopeCheck: true, + }, + properties: { + drawer: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + title: '{{ t("Add record") }}', + 'x-component': 'Action.Container', + 'x-component-props': { + className: 'nb-action-popup', + }, + properties: { + tabs: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Tabs', + 'x-component-props': {}, + 'x-initializer': 'TabPaneInitializersForCreateFormBlock', + properties: { + tab1: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + title: '{{t("Add new")}}', + 'x-component': 'Tabs.TabPane', + 'x-designer': 'Tabs.Designer', + 'x-component-props': {}, + properties: { + grid: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid', + 'x-initializer': 'popup:addNew:addBlock', + 'x-uid': 'yjj9tl588o1', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': '0zjlqupqrd0', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'sjmso5vq3bc', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': '131b76phmyr', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': '4ekiy4xn5ip', + 'x-async': false, + 'x-index': 3, + }, + xi969uyvexr: { + _isJSONSchemaObject: true, + version: '2.0', + title: '{{ t("Delete") }}', + 'x-action': 'destroy', + 'x-component': 'Action', + 'x-toolbar': 'ActionSchemaToolbar', + 'x-settings': 'actionSettings:bulkDelete', + 'x-decorator': 'ACLActionProvider', + 'x-acl-action-props': { + skipScopeCheck: true, + }, + 'x-component-props': { + icon: 'DeleteOutlined', + confirm: { + title: "{{t('Delete record')}}", + content: "{{t('Are you sure you want to delete it?')}}", + }, + useProps: '{{ useBulkDestroyActionProps }}', + }, + 'x-action-settings': { + triggerWorkflows: [], + }, + 'x-acl-action': 'general:destroy', + 'x-align': 'right', + type: 'void', + 'x-uid': 'x5nhm8j5prk', + 'x-async': false, + 'x-index': 4, + }, + }, + 'x-uid': 's99upcj5h12', + 'x-async': false, + 'x-index': 1, + }, + '1pflm3akx4z': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'array', + 'x-initializer': 'table:configureColumns', + 'x-component': 'TableV2', + 'x-component-props': { + rowKey: 'id', + rowSelection: { + type: 'checkbox', + }, + useProps: '{{ useTableBlockProps }}', + }, + properties: { + actions: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + title: '{{ t("Actions") }}', + 'x-action-column': 'actions', + 'x-decorator': 'TableV2.Column.ActionBar', + 'x-component': 'TableV2.Column', + 'x-designer': 'TableV2.ActionColumnDesigner', + 'x-initializer': 'table:configureItemActions', + properties: { + '0vgecinvudu': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-decorator': 'DndContext', + 'x-component': 'Space', + 'x-component-props': { + split: '|', + }, + properties: { + kieddfdng7p: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + title: '{{ t("View") }}', + 'x-action': 'view', + 'x-toolbar': 'ActionSchemaToolbar', + 'x-settings': 'actionSettings:view', + 'x-component': 'Action.Link', + 'x-component-props': { + openMode: 'drawer', + }, + 'x-decorator': 'ACLActionProvider', + 'x-designer-props': { + linkageAction: true, + }, + properties: { + drawer: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + title: '{{ t("View record") }}', + 'x-component': 'Action.Container', + 'x-component-props': { + className: 'nb-action-popup', + }, + properties: { + tabs: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Tabs', + 'x-component-props': {}, + 'x-initializer': 'TabPaneInitializers', + properties: { + tab1: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + title: '{{t("Details")}}', + 'x-component': 'Tabs.TabPane', + 'x-designer': 'Tabs.Designer', + 'x-component-props': {}, + properties: { + grid: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid', + 'x-initializer': 'popup:common:addBlock', + 'x-uid': '2k0540e57ol', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 's7gi356fs70', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': '8grec6h6mtp', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'assiov38tvg', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'utm143emmhc', + 'x-async': false, + 'x-index': 1, + }, + is523lf1al3: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + title: '{{ t("Edit") }}', + 'x-action': 'update', + 'x-toolbar': 'ActionSchemaToolbar', + 'x-settings': 'actionSettings:edit', + 'x-component': 'Action.Link', + 'x-component-props': { + openMode: 'drawer', + icon: 'EditOutlined', + }, + 'x-decorator': 'ACLActionProvider', + 'x-designer-props': { + linkageAction: true, + }, + properties: { + drawer: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + title: '{{ t("Edit record") }}', + 'x-component': 'Action.Container', + 'x-component-props': { + className: 'nb-action-popup', + }, + properties: { + tabs: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Tabs', + 'x-component-props': {}, + 'x-initializer': 'TabPaneInitializers', + properties: { + tab1: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + title: '{{t("Edit")}}', + 'x-component': 'Tabs.TabPane', + 'x-designer': 'Tabs.Designer', + 'x-component-props': {}, + properties: { + grid: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid', + 'x-initializer': 'popup:common:addBlock', + 'x-uid': 'wsyp993s4e3', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'cffbmo4sb6k', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': '9dwrb18ntjm', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'rz924lz6i2u', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'nkrdjd1jz5j', + 'x-async': false, + 'x-index': 2, + }, + k4602nzuf6r: { + _isJSONSchemaObject: true, + version: '2.0', + title: '{{ t("Delete") }}', + 'x-action': 'destroy', + 'x-component': 'Action.Link', + 'x-toolbar': 'ActionSchemaToolbar', + 'x-settings': 'actionSettings:delete', + 'x-component-props': { + icon: 'DeleteOutlined', + confirm: { + title: "{{t('Delete record')}}", + content: "{{t('Are you sure you want to delete it?')}}", + }, + useProps: '{{ useDestroyActionProps }}', + }, + 'x-action-settings': { + triggerWorkflows: [], + }, + 'x-decorator': 'ACLActionProvider', + 'x-designer-props': { + linkageAction: true, + }, + type: 'void', + 'x-uid': 'a6mt7vf9g67', + 'x-async': false, + 'x-index': 3, + }, + }, + 'x-uid': '7q9j7135hk4', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'c8iecn06wyp', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'm0blrbf9bzr', + 'x-async': false, + 'x-index': 2, + }, + }, + 'x-uid': '63uhxny4lrn', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'tcne2atmx0n', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'bk1yx2i13k8', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'if4rb336r5q', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': '532o6vwg8bi', + 'x-async': true, + 'x-index': 1, + }, +}; From 7e32842a6dcebc8edc24a56c0e5563d021974005 Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Sun, 17 Mar 2024 22:16:11 +0800 Subject: [PATCH 6/6] fix: collections undefined inuseCollectionState (#3741) --- .../src/collection-manager/mixins/InheritanceCollectionMixin.ts | 2 +- .../schema-settings/DataTemplates/hooks/useCollectionState.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/client/src/collection-manager/mixins/InheritanceCollectionMixin.ts b/packages/core/client/src/collection-manager/mixins/InheritanceCollectionMixin.ts index fb199d692..3f9549c27 100644 --- a/packages/core/client/src/collection-manager/mixins/InheritanceCollectionMixin.ts +++ b/packages/core/client/src/collection-manager/mixins/InheritanceCollectionMixin.ts @@ -193,7 +193,7 @@ export class InheritanceCollectionMixin extends Collection { }; this.allCollectionsInheritChain = getInheritChain(this.name); - return this.allCollectionsInheritChain; + return this.allCollectionsInheritChain || []; } getInheritCollectionsChain() { diff --git a/packages/core/client/src/schema-settings/DataTemplates/hooks/useCollectionState.ts b/packages/core/client/src/schema-settings/DataTemplates/hooks/useCollectionState.ts index 894841639..5beb6deb8 100644 --- a/packages/core/client/src/schema-settings/DataTemplates/hooks/useCollectionState.ts +++ b/packages/core/client/src/schema-settings/DataTemplates/hooks/useCollectionState.ts @@ -26,7 +26,7 @@ export const useCollectionState = (currentCollectionName: string) => { const templateField: any = useField(); function getCollectionList() { - const collections = getAllCollectionsInheritChain(currentCollectionName); + const collections = getAllCollectionsInheritChain(currentCollectionName) || []; return collections.map((name) => ({ label: getCollection(name)?.title, value: name })); }