@nocobase/client-v2 2.2.0-beta.8 → 2.3.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/APIClient.d.ts +1 -3
- package/es/BaseApplication.d.ts +3 -0
- package/es/RouteRepository.d.ts +8 -0
- package/es/RouterManager.d.ts +15 -0
- package/es/authRedirect.d.ts +1 -0
- package/es/collection-field-interface/CollectionFieldInterface.d.ts +1 -0
- package/es/collection-field-interface/CollectionFieldInterfaceManager.d.ts +1 -0
- package/es/components/category-tabs/SortableCategoryTabs.d.ts +55 -0
- package/es/components/category-tabs/index.d.ts +9 -0
- package/es/components/form/ScanInput/useCodeScanner.d.ts +2 -1
- package/es/components/form/TypedVariableInput.d.ts +31 -5
- package/es/components/form/filter/CollectionFilter.d.ts +2 -0
- package/es/components/form/filter/CollectionFilterItem.d.ts +11 -1
- package/es/components/form/filter/CollectionFilterPanel.d.ts +2 -0
- package/es/components/form/filter/index.d.ts +2 -0
- package/es/components/form/filter/useFilterActionProps.d.ts +2 -0
- package/es/components/index.d.ts +1 -0
- package/es/entry-actions/EntryActionManager.d.ts +24 -0
- package/es/entry-actions/index.d.ts +9 -0
- package/es/flow/actions/index.d.ts +1 -1
- package/es/flow/actions/linkageRules.d.ts +2 -0
- package/es/flow/admin-shell/BaseLayoutModel.d.ts +6 -0
- package/es/flow/admin-shell/BaseLayoutRouteCoordinator.d.ts +7 -0
- package/es/flow/admin-shell/admin-layout/AdminLayoutMenuModels.d.ts +1 -0
- package/es/flow/admin-shell/admin-layout/AppListRender.d.ts +2 -1
- package/es/flow/admin-shell/admin-layout/AppSwitcherActionPanelModel.d.ts +24 -0
- package/es/flow/admin-shell/admin-layout/index.d.ts +1 -0
- package/es/flow/admin-shell/admin-layout/useApplications.d.ts +7 -2
- package/es/flow/components/FieldAssignExactDatePicker.d.ts +1 -0
- package/es/flow/components/FieldAssignValueInput.d.ts +9 -0
- package/es/flow/components/RunJSValueEditor.d.ts +1 -0
- package/es/flow/components/filter/FilterGroup.d.ts +1 -0
- package/es/flow/components/filter/VariableFilterItem.d.ts +6 -1
- package/es/flow/index.d.ts +1 -0
- package/es/flow/models/base/ActionModelCore.d.ts +2 -0
- package/es/flow/models/base/PageModel/PageModel.d.ts +12 -0
- package/es/flow/models/base/PageModel/PageModelTabBar.d.ts +22 -0
- package/es/flow/models/base/PageModel/PageTabModel.d.ts +12 -0
- package/es/flow/models/blocks/form/QuickEditFormModel.d.ts +17 -2
- package/es/flow/routeTransientInputArgs.d.ts +14 -0
- package/es/flow-compat/fieldValidationConstants.d.ts +1 -1
- package/es/flow-compat/routeTypes.d.ts +1 -0
- package/es/index.d.ts +6 -0
- package/es/index.mjs +279 -158
- package/es/utils/getRouteRuntimeVersion.d.ts +23 -0
- package/es/utils/index.d.ts +1 -0
- package/es/utils/markdownSanitize.d.ts +11 -0
- package/lib/index.js +280 -159
- package/lib/locale/languageCodes.js +2 -1
- package/package.json +8 -7
- package/src/APIClient.ts +1 -10
- package/src/Application.tsx +4 -0
- package/src/BaseApplication.tsx +13 -6
- package/src/RouteRepository.ts +25 -0
- package/src/RouterManager.tsx +142 -1
- package/src/__tests__/RouteRepository.test.ts +23 -0
- package/src/__tests__/RouterManager.test.ts +125 -0
- package/src/__tests__/app.test.tsx +73 -0
- package/src/__tests__/authRedirect.test.ts +17 -0
- package/src/__tests__/browserChecker.test.ts +61 -0
- package/src/__tests__/getRouteRuntimeVersion.test.ts +68 -0
- package/src/__tests__/nocobase-buildin-plugin-auth.test.tsx +28 -0
- package/src/authRedirect.ts +38 -0
- package/src/collection-field-interface/CollectionFieldInterface.ts +1 -0
- package/src/collection-field-interface/CollectionFieldInterfaceManager.ts +1 -0
- package/src/collection-manager/field-validation.ts +1 -1
- package/src/components/README.md +7 -1
- package/src/components/README.zh-CN.md +6 -1
- package/src/components/category-tabs/SortableCategoryTabs.tsx +210 -0
- package/src/components/category-tabs/index.ts +10 -0
- package/src/components/form/JsonTextArea.tsx +4 -0
- package/src/components/form/ScanInput/CodeScanner.tsx +23 -6
- package/src/components/form/ScanInput/__tests__/useCodeScanner.test.tsx +180 -3
- package/src/components/form/ScanInput/useCodeScanner.ts +170 -5
- package/src/components/form/TypedVariableInput.tsx +452 -101
- package/src/components/form/__tests__/TypedVariableInput.test.tsx +364 -12
- package/src/components/form/filter/CollectionFilter.tsx +4 -0
- package/src/components/form/filter/CollectionFilterItem.tsx +32 -7
- package/src/components/form/filter/CollectionFilterPanel.tsx +4 -0
- package/src/components/form/filter/__tests__/CollectionFilterItem.test.tsx +38 -0
- package/src/components/form/filter/__tests__/useFilterActionProps.test.tsx +95 -0
- package/src/components/form/filter/index.ts +2 -0
- package/src/components/form/filter/useFilterActionProps.ts +37 -6
- package/src/components/index.ts +1 -0
- package/src/entry-actions/EntryActionManager.ts +76 -0
- package/src/entry-actions/index.ts +10 -0
- package/src/flow/FlowPage.tsx +38 -3
- package/src/flow/__tests__/FlowPage.test.tsx +201 -27
- package/src/flow/__tests__/FlowRoute.test.tsx +549 -4
- package/src/flow/actions/__tests__/dataScopeFilter.test.ts +62 -0
- package/src/flow/actions/__tests__/linkageRules.tab.test.ts +171 -0
- package/src/flow/actions/__tests__/linkageRulesRefresh.test.ts +7 -3
- package/src/flow/actions/__tests__/openView.defineProps.route.test.tsx +80 -20
- package/src/flow/actions/dataScopeFilter.ts +10 -1
- package/src/flow/actions/dateTimeFormat.tsx +2 -2
- package/src/flow/actions/index.ts +2 -0
- package/src/flow/actions/linkageRules.tsx +86 -11
- package/src/flow/actions/linkageRulesRefresh.tsx +2 -6
- package/src/flow/actions/openView.tsx +21 -1
- package/src/flow/admin-shell/BaseLayoutModel.tsx +124 -0
- package/src/flow/admin-shell/BaseLayoutRouteCoordinator.ts +184 -42
- package/src/flow/admin-shell/__tests__/AdminLayoutRouteCoordinator.test.ts +1016 -119
- package/src/flow/admin-shell/admin-layout/AdminLayoutComponent.tsx +41 -5
- package/src/flow/admin-shell/admin-layout/AdminLayoutEntryGuard.test.tsx +177 -1
- package/src/flow/admin-shell/admin-layout/AdminLayoutEntryGuard.tsx +20 -0
- package/src/flow/admin-shell/admin-layout/AppListRender.tsx +13 -2
- package/src/flow/admin-shell/admin-layout/AppSwitcherActionPanelModel.tsx +289 -0
- package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutComponent.test.tsx +253 -6
- package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutModel.test.tsx +436 -2
- package/src/flow/admin-shell/admin-layout/__tests__/TopbarActionsBar.test.tsx +48 -0
- package/src/flow/admin-shell/admin-layout/index.ts +1 -0
- package/src/flow/admin-shell/admin-layout/useApplications.tsx +81 -12
- package/src/flow/common/Markdown/Display.tsx +14 -3
- package/src/flow/common/Markdown/Edit.tsx +19 -7
- package/src/flow/components/FieldAssignExactDatePicker.tsx +25 -11
- package/src/flow/components/FieldAssignValueInput.tsx +91 -20
- package/src/flow/components/FlowRoute.tsx +134 -18
- package/src/flow/components/RunJSValueEditor.tsx +9 -1
- package/src/flow/components/__tests__/FieldAssignValueInput.context.test.tsx +216 -0
- package/src/flow/components/filter/FilterGroup.tsx +33 -5
- package/src/flow/components/filter/VariableFilterItem.tsx +158 -10
- package/src/flow/components/filter/__tests__/FilterGroup.test.tsx +45 -0
- package/src/flow/components/filter/__tests__/VariableFilterItem.leftMetaTree.test.tsx +9 -0
- package/src/flow/components/filter/__tests__/VariableFilterItem.test.tsx +70 -1
- package/src/flow/index.ts +1 -0
- package/src/flow/internal/components/Markdown/util.ts +2 -1
- package/src/flow/models/base/ActionModel.tsx +10 -8
- package/src/flow/models/base/ActionModelCore.tsx +5 -0
- package/src/flow/models/base/PageModel/PageModel.tsx +387 -53
- package/src/flow/models/base/PageModel/PageModelTabBar.tsx +114 -0
- package/src/flow/models/base/PageModel/PageTabModel.tsx +184 -3
- package/src/flow/models/base/PageModel/__tests__/PageModel.test.ts +790 -10
- package/src/flow/models/base/PageModel/__tests__/PageModelTabBar.module-isolation.test.tsx +130 -0
- package/src/flow/models/base/PageModel/__tests__/PageModelTabBar.test.tsx +118 -0
- package/src/flow/models/base/PageModel/__tests__/PageTabModel.test.ts +572 -1
- package/src/flow/models/blocks/filter-form/FilterFormBlockModel.tsx +1 -0
- package/src/flow/models/blocks/filter-form/FilterFormItemModel.tsx +27 -12
- package/src/flow/models/blocks/filter-form/__tests__/FilterFormItemModel.defineChildren.test.ts +36 -0
- package/src/flow/models/blocks/filter-form/__tests__/defaultValues.wiring.test.ts +34 -0
- package/src/flow/models/blocks/form/QuickEditFormModel.tsx +189 -36
- package/src/flow/models/blocks/form/__tests__/QuickEditFormModel.quickEdit.test.ts +350 -2
- package/src/flow/models/blocks/table/TableActionsColumnModel.tsx +2 -1
- package/src/flow/models/blocks/table/TableBlockModel.tsx +1 -1
- package/src/flow/models/blocks/table/TableColumnModel.tsx +6 -2
- package/src/flow/models/blocks/table/__tests__/TableColumnModel.test.tsx +51 -0
- package/src/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/PopupSubTableFieldModel.tsx +2 -1
- package/src/flow/models/fields/AssociationFieldModel/RecordSelectFieldModel.tsx +45 -13
- package/src/flow/models/fields/TextareaFieldModel.tsx +42 -19
- package/src/flow/models/fields/VariableFieldFormModel.tsx +3 -3
- package/src/flow/models/fields/__tests__/TextareaFieldModel.test.tsx +32 -1
- package/src/flow/models/fields/__tests__/VariableFieldFormModel.test.tsx +51 -0
- package/src/flow/models/fields/mobile-components/MobileLazySelect.tsx +20 -10
- package/src/flow/models/fields/mobile-components/MobileSelect.tsx +24 -12
- package/src/flow/models/topbar/TopbarActionModel.tsx +78 -3
- package/src/flow/routeTransientInputArgs.ts +27 -0
- package/src/flow/utils/__tests__/dateTimeFormat.test.ts +42 -0
- package/src/flow-compat/fieldValidationConstants.ts +1 -1
- package/src/flow-compat/routeTypes.ts +1 -0
- package/src/index.ts +6 -0
- package/src/locale/languageCodes.ts +2 -1
- package/src/nocobase-buildin-plugin/index.tsx +19 -1
- package/src/utils/getRouteRuntimeVersion.ts +185 -0
- package/src/utils/index.tsx +1 -0
- package/src/utils/markdownSanitize.ts +88 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { ActionScene } from '@nocobase/flow-engine';
|
|
11
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
12
|
+
|
|
13
|
+
import * as registeredActions from '../index';
|
|
14
|
+
import * as linkageActions from '../linkageRules';
|
|
15
|
+
|
|
16
|
+
const tabLinkageRules = (linkageActions as Record<string, unknown>).tabLinkageRules as
|
|
17
|
+
| typeof linkageActions.menuLinkageRules
|
|
18
|
+
| undefined;
|
|
19
|
+
const linkageSetTabProps = (linkageActions as Record<string, unknown>).linkageSetTabProps as
|
|
20
|
+
| typeof linkageActions.linkageSetMenuItemProps
|
|
21
|
+
| undefined;
|
|
22
|
+
|
|
23
|
+
function createRuntime() {
|
|
24
|
+
let matched = true;
|
|
25
|
+
const setProps = vi.fn(function (this: { props: Record<string, unknown> }, props: Record<string, unknown>) {
|
|
26
|
+
this.props = {
|
|
27
|
+
...this.props,
|
|
28
|
+
...props,
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
const setHidden = vi.fn(function (this: { hidden: boolean }, value: boolean) {
|
|
32
|
+
this.hidden = value;
|
|
33
|
+
});
|
|
34
|
+
const model = {
|
|
35
|
+
uid: 'tab-1',
|
|
36
|
+
props: {} as Record<string, unknown>,
|
|
37
|
+
hidden: false,
|
|
38
|
+
__allModels: [],
|
|
39
|
+
setProps,
|
|
40
|
+
setHidden,
|
|
41
|
+
};
|
|
42
|
+
const ctx = {
|
|
43
|
+
app: { jsonLogic: { apply: () => matched } },
|
|
44
|
+
model,
|
|
45
|
+
t: (text: string) => text,
|
|
46
|
+
getAction: (name: string) => (name === 'linkageSetTabProps' ? linkageSetTabProps : undefined),
|
|
47
|
+
resolveJsonTemplate: vi.fn(async (value: unknown) => value),
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
ctx,
|
|
52
|
+
model,
|
|
53
|
+
setMatched(value: boolean) {
|
|
54
|
+
matched = value;
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const hideRule = {
|
|
60
|
+
value: [
|
|
61
|
+
{
|
|
62
|
+
key: 'rule-1',
|
|
63
|
+
title: 'Hide tab',
|
|
64
|
+
enable: true,
|
|
65
|
+
condition: {
|
|
66
|
+
logic: '$and',
|
|
67
|
+
items: [{ path: 'status', operator: '$eq', value: 'visible' }],
|
|
68
|
+
},
|
|
69
|
+
actions: [
|
|
70
|
+
{
|
|
71
|
+
key: 'action-1',
|
|
72
|
+
name: 'linkageSetTabProps',
|
|
73
|
+
params: { value: 'hidden' },
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
describe('tab linkage rules', () => {
|
|
81
|
+
it('should append the tab linkage scene without changing existing scene values', () => {
|
|
82
|
+
const scenes = ActionScene as unknown as Record<string, number>;
|
|
83
|
+
|
|
84
|
+
expect(scenes.MENU_LINKAGE_RULES).toBe(7);
|
|
85
|
+
expect(scenes.TAB_LINKAGE_RULES).toBe(8);
|
|
86
|
+
expect(scenes.TAB_LINKAGE_RULES).toBe(Math.max(...Object.values(scenes).filter(Number.isInteger)));
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('should register tab linkage actions from the actions entry', () => {
|
|
90
|
+
expect((registeredActions as Record<string, unknown>).tabLinkageRules).toBe(tabLinkageRules);
|
|
91
|
+
expect((registeredActions as Record<string, unknown>).linkageSetTabProps).toBe(linkageSetTabProps);
|
|
92
|
+
expect(tabLinkageRules).toBeDefined();
|
|
93
|
+
expect(linkageSetTabProps).toBeDefined();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('should expose tab state and runjs actions in ui schema', () => {
|
|
97
|
+
expect(tabLinkageRules).toBeDefined();
|
|
98
|
+
expect(linkageSetTabProps).toBeDefined();
|
|
99
|
+
|
|
100
|
+
const schema = tabLinkageRules?.uiSchema?.({
|
|
101
|
+
getActions: () =>
|
|
102
|
+
new Map([
|
|
103
|
+
['linkageSetTabProps', linkageSetTabProps],
|
|
104
|
+
['linkageRunjs', linkageActions.linkageRunjs],
|
|
105
|
+
['linkageSetMenuItemProps', linkageActions.linkageSetMenuItemProps],
|
|
106
|
+
]),
|
|
107
|
+
} as never) as Record<string, Record<string, Record<string, unknown>>> | undefined;
|
|
108
|
+
|
|
109
|
+
expect(schema?.value?.['x-component-props']?.supportedActions).toEqual(['linkageSetTabProps', 'linkageRunjs']);
|
|
110
|
+
expect(linkageSetTabProps?.scene).toBe((ActionScene as unknown as Record<string, number>).TAB_LINKAGE_RULES);
|
|
111
|
+
expect(linkageActions.linkageRunjs.scene).toContain(
|
|
112
|
+
(ActionScene as unknown as Record<string, number>).TAB_LINKAGE_RULES,
|
|
113
|
+
);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('should hide the tab when the condition matches and restore it when the condition misses', async () => {
|
|
117
|
+
expect(tabLinkageRules).toBeDefined();
|
|
118
|
+
const runtime = createRuntime();
|
|
119
|
+
|
|
120
|
+
await tabLinkageRules?.handler(runtime.ctx as never, hideRule);
|
|
121
|
+
expect(runtime.model.hidden).toBe(true);
|
|
122
|
+
|
|
123
|
+
runtime.setMatched(false);
|
|
124
|
+
await tabLinkageRules?.handler(runtime.ctx as never, hideRule);
|
|
125
|
+
expect(runtime.model.hidden).toBe(false);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('should restore the tab when linkage rules are cleared', async () => {
|
|
129
|
+
expect(tabLinkageRules).toBeDefined();
|
|
130
|
+
const runtime = createRuntime();
|
|
131
|
+
|
|
132
|
+
await tabLinkageRules?.handler(runtime.ctx as never, hideRule);
|
|
133
|
+
expect(runtime.model.hidden).toBe(true);
|
|
134
|
+
|
|
135
|
+
await tabLinkageRules?.handler(runtime.ctx as never, { value: [] });
|
|
136
|
+
expect(runtime.model.hidden).toBe(false);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('should not restore stale tab props while applying or clearing visibility rules', async () => {
|
|
140
|
+
expect(tabLinkageRules).toBeDefined();
|
|
141
|
+
const runtime = createRuntime();
|
|
142
|
+
runtime.model.props = {
|
|
143
|
+
title: 'Original title',
|
|
144
|
+
icon: 'original-icon',
|
|
145
|
+
route: { options: { badge: 'original' } },
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
await tabLinkageRules?.handler(runtime.ctx as never, hideRule);
|
|
149
|
+
expect(runtime.model.hidden).toBe(true);
|
|
150
|
+
|
|
151
|
+
const updatedProps = {
|
|
152
|
+
title: 'Updated title',
|
|
153
|
+
icon: 'updated-icon',
|
|
154
|
+
route: { options: { badge: 'updated' } },
|
|
155
|
+
};
|
|
156
|
+
runtime.model.props = updatedProps;
|
|
157
|
+
|
|
158
|
+
await tabLinkageRules?.handler(runtime.ctx as never, hideRule);
|
|
159
|
+
expect(runtime.model.props).toMatchObject(updatedProps);
|
|
160
|
+
expect(runtime.model.hidden).toBe(true);
|
|
161
|
+
|
|
162
|
+
runtime.setMatched(false);
|
|
163
|
+
await tabLinkageRules?.handler(runtime.ctx as never, hideRule);
|
|
164
|
+
expect(runtime.model.props).toMatchObject(updatedProps);
|
|
165
|
+
expect(runtime.model.hidden).toBe(false);
|
|
166
|
+
|
|
167
|
+
await tabLinkageRules?.handler(runtime.ctx as never, { value: [] });
|
|
168
|
+
expect(runtime.model.props).toMatchObject(updatedProps);
|
|
169
|
+
expect(runtime.model.hidden).toBe(false);
|
|
170
|
+
});
|
|
171
|
+
});
|
|
@@ -135,11 +135,15 @@ describe('linkageRulesRefresh action', () => {
|
|
|
135
135
|
expect(handler).toHaveBeenCalledWith(ctx, { value: ['master-mounted'] });
|
|
136
136
|
});
|
|
137
137
|
|
|
138
|
-
it('
|
|
138
|
+
it('skips master model when forks can handle flow in design mode', async () => {
|
|
139
139
|
const handler = vi.fn(async () => {});
|
|
140
140
|
const model: any = {
|
|
141
141
|
isFork: false,
|
|
142
|
-
forks: new Set([
|
|
142
|
+
forks: new Set([
|
|
143
|
+
{
|
|
144
|
+
getFlow: vi.fn(() => ({})),
|
|
145
|
+
},
|
|
146
|
+
]),
|
|
143
147
|
getFlow: vi.fn(() => ({})),
|
|
144
148
|
getStepParams: vi.fn(() => ({ value: ['master'] })),
|
|
145
149
|
context: {
|
|
@@ -157,7 +161,7 @@ describe('linkageRulesRefresh action', () => {
|
|
|
157
161
|
flowKey: 'buttonSettings',
|
|
158
162
|
});
|
|
159
163
|
|
|
160
|
-
expect(handler).
|
|
164
|
+
expect(handler).not.toHaveBeenCalled();
|
|
161
165
|
});
|
|
162
166
|
|
|
163
167
|
it('runs linkage action on fork model and resolves params', async () => {
|
|
@@ -12,6 +12,7 @@ import { describe, it, expect, vi } from 'vitest';
|
|
|
12
12
|
import { RUNJS_OPEN_VIEW_ROUTE_STATE } from '@nocobase/flow-engine';
|
|
13
13
|
import { openView } from '../openView';
|
|
14
14
|
import { FlowPage } from '../../FlowPage';
|
|
15
|
+
import { ROUTE_TRANSIENT_INPUT_ARGS_KEY } from '../../routeTransientInputArgs';
|
|
15
16
|
|
|
16
17
|
describe('openView action - route mode defineProperties/defineMethods', () => {
|
|
17
18
|
const createRouteManagedCtx = () => {
|
|
@@ -172,6 +173,56 @@ describe('openView action - route mode defineProperties/defineMethods', () => {
|
|
|
172
173
|
expect(defineMethodCalls).toContain('pong');
|
|
173
174
|
});
|
|
174
175
|
|
|
176
|
+
it('passes formData through route navigation state', async () => {
|
|
177
|
+
const navigateTo = vi.fn();
|
|
178
|
+
const ctx: any = {
|
|
179
|
+
inputArgs: {
|
|
180
|
+
formData: {
|
|
181
|
+
start: '2026-06-24 08:00:00',
|
|
182
|
+
end: '2026-06-24 09:00:00',
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
engine: {
|
|
186
|
+
context: {},
|
|
187
|
+
},
|
|
188
|
+
model: {
|
|
189
|
+
uid: 'popup-uid',
|
|
190
|
+
context: {
|
|
191
|
+
defineProperty: vi.fn(),
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
view: {
|
|
195
|
+
navigation: {
|
|
196
|
+
navigateTo,
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
isNavigationEnabled: true,
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
await openView.handler(ctx, { navigation: true });
|
|
203
|
+
|
|
204
|
+
expect(navigateTo).toHaveBeenCalledWith(
|
|
205
|
+
{
|
|
206
|
+
viewUid: 'popup-uid',
|
|
207
|
+
filterByTk: undefined,
|
|
208
|
+
sourceId: undefined,
|
|
209
|
+
tabUid: undefined,
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
state: {
|
|
213
|
+
[ROUTE_TRANSIENT_INPUT_ARGS_KEY]: {
|
|
214
|
+
'popup-uid': {
|
|
215
|
+
formData: {
|
|
216
|
+
start: '2026-06-24 08:00:00',
|
|
217
|
+
end: '2026-06-24 09:00:00',
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
);
|
|
224
|
+
});
|
|
225
|
+
|
|
175
226
|
it('adds route state to first-stage navigation only for RunJS ctx.openView calls', async () => {
|
|
176
227
|
const { ctx, navigateTo } = createFirstStageCtx({
|
|
177
228
|
mode: 'dialog',
|
|
@@ -181,13 +232,16 @@ describe('openView action - route mode defineProperties/defineMethods', () => {
|
|
|
181
232
|
|
|
182
233
|
await openView.handler(ctx, { mode: 'drawer', size: 'medium', navigation: true });
|
|
183
234
|
|
|
184
|
-
expect(navigateTo).toHaveBeenCalledWith(
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
235
|
+
expect(navigateTo).toHaveBeenCalledWith(
|
|
236
|
+
{
|
|
237
|
+
viewUid: 'popup-uid',
|
|
238
|
+
filterByTk: undefined,
|
|
239
|
+
sourceId: undefined,
|
|
240
|
+
tabUid: undefined,
|
|
241
|
+
openViewRouteState: { mode: 'dialog', size: 'large' },
|
|
242
|
+
},
|
|
243
|
+
undefined,
|
|
244
|
+
);
|
|
191
245
|
});
|
|
192
246
|
|
|
193
247
|
it('normalizes first-stage RunJS route state mode on mobile layout', async () => {
|
|
@@ -200,13 +254,16 @@ describe('openView action - route mode defineProperties/defineMethods', () => {
|
|
|
200
254
|
|
|
201
255
|
await openView.handler(ctx, { mode: 'drawer', size: 'medium', navigation: true });
|
|
202
256
|
|
|
203
|
-
expect(navigateTo).toHaveBeenCalledWith(
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
257
|
+
expect(navigateTo).toHaveBeenCalledWith(
|
|
258
|
+
{
|
|
259
|
+
viewUid: 'popup-uid',
|
|
260
|
+
filterByTk: undefined,
|
|
261
|
+
sourceId: undefined,
|
|
262
|
+
tabUid: undefined,
|
|
263
|
+
openViewRouteState: { mode: 'embed', size: 'large' },
|
|
264
|
+
},
|
|
265
|
+
undefined,
|
|
266
|
+
);
|
|
210
267
|
});
|
|
211
268
|
|
|
212
269
|
it('uses route replay mode and size before persisted openView defaults', async () => {
|
|
@@ -246,11 +303,14 @@ describe('openView action - route mode defineProperties/defineMethods', () => {
|
|
|
246
303
|
|
|
247
304
|
await openView.handler(ctx, { mode: 'drawer', size: 'medium', navigation: true });
|
|
248
305
|
|
|
249
|
-
expect(navigateTo).toHaveBeenCalledWith(
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
306
|
+
expect(navigateTo).toHaveBeenCalledWith(
|
|
307
|
+
{
|
|
308
|
+
viewUid: 'popup-uid',
|
|
309
|
+
filterByTk: undefined,
|
|
310
|
+
sourceId: undefined,
|
|
311
|
+
tabUid: undefined,
|
|
312
|
+
},
|
|
313
|
+
undefined,
|
|
314
|
+
);
|
|
255
315
|
});
|
|
256
316
|
});
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { isVariableExpression, pruneFilter } from '@nocobase/flow-engine';
|
|
10
|
+
import { extractPropertyPath, isVariableExpression, pruneFilter } from '@nocobase/flow-engine';
|
|
11
11
|
import { transformFilter } from '@nocobase/utils/client';
|
|
12
12
|
import _ from 'lodash';
|
|
13
13
|
|
|
@@ -45,6 +45,14 @@ function restorePreservedNull(value: any): any {
|
|
|
45
45
|
return value;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
function isUrlSearchParamsExpression(value: any) {
|
|
49
|
+
if (!isVariableExpression(value)) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return extractPropertyPath(value)?.[0] === 'urlSearchParams';
|
|
54
|
+
}
|
|
55
|
+
|
|
48
56
|
function markEmptyVariableValues(rawNode: any, resolvedNode: any) {
|
|
49
57
|
if (!rawNode || !resolvedNode || typeof rawNode !== 'object' || typeof resolvedNode !== 'object') {
|
|
50
58
|
return;
|
|
@@ -57,6 +65,7 @@ function markEmptyVariableValues(rawNode: any, resolvedNode: any) {
|
|
|
57
65
|
}
|
|
58
66
|
if (
|
|
59
67
|
isVariableExpression(rawNode.value) &&
|
|
68
|
+
!isUrlSearchParamsExpression(rawNode.value) &&
|
|
60
69
|
(resolvedNode.value === undefined || resolvedNode.value === null || resolvedNode.value === '')
|
|
61
70
|
) {
|
|
62
71
|
resolvedNode.value = PRESERVE_NULL;
|
|
@@ -28,11 +28,11 @@ const isTableColumnFieldSubModel = (model) => {
|
|
|
28
28
|
|
|
29
29
|
const syncTableColumnDateTimeFormatProps = (ctx, props) => {
|
|
30
30
|
const model = ctx.model;
|
|
31
|
-
if (!isTableColumnFieldSubModel(model)
|
|
31
|
+
if (!isTableColumnFieldSubModel(model)) {
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
model.parent
|
|
35
|
+
model.parent?.setProps?.(props);
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
export const dateTimeFormat = defineAction({
|
|
@@ -43,10 +43,12 @@ export {
|
|
|
43
43
|
linkageSetDetailsFieldProps,
|
|
44
44
|
actionLinkageRules,
|
|
45
45
|
menuLinkageRules,
|
|
46
|
+
tabLinkageRules,
|
|
46
47
|
blockLinkageRules,
|
|
47
48
|
linkageSetBlockProps,
|
|
48
49
|
linkageSetActionProps,
|
|
49
50
|
linkageSetMenuItemProps,
|
|
51
|
+
linkageSetTabProps,
|
|
50
52
|
linkageSetFieldProps,
|
|
51
53
|
subFormLinkageSetFieldProps,
|
|
52
54
|
linkageAssignField,
|
|
@@ -731,6 +731,41 @@ export const linkageSetMenuItemProps = defineAction({
|
|
|
731
731
|
},
|
|
732
732
|
});
|
|
733
733
|
|
|
734
|
+
export const linkageSetTabProps = defineAction({
|
|
735
|
+
name: 'linkageSetTabProps',
|
|
736
|
+
title: tExpr('Set tab state'),
|
|
737
|
+
scene: ActionScene.TAB_LINKAGE_RULES,
|
|
738
|
+
sort: 100,
|
|
739
|
+
uiSchema: {
|
|
740
|
+
value: {
|
|
741
|
+
type: 'string',
|
|
742
|
+
'x-component': (props) => {
|
|
743
|
+
const { value, onChange } = props;
|
|
744
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
745
|
+
const ctx = useFlowContext();
|
|
746
|
+
const t = ctx.model.translate.bind(ctx.model);
|
|
747
|
+
|
|
748
|
+
return (
|
|
749
|
+
<Select
|
|
750
|
+
value={value}
|
|
751
|
+
onChange={onChange}
|
|
752
|
+
placeholder={t('Please select state')}
|
|
753
|
+
style={{ width: '100%' }}
|
|
754
|
+
options={[
|
|
755
|
+
{ label: t('Visible'), value: 'visible' },
|
|
756
|
+
{ label: t('Hidden'), value: 'hidden' },
|
|
757
|
+
]}
|
|
758
|
+
allowClear
|
|
759
|
+
/>
|
|
760
|
+
);
|
|
761
|
+
},
|
|
762
|
+
},
|
|
763
|
+
},
|
|
764
|
+
handler(ctx, { value, setProps }) {
|
|
765
|
+
setProps(ctx.model, { hiddenModel: value === 'hidden' });
|
|
766
|
+
},
|
|
767
|
+
});
|
|
768
|
+
|
|
734
769
|
export const linkageSetFieldProps = defineAction({
|
|
735
770
|
name: 'linkageSetFieldProps',
|
|
736
771
|
title: tExpr('Set field state'),
|
|
@@ -1339,6 +1374,7 @@ export const linkageRunjs = defineAction({
|
|
|
1339
1374
|
ActionScene.FIELD_LINKAGE_RULES,
|
|
1340
1375
|
ActionScene.ACTION_LINKAGE_RULES,
|
|
1341
1376
|
ActionScene.MENU_LINKAGE_RULES,
|
|
1377
|
+
ActionScene.TAB_LINKAGE_RULES,
|
|
1342
1378
|
ActionScene.DETAILS_FIELD_LINKAGE_RULES,
|
|
1343
1379
|
ActionScene.SUB_FORM_FIELD_LINKAGE_RULES,
|
|
1344
1380
|
],
|
|
@@ -2169,17 +2205,30 @@ const commonLinkageRulesHandler = async (ctx: FlowContext, params: any) => {
|
|
|
2169
2205
|
}
|
|
2170
2206
|
: props;
|
|
2171
2207
|
|
|
2172
|
-
//
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2208
|
+
// 只记录联动实际控制的属性,避免之后恢复状态时把标题、路由等无关的新配置回滚到旧快照。
|
|
2209
|
+
const originalProps = model.__originalProps || (model.__originalProps = {});
|
|
2210
|
+
const rememberOriginalProp = (key: string, value: unknown) => {
|
|
2211
|
+
if (!Object.prototype.hasOwnProperty.call(originalProps, key)) {
|
|
2212
|
+
originalProps[key] = value;
|
|
2213
|
+
}
|
|
2214
|
+
};
|
|
2215
|
+
Object.keys(normalizedProps || {}).forEach((key) => {
|
|
2216
|
+
if (key === 'hiddenModel') {
|
|
2217
|
+
rememberOriginalProp(
|
|
2218
|
+
key,
|
|
2219
|
+
Object.prototype.hasOwnProperty.call(model.props || {}, key) ? model.props?.[key] : model.hidden,
|
|
2220
|
+
);
|
|
2221
|
+
return;
|
|
2222
|
+
}
|
|
2223
|
+
|
|
2224
|
+
rememberOriginalProp(key, model.props?.[key]);
|
|
2225
|
+
if (key === 'hiddenText') {
|
|
2226
|
+
rememberOriginalProp('title', model.props?.title);
|
|
2227
|
+
}
|
|
2228
|
+
if (key === 'required') {
|
|
2229
|
+
rememberOriginalProp('rules', model.props?.rules);
|
|
2230
|
+
}
|
|
2231
|
+
});
|
|
2183
2232
|
|
|
2184
2233
|
// 临时存起来,遍历完所有规则后,再统一处理
|
|
2185
2234
|
patchPropsByModel.set(model, {
|
|
@@ -2463,6 +2512,32 @@ export const menuLinkageRules = defineAction({
|
|
|
2463
2512
|
},
|
|
2464
2513
|
});
|
|
2465
2514
|
|
|
2515
|
+
export const tabLinkageRules = defineAction({
|
|
2516
|
+
name: 'tabLinkageRules',
|
|
2517
|
+
title: tExpr('Tab linkage rules'),
|
|
2518
|
+
uiMode: 'embed',
|
|
2519
|
+
uiSchema(ctx) {
|
|
2520
|
+
return {
|
|
2521
|
+
value: {
|
|
2522
|
+
type: 'array',
|
|
2523
|
+
'x-component': LinkageRulesUI,
|
|
2524
|
+
'x-component-props': {
|
|
2525
|
+
supportedActions: getSupportedActions(ctx, ActionScene.TAB_LINKAGE_RULES),
|
|
2526
|
+
title: tExpr('Tab linkage rules'),
|
|
2527
|
+
},
|
|
2528
|
+
},
|
|
2529
|
+
};
|
|
2530
|
+
},
|
|
2531
|
+
defaultParams: {
|
|
2532
|
+
value: [],
|
|
2533
|
+
},
|
|
2534
|
+
useRawParams: true,
|
|
2535
|
+
handler: async (ctx, params) => {
|
|
2536
|
+
const resolved = await resolveLinkageRulesParamsPreservingRunJsScripts(ctx, params);
|
|
2537
|
+
return commonLinkageRulesHandler(ctx, resolved);
|
|
2538
|
+
},
|
|
2539
|
+
});
|
|
2540
|
+
|
|
2466
2541
|
export const fieldLinkageRules = defineAction({
|
|
2467
2542
|
name: 'fieldLinkageRules',
|
|
2468
2543
|
title: tExpr('Field linkage rules'),
|
|
@@ -35,12 +35,8 @@ export const linkageRulesRefresh = defineAction({
|
|
|
35
35
|
// Prefer running on the current model; fallback to blockModel when the current model doesn't own the flow.
|
|
36
36
|
if (!hasFlow) return;
|
|
37
37
|
|
|
38
|
-
//
|
|
38
|
+
// Skip master when unmounted forks can handle the same flow.
|
|
39
39
|
// Otherwise master is likely the rendered model and still needs refresh.
|
|
40
|
-
// In design mode, always refresh master so the currently edited model state stays in sync.
|
|
41
|
-
const flowSettingsEnabled = Boolean(
|
|
42
|
-
(ctx as any)?.flowSettingsEnabled || (model as any)?.context?.flowSettingsEnabled,
|
|
43
|
-
);
|
|
44
40
|
const hasForkWithFlow =
|
|
45
41
|
!model?.isFork &&
|
|
46
42
|
!!model?.forks?.size &&
|
|
@@ -49,7 +45,7 @@ export const linkageRulesRefresh = defineAction({
|
|
|
49
45
|
return !!fork?.getFlow?.(flowKey);
|
|
50
46
|
});
|
|
51
47
|
const isMasterMounted = Boolean((model as any)?.context?.ref?.current);
|
|
52
|
-
if (hasForkWithFlow && !isMasterMounted
|
|
48
|
+
if (hasForkWithFlow && !isMasterMounted) {
|
|
53
49
|
return;
|
|
54
50
|
}
|
|
55
51
|
|
|
@@ -20,6 +20,7 @@ import React from 'react';
|
|
|
20
20
|
import { FlowPage } from '../FlowPage';
|
|
21
21
|
import { PageModel, RootPageModel } from '../models';
|
|
22
22
|
import _ from 'lodash';
|
|
23
|
+
import { ROUTE_TRANSIENT_INPUT_ARGS_KEY } from '../routeTransientInputArgs';
|
|
23
24
|
|
|
24
25
|
type DirtyAwareFlowModel = FlowModel & {
|
|
25
26
|
getUserModifiedFields?: () => Set<string> | undefined;
|
|
@@ -31,6 +32,15 @@ type BeforeCloseDirtyState = {
|
|
|
31
32
|
formModelUids: string[];
|
|
32
33
|
};
|
|
33
34
|
|
|
35
|
+
const pickRouteTransientInputArgs = (inputArgs: Record<string, unknown>) => {
|
|
36
|
+
return _.pickBy(
|
|
37
|
+
{
|
|
38
|
+
formData: inputArgs.formData,
|
|
39
|
+
},
|
|
40
|
+
(value) => typeof value !== 'undefined',
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
34
44
|
function collectDirtyFormModelUids(model?: FlowModel | null, ignoredDirtyFormModelUids: string[] = []): string[] {
|
|
35
45
|
if (!model) {
|
|
36
46
|
return [];
|
|
@@ -363,7 +373,17 @@ export const openView = defineAction({
|
|
|
363
373
|
tabUid: mergedTabUid,
|
|
364
374
|
...(effectiveRunJSOpenViewRouteState ? { openViewRouteState: effectiveRunJSOpenViewRouteState } : {}),
|
|
365
375
|
};
|
|
366
|
-
|
|
376
|
+
const transientInputArgs = pickRouteTransientInputArgs(inputArgs);
|
|
377
|
+
const navigationOptions = Object.keys(transientInputArgs).length
|
|
378
|
+
? {
|
|
379
|
+
state: {
|
|
380
|
+
[ROUTE_TRANSIENT_INPUT_ARGS_KEY]: {
|
|
381
|
+
[nextView.viewUid]: transientInputArgs,
|
|
382
|
+
},
|
|
383
|
+
},
|
|
384
|
+
}
|
|
385
|
+
: undefined;
|
|
386
|
+
ctx.view.navigation.navigateTo(nextView, navigationOptions);
|
|
367
387
|
return;
|
|
368
388
|
}
|
|
369
389
|
}
|