Skip to content

Commit b89a67b

Browse files
authored
Merge pull request #762 from actiontech/feature/sql-workbench
feat(sql-workbench): Support new and old version coexistence
2 parents 1261dd5 + 567e744 commit b89a67b

File tree

13 files changed

+317
-192
lines changed

13 files changed

+317
-192
lines changed

packages/base/src/locale/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ const initReactI18n = () => {
6161
[SupportLanguage.zhCN]: allZhCN,
6262
[SupportLanguage.enUS]: allEnUS
6363
},
64+
// #if [DEV]
65+
debug: true,
66+
// #endif
6467
lng: LocalStorageWrapper.getOrDefault(
6568
StorageKey.Language,
6669
DEFAULT_LANGUAGE

packages/base/src/locale/zh-CN/dmsCloudBeaver.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ export default {
55
eeErrorTips: '该环境未配置SQL查询,请设置后再使用',
66
eeErrorTips2: '配置方式及使用说明请查看使用文档',
77
jumpToCloudBeaver: '打开SQL工作台',
8+
noInstanceAvailable: '暂无可用SQL工作台',
9+
loading: '加载中...',
10+
sqlQuery: 'SQL工作台(旧)',
11+
odcQuery: 'SQL工作台(新)',
812
ceTips:
913
'当您需要对SQL工作台产生的数据操作进行细粒度的审计和记录时,可以使用SQL工作台审计功能,确保数据操作的可追溯性和责任明晰。',
1014
statistic: {

packages/base/src/page/CloudBeaver/__snapshots__/index.ce.test.tsx.snap

Lines changed: 36 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -17,73 +17,33 @@ exports[`test base/page/CloudBeaver should match snapshot when sql query is disa
1717
<div
1818
class="ant-spin-nested-loading"
1919
>
20-
<div
21-
class="ant-spin-container"
22-
>
23-
<section
24-
class="css-l3x35e"
20+
<div>
21+
<div
22+
aria-busy="true"
23+
aria-live="polite"
24+
class="ant-spin ant-spin-spinning"
2525
>
26-
<div
27-
class="ant-space ant-space-vertical css-1ago99h"
26+
<span
27+
class="ant-spin-dot ant-spin-dot-spin"
2828
>
29-
<div
30-
class="ant-space-item"
31-
>
32-
<div
33-
class="ant-card ant-card-bordered"
34-
>
35-
<div
36-
class="ant-card-body"
37-
>
38-
<div
39-
class="ant-space ant-space-horizontal ant-space-align-center"
40-
>
41-
<div
42-
class="ant-space-item"
43-
style="margin-right: 8px;"
44-
>
45-
<span
46-
aria-label="warning"
47-
class="anticon anticon-warning css-hvou6e"
48-
role="img"
49-
>
50-
<svg
51-
aria-hidden="true"
52-
data-icon="warning"
53-
fill="currentColor"
54-
focusable="false"
55-
height="1em"
56-
viewBox="64 64 896 896"
57-
width="1em"
58-
>
59-
<path
60-
d="M464 720a48 48 0 1096 0 48 48 0 10-96 0zm16-304v184c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V416c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8zm475.7 440l-416-720c-6.2-10.7-16.9-16-27.7-16s-21.6 5.3-27.7 16l-416 720C56 877.4 71.4 904 96 904h832c24.6 0 40-26.6 27.7-48zm-783.5-27.9L512 239.9l339.8 588.2H172.2z"
61-
/>
62-
</svg>
63-
</span>
64-
</div>
65-
<div
66-
class="ant-space-item"
67-
>
68-
<div>
69-
该环境未配置SQL查询,请设置后再使用
70-
71-
配置方式及使用说明请查看使用文档
72-
<a
73-
href="https://actiontech.github.io/sqle-docs-cn/3.modules/4.2_sql_editor/overview.html"
74-
rel="noreferrer"
75-
target="_blank"
76-
>
77-
点击此处
78-
</a>
79-
</div>
80-
</div>
81-
</div>
82-
</div>
83-
</div>
84-
</div>
85-
</div>
86-
</section>
29+
<i
30+
class="ant-spin-dot-item"
31+
/>
32+
<i
33+
class="ant-spin-dot-item"
34+
/>
35+
<i
36+
class="ant-spin-dot-item"
37+
/>
38+
<i
39+
class="ant-spin-dot-item"
40+
/>
41+
</span>
42+
</div>
43+
</div>
44+
<div
45+
class="ant-spin-container ant-spin-blur"
46+
>
8747
<section
8848
class="css-vops52"
8949
>
@@ -1521,7 +1481,17 @@ exports[`test base/page/CloudBeaver should match snapshot when sql query is disa
15211481
</div>
15221482
<div
15231483
class="extra"
1524-
/>
1484+
>
1485+
<button
1486+
class="ant-btn ant-btn-default basic-button-wrapper css-geipcv"
1487+
disabled=""
1488+
type="button"
1489+
>
1490+
<span>
1491+
暂无可用SQL工作台
1492+
</span>
1493+
</button>
1494+
</div>
15251495
</div>
15261496
<div
15271497
class="ant-spin-nested-loading"

packages/base/src/page/CloudBeaver/__snapshots__/index.test.tsx.snap

Lines changed: 36 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -17,73 +17,33 @@ exports[`test base/page/CloudBeaver should match snapshot when sql query is disa
1717
<div
1818
class="ant-spin-nested-loading"
1919
>
20-
<div
21-
class="ant-spin-container"
22-
>
23-
<section
24-
class="css-l3x35e"
20+
<div>
21+
<div
22+
aria-busy="true"
23+
aria-live="polite"
24+
class="ant-spin ant-spin-spinning"
2525
>
26-
<div
27-
class="ant-space ant-space-vertical css-1ago99h"
26+
<span
27+
class="ant-spin-dot ant-spin-dot-spin"
2828
>
29-
<div
30-
class="ant-space-item"
31-
>
32-
<div
33-
class="ant-card ant-card-bordered"
34-
>
35-
<div
36-
class="ant-card-body"
37-
>
38-
<div
39-
class="ant-space ant-space-horizontal ant-space-align-center"
40-
>
41-
<div
42-
class="ant-space-item"
43-
style="margin-right: 8px;"
44-
>
45-
<span
46-
aria-label="warning"
47-
class="anticon anticon-warning css-hvou6e"
48-
role="img"
49-
>
50-
<svg
51-
aria-hidden="true"
52-
data-icon="warning"
53-
fill="currentColor"
54-
focusable="false"
55-
height="1em"
56-
viewBox="64 64 896 896"
57-
width="1em"
58-
>
59-
<path
60-
d="M464 720a48 48 0 1096 0 48 48 0 10-96 0zm16-304v184c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V416c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8zm475.7 440l-416-720c-6.2-10.7-16.9-16-27.7-16s-21.6 5.3-27.7 16l-416 720C56 877.4 71.4 904 96 904h832c24.6 0 40-26.6 27.7-48zm-783.5-27.9L512 239.9l339.8 588.2H172.2z"
61-
/>
62-
</svg>
63-
</span>
64-
</div>
65-
<div
66-
class="ant-space-item"
67-
>
68-
<div>
69-
该环境未配置SQL查询,请设置后再使用
70-
71-
配置方式及使用说明请查看使用文档
72-
<a
73-
href="https://actiontech.github.io/sqle-docs-cn/3.modules/4.2_sql_editor/overview.html"
74-
rel="noreferrer"
75-
target="_blank"
76-
>
77-
点击此处
78-
</a>
79-
</div>
80-
</div>
81-
</div>
82-
</div>
83-
</div>
84-
</div>
85-
</div>
86-
</section>
29+
<i
30+
class="ant-spin-dot-item"
31+
/>
32+
<i
33+
class="ant-spin-dot-item"
34+
/>
35+
<i
36+
class="ant-spin-dot-item"
37+
/>
38+
<i
39+
class="ant-spin-dot-item"
40+
/>
41+
</span>
42+
</div>
43+
</div>
44+
<div
45+
class="ant-spin-container ant-spin-blur"
46+
>
8747
<section
8848
class="css-1c1a29h"
8949
>
@@ -660,7 +620,17 @@ exports[`test base/page/CloudBeaver should match snapshot when sql query is disa
660620
</div>
661621
<div
662622
class="extra"
663-
/>
623+
>
624+
<button
625+
class="ant-btn ant-btn-default basic-button-wrapper css-geipcv"
626+
disabled=""
627+
type="button"
628+
>
629+
<span>
630+
暂无可用SQL工作台
631+
</span>
632+
</button>
633+
</div>
664634
</div>
665635
<div
666636
class="ant-spin-nested-loading"

packages/base/src/page/CloudBeaver/index.ce.test.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import cloudBeaver from '@actiontech/shared/lib/testUtil/mockApi/base/cloudBeave
66
import { act, cleanup, fireEvent, screen } from '@testing-library/react';
77
import { createSpySuccessResponse } from '@actiontech/shared/lib/testUtil/mockApi';
88
import { enableSqlQueryUrlData } from '@actiontech/shared/lib/testUtil/mockApi/base/cloudBeaver/data';
9-
import { OPEN_CLOUD_BEAVER_URL_PARAM_NAME } from '@actiontech/dms-kit';
109
import { baseSuperRender } from '../../testUtils/superRender';
10+
import { OPEN_CLOUD_BEAVER_URL_PARAM_NAME } from '@actiontech/dms-kit';
1111

1212
describe('test base/page/CloudBeaver', () => {
1313
let getSqlQueryUrlSpy: jest.SpyInstance;
@@ -54,7 +54,8 @@ describe('test base/page/CloudBeaver', () => {
5454

5555
expect(global.open).toHaveBeenCalledTimes(1);
5656
expect(global.open).toHaveBeenCalledWith(
57-
enableSqlQueryUrlData.sql_query_root_uri
57+
enableSqlQueryUrlData.sql_query_root_uri,
58+
'_blank'
5859
);
5960
});
6061

packages/base/src/page/CloudBeaver/index.test.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,19 @@ describe('test base/page/CloudBeaver', () => {
8888

8989
expect(container).toMatchSnapshot();
9090
expect(screen.getByText('打开SQL工作台')).toBeInTheDocument();
91+
expect(getSqlQueryUrlSpy).toHaveBeenCalledTimes(1);
9192

9293
fireEvent.click(screen.getByText('打开SQL工作台'));
93-
expect(global.open).toHaveBeenCalledTimes(0);
9494

95+
await act(async () => jest.advanceTimersByTime(0));
96+
97+
expect(getSqlQueryUrlSpy).toHaveBeenCalledTimes(2);
9598
await act(async () => jest.advanceTimersByTime(3000));
9699

97100
expect(global.open).toHaveBeenCalledTimes(1);
98101
expect(global.open).toHaveBeenCalledWith(
99-
enableSqlQueryUrlData.sql_query_root_uri
102+
enableSqlQueryUrlData.sql_query_root_uri,
103+
'_blank'
100104
);
101105
});
102106

@@ -111,6 +115,10 @@ describe('test base/page/CloudBeaver', () => {
111115

112116
await act(async () => jest.advanceTimersByTime(3000));
113117

118+
expect(window.location.href).not.toBe(
119+
enableSqlQueryUrlData.sql_query_root_uri
120+
);
121+
114122
cleanup();
115123

116124
getSqlQueryUrlSpy.mockImplementation(() =>
@@ -125,6 +133,7 @@ describe('test base/page/CloudBeaver', () => {
125133
]
126134
}
127135
});
136+
128137
await act(async () => jest.advanceTimersByTime(3000));
129138

130139
expect(window.location.href).toBe(enableSqlQueryUrlData.sql_query_root_uri);

0 commit comments

Comments
 (0)