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 Management and scanning tasks add auditing status #419

Merged
merged 4 commits into from
Sep 6, 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
19 changes: 11 additions & 8 deletions packages/shared/lib/api/sqle/service/common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
RuleResV1LevelEnum,
SQLQueryConfigResV1AllowQueryWhenLessThanAuditLevelEnum,
ScheduleTaskDefaultOptionDefaultSelectorEnum,
SqlManageAuditStatusEnum,
SqlManageStatusEnum,
TestFeishuConfigurationReqV1AccountTypeEnum,
UpdateAuditPlanNotifyConfigReqV1NotifyLevelEnum,
Expand All @@ -58,9 +59,9 @@ import {
pipelineNodeDetailAuditMethodEnum,
pipelineNodeDetailObjectTypeEnum,
pipelineNodeDetailTypeEnum,
pipelineNodeToBeUpdatedAuditMethodEnum,
pipelineNodeToBeUpdatedObjectTypeEnum,
pipelineNodeToBeUpdatedTypeEnum,
updatePipelineNodeAuditMethodEnum,
updatePipelineNodeObjectTypeEnum,
updatePipelineNodeTypeEnum,
AuditResDataV2AuditLevelEnum,
DirectAuditFileReqV2SqlTypeEnum,
DirectAuditReqV2SqlTypeEnum,
Expand Down Expand Up @@ -2344,6 +2345,8 @@ export interface ISqlManage {

audit_result?: IAuditResult[];

audit_status?: SqlManageAuditStatusEnum;

endpoints?: string;

first_appear_timestamp?: string;
Expand Down Expand Up @@ -2630,7 +2633,7 @@ export interface IUpdatePipelineReqV1 {

name?: string;

nodes?: IPipelineNodeToBeUpdated[];
nodes?: IUpdatePipelineNode[];
}

export interface IUpdateProjectRuleTemplateReqV1 {
Expand Down Expand Up @@ -2989,8 +2992,8 @@ export interface IPipelineNodeDetail {
type?: pipelineNodeDetailTypeEnum;
}

export interface IPipelineNodeToBeUpdated {
audit_method?: pipelineNodeToBeUpdatedAuditMethodEnum;
export interface IUpdatePipelineNode {
audit_method?: updatePipelineNodeAuditMethodEnum;

id?: number;

Expand All @@ -3002,11 +3005,11 @@ export interface IPipelineNodeToBeUpdated {

object_path?: string;

object_type?: pipelineNodeToBeUpdatedObjectTypeEnum;
object_type?: updatePipelineNodeObjectTypeEnum;

rule_template_name?: string;

type?: pipelineNodeToBeUpdatedTypeEnum;
type?: updatePipelineNodeTypeEnum;
}

export interface IAuditFileExecStatistic {
Expand Down
10 changes: 7 additions & 3 deletions packages/shared/lib/api/sqle/service/common.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ export enum ScheduleTaskDefaultOptionDefaultSelectorEnum {
'feishu' = 'feishu'
}

export enum SqlManageAuditStatusEnum {
'being_audited' = 'being_audited'
}

export enum SqlManageStatusEnum {
'unhandled' = 'unhandled',

Expand Down Expand Up @@ -504,19 +508,19 @@ export enum pipelineNodeDetailTypeEnum {
'release' = 'release'
}

export enum pipelineNodeToBeUpdatedAuditMethodEnum {
export enum updatePipelineNodeAuditMethodEnum {
'offline' = 'offline',

'online' = 'online'
}

export enum pipelineNodeToBeUpdatedObjectTypeEnum {
export enum updatePipelineNodeObjectTypeEnum {
'sql' = 'sql',

'mybatis' = 'mybatis'
}

export enum pipelineNodeToBeUpdatedTypeEnum {
export enum updatePipelineNodeTypeEnum {
'audit' = 'audit',

'release' = 'release'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@
InfoHexagonFilled,
CloseCircleFilled
} from '@actiontech/icons';
import { EmptyBox } from '@actiontech/shared';
import { useTranslation } from 'react-i18next';
import { ResultIconTagStyleWrapper } from './style';

export type IResultIconRender = {
iconLevels?: string[];
isAuditing?: boolean;
};

const ResultIconRender = (props: IResultIconRender) => {
const { iconLevels } = props;
const { iconLevels, isAuditing } = props;

const { t } = useTranslation();

const iconData = useMemo(() => {
return Array.from(new Set(iconLevels?.filter((icon: string) => icon)));
Expand All @@ -29,17 +35,26 @@
}, []);

return (
<Space size={8}>
{!!iconData.length
? iconData.map((icon) => {
return (
<React.Fragment key={icon}>
{renderIcon[icon as keyof typeof renderIcon] ?? null}
</React.Fragment>
);
})
: renderIcon.normal}
</Space>
<EmptyBox
if={!isAuditing}
defaultNode={
<ResultIconTagStyleWrapper size="small" color="geekblue">
{t(`sqlAudit.list.status.auditStatus.auditing`)}
</ResultIconTagStyleWrapper>
}
>
<Space size={8}>
{!!iconData.length
? iconData.map((icon) => {
return (
<React.Fragment key={icon}>
{renderIcon[icon as keyof typeof renderIcon] ?? null}

Check warning on line 51 in packages/sqle/src/components/AuditResultMessage/ResultIconRender.tsx

View workflow job for this annotation

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

🌿 Branch is not covered

Warning! Not covered branch
</React.Fragment>
);
})
: renderIcon.normal}
</Space>
</EmptyBox>
);
};

Expand Down
5 changes: 5 additions & 0 deletions packages/sqle/src/components/AuditResultMessage/style.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { styled } from '@mui/material/styles';

import { AuditResultMessageProps } from './index.type';
import { BasicTag } from '@actiontech/shared';

export const ResultIconTagStyleWrapper = styled(BasicTag)`
width: fit-content;
`;

export const AuditResultMessageStyleWrapper = styled('div')`
display: flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,9 @@ describe('sqle/components/AuditResultMessage/ResultIconRender', () => {
const { baseElement } = customRender({});
expect(baseElement).toMatchSnapshot();
});

it('render auditing tag when isAuditing is truthy', async () => {
const { baseElement } = customRender({ isAuditing: true });
expect(baseElement).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`sqle/components/AuditResultMessage/ResultIconRender render auditing tag when isAuditing is truthy 1`] = `
<body>
<div>
<span
class="ant-tag ant-tag-geekblue basic-tag-wrapper basic-small-tag-wrapper css-sdwkac css-dev-only-do-not-override-txh9fw"
>
审核中
</span>
</div>
</body>
`;

exports[`sqle/components/AuditResultMessage/ResultIconRender render icon when has diff icon 1`] = `
<body>
<div>
Expand Down
12 changes: 6 additions & 6 deletions packages/sqle/src/page/PipelineConfiguration/Update/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import { useRequest } from 'ahooks';
import { ResponseCode } from '@actiontech/shared/lib/enum';
import { omit } from 'lodash';
import {
pipelineNodeToBeUpdatedAuditMethodEnum,
pipelineNodeToBeUpdatedObjectTypeEnum,
pipelineNodeToBeUpdatedTypeEnum
updatePipelineNodeAuditMethodEnum,
updatePipelineNodeObjectTypeEnum,
updatePipelineNodeTypeEnum
} from '@actiontech/shared/lib/api/sqle/service/common.enum';
import usePipelineConfigurationFormState from '../Common/ConfigurationForm/hooks/usePipelineConfigurationFormState';

Expand Down Expand Up @@ -81,10 +81,10 @@ const CreatePipelineConfiguration = () => {
...i,
id: isNaN(parseInt(i?.id)) ? undefined : parseInt(i?.id),
audit_method:
i.audit_method as unknown as pipelineNodeToBeUpdatedAuditMethodEnum,
i.audit_method as unknown as updatePipelineNodeAuditMethodEnum,
object_type:
i.object_type as unknown as pipelineNodeToBeUpdatedObjectTypeEnum,
type: i.type as unknown as pipelineNodeToBeUpdatedTypeEnum
i.object_type as unknown as updatePipelineNodeObjectTypeEnum,
type: i.type as unknown as updatePipelineNodeTypeEnum
})) ?? []
})
.then((res) => {
Expand Down
Loading
Loading