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

[feature]:(SQLManagement) build api and add schema column for list #351

Merged
merged 2 commits into from
Dec 15, 2023
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
6 changes: 6 additions & 0 deletions src/api/SqlManage/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export interface IGetSqlManageListParams {

fuzzy_search_endpoint?: string;

fuzzy_search_schema_name?: string;

sort_field?: GetSqlManageListSortFieldEnum;

sort_order?: GetSqlManageListSortOrderEnum;
Expand Down Expand Up @@ -90,6 +92,8 @@ export interface IExportSqlManageV1Params {

fuzzy_search_endpoint?: string;

fuzzy_search_schema_name?: string;

sort_field?: exportSqlManageV1SortFieldEnum;

sort_order?: exportSqlManageV1SortOrderEnum;
Expand Down Expand Up @@ -127,6 +131,8 @@ export interface IGetSqlManageListV2Params {

fuzzy_search_endpoint?: string;

fuzzy_search_schema_name?: string;

sort_field?: GetSqlManageListV2SortFieldEnum;

sort_order?: GetSqlManageListV2SortOrderEnum;
Expand Down
2 changes: 1 addition & 1 deletion src/api/SqlManage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
IGetSqlManageRuleTipsParams,
IGetSqlManageRuleTipsReturn,
IGetSqlManageListV2Params,
IGetSqlManageListV2Return,
IGetSqlManageListV2Return
} from './index.d';

class SqlManageService extends ServiceBase {
Expand Down
22 changes: 21 additions & 1 deletion src/api/audit_plan/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ import {
ITriggerAuditPlanResV1,
IGetAuditPlansResV2,
IGetAuditPlanReportSQLsResV2,
IGetAuditPlanAnalysisDataResV2
IGetAuditPlanAnalysisDataResV2,
IFullSyncAuditPlanSQLsReqV2,
IPartialSyncAuditPlanSQLsReqV2
} from '../common.d';

export interface IGetAuditPlanMetasV1Params {
Expand Down Expand Up @@ -247,3 +249,21 @@ export interface IGetAuditPlantAnalysisDataV2Params {

export interface IGetAuditPlantAnalysisDataV2Return
extends IGetAuditPlanAnalysisDataResV2 {}

export interface IFullSyncAuditPlanSQLsV2Params
extends IFullSyncAuditPlanSQLsReqV2 {
project_name: string;

audit_plan_name: string;
}

export interface IFullSyncAuditPlanSQLsV2Return extends IBaseRes {}

export interface IPartialSyncAuditPlanSQLsV2Params
extends IPartialSyncAuditPlanSQLsReqV2 {
project_name: string;

audit_plan_name: string;
}

export interface IPartialSyncAuditPlanSQLsV2Return extends IBaseRes {}
42 changes: 41 additions & 1 deletion src/api/audit_plan/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ import {
IGetAuditPlanReportsSQLsParams,
IGetAuditPlanReportsSQLsReturn,
IGetAuditPlantAnalysisDataV2Params,
IGetAuditPlantAnalysisDataV2Return
IGetAuditPlantAnalysisDataV2Return,
IFullSyncAuditPlanSQLsV2Params,
IFullSyncAuditPlanSQLsV2Return,
IPartialSyncAuditPlanSQLsV2Params,
IPartialSyncAuditPlanSQLsV2Return
} from './index.d';

class AuditPlanService extends ServiceBase {
Expand Down Expand Up @@ -446,6 +450,42 @@ class AuditPlanService extends ServiceBase {
options
);
}

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

const audit_plan_name = paramsData.audit_plan_name;
delete paramsData.audit_plan_name;

return this.post<IFullSyncAuditPlanSQLsV2Return>(
`/v2/projects/${project_name}/audit_plans/${audit_plan_name}/sqls/full`,
paramsData,
options
);
}

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

const audit_plan_name = paramsData.audit_plan_name;
delete paramsData.audit_plan_name;

return this.post<IPartialSyncAuditPlanSQLsV2Return>(
`/v2/projects/${project_name}/audit_plans/${audit_plan_name}/sqls/partial`,
paramsData,
options
);
}
}

export default new AuditPlanService();
30 changes: 30 additions & 0 deletions src/api/common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3125,6 +3125,28 @@ export interface IAuditPlanResV2 {
rule_template?: IRuleTemplateV2;
}

export interface IAuditPlanSQLReqV2 {
audit_plan_sql_counter?: string;

audit_plan_sql_fingerprint?: string;

audit_plan_sql_last_receive_text?: string;

audit_plan_sql_last_receive_timestamp?: string;

audit_plan_sql_schema?: string;

db_user?: string;

endpoints?: string[];

first_query_at?: string;

query_time_avg?: number;

query_time_max?: number;
}

export interface IAuditResDataV2 {
audit_level?: AuditResDataV2AuditLevelEnum;

Expand Down Expand Up @@ -3255,6 +3277,10 @@ export interface IDriverMeta {
logo_url?: string;
}

export interface IFullSyncAuditPlanSQLsReqV2 {
audit_plan_sql_list?: IAuditPlanSQLReqV2[];
}

export interface IGetAuditPlanAnalysisDataResV2 {
code?: number;

Expand Down Expand Up @@ -3391,6 +3417,10 @@ export interface IInstanceResV2 {
sql_query_config?: ISQLQueryConfigResV1;
}

export interface IPartialSyncAuditPlanSQLsReqV2 {
audit_plan_sql_list?: IAuditPlanSQLReqV2[];
}

export interface IPerformanceStatistics {
affect_rows?: IAffectRows;
}
Expand Down
15 changes: 12 additions & 3 deletions src/page/SQLManagement/SQLPanel/FilterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,197 +25,206 @@
import useRuleTips from './hooks/useRuleTips';
import { extractTextFromReactNode } from '../../../utils/Common';

const FilterForm: React.FC<SQLPanelFilterFormProps> = ({
form,
reset,
submit,
projectName,
}) => {
const { t } = useTranslation();
const {
generateInstanceSelectOption,
updateInstanceList,
loading: getInstanceListLoading,
} = useInstance();
const {
generateRuleTipsSelectOptions,
updateRuleTips,
loading: getRuleTipsLoading,
} = useRuleTips();
const {
generateSourceSelectOptions,
generateAuditLevelSelectOptions,
generateStatusSelectOptions,
} = useStaticStatus();
const computeDisabledDate = (current: moment.Moment) => {
return current && current > moment().endOf('day');
};

const ruleTipsFilterOptions: SelectProps['filterOption'] = (
inputValue,
option
) => {
const label = extractTextFromReactNode(option?.label);
return label.toLowerCase().includes(inputValue.toLowerCase());
};

useEffect(() => {
form.setFieldValue(
'filter_status',
GetSqlManageListV2FilterStatusEnum.unhandled
);
updateInstanceList({
project_name: projectName,
functional_module: getInstanceTipListV1FunctionalModuleEnum.sql_manage,
});
updateRuleTips(projectName);
}, [form, projectName, updateInstanceList, updateRuleTips]);
return (
<Form<SQLPanelFilterFormFields> form={form} onFinish={submit}>
<Row {...FilterFormRowLayout}>
<Col {...FilterFormColLayout}>
<Form.Item
label={t('sqlManagement.filterForm.source')}
name="filter_source"
>
<Select
placeholder={t('common.form.placeholder.searchSelect', {
name: t('sqlManagement.filterForm.source'),
})}
options={generateSourceSelectOptions}
/>
</Form.Item>
</Col>
<Col {...FilterFormColLayout}>
<Form.Item
label={t('sqlManagement.filterForm.SQLFingerprint')}
name="fuzzy_search_sql_fingerprint"
>
<Input
placeholder={t('common.form.placeholder.input', {
name: t('sqlManagement.filterForm.SQLFingerprint'),
})}
/>
</Form.Item>
</Col>
<Col {...FilterFormColLayout}>
<Form.Item
label={t('sqlManagement.filterForm.instanceName')}
name="filter_instance_name"
>
<Select
loading={getInstanceListLoading}
placeholder={t('common.form.placeholder.searchSelect', {
name: t('sqlManagement.filterForm.instanceName'),
})}
>
{generateInstanceSelectOption()}
</Select>
</Form.Item>
</Col>
<Col {...FilterFormColLayout}>
<Form.Item label="Schema" name="fuzzy_search_schema_name">
<Input
placeholder={t('common.form.placeholder.input', {
name: 'Schema',
})}
/>
</Form.Item>
</Col>
<Col {...FilterFormColLayout}>
<Form.Item
label={t('sqlManagement.filterForm.auditLevel')}
name="filter_audit_level"
>
<Select
placeholder={t('common.form.placeholder.searchSelect', {
name: t('sqlManagement.filterForm.auditLevel'),
})}
options={generateAuditLevelSelectOptions}
/>
</Form.Item>
</Col>
<Col {...FilterFormColLayout}>
<Form.Item
label={t('sqlManagement.filterForm.status')}
name="filter_status"
>
<Select
placeholder={t('common.form.placeholder.searchSelect', {
name: t('sqlManagement.filterForm.status'),
})}
options={generateStatusSelectOptions}
/>
</Form.Item>
</Col>
<Col {...FilterFormColLayout}>
<Form.Item
name="filter_last_audit_time"
label={t('sqlManagement.filterForm.time')}
>
<DatePicker.RangePicker
style={{ width: '100%' }}
disabledDate={computeDisabledDate}
showTime
/>
</Form.Item>
</Col>
<Col {...FilterFormColLayout}>
<Form.Item
name="filter_rule"
label={t('sqlManagement.filterForm.rule')}
>
<Select
filterOption={ruleTipsFilterOptions}
optionFilterProp="children"
loading={getRuleTipsLoading}
showSearch
>
{generateRuleTipsSelectOptions()}
</Select>
</Form.Item>
</Col>
<Col {...FilterFormColLayout}>
<Form.Item
label={t('sqlManagement.filterForm.endpoint')}
name="fuzzy_search_endpoint"
>
<Input
placeholder={t('common.form.placeholder.input', {
name: t('sqlManagement.filterForm.endpoint'),
})}
/>
</Form.Item>
</Col>

<Col
{...{
xs: 24,
sm: {
span: 24,
span: 12,
offset: 0,
},
xl: {
span: 8,
span: 24,
offset: 0,
},
xxl: {
span: 24,
span: 18,
offset: 0,
},
}}
className="flex-space-between"
>
<Form.Item
label={t('sqlManagement.filterForm.relatedToMe')}
name="filter_assignee"
valuePropName="checked"
>
<Switch />
</Form.Item>

<Form.Item className="clear-margin-right" label=" " colon={false}>
<Space>
<Button onClick={reset}>{t('common.reset')}</Button>
<Button type="primary" htmlType="submit">
{t('common.search')}
</Button>
</Space>
</Form.Item>
</Col>
</Row>
</Form>
);

Check warning on line 228 in src/page/SQLManagement/SQLPanel/FilterForm.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 229 in src/page/SQLManagement/SQLPanel/FilterForm.tsx

View workflow job for this annotation

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

🧾 Statement is not covered

Warning! Not covered statement
export default FilterForm;
48 changes: 34 additions & 14 deletions src/page/SQLManagement/SQLPanel/column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,68 +53,84 @@
| (ColumnGroupType<ISqlManage> | ColumnType<ISqlManage>) & {
dataIndex?: keyof ISqlManage | 'operator';
}
> = ({
projectName,
updateRemark,
signalActionsLoading,
signalAssignment,
actionPermission,
username,
updateSQLStatus,
}) => {
const columns: Array<
| (ColumnGroupType<ISqlManage> | ColumnType<ISqlManage>) & {
dataIndex?: keyof ISqlManage | 'operator';
}
> = [
{
dataIndex: 'sql_fingerprint',
title: () => t('sqlManagement.table.SQLFingerprint'),
className: 'table-column-sql-fingerprint',
render: (sql: string) => <RenderExecuteSql sql={sql} rows={2} />,
},
{
dataIndex: 'sql',
title: () => 'SQL',
className: 'table-column-sql',
render: (sql: string) => <RenderExecuteSql sql={sql} rows={2} />,
},
{
dataIndex: 'source',
title: () => t('sqlManagement.table.source'),
render: (source: ISource) => {
if (source.type && source.type === SourceTypeEnum.audit_plan) {
return (
<Link
to={`project/${projectName}/auditPlan/detail/${source.audit_plan_name}`}
>
{t(sourceDictionary[source.type])}
</Link>
);
} else if (
source.type &&
source.type === SourceTypeEnum.sql_audit_record
) {
return (
<Link
to={`project/${projectName}/sqlAudit?${
SQLAuditRecordListUrlParamsKey.SQLAuditRecordID
}=${
source.sql_audit_record_ids?.join(
SQLAuditRecordIDValuesSplit
) ?? ''
}`}
>
{t(sourceDictionary[source.type])}
</Link>
);
}
return '--';
},
},
{
dataIndex: 'instance_name',
title: () => t('sqlManagement.table.instanceName'),
render: (name) => {

Check warning on line 118 in src/page/SQLManagement/SQLPanel/column.tsx

View workflow job for this annotation

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

🕹️ Function is not covered

Warning! Not covered function
if (!name) {
return '--';

Check warning on line 120 in src/page/SQLManagement/SQLPanel/column.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 121 in src/page/SQLManagement/SQLPanel/column.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 121 in src/page/SQLManagement/SQLPanel/column.tsx

View workflow job for this annotation

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

🌿 Branch is not covered

Warning! Not covered branch
return name;

Check warning on line 122 in src/page/SQLManagement/SQLPanel/column.tsx

View workflow job for this annotation

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

🧾 Statement is not covered

Warning! Not covered statement
},
},
{
dataIndex: 'schema_name',
title: () => 'Schema',

Check warning on line 127 in src/page/SQLManagement/SQLPanel/column.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 127 in src/page/SQLManagement/SQLPanel/column.tsx

View workflow job for this annotation

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

🕹️ Function is not covered

Warning! Not covered function
render: (schema) => {

Check warning on line 128 in src/page/SQLManagement/SQLPanel/column.tsx

View workflow job for this annotation

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

🕹️ Function is not covered

Warning! Not covered function
if (!schema) {
return '--';

Check warning on line 130 in src/page/SQLManagement/SQLPanel/column.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 131 in src/page/SQLManagement/SQLPanel/column.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 131 in src/page/SQLManagement/SQLPanel/column.tsx

View workflow job for this annotation

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

🌿 Branch is not covered

Warning! Not covered branch
return schema;

Check warning on line 132 in src/page/SQLManagement/SQLPanel/column.tsx

View workflow job for this annotation

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

🧾 Statement is not covered

Warning! Not covered statement
},
},
{
dataIndex: 'audit_result',
Expand Down Expand Up @@ -168,23 +184,24 @@
}
if (endpoints.length === 1) {
return <Tag>{endpoints[0]}</Tag>;

}
return (
<Popover content={
<div style={{ maxWidth: '600px' }}>
<Space wrap>{
endpoints.map((v) => (
<Tag key={v}>{v}</Tag>
))
}</Space>
</div>
}>
<Popover
content={
<div style={{ maxWidth: '600px' }}>
<Space wrap>
{endpoints.map((v) => (

Check warning on line 193 in src/page/SQLManagement/SQLPanel/column.tsx

View workflow job for this annotation

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

🕹️ Function is not covered

Warning! Not covered function
<Tag key={v}>{v}</Tag>

Check warning on line 194 in src/page/SQLManagement/SQLPanel/column.tsx

View workflow job for this annotation

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

🧾 Statement is not covered

Warning! Not covered statement
))}
</Space>
</div>
}
>
<Tag>{endpoints[0]}</Tag>
{endpoints.length > 1 ? '...' : null}
</Popover >
)
}
</Popover>
);

Check warning on line 203 in src/page/SQLManagement/SQLPanel/column.tsx

View workflow job for this annotation

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

🧾 Statement is not covered

Warning! Not covered statement
},
},
{
dataIndex: 'status',
Expand Down Expand Up @@ -214,8 +231,11 @@
title: () => t('sqlManagement.table.comment'),
width: 200,
render: (remark: string, record) => {
return (
<EmptyBox if={actionPermission} defaultNode={<>{renderRemark(remark) ?? '--'}</>}>
<EmptyBox
if={actionPermission}
defaultNode={<>{renderRemark(remark) ?? '--'}</>}

Check warning on line 237 in src/page/SQLManagement/SQLPanel/column.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 237 in src/page/SQLManagement/SQLPanel/column.tsx

View workflow job for this annotation

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

🌿 Branch is not covered

Warning! Not covered branch
>
<EditText
editable={{
autoSize: true,
Expand Down
22 changes: 12 additions & 10 deletions src/page/SQLManagement/SQLPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,106 +37,107 @@
filter_status: GetSqlManageListFilterStatusEnum.unhandled,
};

const SQLPanel: React.FC = () => {
const { t } = useTranslation();
const {
pagination,
filterForm,
filterInfo,
submitFilter,
tableChange,
resetFilter,
sorterInfo,
} = useTable<SQLPanelFilterFormFields>({
defaultFilterInfo,
});

const { projectName } = useCurrentProjectName();
const { username, isAdmin, isProjectManager } = useCurrentUser();
const [SQLNum, setSQLNum] = useState<SQLStatisticsProps>({
SQLTotalNum: 0,
problemSQlNum: 0,
optimizedSQLNum: 0,
});
const [selectedRowKeys, setSelectedRowKeys] = useState<number[]>([]);
const actionPermission = useMemo(() => {
return isAdmin || isProjectManager(projectName);
}, [isAdmin, isProjectManager, projectName]);
const [
batchActionsLoading,
{ setFalse: finishBatchAction, setTrue: startBatchAction },
] = useBoolean();
const [
signalActionsLoading,
{ setFalse: finishSignalAction, setTrue: startSignalAction },
] = useBoolean();

const rowSelection: TableRowSelection<ISqlManage> = {
selectedRowKeys,
onChange: (selectedRowKeys) => {
setSelectedRowKeys(selectedRowKeys as number[]);
},
};

const { data, loading, refresh } = useRequest(
() => {
const getSortField = () => {
if (Array.isArray(sorterInfo)) {
return undefined;
}

return sorterInfo?.field as GetSqlManageListV2SortFieldEnum;
};
const getSortOrder = () => {
if (Array.isArray(sorterInfo)) {
return undefined;
}

if (sorterInfo?.order === 'ascend') {
return GetSqlManageListV2SortOrderEnum.asc;
}

if (sorterInfo?.order === 'descend') {
return GetSqlManageListV2SortOrderEnum.desc;
}
};
return SqlManage.GetSqlManageListV2({
project_name: projectName,
page_index: pagination.pageIndex,
page_size: pagination.pageSize,
filter_assignee: !!filterInfo.filter_assignee ? username : undefined,
filter_last_audit_start_time_from: translateTimeForRequest(
filterInfo.filter_last_audit_time?.[0]
),
filter_last_audit_start_time_to: translateTimeForRequest(
filterInfo.filter_last_audit_time?.[1]
),

fuzzy_search_sql_fingerprint: filterInfo.fuzzy_search_sql_fingerprint,
filter_instance_name: filterInfo.filter_instance_name,
fuzzy_search_schema_name: filterInfo.fuzzy_search_schema_name,
filter_status: filterInfo.filter_status,
filter_source: filterInfo.filter_source,
filter_audit_level: filterInfo.filter_audit_level,
filter_db_type: filterInfo.filter_rule?.split(
DB_TYPE_RULE_NAME_SEPARATOR
)?.[0],
filter_rule_name: filterInfo.filter_rule?.split(
DB_TYPE_RULE_NAME_SEPARATOR
)?.[1],
fuzzy_search_endpoint: filterInfo.fuzzy_search_endpoint,
sort_field: getSortField(),
sort_order: getSortOrder(),
}).then((res) => {
setSQLNum({
SQLTotalNum: res.data?.sql_manage_total_num ?? 0,
problemSQlNum: res.data?.sql_manage_bad_num ?? 0,
optimizedSQLNum: res.data?.sql_manage_optimized_num ?? 0,
});
return {
list: res.data?.data ?? [],
total: res.data?.sql_manage_total_num ?? 0,
};
});

Check warning on line 140 in src/page/SQLManagement/SQLPanel/index.tsx

View workflow job for this annotation

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

🧾 Statement is not covered

Warning! Not covered statement
},
{
refreshDeps: [pagination, filterInfo, sorterInfo],
Expand Down Expand Up @@ -310,42 +311,43 @@
{ setFalse: finishExport, setTrue: startExport },
] = useBoolean(false);

const exportAction = () => {
startExport();
const hideLoading = message.loading(
t('sqlManagement.table.actions.exporting')
);

const filterValues = filterForm.getFieldsValue();

const params: IExportSqlManageV1Params = {
project_name: projectName,
fuzzy_search_sql_fingerprint: filterValues.fuzzy_search_sql_fingerprint,
filter_assignee: !!filterValues.filter_assignee ? username : undefined,
filter_instance_name: filterValues.filter_instance_name,
fuzzy_search_schema_name: filterValues.fuzzy_search_schema_name,
filter_source: filterValues.filter_source as
| exportSqlManageV1FilterSourceEnum
| undefined,
filter_audit_level: filterValues.filter_audit_level as
| exportSqlManageV1FilterAuditLevelEnum
| undefined,
filter_last_audit_start_time_from: translateTimeForRequest(
filterValues.filter_last_audit_time?.[0]
),
filter_last_audit_start_time_to: translateTimeForRequest(
filterValues.filter_last_audit_time?.[1]
),
filter_status: filterValues.filter_status as
| exportSqlManageV1FilterStatusEnum
| undefined,
filter_db_type: filterValues.filter_rule?.split(
DB_TYPE_RULE_NAME_SEPARATOR
)?.[0],
filter_rule_name: filterValues.filter_rule?.split(
DB_TYPE_RULE_NAME_SEPARATOR
)?.[1],
fuzzy_search_endpoint: filterValues.fuzzy_search_endpoint,
};

Check warning on line 350 in src/page/SQLManagement/SQLPanel/index.tsx

View workflow job for this annotation

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

🧾 Statement is not covered

Warning! Not covered statement

SqlManage.exportSqlManageV1(params, { responseType: 'blob' })
.then((res) => {
Expand All @@ -359,126 +361,126 @@
});
};

Check warning on line 362 in src/page/SQLManagement/SQLPanel/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 (
<section className="padding-content">
<Card>
<Space direction="vertical" size={16} className="full-width-element">
<SQLStatistics {...SQLNum} />

<FilterForm
form={filterForm}
reset={resetFilter}
submit={submitFilter}
projectName={projectName}
/>

<Divider style={{ margin: 0 }} />
<Space>
<EmptyBox if={actionPermission}>
<Space>
<AssignMember
disabled={selectedRowKeys.length === 0 || batchActionsLoading}
projectName={projectName}
onConfirm={batchAssignment}
>
<Button
disabled={
selectedRowKeys.length === 0 || batchActionsLoading
}
type="primary"
>
{t("sqlManagement.table.actions.batchAssignment")}
{t('sqlManagement.table.actions.batchAssignment')}
</Button>
</AssignMember>

<Popconfirm
title={t("sqlManagement.table.actions.batchSolveTips")}
title={t('sqlManagement.table.actions.batchSolveTips')}
placement="topLeft"
okText={t("common.ok")}
okText={t('common.ok')}
disabled={selectedRowKeys.length === 0 || batchActionsLoading}
onConfirm={batchSolve}
>
<Button
disabled={
selectedRowKeys.length === 0 || batchActionsLoading
}
type="primary"
>
{t("sqlManagement.table.actions.batchSolve")}
{t('sqlManagement.table.actions.batchSolve')}
</Button>
</Popconfirm>
<Popconfirm
title={t("sqlManagement.table.actions.batchIgnoreTips")}
title={t('sqlManagement.table.actions.batchIgnoreTips')}
placement="topLeft"
okText={t("common.ok")}
okText={t('common.ok')}
disabled={selectedRowKeys.length === 0 || batchActionsLoading}
onConfirm={batchIgnore}
>
<Button
disabled={
selectedRowKeys.length === 0 || batchActionsLoading
}
type="primary"
>
{t("sqlManagement.table.actions.batchIgnore")}
{t('sqlManagement.table.actions.batchIgnore')}
</Button>
</Popconfirm>
</Space>
</EmptyBox>

<Button
type="primary"
onClick={exportAction}
disabled={exportButtonDisabled}
>
{t("sqlManagement.table.actions.export")}
{t('sqlManagement.table.actions.export')}
</Button>
</Space>

<Table
className="sql-management-table-namespace"
onChange={tableChange}
rowKey={(record: ISqlManage) => {
return record?.id ?? 0;
}}
rowSelection={actionPermission ? rowSelection : undefined}
loading={loading}
dataSource={data?.list}
columns={SQLPanelColumns({
projectName,
updateRemark,
signalAssignment,
signalActionsLoading,
actionPermission,
username,
updateSQLStatus,
})}
pagination={{
showSizeChanger: true,
total: data?.total ?? 0,
current: pagination.pageIndex,
pageSize: pagination.pageSize
pageSize: pagination.pageSize,
}}
expandable={{
expandedRowRender,
rowExpandable: (record) =>
!!record.audit_result && record.audit_result.length > 1,
expandIcon: ({ expanded, onExpand, record }) =>
!!record.audit_result && record.audit_result.length > 1 ? (
expanded ? (
<UpOutlined onClick={(e) => onExpand(record, e)} />
) : (
<DownOutlined onClick={(e) => onExpand(record, e)} />
)
) : null,
columnWidth: 14,
}}
scroll={{ x: "max-content" }}
scroll={{ x: 'max-content' }}
/>
</Space>
</Card>
</section>
);

Check warning on line 483 in src/page/SQLManagement/SQLPanel/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 484 in src/page/SQLManagement/SQLPanel/index.tsx

View workflow job for this annotation

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

🧾 Statement is not covered

Warning! Not covered statement

export default SQLPanel;
2 changes: 2 additions & 0 deletions src/page/SQLManagement/SQLPanel/index.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export type SQLPanelFilterFormFields = {
filter_rule?: string;

fuzzy_search_endpoint?: string;

fuzzy_search_schema_name?: string;
};

export type SQLPanelFilterFormProps = {
Expand Down