Skip to content

Commit c528056

Browse files
committed
Merge branch 'main' into feature/sql-insights
2 parents d0d2cf0 + ce73ef0 commit c528056

File tree

1,203 files changed

+77617
-66428
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,203 files changed

+77617
-66428
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,6 @@ yarn-error.log*
4242
docs-dist
4343
docs-dist.tar.gz
4444
es
45-
.cursor
45+
46+
# cursor
47+
.cursor

jest.config.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,18 @@ module.exports = {
2222
moduleNameMapper: {
2323
'.+\\.(css|style|less|sass|scss|ttf|woff|woff2)$': 'identity-obj-proxy',
2424
'@ant-design/plots':
25-
'<rootDir>/packages/shared/lib/testUtil/mockAntDesignPlots.jsx',
26-
'monaco-editor': '<rootDir>/packages/shared/lib/testUtil/mockEditor.jsx',
25+
'<rootDir>/packages/shared/lib/testUtil/mockModule/mockAntDesignPlots.jsx',
26+
'monaco-editor':
27+
'<rootDir>/packages/shared/lib/testUtil/mockModule/mockEditor.jsx',
2728
'@monaco-editor/react':
28-
'<rootDir>/packages/shared/lib/testUtil/mockEditor.jsx',
29+
'<rootDir>/packages/shared/lib/testUtil/mockModule/mockEditor.jsx',
2930
'@uiw/react-md-editor':
30-
'<rootDir>/packages/shared/lib/testUtil/mockEditor.jsx',
31+
'<rootDir>/packages/shared/lib/testUtil/mockModule/mockEditor.jsx',
3132
'@actiontech/(.*)': '<rootDir>/packages/$1',
3233
'@react-sigma/core(.*)$':
33-
'<rootDir>/packages/shared/lib/testUtil/mockSigmaCore.tsx',
34+
'<rootDir>/packages/shared/lib/testUtil/mockModule/mockSigmaCore.tsx',
3435
'@react-sigma/graph-search$':
35-
'<rootDir>/packages/shared/lib/testUtil/mockSigmaGraphSearch.tsx',
36+
'<rootDir>/packages/shared/lib/testUtil/mockModule/mockSigmaGraphSearch.tsx',
3637
...pathsToModuleNameMapper(compilerOptions.paths)
3738
},
3839

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"description": "",
55
"main": "index.js",
66
"packageManager": "[email protected]",
7+
"engines": {
8+
"pnpm": ">=9.7.0"
9+
},
710
"scripts": {
811
"preinstall": "npx only-allow pnpm",
912
"start": "pnpm --filter base start",
@@ -29,7 +32,8 @@
2932
"icon:build": "pnpm --filter @actiontech/icons build",
3033
"dms:g": "pnpm --filter @actiontech/cli-create-dms-page build && create-dms-page",
3134
"api_client:g": "npm_config_registry=http://10.186.18.19:4873 pnpx @actiontech/cli api-client -y",
32-
"api_mocks:g": "npm_config_registry=http://10.186.18.19:4873 pnpx @actiontech/cli api-mocks -y"
35+
"api_mocks:g": "npm_config_registry=http://10.186.18.19:4873 pnpx @actiontech/cli api-mocks -y",
36+
"ai-doc": "npm_config_registry=http://10.186.18.19:4873 pnpx @actiontech/cli ai-doc"
3337
},
3438
"keywords": [],
3539
"author": "",

packages/base/src/App.ce.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
import { useNavigate } from 'react-router-dom';
66
import { useDispatch, useSelector } from 'react-redux';
7-
import mockDMSGlobalApi from './testUtils/mockApi/global';
7+
import mockDMSGlobalApi from '@actiontech/shared/lib/testUtil/mockApi/base/global';
88
import { mockUseDbServiceDriver } from '@actiontech/shared/lib/testUtil/mockHook/mockUseDbServiceDriver';
99
import { mockUseCurrentUser } from '@actiontech/shared/lib/testUtil/mockHook/mockUseCurrentUser';
1010
import { mockUsePermission } from '@actiontech/shared/lib/testUtil/mockHook/mockUsePermission';
1111
import { mockSystemConfig } from './testUtils/mockHooks/mockSystemConfig';
1212
import { LocalStorageWrapper } from '@actiontech/shared';
13-
import system from 'sqle/src/testUtils/mockApi/system';
14-
import baseSystem from './testUtils/mockApi/system';
15-
import { superRender } from '@actiontech/shared/lib/testUtil/customRender';
13+
import system from '@actiontech/shared/lib/testUtil/mockApi/sqle/system';
14+
import baseSystem from '@actiontech/shared/lib/testUtil/mockApi/base/system';
15+
import { superRender } from '@actiontech/shared/lib/testUtil/superRender';
1616
import { compressToBase64 } from 'lz-string';
1717
import App from './App';
1818
import { ModalName } from './data/ModalName';

packages/base/src/App.test.tsx

Lines changed: 56 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,39 @@
11
import { useNavigate } from 'react-router-dom';
22
import { useDispatch, useSelector } from 'react-redux';
3-
import { superRender } from '@actiontech/shared/lib/testUtil/customRender';
3+
import { baseSuperRender } from './testUtils/superRender';
44
import App, { Wrapper } from './App';
55
import { act, cleanup, screen } from '@testing-library/react';
6-
import mockDMSGlobalApi from './testUtils/mockApi/global';
6+
import mockDMSGlobalApi from '@actiontech/shared/lib/testUtil/mockApi/base/global';
77
import { mockUseDbServiceDriver } from '@actiontech/shared/lib/testUtil/mockHook/mockUseDbServiceDriver';
88
import { renderLocationDisplay } from '@actiontech/shared/lib/testUtil/LocationDisplay';
99
import { mockUseCurrentUser } from '@actiontech/shared/lib/testUtil/mockHook/mockUseCurrentUser';
1010
import { mockUsePermission } from '@actiontech/shared/lib/testUtil/mockHook/mockUsePermission';
1111
import { mockSystemConfig } from './testUtils/mockHooks/mockSystemConfig';
1212
import { ModalName } from './data/ModalName';
1313
import { mockSystemConfigData } from './testUtils/mockHooks/data';
14-
import { BasicInfoMockData } from './testUtils/mockApi/global/data';
14+
import { BasicInfoMockData } from '@actiontech/shared/lib/testUtil/mockApi/base/global/data';
1515
import { mockDBServiceDriverInfo } from '@actiontech/shared/lib/testUtil/mockHook/data';
1616
import {
1717
ignoreConsoleErrors,
1818
UtilsConsoleErrorStringsEnum
1919
} from '@actiontech/shared/lib/testUtil/common';
20-
import system from 'sqle/src/testUtils/mockApi/system';
21-
import baseSystem from './testUtils/mockApi/system';
20+
import system from '@actiontech/shared/lib/testUtil/mockApi/sqle/system';
21+
import baseSystem from '@actiontech/shared/lib/testUtil/mockApi/base/system';
2222
import { LocalStorageWrapper } from '@actiontech/shared';
2323
import { compressToBase64 } from 'lz-string';
2424
import { DMS_REDIRECT_KEY_PARAMS_NAME } from '@actiontech/shared/lib/data/routePaths';
2525
import { SystemRole } from '@actiontech/shared/lib/enum';
2626
import { AuthRouterConfig } from './router/router';
2727
import { cloneDeep } from 'lodash';
28-
import dmsSystem from './testUtils/mockApi/system';
28+
import dmsSystem from '@actiontech/shared/lib/testUtil/mockApi/base/system';
2929
import { mockUseRecentlySelectedZone } from './testUtils/mockHooks/mockUseRecentlySelectedZone';
3030
import { mockUseRecentlySelectedZoneData } from './testUtils/mockHooks/data';
31-
import gateway from './testUtils/mockApi/gateway';
32-
import project from './testUtils/mockApi/project';
31+
import gateway from '@actiontech/shared/lib/testUtil/mockApi/base/gateway';
32+
import project from '@actiontech/shared/lib/testUtil/mockApi/base/project';
3333
import EventEmitter from './utils/EventEmitter';
3434
import EmitterKey from './data/EmitterKey';
35+
import { eventEmitter as sharedEventEmitter } from '@actiontech/shared/lib/utils/EventEmitter';
36+
import sharedEmitterKey from '@actiontech/shared/lib/data/EmitterKey';
3537

3638
jest.mock('react-router-dom', () => ({
3739
...jest.requireActual('react-router-dom'),
@@ -105,7 +107,7 @@ describe('App', () => {
105107

106108
it('render Wrapper when token is existed', () => {
107109
const [, LocationComponent] = renderLocationDisplay();
108-
superRender(
110+
baseSuperRender(
109111
<Wrapper>
110112
<span>children</span>
111113
<LocationComponent />
@@ -132,7 +134,7 @@ describe('App', () => {
132134
});
133135

134136
const [, LocationComponent] = renderLocationDisplay();
135-
superRender(
137+
baseSuperRender(
136138
<Wrapper>
137139
<span>children</span>
138140
<LocationComponent />
@@ -152,7 +154,7 @@ describe('App', () => {
152154
});
153155

154156
it('render App when token is existed', async () => {
155-
const { container } = superRender(<App />, undefined, {
157+
const { container } = baseSuperRender(<App />, undefined, {
156158
routerProps: { initialEntries: ['/'] }
157159
});
158160
expect(requestGetBasicInfo).toHaveBeenCalledTimes(1);
@@ -170,26 +172,26 @@ describe('App', () => {
170172

171173
it('render App when "isUserInfoFetched" is equal false', () => {
172174
mockUseCurrentUser({ isUserInfoFetched: false });
173-
const { container } = superRender(<App />);
175+
const { container } = baseSuperRender(<App />);
174176
expect(container).toMatchSnapshot();
175177
});
176178

177179
it('render App when "isDriverInfoFetched" is equal false', () => {
178180
mockUseDbServiceDriver({ isDriverInfoFetched: false });
179-
const { container } = superRender(<App />);
181+
const { container } = baseSuperRender(<App />);
180182
expect(container).toMatchSnapshot();
181183
});
182184

183185
it('render App when "isFeatureSupportFetched" is equal false', () => {
184186
mockUseCurrentUser({ isUserInfoFetched: true });
185187
mockUseDbServiceDriver({ isDriverInfoFetched: true });
186-
const { container } = superRender(<App />);
188+
const { container } = baseSuperRender(<App />);
187189
expect(container).toMatchSnapshot();
188190
});
189191

190192
it('render App when "checkPageAction" is false', async () => {
191193
checkPageActionSpy.mockReturnValue(false);
192-
const { container } = superRender(<App />);
194+
const { container } = baseSuperRender(<App />);
193195
await act(async () => jest.advanceTimersByTime(3000));
194196

195197
expect(container).toMatchSnapshot();
@@ -208,11 +210,11 @@ describe('App', () => {
208210
}
209211
});
210212
});
211-
const { container } = superRender(<App />, undefined, {
213+
const { container } = baseSuperRender(<App />, undefined, {
212214
routerProps: { initialEntries: ['/exec-workflow?query=test'] }
213215
});
214216

215-
expect(requestGetBasicInfo).toHaveBeenCalledTimes(0);
217+
expect(requestGetBasicInfo).toHaveBeenCalledTimes(1);
216218
expect(getUserBySessionSpy).toHaveBeenCalledTimes(0);
217219
expect(mockDBServiceDriverInfo.updateDriverList).toHaveBeenCalledTimes(0);
218220
expect(navigateSpy).toHaveBeenCalledTimes(1);
@@ -233,7 +235,7 @@ describe('App', () => {
233235

234236
LocalStorageWrapperGetSpy.mockReturnValue('');
235237

236-
superRender(<App />);
238+
baseSuperRender(<App />);
237239

238240
expect(LocalStorageWrapperSetSpy).toHaveBeenCalledTimes(1);
239241
expect(LocalStorageWrapperSetSpy).toHaveBeenCalledWith(
@@ -248,7 +250,7 @@ describe('App', () => {
248250

249251
LocalStorageWrapperGetSpy.mockReturnValue('ce');
250252

251-
superRender(<App />);
253+
baseSuperRender(<App />);
252254

253255
expect(LocalStorageWrapperSetSpy).toHaveBeenCalledTimes(1);
254256
expect(LocalStorageWrapperSetSpy).toHaveBeenCalledWith(
@@ -263,14 +265,14 @@ describe('App', () => {
263265

264266
LocalStorageWrapperGetSpy.mockReturnValue('ee');
265267

266-
superRender(<App />);
268+
baseSuperRender(<App />);
267269

268270
expect(LocalStorageWrapperSetSpy).toHaveBeenCalledTimes(0);
269271
});
270272

271273
it('verify route permission should not modify the route datasource', async () => {
272274
const routerConfigBackup = cloneDeep(AuthRouterConfig);
273-
superRender(<App />);
275+
baseSuperRender(<App />);
274276
await act(async () => jest.advanceTimersByTime(3000));
275277
expect(AuthRouterConfig).toEqual(routerConfigBackup);
276278

@@ -279,25 +281,25 @@ describe('App', () => {
279281
userRoles: {
280282
[SystemRole.admin]: false,
281283
[SystemRole.certainProjectManager]: false,
282-
[SystemRole.globalManager]: false,
283-
[SystemRole.globalViewing]: false,
284-
[SystemRole.createProject]: false
284+
[SystemRole.systemAdministrator]: false,
285+
[SystemRole.auditAdministrator]: false,
286+
[SystemRole.projectDirector]: false
285287
}
286288
});
287-
superRender(<App />);
289+
baseSuperRender(<App />);
288290
await act(async () => jest.advanceTimersByTime(3000));
289291
expect(AuthRouterConfig).toEqual(routerConfigBackup);
290292
});
291293

292294
it('should initialize the availability zone', () => {
293-
superRender(<App />);
295+
baseSuperRender(<App />);
294296
expect(
295297
mockUseRecentlySelectedZoneData.initializeAvailabilityZone
296298
).toHaveBeenCalledTimes(1);
297299
});
298300

299301
it('should reload the initial data when the event is triggered', async () => {
300-
superRender(<App />);
302+
baseSuperRender(<App />);
301303
expect(getUserBySessionSpy).toHaveBeenCalledTimes(1);
302304
expect(requestGetModalStatus).toHaveBeenCalledTimes(2);
303305
expect(mockDBServiceDriverInfo.updateDriverList).toHaveBeenCalledTimes(1);
@@ -309,4 +311,31 @@ describe('App', () => {
309311
expect(requestGetModalStatus).toHaveBeenCalledTimes(4);
310312
expect(mockDBServiceDriverInfo.updateDriverList).toHaveBeenCalledTimes(2);
311313
});
314+
315+
it('should clear availability zone and reload initial data when shared event is triggered', async () => {
316+
baseSuperRender(<App />);
317+
318+
expect(getUserBySessionSpy).toHaveBeenCalledTimes(1);
319+
expect(requestGetModalStatus).toHaveBeenCalledTimes(2);
320+
expect(mockDBServiceDriverInfo.updateDriverList).toHaveBeenCalledTimes(1);
321+
expect(
322+
mockUseRecentlySelectedZoneData.clearRecentlySelectedZone
323+
).toHaveBeenCalledTimes(0);
324+
325+
act(() => {
326+
sharedEventEmitter.emit(
327+
sharedEmitterKey.DMS_CLEAR_AVAILABILITY_ZONE_AND_RELOAD_INITIAL_DATA
328+
);
329+
});
330+
331+
await act(async () => jest.advanceTimersByTime(1000));
332+
333+
expect(
334+
mockUseRecentlySelectedZoneData.clearRecentlySelectedZone
335+
).toHaveBeenCalledTimes(1);
336+
337+
expect(getUserBySessionSpy).toHaveBeenCalledTimes(2);
338+
expect(requestGetModalStatus).toHaveBeenCalledTimes(4);
339+
expect(mockDBServiceDriverInfo.updateDriverList).toHaveBeenCalledTimes(2);
340+
});
312341
});

packages/base/src/App.tsx

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ import { getSystemModuleStatusModuleNameEnum } from '@actiontech/shared/lib/api/
5252
import { ComponentControlHeight } from '@actiontech/shared/lib/data/common';
5353
import EventEmitter from './utils/EventEmitter';
5454
import EmitterKey from './data/EmitterKey';
55+
import { eventEmitter as sharedEventEmitter } from '@actiontech/shared/lib/utils/EventEmitter';
56+
import sharedEmitterKey from '@actiontech/shared/lib/data/EmitterKey';
5557
import useRecentlySelectedZone from './hooks/useRecentlySelectedZone';
58+
import { debounce } from 'lodash';
5659
import './index.less';
5760

5861
dayjs.extend(updateLocale);
@@ -121,20 +124,16 @@ function App() {
121124

122125
const { isDriverInfoFetched, updateDriverList } = useDbServiceDriver();
123126

124-
const { checkPagePermission } = usePermission();
127+
const { checkPagePermission, userOperationPermissions } = usePermission();
125128

126129
// #if [ee]
127130
const { syncWebTitleAndLogo } = useSystemConfig();
128-
useRequest(
129-
() =>
130-
BasicInfo.GetBasicInfo().then((res) => {
131-
if (res.data.data) {
132-
syncWebTitleAndLogo(res.data.data);
133-
}
134-
}),
135-
{
136-
ready: !!token
137-
}
131+
useRequest(() =>
132+
BasicInfo.GetBasicInfo().then((res) => {
133+
if (res.data.data) {
134+
syncWebTitleAndLogo(res.data.data);
135+
}
136+
})
138137
);
139138
// #endif
140139

@@ -159,11 +158,20 @@ function App() {
159158
}, verifiedRoutes);
160159
};
161160

162-
if (isUserInfoFetched && isFeatureSupportFetched) {
161+
if (
162+
isUserInfoFetched &&
163+
isFeatureSupportFetched &&
164+
userOperationPermissions
165+
) {
163166
return filterRoutesByPermission(AuthRouterConfig);
164167
}
165168
return AuthRouterConfig;
166-
}, [checkPagePermission, isFeatureSupportFetched, isUserInfoFetched]);
169+
}, [
170+
checkPagePermission,
171+
isFeatureSupportFetched,
172+
isUserInfoFetched,
173+
userOperationPermissions
174+
]);
167175

168176
const elements = useRoutes(
169177
token ? (AuthRouterConfigData as RouteObject[]) : unAuthRouterConfig
@@ -224,6 +232,9 @@ function App() {
224232
}, [currentLanguage]);
225233

226234
// #if [ee]
235+
const { initializeAvailabilityZone, clearRecentlySelectedZone } =
236+
useRecentlySelectedZone();
237+
227238
useEffect(() => {
228239
const { unsubscribe } = EventEmitter.subscribe(
229240
EmitterKey.DMS_Reload_Initial_Data,
@@ -233,7 +244,17 @@ function App() {
233244
return unsubscribe;
234245
}, [getInitialData]);
235246

236-
const { initializeAvailabilityZone } = useRecentlySelectedZone();
247+
useEffect(() => {
248+
const { unsubscribe } = sharedEventEmitter.subscribe(
249+
sharedEmitterKey.DMS_CLEAR_AVAILABILITY_ZONE_AND_RELOAD_INITIAL_DATA,
250+
debounce(() => {
251+
clearRecentlySelectedZone();
252+
getInitialData();
253+
}, 1000)
254+
);
255+
256+
return unsubscribe;
257+
}, [getInitialData, clearRecentlySelectedZone]);
237258

238259
useEffect(() => {
239260
initializeAvailabilityZone();

0 commit comments

Comments
 (0)