Skip to content

Commit

Permalink
update scroll position
Browse files Browse the repository at this point in the history
  • Loading branch information
anny1021 committed Nov 16, 2023
1 parent d049e9b commit 21592d0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/page/Order/AuditResult/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { DownOutlined, UpOutlined } from '@ant-design/icons';

const AuditResult: React.FC<AuditResultProps> = (props) => {
const { t } = useTranslation();
const { mode = 'order' } = props;
const { mode = "order", getResultCallBack } = props;
const [duplicate, { toggle: toggleDuplicate }] = useBoolean();
const {
filterInfo,
Expand All @@ -44,6 +44,7 @@ const AuditResult: React.FC<AuditResultProps> = (props) => {
no_duplicate: duplicate,
})
.then((res) => {
getResultCallBack?.();
return {
list: res.data.data,
total: res.data.total_nums,
Expand Down
1 change: 1 addition & 0 deletions src/page/Order/AuditResult/index.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type AuditResultProps = {
updateTaskRecordTotalNum?: (taskId: string, sqlNumber: number) => void;
projectName: string;
mode?: 'order' | 'auditRecordCreate' | 'auditRecordDetail';
getResultCallBack?: () => void
};

export interface AuditResultCollectionProps {
Expand Down
28 changes: 18 additions & 10 deletions src/page/SqlAuditRecord/Create/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const SQLAuditCreate: React.FC = () => {
const [sqlInfoForm] = useForm<SQLInfoFormFields>();
const { projectName } = useCurrentProjectName();
const [task, setTask] = useState<IAuditTaskResV1>();
const [finishGetResult, setFinishGetResult] = useState(false);

Check warning on line 33 in src/page/SqlAuditRecord/Create/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
const baseRef = useRef<BaseInfoFormRef>(null);
const sqlInfoRef = useRef<SQLInfoFormRef>(null);

Expand All @@ -45,6 +46,7 @@ const SQLAuditCreate: React.FC = () => {

const auditSQL: SQLInfoFormProps['submit'] = async (values) => {
const baseValues = await baseForm.validateFields();
setFinishGetResult(false);

Check warning on line 49 in src/page/SqlAuditRecord/Create/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
const params: ICreateSQLAuditRecordV1Params = {
project_name: projectName,
sqls: values.sql,
Expand Down Expand Up @@ -91,19 +93,22 @@ const SQLAuditCreate: React.FC = () => {
baseRef.current?.reset();
sqlInfoRef.current?.reset();
setTask(undefined);
setFinishGetResult(false);

Check warning on line 96 in src/page/SqlAuditRecord/Create/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
};

Check warning on line 97 in src/page/SqlAuditRecord/Create/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

useEffect(() => {
if (typeof task?.task_id === 'number') {
if ((typeof task?.task_id === "number" && finishGetResult)) {

Check warning on line 100 in src/page/SqlAuditRecord/Create/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 100 in src/page/SqlAuditRecord/Create/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
message.success(t("sqlAudit.create.SQLInfo.successTips"));
scrollToAuditResult();
setTimeout(() => {

Check warning on line 102 in src/page/SqlAuditRecord/Create/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
scrollToAuditResult();

Check warning on line 103 in src/page/SqlAuditRecord/Create/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}, 500);

Check warning on line 104 in src/page/SqlAuditRecord/Create/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

Check warning on line 105 in src/page/SqlAuditRecord/Create/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 105 in src/page/SqlAuditRecord/Create/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
}, [task, t]);
}, [task, t, finishGetResult]);

Check warning on line 106 in src/page/SqlAuditRecord/Create/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

return (
<>
<PageHeader title={t('sqlAudit.create.title')} ghost={false}>
{t('sqlAudit.create.pageDesc')}
<PageHeader title={t("sqlAudit.create.title")} ghost={false}>
{t("sqlAudit.create.pageDesc")}
</PageHeader>

<section className="padding-content">
Expand All @@ -112,14 +117,14 @@ const SQLAuditCreate: React.FC = () => {
className="full-width-element"
direction="vertical"
>
<Card title={t('sqlAudit.create.baseInfo.title')}>
<Card title={t("sqlAudit.create.baseInfo.title")}>
<BaseInfoForm
ref={baseRef}
form={baseForm}
projectName={projectName}
/>
</Card>
<Card title={t('sqlAudit.create.SQLInfo.title')}>
<Card title={t("sqlAudit.create.SQLInfo.title")}>
<SQLInfoForm
ref={sqlInfoRef}
form={sqlInfoForm}
Expand All @@ -128,24 +133,27 @@ const SQLAuditCreate: React.FC = () => {
/>
</Card>

<EmptyBox if={typeof task?.task_id === 'number'}>
<EmptyBox if={typeof task?.task_id === "number"}>
<AuditResult
mode="auditRecordCreate"
projectName={projectName}
taskId={task?.task_id}
auditScore={task?.score}
passRate={task?.pass_rate}
getResultCallBack={() => {

Check warning on line 143 in src/page/SqlAuditRecord/Create/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
setFinishGetResult(true);

Check warning on line 144 in src/page/SqlAuditRecord/Create/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}}
/>
</EmptyBox>
</Space>

<FooterButtonWrapper>
<Space>
<Link to={`project/${projectName}/sqlAudit`}>
<Button>{t('common.close')}</Button>
<Button>{t("common.close")}</Button>
</Link>
<Button type="primary" onClick={resetForm}>
{t('common.reset')}
{t("common.reset")}
</Button>
</Space>
</FooterButtonWrapper>
Expand Down

0 comments on commit 21592d0

Please sign in to comment.