Skip to content
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
18 changes: 18 additions & 0 deletions packages/shared/lib/api/sqle/service/SqlManage/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ export interface IGetSqlManageListParams {

fuzzy_search_schema_name?: string;

filter_schema_name?: string;

sort_field?: GetSqlManageListSortFieldEnum;

sort_order?: GetSqlManageListSortOrderEnum;
Expand Down Expand Up @@ -102,6 +104,10 @@ export interface IExportSqlManageV1Params {

fuzzy_search_schema_name?: string;

filter_schema_name?: string;

filter_parse_failed?: boolean;

sort_field?: string;

sort_order?: exportSqlManageV1SortOrderEnum;
Expand Down Expand Up @@ -149,6 +155,10 @@ export interface IExportSqlManageRemediationV1Params {

fuzzy_search_schema_name?: string;

filter_schema_name?: string;

filter_parse_failed?: boolean;

extra_filters?: string;

/** scan_task scope:与明细 sql_data / 扫描任务报表同结构的 filter_list JSON 字符串 */
Expand Down Expand Up @@ -211,6 +221,10 @@ export interface IGetSqlManageListV2Params {

fuzzy_search_schema_name?: string;

filter_schema_name?: string;

filter_parse_failed?: boolean;

sort_field?: string;

sort_order?: GetSqlManageListV2SortOrderEnum;
Expand Down Expand Up @@ -255,6 +269,10 @@ export interface IGetSqlManageStatisticsV2Params {

fuzzy_search_schema_name?: string;

filter_schema_name?: string;

filter_parse_failed?: boolean;

extra_filters?: string;
}

Expand Down
20 changes: 17 additions & 3 deletions packages/sqle/src/hooks/useInstanceSchema/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@ import React from 'react';
import { ResponseCode } from '../../data/common';
import instance from '@actiontech/shared/lib/api/sqle/service/instance';

const useInstanceSchema = (projectName: string, instanceName?: string) => {
type UseInstanceSchemaOptions = {
/** 默认 true:instanceName 变化时自动拉取。SQL 管控 Schema 筛选用 false,仅点开下拉时拉取。 */
autoFetch?: boolean;
};

const useInstanceSchema = (
projectName: string,
instanceName?: string,
options?: UseInstanceSchemaOptions
) => {
const autoFetch = options?.autoFetch !== false;
const [schemaList, setSchemaList] = React.useState<string[]>([]);
const [loading, { setTrue, setFalse }] = useBoolean();

Expand Down Expand Up @@ -38,8 +48,12 @@ const useInstanceSchema = (projectName: string, instanceName?: string) => {
}, [schemaList]);

React.useEffect(() => {
updateSchemaList();
}, [instanceName, updateSchemaList]);
if (autoFetch) {
updateSchemaList();
return;
}
setSchemaList([]);
}, [autoFetch, instanceName, updateSchemaList]);

return {
schemaList,
Expand Down
4 changes: 4 additions & 0 deletions packages/sqle/src/locale/en-US/sqlManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export default {
},
business: 'Business',
instanceName: 'DB instance',
schema: 'Schema',
source: {
label: 'Source',
auditPlan: 'Scan task',
Expand All @@ -123,7 +124,10 @@ export default {
notice: 'Notice'
},
assignee: 'Related to me',
highPriority: 'High priority',
viewHighPrioritySql: 'View high priority SQL',
parseFailed: 'Syntax error or unsupported by parser',
schemaSelectTip: 'Select a data source to enable the dropdown',
rule: 'Audit rule',
ruleSelectDbTypeFirst: 'Database type',
ruleDbTypeFilter: 'Database type',
Expand Down
4 changes: 4 additions & 0 deletions packages/sqle/src/locale/zh-CN/sqlManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export default {
},
business: '业务',
instanceName: '数据源',
schema: 'Schema',
source: {
label: '来源',
auditPlan: '扫描任务',
Expand All @@ -126,7 +127,10 @@ export default {
notice: '提示'
},
assignee: '与我相关',
highPriority: '高优先级',
viewHighPrioritySql: '查看高优先级SQL',
parseFailed: '语法错误或解析器不支持',
schemaSelectTip: '选择数据源后可下拉选择',
rule: '审核规则',
ruleSelectDbTypeFirst: '数据源类型',
ruleDbTypeFilter: '数据源类型',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,17 @@ exports[`page/SqlManagement render sql management page 1`] = `
class="ant-btn css-dev-only-do-not-override-czn7jp ant-btn-default ant-btn-sm actiontech-table-actions-button switch-btn-default basic-button-wrapper css-geipcv"
type="button"
>
<span>
查看高优先级SQL
</span>
<div
class="ant-space css-dev-only-do-not-override-czn7jp ant-space-horizontal ant-space-align-center basic-tooltips-wrapper css-4jbtl9"
>
<div
class="ant-space-item"
>
<span>
高优先级
</span>
</div>
</div>
</button>
</div>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,17 @@ exports[`page/SqlManagement/SQLEEIndex filter data with rule name 1`] = `
class="ant-btn css-dev-only-do-not-override-czn7jp ant-btn-default ant-btn-sm actiontech-table-actions-button switch-btn-default basic-button-wrapper css-geipcv"
type="button"
>
<span>
查看高优先级SQL
</span>
<div
class="ant-space css-dev-only-do-not-override-czn7jp ant-space-horizontal ant-space-align-center basic-tooltips-wrapper css-4jbtl9"
>
<div
class="ant-space-item"
>
<span>
高优先级
</span>
</div>
</div>
</button>
</div>
<div
Expand Down Expand Up @@ -607,6 +615,36 @@ exports[`page/SqlManagement/SQLEEIndex filter data with rule name 1`] = `
/>
</div>
</div>
<div
class="ant-space-item"
style="margin-right: 12px; padding-bottom: 12px;"
>
<span
class="ant-input-affix-wrapper basic-input-wrapper custom-input-namespace css-1v8xzxw ant-input-affix-wrapper-sm css-dev-only-do-not-override-mlhibv"
>
<span
class="ant-input-prefix"
>
<div
class="ant-space css-dev-only-do-not-override-mlhibv ant-space-horizontal ant-space-align-center basic-tooltips-wrapper css-4jbtl9"
>
<div
class="ant-space-item"
>
<span>
Schema
</span>
</div>
</div>
</span>
<input
class="ant-input ant-input-sm css-dev-only-do-not-override-mlhibv"
placeholder="请输入{{name}}"
type="text"
value=""
/>
</span>
</div>
<div
class="ant-space-item"
style="margin-right: 12px; padding-bottom: 12px;"
Expand Down Expand Up @@ -2039,6 +2077,13 @@ exports[`page/SqlManagement/SQLEEIndex filter data with rule name 1`] = `
aria-selected="false"
id="rc_select_TEST_OR_SSR_list_0"
role="option"
>
__PARSE_FAILED__
</div>
<div
aria-selected="false"
id="rc_select_TEST_OR_SSR_list_1"
role="option"
>
MySQL_DB_TYPE_RULE_NAME_SEPARATOR_test
</div>
Expand All @@ -2059,6 +2104,53 @@ exports[`page/SqlManagement/SQLEEIndex filter data with rule name 1`] = `
<div
aria-selected="false"
class="ant-select-item ant-select-item-option ant-select-item-option-active"
>
<div
class="ant-select-item-option-content"
>
<div
class="ant-space css-dev-only-do-not-override-jx040l ant-space-horizontal ant-space-align-center"
>
<div
class="ant-space-item"
style="margin-right: 6px;"
>
<span
class="audit-level-icon audit-level-icon-warn"
>
<svg
fill="none"
height="14"
viewBox="0 0 16 16"
width="14"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="m8.577 2 6.35 11a.667.667 0 0 1-.577 1H1.648a.667.667 0 0 1-.577-1l6.35-11a.667.667 0 0 1 1.156 0m-1.244 8.667V12h1.333v-1.333zm0-4.667v3.334h1.333V6z"
fill="#EBAD1C"
/>
</svg>
</span>
</div>
<div
class="ant-space-item"
>
<span>
语法错误或解析器不支持
</span>
</div>
</div>
</div>
<span
aria-hidden="true"
class="ant-select-item-option-state"
style="user-select: none;"
unselectable="on"
/>
</div>
<div
aria-selected="false"
class="ant-select-item ant-select-item-option"
>
<div
class="ant-select-item-option-content"
Expand Down Expand Up @@ -2475,9 +2567,17 @@ exports[`page/SqlManagement/SQLEEIndex filter data with sort 1`] = `
class="ant-btn css-dev-only-do-not-override-czn7jp ant-btn-default ant-btn-sm actiontech-table-actions-button switch-btn-default basic-button-wrapper css-geipcv"
type="button"
>
<span>
查看高优先级SQL
</span>
<div
class="ant-space css-dev-only-do-not-override-czn7jp ant-space-horizontal ant-space-align-center basic-tooltips-wrapper css-4jbtl9"
>
<div
class="ant-space-item"
>
<span>
高优先级
</span>
</div>
</div>
</button>
</div>
<div
Expand Down Expand Up @@ -3487,9 +3587,17 @@ exports[`page/SqlManagement/SQLEEIndex render sql statics data 1`] = `
class="ant-btn css-dev-only-do-not-override-czn7jp ant-btn-default ant-btn-sm actiontech-table-actions-button switch-btn-default basic-button-wrapper css-geipcv"
type="button"
>
<span>
查看高优先级SQL
</span>
<div
class="ant-space css-dev-only-do-not-override-czn7jp ant-space-horizontal ant-space-align-center basic-tooltips-wrapper css-4jbtl9"
>
<div
class="ant-space-item"
>
<span>
高优先级
</span>
</div>
</div>
</button>
</div>
<div
Expand Down Expand Up @@ -4931,9 +5039,17 @@ exports[`page/SqlManagement/SQLEEIndex render table data 1`] = `
class="ant-btn css-dev-only-do-not-override-czn7jp ant-btn-default ant-btn-sm actiontech-table-actions-button switch-btn-default basic-button-wrapper css-geipcv"
type="button"
>
<span>
查看高优先级SQL
</span>
<div
class="ant-space css-dev-only-do-not-override-czn7jp ant-space-horizontal ant-space-align-center basic-tooltips-wrapper css-4jbtl9"
>
<div
class="ant-space-item"
>
<span>
高优先级
</span>
</div>
</div>
</button>
</div>
<div
Expand Down Expand Up @@ -7862,9 +7978,17 @@ exports[`page/SqlManagement/SQLEEIndex render table for not admin 1`] = `
class="ant-btn css-dev-only-do-not-override-czn7jp ant-btn-default ant-btn-sm actiontech-table-actions-button switch-btn-default basic-button-wrapper css-geipcv"
type="button"
>
<span>
查看高优先级SQL
</span>
<div
class="ant-space css-dev-only-do-not-override-czn7jp ant-space-horizontal ant-space-align-center basic-tooltips-wrapper css-4jbtl9"
>
<div
class="ant-space-item"
>
<span>
高优先级
</span>
</div>
</div>
</button>
</div>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@ import { formatTime } from '@actiontech/shared/lib/utils/Common';
import { SQLAuditRecordListUrlParamsKey } from './index.data';
export type SqlManagementTableFilterParamType = PageInfoWithoutIndexAndSize<
IGetSqlManageListV2Params,
'fuzzy_search_sql_fingerprint' | 'filter_status' | 'project_name'
| 'fuzzy_search_sql_fingerprint'
| 'filter_status'
| 'project_name'
| 'filter_parse_failed'
> &
Record<string, string | [string, string] | undefined>;

export type ExtraFilterMetaType = ISqlManage & {
filter_business?: string;
filter_source?: string;
filter_instance_id?: string;
filter_schema_name?: string;
filter_audit_level?: string;
filter_rule_name?: string;
time?: string;
Expand Down Expand Up @@ -70,6 +74,15 @@ export const ExtraFilterMeta: () => ActiontechTableFilterMeta<
checked: false
}
],
[
'filter_schema_name',
{
filterCustomType: 'input',
filterKey: 'filter_schema_name',
filterLabel: t('sqlManagement.table.filter.schema'),
checked: false
}
],
[
'filter_source',
{
Expand Down
Loading
Loading