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]:sql management #36

Merged
merged 21 commits into from
Nov 6, 2023
Merged
1 change: 1 addition & 0 deletions packages/base/src/locale/en-US/dmsMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default {
ruleTemplate: '规则模板',
whitelist: '白名单',
workflowTemplate: '流程模板',
sqlManagement: 'SQL管控',
SQLOrder: 'SQL工单',
auditPlan: '扫描任务',
permissionGroup: '权限组',
Expand Down
1 change: 1 addition & 0 deletions packages/base/src/locale/zh-CN/dmsMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default {
ruleTemplate: '规则模板',
whitelist: '白名单',
workflowTemplate: '流程模板',
sqlManagement: 'SQL管控',
SQLOrder: 'SQL工单',
auditPlan: '扫描任务',
permissionGroup: '权限组',
Expand Down
6 changes: 6 additions & 0 deletions packages/base/src/page/Nav/SideMenu/menus/sqle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ export const SQLEMenuItems: GenerateMenuItemsType = ({
icon: <Icon component={IconWorkflowTemplate} />,
onClick: () => navigate(`/sqle/project/${projectID}/progress`)
},
{
LZS911 marked this conversation as resolved.
Show resolved Hide resolved
label: t('dmsMenu.sqlManagement'),
icon: <Icon component={IconSQLOrder} />,
key: `sqle/project/${SIDE_MENU_DATA_PLACEHOLDER_KEY}/sqlManagement`,
onClick: () => navigate(`/sqle/project/${projectID}/sqlManagement`)
},
{
label: t('dmsMenu.SQLOrder'),
key: `sqle/project/${SIDE_MENU_DATA_PLACEHOLDER_KEY}/order`,
Expand Down
4 changes: 3 additions & 1 deletion packages/base/src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import ruleTemplate from 'sqle/src/store/ruleTemplate';
import whitelist from 'sqle/src/store/whitelist';
// import system from 'sqle/src/store/system';
import projectManage from 'sqle/src/store/projectManage';
import sqleManagement from 'sqle/src/store/sqleManagement';

const store = configureStore({
reducer: {
Expand All @@ -30,7 +31,8 @@ const store = configureStore({
reportStatistics,
ruleTemplate,
whitelist,
projectManage
projectManage,
sqleManagement
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,24 @@ const useTableRequestError = () => {
message?: string;
total_nums?: number;
},
R = { list: T['data']; total: number }
R = { list: T['data']; total: number; otherData?: Record<string, any> }
>(request: Promise<AxiosResponse<T>>): Promise<R> {
return request
.then((response) => {
setRequestErrorMessage('');
if ('data' in response.data && 'total_nums' in response.data) {
const { data, total_nums, ...otherData } = response.data;
return {
list: response.data.data ?? [],
total: response.data?.total_nums ?? 0
total: response.data?.total_nums ?? 0,
otherData
};
} else if ('data' in response.data) {
const { data, total_nums, ...otherData } = response.data;
LZS911 marked this conversation as resolved.
Show resolved Hide resolved
return {
list: response.data.data ?? [],
total: response.data.data?.length ?? 0
total: response.data.data?.length ?? 0,
otherData
};
}
})
Expand Down
18 changes: 18 additions & 0 deletions packages/shared/lib/components/BasicButton/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,22 @@ export const BasicButtonStyleWrapper = styled(Button)`
}
}
}

/* switch button */
&.basic-button-wrapper.${ANTD_PREFIX_STR}-btn-default.switch-btn-default {
color: ${({ theme }) => theme.sharedTheme.uiToken.colorTextSecondary};
background: ${({ theme }) => theme.sharedTheme.uiToken.colorFillTertiary};
}

&.basic-button-wrapper.${ANTD_PREFIX_STR}-btn-default.switch-btn-active {
color: ${({ theme }) => theme.sharedTheme.uiToken.colorPrimary};
background: ${({ theme }) => theme.sharedTheme.basic.colorPrimaryBgActive};
}

&.basic-button-wrapper.${ANTD_PREFIX_STR}-btn-default.has-icon-primary {
.custom-icon {
color: ${({ theme }) =>
theme.sharedTheme.uiToken.colorPrimary} !important;
}
}
`;
5 changes: 4 additions & 1 deletion packages/shared/lib/components/BasicSelect/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ export const filterOptionByLabel: SelectProps['filterOption'] = (
input: string,
option?: DefaultOptionType
) => {
const label = extractTextFromReactNode(option?.label);
const label = extractTextFromReactNode(
option?.label ??
(typeof option?.children === 'string' ? option?.children : '')
);
return label.toLowerCase().includes(input.toLowerCase());
};
4 changes: 2 additions & 2 deletions packages/shared/lib/components/BasicTag/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export const BasicTagStyleWrapper = styled(Tag)<{ color: BasicTagColor }>`

&.basic-tag-wrapper.${ANTD_PREFIX_STR}-tag:not(.basic-default-tag-wrapper) {
color: ${({ color, theme }) =>
theme.sharedTheme.components.basicTag[color].color};
theme.sharedTheme.components.basicTag[color].color} !important;
background: ${({ color, theme }) =>
theme.sharedTheme.components.basicTag[color].backgroundColor};
theme.sharedTheme.components.basicTag[color].backgroundColor} !important;
}
`;
6 changes: 6 additions & 0 deletions packages/shared/lib/components/EditText/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import EmptyBox from '../EmptyBox';
import BasicButton from '../BasicButton';
import { IconEdit } from '../../Icon/common';
import { EditTextStyleWrapper } from './style';
import classNames from 'classnames';

const EditText: React.FC<EditTypeProps> = ({
value,
Expand Down Expand Up @@ -41,6 +42,11 @@ const EditText: React.FC<EditTypeProps> = ({
if={showEdit}
defaultNode={
<BasicButton
size="small"
className={classNames({
'has-icon-primary': !editButtonProps?.children
})}
icon={editButtonProps?.children ? undefined : <IconEdit />}
{...editButtonProps}
onClick={(e) => {
e.stopPropagation();
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/lib/theme/light/components/tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const tagTheme: BasicTagTheme = {
backgroundColor: '#fffff'
},
gray: {
color: '#7d8ca8',
backgroundColor: 'rgba(125, 140, 168, 0.1)'
color: '#7D8CA8',
backgroundColor: 'rgba(125, 140, 168, 0.10)'
},
red: {
color: '#F66074',
Expand Down
4 changes: 3 additions & 1 deletion packages/sqle/src/data/EmitterKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ enum EmitterKey {

Refresh_Sync_Task_Rule_Template_Tips = 'REFRESH_SYNC_TASK_RULE_TEMPLATE_TIPS',
Refresh_Report_Statistics = 'Refresh_Report_Statistics',
Refresh_Project_Overview = 'Refresh_Project_Overview'
Refresh_Project_Overview = 'Refresh_Project_Overview',

Refresh_SQL_Management = 'Refresh_SQL_Management'
}

export default EmitterKey;
8 changes: 7 additions & 1 deletion packages/sqle/src/data/ModalName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,11 @@ export enum ModalName {
Add_Member = 'Add_Member',
Update_Member = 'Update_Member',
Add_Member_Group = 'Add_Member_Group',
Update_Member_Group = 'Update_Member_Group'
Update_Member_Group = 'Update_Member_Group',

// sqle management
Assignment_Member_Single = 'Assignment_Member_Single',
Assignment_Member_Batch = 'Assignment_Member_Batch',
Change_Status_Single = 'Change_Status_Single',
View_Audit_Result_Drawer = 'View_Audit_Result_Drawer'
}
13 changes: 13 additions & 0 deletions packages/sqle/src/hooks/useStaticStatus/index.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from '@actiontech/shared/lib/api/sqle/service/task/index.enum';
import { getWorkflowsV1FilterStatusEnum } from '@actiontech/shared/lib/api/sqle/service/workflow/index.enum';
import { StaticEnumDictionary } from './index.type';
import { GetSqlManageListFilterStatusEnum } from '@actiontech/shared/lib/api/sqle/service/SqlManage/index.enum';

export const execStatusDictionary: StaticEnumDictionary<getAuditTaskSQLsV2FilterExecStatusEnum> =
{
Expand Down Expand Up @@ -80,3 +81,15 @@ export const auditLevelDictionary: StaticEnumDictionary<WorkflowTemplateDetailRe
[WorkflowTemplateDetailResV1AllowSubmitWhenLessAuditLevelEnum.error]:
'workflowTemplate.auditLevel.error'
};

export const sqlManagementDictionary: StaticEnumDictionary<GetSqlManageListFilterStatusEnum> =
{
[GetSqlManageListFilterStatusEnum.unhandled]:
'sqlManagement.table.filter.status.unhandled',
[GetSqlManageListFilterStatusEnum.solved]:
'sqlManagement.table.filter.status.solved',
[GetSqlManageListFilterStatusEnum.ignored]:
'sqlManagement.table.filter.status.ignored',
[GetSqlManageListFilterStatusEnum.manual_audited]:
'sqlManagement.table.filter.status.manual_audited'
};
4 changes: 3 additions & 1 deletion packages/sqle/src/locale/en-US/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import whitelist from './whitelist';
import system from './system';
import reportStatistics from './reportStatistics';
import projectManage from './projectManage';
import sqlManagement from './sqlManagement';

// eslint-disable-next-line import/no-anonymous-default-export
export default {
Expand All @@ -25,6 +26,7 @@ export default {
whitelist,
system,
reportStatistics,
projectManage
projectManage,
sqlManagement
}
};
80 changes: 80 additions & 0 deletions packages/sqle/src/locale/en-US/sqlManagement.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// eslint-disable-next-line import/no-anonymous-default-export
export default {
pageTitle: 'SQL管控',
pageHeader: {
action: {
export: '导出',
exporting: '正在导出文件',
exportSuccessTips: '导出文件成功'
}
},
statistics: {
SQLTotalNum: 'SQL总数',
problemSQlNum: '问题SQL数',
optimizedSQLNum: '已优化SQL数'
},
ceTips:
'SQL管控为用户提供SQL全生命周期监控,面板将整合所有的业务SQL,用户可以在该面板中查看项目中采集并审核的所有SQL,暴露其中的问题SQL,同时支持用户解决问题SQL。',
table: {
action: {
batch: {
assignment: '批量指派',
assignmentSuccessTips: '批量指派负责人成功',
solve: '批量解决',
solveTips: '是否确认将所选SQL设为已解决?',
solveSuccessTips: '批量解决SQL成功',
ignore: '批量忽略',
ignoreTips: '是否确认将所选SQL设为已忽略?',
ignoreSuccessTips: '批量忽略SQL成功'
},
single: {
assignment: '指派负责人',
assignmentSuccessTips: '指派负责人成功',
updateStatus: {
triggerText: '变更状态',
label: '当前SQL状态',
solve: '解决',
ignore: '忽略',
manualAudit: '人工审核',
signalUpdateStatusSuccessTips: '更新SQL状态成功'
}
}
},
column: {
SQLFingerprint: 'SQL指纹',
source: '来源',
instanceName: '数据源',
auditResult: '审核结果',
firstOccurrence: '初次出现时间',
lastOccurrence: '最后一次出现时间',
occurrenceCount: '出现数量',
personInCharge: '负责人',
status: '状态',
comment: '备注'
},
filter: {
time: '时间范围',
status: {
unhandled: '未处理',
solved: '已解决',
ignored: '已忽略',
manual_audited: '已人工审核'
},
source: {
auditPlan: '智能扫描',
apiAudit: 'SQL审核'
},
auditLevel: {
label: '最低审核等级',
normal: '普通',
error: '错误',
warn: '告警',
notice: '提示'
},
assignee: '与我相关'
},
statusReport: {
title: 'SQL审核结果'
}
}
};
4 changes: 3 additions & 1 deletion packages/sqle/src/locale/zh-CN/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import projectManage from './projectManage';
import operationRecord from './operationRecord';
import customRule from './customRule';
import ruleManager from './ruleManager';
import sqlManagement from './sqlManagement';

// eslint-disable-next-line import/no-anonymous-default-export
export default {
Expand All @@ -37,6 +38,7 @@ export default {
projectManage,
operationRecord,
customRule,
ruleManager
ruleManager,
sqlManagement
}
};
3 changes: 2 additions & 1 deletion packages/sqle/src/locale/zh-CN/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ export default {
projectOverview: '项目概览',
allInstanceType: '所有数据库类型',
syncDataSource: '外部数据源同步',
operationRecord: 'SQLE操作记录'
operationRecord: 'SQLE操作记录',
sqlManagement: 'SQL管控'
};
Loading