@nocobase/flow-engine 2.1.10 → 2.1.12
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/lib/components/dnd/index.js +9 -2
- package/lib/components/settings/wrappers/contextual/FlowsFloatContextMenu.js +86 -32
- package/lib/components/settings/wrappers/contextual/useFloatToolbarVisibility.js +20 -0
- package/lib/flowContext.d.ts +1 -1
- package/lib/flowContext.js +32 -8
- package/lib/locale/en-US.json +1 -0
- package/lib/locale/index.d.ts +2 -0
- package/lib/locale/zh-CN.json +1 -0
- package/lib/resources/apiResource.js +2 -1
- package/lib/resources/baseRecordResource.js +6 -17
- package/lib/resources/multiRecordResource.js +13 -3
- package/lib/resources/singleRecordResource.js +7 -2
- package/lib/utils/dataSourceDirty.d.ts +20 -0
- package/lib/utils/dataSourceDirty.js +139 -0
- package/lib/utils/dirtyAwareApiClient.d.ts +11 -0
- package/lib/utils/dirtyAwareApiClient.js +378 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +11 -0
- package/lib/utils/openViewRouteState.d.ts +28 -0
- package/lib/utils/openViewRouteState.js +125 -0
- package/lib/utils/parsePathnameToViewParams.d.ts +3 -0
- package/lib/utils/parsePathnameToViewParams.js +18 -1
- package/lib/views/ViewNavigation.js +5 -0
- package/package.json +4 -4
- package/src/__tests__/flowContext.test.ts +131 -0
- package/src/__tests__/flowEngine.dataSourceDirty.test.ts +51 -0
- package/src/__tests__/runjsRuntimeFeatures.test.ts +15 -2
- package/src/components/dnd/index.tsx +11 -2
- package/src/components/settings/wrappers/contextual/FlowsFloatContextMenu.tsx +105 -35
- package/src/components/settings/wrappers/contextual/__tests__/FlowsFloatContextMenu.test.tsx +381 -12
- package/src/components/settings/wrappers/contextual/useFloatToolbarVisibility.ts +28 -0
- package/src/flowContext.ts +45 -8
- package/src/locale/en-US.json +1 -0
- package/src/locale/zh-CN.json +1 -0
- package/src/resources/apiResource.ts +2 -1
- package/src/resources/baseRecordResource.ts +6 -23
- package/src/resources/multiRecordResource.ts +13 -3
- package/src/resources/singleRecordResource.ts +6 -1
- package/src/utils/__tests__/dirtyAwareApiClient.test.ts +392 -0
- package/src/utils/__tests__/openViewRouteState.test.ts +40 -0
- package/src/utils/__tests__/parsePathnameToViewParams.test.ts +36 -0
- package/src/utils/dataSourceDirty.ts +126 -0
- package/src/utils/dirtyAwareApiClient.ts +430 -0
- package/src/utils/index.ts +10 -0
- package/src/utils/openViewRouteState.ts +107 -0
- package/src/utils/parsePathnameToViewParams.ts +23 -1
- package/src/views/ViewNavigation.ts +6 -1
- package/src/views/__tests__/ViewNavigation.test.ts +15 -0
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
import { decodeOpenViewRouteState, type OpenViewRouteState } from './openViewRouteState';
|
|
11
|
+
|
|
10
12
|
export interface ViewParam {
|
|
11
13
|
/** 视图唯一标识符,一般为某个 Model 实例的 uid */
|
|
12
14
|
viewUid: string;
|
|
@@ -16,6 +18,8 @@ export interface ViewParam {
|
|
|
16
18
|
filterByTk?: string | Record<string, string | number>;
|
|
17
19
|
/** source Id */
|
|
18
20
|
sourceId?: string;
|
|
21
|
+
/** RunJS ctx.openView runtime display overrides decoded from URL. */
|
|
22
|
+
openViewRouteState?: OpenViewRouteState;
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
export interface ParsePathnameToViewParamsOptions {
|
|
@@ -109,7 +113,25 @@ export const parsePathnameToViewParams = (
|
|
|
109
113
|
}
|
|
110
114
|
}
|
|
111
115
|
// 处理参数
|
|
112
|
-
else if (currentView
|
|
116
|
+
else if (currentView) {
|
|
117
|
+
if (segment === 'opts') {
|
|
118
|
+
if (i + 1 < segments.length) {
|
|
119
|
+
const routeState = decodeOpenViewRouteState(currentView.viewUid, segments[i + 1]);
|
|
120
|
+
if (routeState) {
|
|
121
|
+
currentView.openViewRouteState = routeState;
|
|
122
|
+
}
|
|
123
|
+
i += 2;
|
|
124
|
+
} else {
|
|
125
|
+
i++;
|
|
126
|
+
}
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (i + 1 >= segments.length) {
|
|
131
|
+
i++;
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
|
|
113
135
|
const rawValue = segments[i + 1];
|
|
114
136
|
// 尝试对路径段进行解码
|
|
115
137
|
let decoded: string = rawValue;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import { FlowEngineContext } from '../flowContext';
|
|
11
11
|
import { define, observable } from '../reactive';
|
|
12
|
-
import { ViewParam as SharedViewParam } from '../utils';
|
|
12
|
+
import { encodeOpenViewRouteState, ViewParam as SharedViewParam } from '../utils';
|
|
13
13
|
|
|
14
14
|
type ViewParams = Omit<SharedViewParam, 'viewUid'> & { viewUid?: string };
|
|
15
15
|
|
|
@@ -79,6 +79,11 @@ export function generatePathnameFromViewParams(
|
|
|
79
79
|
// 添加视图 UID
|
|
80
80
|
segments.push(viewParam.viewUid);
|
|
81
81
|
|
|
82
|
+
const openViewRouteStateToken = encodeOpenViewRouteState(viewParam.viewUid, viewParam.openViewRouteState);
|
|
83
|
+
if (openViewRouteStateToken) {
|
|
84
|
+
segments.push('opts', openViewRouteStateToken);
|
|
85
|
+
}
|
|
86
|
+
|
|
82
87
|
// 添加参数
|
|
83
88
|
if (viewParam.tabUid) {
|
|
84
89
|
segments.push('tab', viewParam.tabUid);
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
import { encodeOpenViewRouteState } from '../../utils/openViewRouteState';
|
|
10
11
|
import { ViewNavigation, generatePathnameFromViewParams } from '../ViewNavigation';
|
|
11
12
|
|
|
12
13
|
describe('ViewNavigation', () => {
|
|
@@ -220,6 +221,20 @@ describe('generatePathnameFromViewParams', () => {
|
|
|
220
221
|
expect(generatePathnameFromViewParams([{ viewUid: 'xxx' }, { viewUid: 'yyy' }])).toBe('/admin/xxx/view/yyy');
|
|
221
222
|
});
|
|
222
223
|
|
|
224
|
+
it('should generate RunJS openView route state params after the matching view uid', () => {
|
|
225
|
+
const token = encodeOpenViewRouteState('yyy', { mode: 'dialog', size: 'large' });
|
|
226
|
+
if (!token) {
|
|
227
|
+
throw new Error('Expected openView route state token.');
|
|
228
|
+
}
|
|
229
|
+
const pathname = generatePathnameFromViewParams([
|
|
230
|
+
{ viewUid: 'xxx' },
|
|
231
|
+
{ viewUid: 'yyy', openViewRouteState: { mode: 'dialog', size: 'large' }, filterByTk: '1' },
|
|
232
|
+
]);
|
|
233
|
+
|
|
234
|
+
expect(token).toMatch(/^[A-Za-z]{8}$/);
|
|
235
|
+
expect(pathname).toBe(`/admin/xxx/view/yyy/opts/${token}/filterbytk/1`);
|
|
236
|
+
});
|
|
237
|
+
|
|
223
238
|
it('should generate complex path with all parameters', () => {
|
|
224
239
|
expect(
|
|
225
240
|
generatePathnameFromViewParams([
|