-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature]:(SqlAuditDrawer, SqlExecWorkflow, DataExportManagement) han…
…dle exception scenarios in SQL audit
- Loading branch information
Showing
54 changed files
with
1,297 additions
and
391 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
packages/base/src/page/DataExportManagement/Common/AuditResultList/index.type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
import { IListDataExportTaskSQL } from '@actiontech/shared/lib/api/base/service/common'; | ||
|
||
export type AuditResultListProps = { | ||
taskIDs: string[]; | ||
projectID: string; | ||
updateExecuteSQLsTypeIsDQL?: (val: boolean) => void; | ||
onSuccessGetDataExportTaskSqls?: (taskSqls: IListDataExportTaskSQL[]) => void; | ||
onErrorGetDataExportTaskSqls?: () => void; | ||
}; |
14 changes: 14 additions & 0 deletions
14
...omponents/SubmitWorkflow/SubmitWorkflowButton/__tests__/__snapshots__/index.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`test SubmitWorkflowButton handles button click 1`] = ` | ||
<div> | ||
<button | ||
class="ant-btn css-dev-only-do-not-override-674gwq ant-btn-primary basic-button-wrapper css-geipcv" | ||
type="button" | ||
> | ||
<span> | ||
提交工单 | ||
</span> | ||
</button> | ||
</div> | ||
`; |
77 changes: 77 additions & 0 deletions
77
...Management/Create/components/SubmitWorkflow/SubmitWorkflowButton/__tests__/index.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { fireEvent, screen } from '@testing-library/dom'; | ||
import SubmitWorkflowButton from '..'; | ||
import { superRender } from '../../../../../../../testUtils/customRender'; | ||
|
||
describe('test SubmitWorkflowButton', () => { | ||
it('handles button click', () => { | ||
const onClick = jest.fn(); | ||
|
||
const { container } = superRender( | ||
<SubmitWorkflowButton | ||
executeSQLsIsDQL={true} | ||
loading={false} | ||
onClick={onClick} | ||
hasExceptionAuditRule={false} | ||
/> | ||
); | ||
expect(container).toMatchSnapshot(); | ||
|
||
fireEvent.click(screen.getByText('提交工单')); | ||
expect(onClick).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('displays the tooltip message when executeSQLsIsDQL is false', async () => { | ||
const onClick = jest.fn(); | ||
|
||
superRender( | ||
<SubmitWorkflowButton | ||
executeSQLsIsDQL={false} | ||
loading={false} | ||
onClick={onClick} | ||
hasExceptionAuditRule={false} | ||
/> | ||
); | ||
fireEvent.click(screen.getByText('提交工单')); | ||
expect(onClick).not.toHaveBeenCalled(); | ||
|
||
fireEvent.mouseOver(screen.getByText('提交工单')); | ||
|
||
await screen.findByText('仅支持对DQL语句创建导出工单'); | ||
}); | ||
|
||
it('disables the button when loading prop is true', () => { | ||
const onClick = jest.fn(); | ||
|
||
superRender( | ||
<SubmitWorkflowButton | ||
executeSQLsIsDQL={true} | ||
loading={true} | ||
onClick={onClick} | ||
hasExceptionAuditRule={false} | ||
/> | ||
); | ||
fireEvent.click(screen.getByText('提交工单')); | ||
expect(onClick).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it('displays the tooltip message when hasExceptionAuditRule is equal true', async () => { | ||
const onClick = jest.fn(); | ||
|
||
superRender( | ||
<SubmitWorkflowButton | ||
executeSQLsIsDQL={false} | ||
loading={false} | ||
onClick={onClick} | ||
hasExceptionAuditRule | ||
/> | ||
); | ||
fireEvent.click(screen.getByText('提交工单')); | ||
expect(onClick).not.toHaveBeenCalled(); | ||
|
||
fireEvent.mouseOver(screen.getByText('提交工单')); | ||
|
||
await screen.findByText( | ||
'当前存在审核规则未被校验,请排除问题后重新触发审核' | ||
); | ||
}); | ||
}); |
50 changes: 50 additions & 0 deletions
50
...page/DataExportManagement/Create/components/SubmitWorkflow/SubmitWorkflowButton/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { ActionButton, BasicButton } from '@actiontech/shared'; | ||
import { SubmitWorkflowButtonProps } from './index.type'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { InfoHexagonOutlined } from '@actiontech/icons'; | ||
|
||
const SubmitWorkflowButton: React.FC<SubmitWorkflowButtonProps> = ({ | ||
loading, | ||
onClick, | ||
hasExceptionAuditRule, | ||
executeSQLsIsDQL | ||
}) => { | ||
const { t } = useTranslation(); | ||
|
||
if (hasExceptionAuditRule) { | ||
return ( | ||
<ActionButton | ||
danger | ||
disabled | ||
actionType="tooltip" | ||
icon={<InfoHexagonOutlined color="currentColor" height={20} />} | ||
tooltip={{ | ||
title: t('dmsDataExport.create.submit.hasExceptionRule') | ||
}} | ||
text={t('dmsDataExport.create.submit.buttonText')} | ||
/> | ||
); | ||
} | ||
|
||
if (!executeSQLsIsDQL) { | ||
return ( | ||
<ActionButton | ||
disabled | ||
actionType="tooltip" | ||
icon={<InfoHexagonOutlined color="currentColor" height={20} />} | ||
tooltip={{ | ||
title: t('dmsDataExport.create.submit.onlySupportDDLSqls') | ||
}} | ||
text={t('dmsDataExport.create.submit.buttonText')} | ||
/> | ||
); | ||
} | ||
|
||
return ( | ||
<BasicButton loading={loading} type="primary" onClick={onClick}> | ||
{t('dmsDataExport.create.submit.buttonText')} | ||
</BasicButton> | ||
); | ||
}; | ||
|
||
export default SubmitWorkflowButton; |
6 changes: 6 additions & 0 deletions
6
.../DataExportManagement/Create/components/SubmitWorkflow/SubmitWorkflowButton/index.type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export type SubmitWorkflowButtonProps = { | ||
executeSQLsIsDQL: boolean; | ||
onClick: () => void; | ||
loading: boolean; | ||
hasExceptionAuditRule: boolean; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.