mirror of
https://github.com/nocobase/nocobase
synced 2024-11-14 22:15:10 +00:00
fix(variable): fix issue of not parsing URL variables (#5454)
* fix(variable): fix issue of not parsing URL variables * test: add e2e test
This commit is contained in:
parent
495dde46ab
commit
32b3b76172
@ -8,7 +8,12 @@
|
||||
*/
|
||||
|
||||
import { expect, test } from '@nocobase/test/e2e';
|
||||
import { PopupAndSubPageWithParams, oneEmptyTableWithUsers, openInNewWidow } from './templates';
|
||||
import {
|
||||
PopupAndSubPageWithParams,
|
||||
URLSearchParamsUseAssociationFieldValue,
|
||||
oneEmptyTableWithUsers,
|
||||
openInNewWidow,
|
||||
} from './templates';
|
||||
|
||||
test.describe('Link', () => {
|
||||
test('basic', async ({ page, mockPage, mockRecords }) => {
|
||||
@ -140,4 +145,13 @@ test.describe('Link', () => {
|
||||
await page.reload();
|
||||
await expect(page.getByLabel('block-item-CollectionField-').getByRole('textbox')).toHaveValue('abc');
|
||||
});
|
||||
|
||||
test('URL search params: use association field value', async ({ page, mockPage, mockRecords }) => {
|
||||
await mockPage(URLSearchParamsUseAssociationFieldValue).goto();
|
||||
|
||||
// After clicking the Link button, the browser URL will change, and the value of the input box using variables will be updated
|
||||
await page.getByLabel('action-Action.Link-Link-').click();
|
||||
await page.waitForTimeout(100);
|
||||
await expect(page.getByLabel('block-item-CollectionField-')).toHaveText(`Roles:adminmemberroot`);
|
||||
});
|
||||
});
|
||||
|
@ -757,3 +757,317 @@ export const PopupAndSubPageWithParams = {
|
||||
'x-index': 1,
|
||||
},
|
||||
};
|
||||
export const URLSearchParamsUseAssociationFieldValue = {
|
||||
pageSchema: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Page',
|
||||
'x-app-version': '1.3.33-beta',
|
||||
properties: {
|
||||
gbfvfwym8ds: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid',
|
||||
'x-initializer': 'page:addBlock',
|
||||
'x-app-version': '1.3.33-beta',
|
||||
properties: {
|
||||
'33bst9cikf7': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Row',
|
||||
'x-app-version': '1.3.33-beta',
|
||||
properties: {
|
||||
fewb4k72bc8: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Col',
|
||||
'x-app-version': '1.3.33-beta',
|
||||
properties: {
|
||||
'5cfypzqvw57': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-decorator': 'TableBlockProvider',
|
||||
'x-acl-action': 'users:list',
|
||||
'x-use-decorator-props': 'useTableBlockDecoratorProps',
|
||||
'x-decorator-props': {
|
||||
collection: 'users',
|
||||
dataSource: 'main',
|
||||
action: 'list',
|
||||
params: {
|
||||
pageSize: 20,
|
||||
},
|
||||
rowKey: 'id',
|
||||
showIndex: true,
|
||||
dragSort: false,
|
||||
},
|
||||
'x-toolbar': 'BlockSchemaToolbar',
|
||||
'x-settings': 'blockSettings:table',
|
||||
'x-component': 'CardItem',
|
||||
'x-filter-targets': [],
|
||||
'x-app-version': '1.3.33-beta',
|
||||
properties: {
|
||||
actions: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-initializer': 'table:configureActions',
|
||||
'x-component': 'ActionBar',
|
||||
'x-component-props': {
|
||||
style: {
|
||||
marginBottom: 'var(--nb-spacing)',
|
||||
},
|
||||
},
|
||||
'x-app-version': '1.3.33-beta',
|
||||
'x-uid': '1xy1166yc9k',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
'6a59q3gjjqu': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'array',
|
||||
'x-initializer': 'table:configureColumns',
|
||||
'x-component': 'TableV2',
|
||||
'x-use-component-props': 'useTableBlockProps',
|
||||
'x-component-props': {
|
||||
rowKey: 'id',
|
||||
rowSelection: {
|
||||
type: 'checkbox',
|
||||
},
|
||||
},
|
||||
'x-app-version': '1.3.33-beta',
|
||||
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-toolbar': 'TableColumnSchemaToolbar',
|
||||
'x-initializer': 'table:configureItemActions',
|
||||
'x-settings': 'fieldSettings:TableColumn',
|
||||
'x-toolbar-props': {
|
||||
initializer: 'table:configureItemActions',
|
||||
},
|
||||
'x-app-version': '1.3.33-beta',
|
||||
properties: {
|
||||
lzxiek232g3: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-decorator': 'DndContext',
|
||||
'x-component': 'Space',
|
||||
'x-component-props': {
|
||||
split: '|',
|
||||
},
|
||||
'x-app-version': '1.3.33-beta',
|
||||
properties: {
|
||||
qhrjv5sk1tc: {
|
||||
'x-uid': 'o7zrp842yhz',
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
title: '{{ t("Link") }}',
|
||||
'x-action': 'customize:link',
|
||||
'x-toolbar': 'ActionSchemaToolbar',
|
||||
'x-settings': 'actionSettings:link',
|
||||
'x-component': 'Action.Link',
|
||||
'x-use-component-props': 'useLinkActionProps',
|
||||
'x-designer-props': {
|
||||
linkageAction: true,
|
||||
},
|
||||
'x-component-props': {
|
||||
url: '/admin/ids0d9esx8k',
|
||||
params: [
|
||||
{
|
||||
name: 'roles',
|
||||
value: '{{$nRecord.roles}}',
|
||||
},
|
||||
],
|
||||
},
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'y0m958j0dh0',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': '4d4wnl1b6xx',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': '238yee6oghy',
|
||||
'x-async': false,
|
||||
'x-index': 2,
|
||||
},
|
||||
},
|
||||
'x-uid': 'gjzmrbmobaf',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'z4rsa4oitvz',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': '6tec1zys03w',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
sbdgc6nmy9x: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Row',
|
||||
'x-app-version': '1.3.33-beta',
|
||||
properties: {
|
||||
'3sfuujjet76': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Col',
|
||||
'x-app-version': '1.3.33-beta',
|
||||
properties: {
|
||||
p3zmu2uua0x: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-acl-action-props': {
|
||||
skipScopeCheck: true,
|
||||
},
|
||||
'x-acl-action': 'users:create',
|
||||
'x-decorator': 'FormBlockProvider',
|
||||
'x-use-decorator-props': 'useCreateFormBlockDecoratorProps',
|
||||
'x-decorator-props': {
|
||||
dataSource: 'main',
|
||||
collection: 'users',
|
||||
},
|
||||
'x-toolbar': 'BlockSchemaToolbar',
|
||||
'x-settings': 'blockSettings:createForm',
|
||||
'x-component': 'CardItem',
|
||||
'x-app-version': '1.3.33-beta',
|
||||
properties: {
|
||||
'1oq2w1ia4jy': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'FormV2',
|
||||
'x-use-component-props': 'useCreateFormBlockProps',
|
||||
'x-app-version': '1.3.33-beta',
|
||||
properties: {
|
||||
grid: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid',
|
||||
'x-initializer': 'form:configureFields',
|
||||
'x-app-version': '1.3.33-beta',
|
||||
properties: {
|
||||
efdbxp35iht: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Row',
|
||||
'x-app-version': '1.3.33-beta',
|
||||
properties: {
|
||||
k40ivzy5kcu: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Col',
|
||||
'x-app-version': '1.3.33-beta',
|
||||
properties: {
|
||||
roles: {
|
||||
'x-uid': 'v8jvm1d9j8q',
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'string',
|
||||
'x-toolbar': 'FormItemSchemaToolbar',
|
||||
'x-settings': 'fieldSettings:FormItem',
|
||||
'x-component': 'CollectionField',
|
||||
'x-decorator': 'FormItem',
|
||||
'x-collection-field': 'users.roles',
|
||||
'x-component-props': {
|
||||
fieldNames: {
|
||||
label: 'name',
|
||||
value: 'name',
|
||||
},
|
||||
},
|
||||
'x-app-version': '1.3.33-beta',
|
||||
default: '{{$nURLSearchParams.roles}}',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': '3rs4fwe2gak',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'tuqcvp6tzbg',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'dz9070niyqm',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
'5mu8w85umxn': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-initializer': 'createForm:configureActions',
|
||||
'x-component': 'ActionBar',
|
||||
'x-component-props': {
|
||||
layout: 'one-column',
|
||||
},
|
||||
'x-app-version': '1.3.33-beta',
|
||||
'x-uid': 'xgak2t61ukm',
|
||||
'x-async': false,
|
||||
'x-index': 2,
|
||||
},
|
||||
},
|
||||
'x-uid': 'asfu0o75c3k',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'tgsr3gv33qk',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'pjd4g9evi3v',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'hj4wq3bdtip',
|
||||
'x-async': false,
|
||||
'x-index': 2,
|
||||
},
|
||||
},
|
||||
'x-uid': '1xgpa64dn71',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'ocal3pnltf2',
|
||||
'x-async': true,
|
||||
'x-index': 1,
|
||||
},
|
||||
keepUid: true,
|
||||
pageUid: 'ids0d9esx8k',
|
||||
};
|
||||
|
@ -108,9 +108,9 @@ const useParseDefaultValue = () => {
|
||||
fieldOperator: getOperator(fieldSchema.name),
|
||||
});
|
||||
|
||||
// fix https://tasks.aliyun.nocobase.com/admin/ugmnj2ycfgg/popups/1qlw5c38t3b/puid/dz42x7ffr7i/filterbytk/199
|
||||
if (
|
||||
collectionField.target &&
|
||||
collectionNameOfVariable &&
|
||||
collectionField.target !== collectionNameOfVariable &&
|
||||
!isInherit({
|
||||
collectionName: collectionField.target,
|
||||
|
@ -181,6 +181,8 @@ export interface PageConfig {
|
||||
pageSchema?: any;
|
||||
/** 如果为 true 则表示不会更改 PageSchema 的 uid */
|
||||
keepUid?: boolean;
|
||||
/** 在 URL 中的 uid,例如:/admin/0ig6xhe03u2 */
|
||||
pageUid?: string;
|
||||
}
|
||||
|
||||
export interface MobilePageConfig extends Omit<PageConfig, 'type'> {
|
||||
@ -199,6 +201,8 @@ interface CreatePageOptions {
|
||||
pageSchema?: any;
|
||||
/** 如果为 true 则表示不会更改 PageSchema 的 uid */
|
||||
keepUid?: boolean;
|
||||
/** 在 URL 中的 uid,例如:/admin/0ig6xhe03u2 */
|
||||
pageUid?: string;
|
||||
}
|
||||
|
||||
interface CreateMobilePageOptions extends Omit<CreatePageOptions, 'type'> {
|
||||
@ -346,6 +350,7 @@ export class NocoPage {
|
||||
pageSchema: this.options?.pageSchema,
|
||||
url: this.options?.url,
|
||||
keepUid: this.options?.keepUid,
|
||||
pageUid: this.options?.pageUid,
|
||||
}),
|
||||
);
|
||||
|
||||
@ -706,7 +711,7 @@ const updateUidOfPageSchema = (uiSchema: any) => {
|
||||
* 在 NocoBase 中创建一个页面
|
||||
*/
|
||||
const createPage = async (options?: CreatePageOptions) => {
|
||||
const { type = 'page', url, name, pageSchema, keepUid } = options || {};
|
||||
const { type = 'page', url, name, pageSchema, keepUid, pageUid: pageUidFromOptions } = options || {};
|
||||
const api = await request.newContext({
|
||||
storageState: process.env.PLAYWRIGHT_AUTH_FILE,
|
||||
});
|
||||
@ -728,7 +733,7 @@ const createPage = async (options?: CreatePageOptions) => {
|
||||
};
|
||||
const state = await api.storageState();
|
||||
const headers = getHeaders(state);
|
||||
const pageUid = uid();
|
||||
const pageUid = pageUidFromOptions || uid();
|
||||
const gridName = uid();
|
||||
|
||||
const result = await api.post(`/api/uiSchemas:insertAdjacent/nocobase-admin-menu?position=beforeEnd`, {
|
||||
|
Loading…
Reference in New Issue
Block a user