Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/sql order #331

Merged
merged 2 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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