Skip to content

Commit

Permalink
fix: table row action linkage rule defect error (#4436)
Browse files Browse the repository at this point in the history
* fix: useCurrentFormVariable

* test: table action row action linkage by row data

* test: detail block support linkage rule

* test: detail block support linkage rule

* test: detail block support linkage rule
  • Loading branch information
Katherine committed May 21, 2024
1 parent d62f611 commit 3f14a9b
Show file tree
Hide file tree
Showing 5 changed files with 586 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
test,
expect,
} from '@nocobase/test/e2e';
import { detailBlockWithLinkageRule } from './templatesOfBug';
import { detailBlockWithLinkageRule, detailsBlockWithLinkageRule } from './templatesOfBug';

test.describe('multi data details block schema settings', () => {
test('supported options', async ({ page, mockPage, mockRecord }) => {
Expand Down Expand Up @@ -51,6 +51,13 @@ test.describe('multi data details block schema settings', () => {
await page.reload();
await expect(page.getByLabel('block-item-CollectionField-users-details-users.email-Email')).toBeVisible();
});
test('multi detail block support linkage rule', async ({ page, mockPage }) => {
const nocoPage = await mockPage(detailsBlockWithLinkageRule).waitForInit();
await nocoPage.goto();
await expect(await page.getByLabel('block-item-CollectionField-roles-details-roles.title')).not.toBeVisible();
await page.getByRole('button', { name: 'right' }).click();
await expect(await page.getByLabel('block-item-CollectionField-roles-details-roles.title')).toBeVisible();
});
});

test.describe('actions schema settings', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1328,3 +1328,233 @@ export const detailBlockWithLinkageRule = {
'x-index': 1,
},
};

//翻页
export const detailsBlockWithLinkageRule = {
pageSchema: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Page',
'x-app-version': '1.0.0-alpha.15',
properties: {
s0cyq6zg42k: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid',
'x-initializer': 'page:addBlock',
'x-app-version': '1.0.0-alpha.15',
properties: {
vtjrbevb2r2: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Row',
'x-app-version': '1.0.0-alpha.15',
properties: {
ql4nxn8v031: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Col',
'x-app-version': '1.0.0-alpha.15',
properties: {
'17o39djmjom': {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-acl-action': 'roles:view',
'x-decorator': 'DetailsBlockProvider',
'x-use-decorator-props': 'useDetailsWithPaginationDecoratorProps',
'x-decorator-props': {
dataSource: 'main',
collection: 'roles',
readPretty: true,
action: 'list',
params: {
pageSize: 1,
},
},
'x-toolbar': 'BlockSchemaToolbar',
'x-settings': 'blockSettings:detailsWithPagination',
'x-component': 'CardItem',
'x-app-version': '1.0.0-alpha.15',
properties: {
vge14uwsfcx: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Details',
'x-read-pretty': true,
'x-use-component-props': 'useDetailsWithPaginationProps',
'x-app-version': '1.0.0-alpha.15',
properties: {
p1oiur6ch01: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-initializer': 'details:configureActions',
'x-component': 'ActionBar',
'x-component-props': {
style: {
marginBottom: 24,
},
},
'x-app-version': '1.0.0-alpha.15',
'x-uid': 'o6l10d94uyu',
'x-async': false,
'x-index': 1,
},
grid: {
'x-uid': 'ndhiwwmhgd3',
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid',
'x-initializer': 'details:configureFields',
'x-app-version': '1.0.0-alpha.15',
'x-linkage-rules': [
{
condition: {
$and: [
{
name: {
$includes: 'admin',
},
},
],
},
actions: [
{
targetFields: ['title'],
operator: 'none',
},
],
},
],
properties: {
'12azgfqtzgg': {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Row',
'x-app-version': '1.0.0-alpha.15',
properties: {
'3huf8qty79r': {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Col',
'x-app-version': '1.0.0-alpha.15',
properties: {
name: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'string',
'x-toolbar': 'FormItemSchemaToolbar',
'x-settings': 'fieldSettings:FormItem',
'x-component': 'CollectionField',
'x-decorator': 'FormItem',
'x-collection-field': 'roles.name',
'x-component-props': {},
'x-app-version': '1.0.0-alpha.15',
'x-uid': 'nlga5pyt4nh',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'nt7vszbunlp',
'x-async': false,
'x-index': 1,
},
},
'x-uid': '5ipi32fnhbw',
'x-async': false,
'x-index': 1,
},
'8jptrhtlnau': {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Row',
'x-app-version': '1.0.0-alpha.15',
properties: {
kjmsoxflttl: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Col',
'x-app-version': '1.0.0-alpha.15',
properties: {
title: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'string',
'x-toolbar': 'FormItemSchemaToolbar',
'x-settings': 'fieldSettings:FormItem',
'x-component': 'CollectionField',
'x-decorator': 'FormItem',
'x-collection-field': 'roles.title',
'x-component-props': {},
'x-app-version': '1.0.0-alpha.15',
'x-uid': '018038od8qu',
'x-async': false,
'x-index': 1,
},
},
'x-uid': '1tf62y66ucg',
'x-async': false,
'x-index': 1,
},
},
'x-uid': '53tuarteip2',
'x-async': false,
'x-index': 2,
},
},
'x-async': false,
'x-index': 2,
},
pagination: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Pagination',
'x-use-component-props': 'useDetailsPaginationProps',
'x-app-version': '1.0.0-alpha.15',
'x-uid': 'fi9s6c663yz',
'x-async': false,
'x-index': 3,
},
},
'x-uid': 'nbrmybpedgx',
'x-async': false,
'x-index': 1,
},
},
'x-uid': '6j7ofcubttd',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'zv7yvwqnaap',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'boyw74bb12g',
'x-async': false,
'x-index': 1,
},
},
'x-uid': '1mcq8no0n7j',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'duuivmvaoaa',
'x-async': true,
'x-index': 1,
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* This file is part of the NocoBase (R) project.
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
* Authors: NocoBase Team.
*
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
* For more information, please refer to: https://www.nocobase.com/agreement.
*/

import { expect, test } from '@nocobase/test/e2e';
import { T4334 } from '../templatesOfBug';

// fix https://nocobase.height.app/T-2187
test('action linkage by row data', async ({ page, mockPage }) => {
await mockPage(T4334).goto();
const adminEditAction = await page.getByLabel('action-Action.Link-Edit-update-roles-table-admin');
const adminEditActionStyle = await adminEditAction.evaluate((element) => {
const computedStyle = window.getComputedStyle(element);
return {
opacity: computedStyle.opacity,
};
});
const rootEditAction = await page.getByLabel('action-Action.Link-Edit-update-roles-table-root');
const rootEditActionStyle = await rootEditAction.evaluate((element) => {
const computedStyle = window.getComputedStyle(element);
return {
opacity: computedStyle.opacity,
// 添加其他你需要的样式属性
};
});

await expect(adminEditActionStyle.opacity).not.toBe('0.1');
await expect(rootEditActionStyle.opacity).not.toBe('1');
});
Loading

0 comments on commit 3f14a9b

Please sign in to comment.