Skip to content

Commit dd1f285

Browse files
authored
Merge pull request #735 from actiontech/fix/issue-3135-2505.x
[fix](SqlExecWorkflow): Show execution results on file mode
2 parents 42cf3db + 2d81333 commit dd1f285

File tree

3 files changed

+267
-5
lines changed

3 files changed

+267
-5
lines changed

packages/sqle/src/page/SqlExecWorkflow/Detail/components/AuditExecResultPanel/TaskResultList/Common/SqlStatementResultTable/__tests__/__snapshots__/index.test.tsx.snap

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,3 +928,233 @@ exports[`test TaskResultList/SQLStatementResultTable should match snapshot 2`] =
928928
</div>
929929
</body>
930930
`;
931+
932+
exports[`test TaskResultList/SQLStatementResultTable should render exec result tooltip 1`] = `
933+
<body>
934+
<div>
935+
<section
936+
class="css-1r1dawj"
937+
>
938+
<div
939+
class="ant-table-wrapper actiontech-table-namespace table-row-cursor css-fxd6ka"
940+
>
941+
<div
942+
class="ant-spin-nested-loading"
943+
>
944+
<div
945+
class="ant-spin-container"
946+
>
947+
<div
948+
class="ant-table ant-table-scroll-horizontal"
949+
>
950+
<div
951+
class="ant-table-container"
952+
>
953+
<div
954+
class="ant-table-content"
955+
style="overflow-x: auto; overflow-y: hidden;"
956+
>
957+
<table
958+
style="min-width: 100%; table-layout: auto;"
959+
>
960+
<colgroup>
961+
<col
962+
style="width: 100px;"
963+
/>
964+
</colgroup>
965+
<thead
966+
class="ant-table-thead"
967+
>
968+
<tr>
969+
<th
970+
class="ant-table-cell"
971+
scope="col"
972+
>
973+
序号
974+
</th>
975+
<th
976+
class="ant-table-cell ellipsis-column-large-width"
977+
scope="col"
978+
>
979+
执行语句
980+
</th>
981+
<th
982+
class="ant-table-cell"
983+
scope="col"
984+
>
985+
审核结果
986+
</th>
987+
<th
988+
class="ant-table-cell exec-status-column"
989+
scope="col"
990+
>
991+
执行结果
992+
</th>
993+
</tr>
994+
</thead>
995+
<tbody
996+
class="ant-table-tbody"
997+
>
998+
<tr
999+
aria-hidden="true"
1000+
class="ant-table-measure-row"
1001+
style="height: 0px; font-size: 0px;"
1002+
>
1003+
<td
1004+
style="padding: 0px; border: 0px; height: 0px;"
1005+
>
1006+
<div
1007+
style="height: 0px; overflow: hidden;"
1008+
>
1009+
 
1010+
</div>
1011+
</td>
1012+
<td
1013+
style="padding: 0px; border: 0px; height: 0px;"
1014+
>
1015+
<div
1016+
style="height: 0px; overflow: hidden;"
1017+
>
1018+
 
1019+
</div>
1020+
</td>
1021+
<td
1022+
style="padding: 0px; border: 0px; height: 0px;"
1023+
>
1024+
<div
1025+
style="height: 0px; overflow: hidden;"
1026+
>
1027+
 
1028+
</div>
1029+
</td>
1030+
<td
1031+
style="padding: 0px; border: 0px; height: 0px;"
1032+
>
1033+
<div
1034+
style="height: 0px; overflow: hidden;"
1035+
>
1036+
 
1037+
</div>
1038+
</td>
1039+
</tr>
1040+
<tr
1041+
class="ant-table-row ant-table-row-level-0"
1042+
data-row-key="1"
1043+
>
1044+
<td
1045+
class="ant-table-cell"
1046+
>
1047+
1
1048+
</td>
1049+
<td
1050+
class="ant-table-cell ellipsis-column-large-width"
1051+
>
1052+
<div
1053+
class="actiontech-sql-snippet-renderer-wrapper css-q962ee"
1054+
>
1055+
<div
1056+
class="ant-typography ant-typography-ellipsis ant-typography-single-line ant-typography-ellipsis-single-line margin-bottom-0"
1057+
>
1058+
<span>
1059+
<span
1060+
class="hljs-keyword"
1061+
>
1062+
SELECT
1063+
</span>
1064+
1065+
<span
1066+
class="hljs-operator"
1067+
>
1068+
*
1069+
</span>
1070+
1071+
<span
1072+
class="hljs-keyword"
1073+
>
1074+
FROM
1075+
</span>
1076+
ab.xx;
1077+
</span>
1078+
</div>
1079+
<div
1080+
class="actiontech-copy-icon actiontech-sql-renderer-copy-icon css-1s8kb8e"
1081+
>
1082+
<span
1083+
aria-label="copy"
1084+
class="anticon anticon-copy"
1085+
role="img"
1086+
>
1087+
<svg
1088+
aria-hidden="true"
1089+
data-icon="copy"
1090+
fill="currentColor"
1091+
focusable="false"
1092+
height="1em"
1093+
viewBox="64 64 896 896"
1094+
width="1em"
1095+
>
1096+
<path
1097+
d="M832 64H296c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h496v688c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V96c0-17.7-14.3-32-32-32zM704 192H192c-17.7 0-32 14.3-32 32v530.7c0 8.5 3.4 16.6 9.4 22.6l173.3 173.3c2.2 2.2 4.7 4 7.4 5.5v1.9h4.2c3.5 1.3 7.2 2 11 2H704c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32zM350 856.2L263.9 770H350v86.2zM664 888H414V746c0-22.1-17.9-40-40-40H232V264h432v624z"
1098+
/>
1099+
</svg>
1100+
</span>
1101+
</div>
1102+
</div>
1103+
</td>
1104+
<td
1105+
class="ant-table-cell"
1106+
>
1107+
<div
1108+
class="audit-result-wrapper"
1109+
>
1110+
<div
1111+
class="ant-space ant-space-horizontal ant-space-align-center"
1112+
>
1113+
<div
1114+
class="ant-space-item"
1115+
>
1116+
<svg
1117+
height="20"
1118+
viewBox="0 0 16 16"
1119+
width="20"
1120+
xmlns="http://www.w3.org/2000/svg"
1121+
>
1122+
<path
1123+
d="M8 14.666A6.666 6.666 0 1 1 8 1.333a6.666 6.666 0 0 1 0 13.333m0-7.609L6.115 5.171l-.944.943L7.057 8 5.171 9.885l.944.943L8 8.942l1.885 1.886.944-.943L8.943 8l1.886-1.886-.944-.943z"
1124+
fill="#F66074"
1125+
/>
1126+
</svg>
1127+
</div>
1128+
</div>
1129+
</div>
1130+
</td>
1131+
<td
1132+
class="ant-table-cell exec-status-column"
1133+
>
1134+
<div
1135+
class="ant-space ant-space-horizontal ant-space-align-center basic-tooltips-wrapper css-4jbtl9"
1136+
>
1137+
<div
1138+
class="ant-space-item"
1139+
>
1140+
<span
1141+
class="ant-tag ant-tag-red ant-tag-borderless basic-tag-wrapper basic-large-tag-wrapper css-xyvxme"
1142+
>
1143+
执行失败
1144+
</span>
1145+
</div>
1146+
</div>
1147+
</td>
1148+
</tr>
1149+
</tbody>
1150+
</table>
1151+
</div>
1152+
</div>
1153+
</div>
1154+
</div>
1155+
</div>
1156+
</div>
1157+
</section>
1158+
</div>
1159+
</body>
1160+
`;

packages/sqle/src/page/SqlExecWorkflow/Detail/components/AuditExecResultPanel/TaskResultList/Common/SqlStatementResultTable/__tests__/index.test.tsx

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,18 @@ describe('test TaskResultList/SQLStatementResultTable', () => {
1717
ignoreConsoleErrors([UtilsConsoleErrorStringsEnum.UNKNOWN_EVENT_HANDLER]);
1818

1919
beforeEach(() => {
20+
jest.useFakeTimers();
2021
mockUseCurrentUser();
2122
});
2223
afterEach(() => {
2324
cleanup();
25+
jest.useRealTimers();
2426
});
2527

2628
it('should match snapshot', async () => {
2729
const openSpy = jest.spyOn(window, 'open');
2830
openSpy.mockImplementation(jest.fn());
2931
rule_template.getRuleList();
30-
jest.useFakeTimers();
3132
const { baseElement } = sqleSuperRender(
3233
<SqlStatementResultTable
3334
taskId="1"
@@ -84,7 +85,34 @@ describe('test TaskResultList/SQLStatementResultTable', () => {
8485
fireEvent.click(screen.getByText('分 析'));
8586

8687
expect(openSpy).toHaveBeenCalledTimes(1);
88+
});
8789

88-
jest.useRealTimers();
90+
it('should render exec result tooltip', async () => {
91+
rule_template.getRuleList();
92+
jest.useFakeTimers();
93+
const { baseElement } = sqleSuperRender(
94+
<SqlStatementResultTable
95+
taskId="1"
96+
dataSource={[
97+
{
98+
number: 1,
99+
exec_sql: 'SELECT * FROM ab.xx;',
100+
audit_result: [
101+
{
102+
level: 'error',
103+
message: 'schema ab 不存在',
104+
rule_name: '',
105+
db_type: 'MySQL'
106+
}
107+
],
108+
exec_status: 'failed',
109+
exec_result:
110+
"exec sql failed: \nSELECT * FROM ab.xx; \nError 1049 (42000): Unknown database 'ab'"
111+
}
112+
]}
113+
/>
114+
);
115+
116+
expect(baseElement).toMatchSnapshot();
89117
});
90118
});

packages/sqle/src/page/SqlExecWorkflow/Detail/components/AuditExecResultPanel/TaskResultList/Common/SqlStatementResultTable/columns.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { IAuditTaskSQLResV2 } from '@actiontech/shared/lib/api/sqle/service/common';
22
import ExecStatusTag from '../ResultCard/components/ExecStatusTag';
33
import { getAuditTaskSQLsV2FilterExecStatusEnum } from '@actiontech/shared/lib/api/sqle/service/task/index.enum';
4-
import { BasicTableProps, SQLRenderer } from '@actiontech/shared';
4+
import { BasicTableProps, SQLRenderer, BasicToolTip } from '@actiontech/shared';
55
import { t } from '../../../../../../../../locale';
66
import ResultIconRender from '../../../../../../../../components/AuditResultMessage/ResultIconRender';
77

@@ -54,8 +54,12 @@ export const SQLStatementResultColumns = (
5454
dataIndex: 'exec_status',
5555
title: () => t('audit.table.execResult'),
5656
className: 'exec-status-column',
57-
render: (status: getAuditTaskSQLsV2FilterExecStatusEnum) => {
58-
return <ExecStatusTag status={status} />;
57+
render: (status: getAuditTaskSQLsV2FilterExecStatusEnum, record) => {
58+
return (
59+
<BasicToolTip title={record.exec_result}>
60+
<ExecStatusTag status={status} />
61+
</BasicToolTip>
62+
);
5963
}
6064
}
6165
];

0 commit comments

Comments
 (0)