Skip to content

Commit

Permalink
Merge branch 'main' of github.com:actiontech/dms-ui into feature/sqle…
Browse files Browse the repository at this point in the history
…-issue-2860
  • Loading branch information
LZS911 committed Jan 16, 2025
2 parents 9740e8f + dee9280 commit 713359b
Show file tree
Hide file tree
Showing 54 changed files with 19,167 additions and 1,390 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { RobotOutlined } from '@actiontech/icons';
import { t } from '../../../../../locale';
import { IListDataExportTaskSQL } from '@actiontech/shared/lib/api/base/service/common';
import {
Expand All @@ -23,19 +22,19 @@ export const AuditResultForCreateOrderActions = (
};
},
permissions: PERMISSIONS.ACTIONS.BASE.DATA_EXPORT.CREATE_WHITELIST
},
{
key: 'sqlRewriter',
text: t('sqlRewrite.actionName'),
buttonProps: (record) => {
return {
icon: <RobotOutlined height={18} width={18} />,
onClick: (e) => {
e.stopPropagation();
handleClickSqlRewritten(record!);
}
};
}
}
// {
// key: 'sqlRewriter',
// text: t('sqlRewrite.actionName'),
// buttonProps: (record) => {
// return {
// icon: <RobotOutlined height={18} width={18} />,
// onClick: (e) => {
// e.stopPropagation();
// handleClickSqlRewritten(record!);
// }
// };
// }
// }
];
};

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -244,20 +244,20 @@ describe('test DataExport/Common/AuditResultList', () => {
);
});

it('should render sql rewriter button', async () => {
getTaskSQLsSpy.mockClear();
getTaskSQLsSpy.mockImplementation(() =>
createSpySuccessResponse({
data: [ListDataExportTaskSQLsResponseData[0]]
})
);
superRender(<AuditResultList taskIDs={taskIDs} projectID={projectID} />);
// it('should render sql rewriter button', async () => {
// getTaskSQLsSpy.mockClear();
// getTaskSQLsSpy.mockImplementation(() =>
// createSpySuccessResponse({
// data: [ListDataExportTaskSQLsResponseData[0]]
// })
// );
// superRender(<AuditResultList taskIDs={taskIDs} projectID={projectID} />);

await act(async () => jest.advanceTimersByTime(3000));
await act(async () => jest.advanceTimersByTime(3000));
// await act(async () => jest.advanceTimersByTime(3000));
// await act(async () => jest.advanceTimersByTime(3000));

fireEvent.click(screen.getByText('SQL合规重写'));
// fireEvent.click(screen.getByText('SQL合规重写'));

expect(screen.getByRole('dialog')).toBeInTheDocument();
});
// expect(screen.getByRole('dialog')).toBeInTheDocument();
// });
});
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ exports[`first should match snapshot when pageState is equal SUBMIT_WORKFLOW 1`]
<col />
<col />
<col
style="width: 164px;"
style="width: 82px;"
/>
</colgroup>
<thead
Expand Down

Large diffs are not rendered by default.

18 changes: 17 additions & 1 deletion packages/shared/lib/api/sqle/service/SqlManage/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import {
IGetSqlManageRuleTipsResp,
ISqlManageCodingReq,
IPostSqlManageCodingResp,
IGetSqlManageSqlAnalysisResp
IGetSqlManageSqlAnalysisResp,
ISqlManageAnalysisChartResp
} from '../common.d';

export interface IGetGlobalSqlManageListParams {
Expand Down Expand Up @@ -160,6 +161,21 @@ export interface IGetSqlManageSqlAnalysisV1Params {
export interface IGetSqlManageSqlAnalysisV1Return
extends IGetSqlManageSqlAnalysisResp {}

export interface IGetSqlManageSqlAnalysisChartV1Params {
project_name: string;

sql_manage_id: string;

start_time: string;

end_time: string;

metric_name: string;
}

export interface IGetSqlManageSqlAnalysisChartV1Return
extends ISqlManageAnalysisChartResp {}

export interface IGetSqlManageListV2Params {
project_name: string;

Expand Down
20 changes: 20 additions & 0 deletions packages/shared/lib/api/sqle/service/SqlManage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import {
ISendSqlManageReturn,
IGetSqlManageSqlAnalysisV1Params,
IGetSqlManageSqlAnalysisV1Return,
IGetSqlManageSqlAnalysisChartV1Params,
IGetSqlManageSqlAnalysisChartV1Return,
IGetSqlManageListV2Params,
IGetSqlManageListV2Return
} from './index.d';
Expand Down Expand Up @@ -144,6 +146,24 @@ class SqlManageService extends ServiceBase {
);
}

public GetSqlManageSqlAnalysisChartV1(
params: IGetSqlManageSqlAnalysisChartV1Params,
options?: AxiosRequestConfig
) {
const paramsData = this.cloneDeep(params);
const project_name = paramsData.project_name;
delete paramsData.project_name;

const sql_manage_id = paramsData.sql_manage_id;
delete paramsData.sql_manage_id;

return this.get<IGetSqlManageSqlAnalysisChartV1Return>(
`/v1/projects/${project_name}/sql_manages/${sql_manage_id}/sql_analysis_chart`,
paramsData,
options
);
}

public GetSqlManageListV2(
params: IGetSqlManageListV2Params,
options?: AxiosRequestConfig
Expand Down
50 changes: 50 additions & 0 deletions packages/shared/lib/api/sqle/service/common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,16 @@ export interface IBlacklistResV1 {
type?: BlacklistResV1TypeEnum;
}

export interface IChartPoint {
info?: Array<{
[key: string]: string;
}>;

x?: string;

y?: number;
}

export interface ICheckLicenseResV1 {
code?: number;

Expand Down Expand Up @@ -880,6 +890,18 @@ export interface IDatabaseDiffObject {
objects_diff_result?: IObjectDiffResult[];
}

export interface IDatabaseDriverLogosV1 {
db_type?: string;

logo?: number[];
}

export interface IDatabaseDriverOptionsV1 {
db_type?: string;

params?: IInstanceAdditionalParamResV1[];
}

export interface IDatabaseObject {
object_name?: string;

Expand Down Expand Up @@ -1296,6 +1318,22 @@ export interface IGetDatabaseComparisonReqV1 {
comparison_db_object?: IDatabaseComparisonObject;
}

export interface IGetDatabaseDriverLogosResV1 {
code?: number;

data?: IDatabaseDriverLogosV1[];

message?: string;
}

export interface IGetDatabaseDriverOptionsResV1 {
code?: number;

data?: IDatabaseDriverOptionsV1[];

message?: string;
}

export interface IGetDepBetweenStageInstanceResV1 {
code?: number;

Expand Down Expand Up @@ -2812,6 +2850,10 @@ export interface ISqlAnalysis {
table_metas?: ITableMetas;
}

export interface ISqlAnalysisChart {
points?: IChartPoint[];
}

export interface ISqlAnalysisResDataV1 {
sql_explain?: ISQLExplain;

Expand Down Expand Up @@ -2902,6 +2944,14 @@ export interface ISqlManage {
status?: SqlManageStatusEnum;
}

export interface ISqlManageAnalysisChartResp {
code?: number;

data?: ISqlAnalysisChart;

message?: string;
}

export interface ISqlManageCodingReq {
coding_project_name?: string;

Expand Down
16 changes: 14 additions & 2 deletions packages/shared/lib/api/sqle/service/instance/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getInstanceTipListV1FunctionalModuleEnum } from './index.enum';

import {
IGetDatabaseDriverLogosResV1,
IGetDatabaseDriverOptionsResV1,
IGetInstanceTipsResV1,
IBatchCheckInstanceConnectionsReqV1,
IBatchGetInstanceConnectionsResV1,
Expand All @@ -12,6 +12,18 @@ import {
IGetInstanceResV2
} from '../common.d';

import { getInstanceTipListV1FunctionalModuleEnum } from './index.enum';

export interface IGetDatabaseDriverLogosParams {
db_types: string;
}

export interface IGetDatabaseDriverLogosReturn
extends IGetDatabaseDriverLogosResV1 {}

export interface IGetDatabaseDriverOptionsReturn
extends IGetDatabaseDriverOptionsResV1 {}

export interface IGetInstanceTipListV1Params {
project_name: string;

Expand Down
23 changes: 23 additions & 0 deletions packages/shared/lib/api/sqle/service/instance/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import ServiceBase from '../Service.base';
import { AxiosRequestConfig } from 'axios';

import {
IGetDatabaseDriverLogosParams,
IGetDatabaseDriverLogosReturn,
IGetDatabaseDriverOptionsReturn,
IGetInstanceTipListV1Params,
IGetInstanceTipListV1Return,
IBatchCheckInstanceIsConnectableByNameParams,
Expand All @@ -26,6 +29,26 @@ import {
} from './index.d';

class InstanceService extends ServiceBase {
public GetDatabaseDriverLogos(
params: IGetDatabaseDriverLogosParams,
options?: AxiosRequestConfig
) {
const paramsData = this.cloneDeep(params);
return this.get<IGetDatabaseDriverLogosReturn>(
'/v1/database_driver_logos',
paramsData,
options
);
}

public getDatabaseDriverOptions(options?: AxiosRequestConfig) {
return this.get<IGetDatabaseDriverOptionsReturn>(
'/v1/database_driver_options',
undefined,
options
);
}

public getInstanceTipListV1(
params: IGetInstanceTipListV1Params,
options?: AxiosRequestConfig
Expand Down
17 changes: 16 additions & 1 deletion packages/shared/lib/testUtil/mockAntDesignPlots.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,20 @@ const RingProgressWithCustomRenderCalled = (options) => (props) => {
return <div data-custom-params={params} />;
};

const LineWithCustomRenderCalled = (options) => (props) => {
const clonePropsData = cloneDeep(props);

const tooltipCustomContent = clonePropsData?.tooltip?.customContent?.(
...(options?.tooltip?.customContent?.(props) ?? [])
);

const params = JSON.stringify(clonePropsData);
if (tooltipCustomContent) {
return <div data-custom-params={params}>{tooltipCustomContent}</div>;
}
return <div data-custom-params={params} />;
};

export {
Line,
Pie,
Expand All @@ -103,7 +117,8 @@ export {
PieWithCustomRenderCalled,
BarWithCustomRenderCalled,
AreaWithCustomRenderCalled,
RingProgressWithCustomRenderCalled
RingProgressWithCustomRenderCalled,
LineWithCustomRenderCalled
};

// eslint-disable-next-line import/no-anonymous-default-export
Expand Down
9 changes: 4 additions & 5 deletions packages/shared/lib/utils/Common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { AxiosResponse } from 'axios';
import moment from 'moment';
import i18n from 'i18next';
import { MIMETypeEnum, ResponseBlobJsonType } from '../enum';
import { Dayjs } from 'dayjs';

export const emailValidate = (email: string): boolean => {
if (!email || typeof email !== 'string') {
Expand Down Expand Up @@ -50,13 +51,11 @@ export const formatTime = (
};

export function translateTimeForRequest(time: undefined): undefined;
export function translateTimeForRequest(time: moment.Moment): string;
export function translateTimeForRequest(time: Dayjs): string;
export function translateTimeForRequest(
time: moment.Moment | undefined
time: Dayjs | undefined
): string | undefined;
export function translateTimeForRequest(
time?: moment.Moment
): string | undefined {
export function translateTimeForRequest(time?: Dayjs): string | undefined {
if (!time) {
return;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/shared/lib/utils/__tests__/Common.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { AxiosResponse } from 'axios';
import moment from 'moment';
import {
cleanEmptyParams,
emailValidate,
Expand All @@ -19,6 +18,7 @@ import {
import { act } from '@testing-library/react';
import 'blob-polyfill';
import { MIMETypeEnum } from '../../enum';
import dayjs from 'dayjs';

describe('utils/Common', () => {
test('should check params is a email address', () => {
Expand Down Expand Up @@ -54,8 +54,8 @@ describe('utils/Common', () => {
expect(formatTime(undefined, '--')).toBe('--');
});

test('should format a time from moment to YYYY-MM-DDTHH:mm:ssZ', () => {
expect(translateTimeForRequest(moment('2021-06-09 08:11:52'))).toBe(
test('should format a time from dayjs to YYYY-MM-DDTHH:mm:ssZ', () => {
expect(translateTimeForRequest(dayjs('2021-06-09 08:11:52'))).toBe(
`2021-06-09T08:11:52+08:00`
);
expect(translateTimeForRequest(undefined)).toBe(undefined);
Expand Down
Loading

0 comments on commit 713359b

Please sign in to comment.