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](SqlManagementConf): Add audit status field #530

Merged
merged 1 commit into from
Dec 16, 2024
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 @@ -39,7 +39,7 @@ const ResultIconRender = (props: IResultIconRender) => {
if={!isAuditing}
defaultNode={
<ResultIconTagStyleWrapper size="small" color="geekblue">
{t(`sqlAudit.list.status.auditStatus.auditing`)}
{t('sqlAudit.list.status.auditStatus.auditing')}
</ResultIconTagStyleWrapper>
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ describe('test ScanTypeSqlCollection', () => {
rows: [
{
...mockAuditPlanSQLData?.rows?.[0],
audit_results: 'being_audited'
audit_results: '[]',
audit_status: 'being_audited'
}
]
}
Expand All @@ -152,8 +153,7 @@ describe('test ScanTypeSqlCollection', () => {
data: {
rows: [
{
...mockAuditPlanSQLData?.rows?.[0],
audit_results: ''
...mockAuditPlanSQLData?.rows?.[0]
}
]
}
Expand All @@ -173,8 +173,7 @@ describe('test ScanTypeSqlCollection', () => {
data: {
rows: [
{
...mockAuditPlanSQLData?.rows?.[0],
audit_results: ''
...mockAuditPlanSQLData?.rows?.[0]
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
pollingInterval: 1000,
pollingErrorRetryCount: 3,
onSuccess: (res) => {
if (res.data?.some((i) => i?.audit_results === BEING_AUDITED)) {
if (res.data?.some((i) => i?.audit_status === BEING_AUDITED)) {
startPollRequest();
} else {
cancel();
Expand Down Expand Up @@ -290,6 +290,19 @@
[polling, getFilterMetaListLoading, getTableRowLoading]
);

const parseAuditResult = (resultString: string) => {
let results: IAuditResult[] = [];
try {
results = JSON.parse(resultString ?? '[]') as IAuditResult[];

Check warning on line 296 in packages/sqle/src/page/SqlManagementConf/Detail/ScanTypeSqlCollection/indx.tsx

View workflow job for this annotation

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

🌿 Branch is not covered

Warning! Not covered branch
} catch (error) {
results = [];

Check warning on line 298 in packages/sqle/src/page/SqlManagementConf/Detail/ScanTypeSqlCollection/indx.tsx

View workflow job for this annotation

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

🧾 Statement is not covered

Warning! Not covered statement
}

return results?.map((item) => {
return item.level ?? '';

Check warning on line 302 in packages/sqle/src/page/SqlManagementConf/Detail/ScanTypeSqlCollection/indx.tsx

View workflow job for this annotation

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

🌿 Branch is not covered

Warning! Not covered branch
});
};

return (
<ScanTypeSqlCollectionStyleWrapper>
<TableToolbar setting={tableSetting}>
Expand All @@ -312,32 +325,21 @@
columnClassName: (type) =>
type === 'sql' ? 'ellipsis-column-large-width' : undefined,
customRender: (text, record, fieldName, type) => {
const currentAuditStatusIsBeingAudited =
record.audit_status === BEING_AUDITED;
if (fieldName === 'audit_results') {
let isAuditing = false;
let results: IAuditResult[] = [];
if (text === BEING_AUDITED) {
isAuditing = true;
} else {
try {
results = JSON.parse(text ?? '[]') as IAuditResult[];
} catch (error) {
results = [];
}
}
return (
<div
data-testid="trigger-open-report-drawer"
onClick={() => {
if (!isAuditing) {
if (!currentAuditStatusIsBeingAudited) {
onClickAuditResult(record);
}
}}
>
<ResultIconRender
iconLevels={results?.map((item) => {
return item.level ?? '';
})}
isAuditing={isAuditing}
iconLevels={parseAuditResult(text)}
isAuditing={currentAuditStatusIsBeingAudited}
/>
</div>
);
Expand All @@ -352,18 +354,14 @@
}

if (type === 'sql') {
let isAuditing = false;
if (record?.audit_results === BEING_AUDITED) {
isAuditing = true;
}
return (
<SQLRenderer.Snippet
tooltip={false}
className="pointer"
onClick={() => {
if (!isAuditing) {
if (!currentAuditStatusIsBeingAudited) {
onClickAuditResult(record);
}

Check warning on line 364 in packages/sqle/src/page/SqlManagementConf/Detail/ScanTypeSqlCollection/indx.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 364 in packages/sqle/src/page/SqlManagementConf/Detail/ScanTypeSqlCollection/indx.tsx

View workflow job for this annotation

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

🌿 Branch is not covered

Warning! Not covered branch
}}
sql={text}
rows={1}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,8 @@ export const mockAuditPlanSQLData: IAuditPlanSQLDataResV1 = {
},
{
id: '1234567',
audit_results: 'being_audited',
audit_results: '[]',
audit_status: 'being_audited',
counter: '598',
db_user: '',
fingerprint: 'SELECT ?,SLEEP(?) LIMIT ?,?',
Expand Down
Loading