Skip to content

Commit

Permalink
Merge pull request #331 from actiontech/fix/sql-order
Browse files Browse the repository at this point in the history
Fix/sql order
  • Loading branch information
Rain-1214 authored Nov 7, 2023
2 parents 80d9869 + c2cb6b9 commit 7fa7720
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ exports[`test AuditResultCollection should be show overview tab when showOvervie
>
<div
class="ant-card ant-card-bordered"
id="audit-result-task-card"
>
<div
class="ant-card-head"
Expand Down Expand Up @@ -2504,6 +2505,7 @@ exports[`test AuditResultCollection should match snapshot when getSummaryOfInsta
>
<div
class="ant-card ant-card-bordered"
id="audit-result-task-card"
>
<div
class="ant-card-head"
Expand Down Expand Up @@ -4316,6 +4318,7 @@ exports[`test AuditResultCollection should match snapshot when showOverview is e
>
<div
class="ant-card ant-card-bordered"
id="audit-result-task-card"
>
<div
class="ant-card-head"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ exports[`Order/Detail/AuditResult should get task sql info when pass task id int
<div>
<div
class="ant-card ant-card-bordered"
id="audit-result-task-card"
>
<div
class="ant-card-head"
Expand Down Expand Up @@ -629,6 +630,7 @@ exports[`Order/Detail/AuditResult should get task sql info when pass task id int
<div>
<div
class="ant-card ant-card-bordered"
id="audit-result-task-card"
>
<div
class="ant-card-head"
Expand Down
2 changes: 1 addition & 1 deletion src/page/Order/AuditResult/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ const AuditResult: React.FC<AuditResultProps> = (props) => {
}, [pagination, filterInfo, duplicate, props.taskId, getAuditTaskSql]);

return (
<Card {...cardProps}>
<Card {...cardProps} id="audit-result-task-card">
<AuditResultFilterForm
form={filterForm}
submit={submitFilter}
Expand Down
2 changes: 2 additions & 0 deletions src/page/Order/Create/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,7 @@ exports[`Order/Create should audit sql when user click audit button 1`] = `
>
<div
class="ant-card ant-card-bordered"
id="audit-result-task-card"
>
<div
class="ant-card-head"
Expand Down Expand Up @@ -3693,6 +3694,7 @@ exports[`Order/Create should audit sql when user click audit button 2`] = `
>
<div
class="ant-card ant-card-bordered"
id="audit-result-task-card"
>
<div
class="ant-card-head"
Expand Down
2 changes: 2 additions & 0 deletions src/page/Order/Create/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@ describe('Order/Create', () => {

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

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

fireEvent.input(screen.getByLabelText('order.sqlInfo.sql'), {
target: { value: 'select * from table3' },
});
Expand Down
8 changes: 6 additions & 2 deletions src/page/Order/Create/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,13 @@ const CreateOrder = () => {
currentTabKey: string
) => {
if (values.isSameSqlOrder) {
auditOrderWithSameSql(values);
return auditOrderWithSameSql(values);
} else {
auditOrderWthDifferenceSql(values, currentTabIndex, currentTabKey);
return auditOrderWthDifferenceSql(
values,
currentTabIndex,
currentTabKey
);
}
},
[auditOrderWithSameSql, auditOrderWthDifferenceSql]
Expand Down
2 changes: 2 additions & 0 deletions src/page/Order/Detail/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,7 @@ exports[`Order/Detail should get new sql audit result when update audit sql 1`]
>
<div
class="ant-card ant-card-bordered"
id="audit-result-task-card"
>
<div
class="ant-card-head"
Expand Down Expand Up @@ -3947,6 +3948,7 @@ exports[`Order/Detail should update order when click update order button 1`] = `
>
<div
class="ant-card ant-card-bordered"
id="audit-result-task-card"
>
<div
class="ant-card-head"
Expand Down
13 changes: 13 additions & 0 deletions src/page/SqlAuditRecord/Create/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ const SQLAuditCreate: React.FC = () => {
const baseRef = useRef<BaseInfoFormRef>(null);
const sqlInfoRef = useRef<SQLInfoFormRef>(null);

const scrollToAuditResult = () => {
const auditResultCardElement = document.getElementById(
'audit-result-task-card'
);
auditResultCardElement?.scrollIntoView({
behavior: 'smooth',
block: 'end',
});
};

const auditSQL: SQLInfoFormProps['submit'] = async (values) => {
const baseValues = await baseForm.validateFields();
const params: ICreateSQLAuditRecordV1Params = {
Expand All @@ -56,6 +66,7 @@ const SQLAuditCreate: React.FC = () => {
} else {
setTask(res.data.data.task);
message.success(t('sqlAudit.create.SQLInfo.successTips'));
scrollToAuditResult();
}
}
});
Expand All @@ -75,13 +86,15 @@ const SQLAuditCreate: React.FC = () => {
if (res.data.code === ResponseCode.SUCCESS) {
setTask(record.task);
message.success(t('sqlAudit.create.SQLInfo.successTips'));
scrollToAuditResult();
}
});
};

const resetForm = () => {
baseRef.current?.reset();
sqlInfoRef.current?.reset();
setTask(undefined);
};

return (
Expand Down

0 comments on commit 7fa7720

Please sign in to comment.