Skip to content

Commit 2649047

Browse files
committed
🎨 issue 列表展示 msg 信息
1 parent 8de8b14 commit 2649047

7 files changed

Lines changed: 129 additions & 37 deletions

File tree

web/packages/tca-analysis/src/modules/projects/issues/index.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,17 @@ const Issues = (props: IssuesProps) => {
360360
sorter
361361
sortOrder={sort.key === 'checkrule_real_name' ? sort.order : undefined}
362362
render={(name: any, item: any) => (
363-
<Tooltip title={item.msg}>
364-
<span>{name}</span>
365-
</Tooltip>
363+
<>
364+
<p>{name}</p>
365+
{
366+
item.msg && item.msg?.length > 120
367+
? (
368+
<Tooltip title={item.msg}>
369+
<p className={style.path}>错误信息:{item?.msg?.substring(0, 120)}...</p>
370+
</Tooltip>
371+
) : <p className={style.path}>错误信息:{item.msg}</p>
372+
}
373+
</>
366374
)}
367375
/>
368376
<Column

web/packages/tca-analysis/src/modules/projects/issues/rule-detail.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ interface RuleDetailProps {
2727
const RuleDetail = (props: RuleDetailProps) => {
2828
const { data, visible, onClose } = props;
2929
const { orgSid } = useParams<any>();
30-
console.log(data);
3130

3231
return (
3332
<Drawer

web/packages/tca-analysis/src/modules/projects/issues/style.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
.path {
4343
font-size: 12px;
44-
color: $grey-7;
44+
color: $grey-6;
4545
max-width: 400px;
4646
word-break: break-all;
4747
}

web/packages/tca-analysis/src/modules/schemes/code-lint/all-rules-search.tsx

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,27 @@
55
// ==============================================================================
66

77
import React, { useEffect } from 'react';
8-
import { toNumber, isString, isEmpty, isArray, cloneDeep } from 'lodash';
9-
import { Input, Form, Button } from 'coding-oa-uikit';
8+
import { toNumber, isString, isEmpty, isArray, cloneDeep, find } from 'lodash';
9+
import { Input, Form, Button, Select } from 'coding-oa-uikit';
1010

1111
import SelectBorderless from '@src/components/select-borderless';
1212
import Filter from '@src/components/filter';
1313
import { SEVERITY, CATEGORY } from '../constants';
1414

15-
const numberParams = ['checkpackage', 'severity', 'category', 'checktool'];
15+
const numberParams = ['checkpackage', 'severity', 'category'];
1616
const arrayParams = ['language'];
1717

1818
interface SearchProps {
1919
filters: any;
2020
searchParams: any;
2121
loading: boolean;
22+
addToolsRules: (toolId: number) => void; // 一键添加工具所有规则
2223
callback: (params: any) => void;
2324
}
2425

2526
const Search = (props: SearchProps) => {
2627
const [form] = Form.useForm();
27-
const { searchParams, loading, filters, callback } = props;
28+
const { searchParams, loading, filters, addToolsRules, callback } = props;
2829
const { allPkgs = [], languages = [], checkTools = [] }: any = filters;
2930

3031
const initialValues = cloneDeep(searchParams);
@@ -36,6 +37,10 @@ const Search = (props: SearchProps) => {
3637
.map((item: string) => toNumber(item));
3738
}
3839

40+
if (initialValues.checktool) {
41+
initialValues.checktool = toNumber(initialValues.checktool);
42+
}
43+
3944
if (arrayParams.includes(key) && isString(value)) {
4045
initialValues[key] = value.split(',');
4146
}
@@ -104,46 +109,70 @@ const Search = (props: SearchProps) => {
104109
}
105110
/>
106111
</Filter.Item>
107-
<Filter.Item label="所属工具" name="checktool">
112+
<Filter.Item label="适用语言" name="language">
108113
<SelectBorderless
109114
multiple
110115
allowClear
111116
placeholder="全部"
112-
data={checkTools?.map((item: any) => ({
113-
value: item.id,
117+
data={languages?.map((item: any) => ({
118+
value: item.name,
114119
text: item.display_name,
115120
}))}
116-
onChange={(value: any) => value && onChange('checktool', value.join(','))
121+
onChange={(value: any) => value && onChange('language', value.join(','))
117122
}
118123
/>
119124
</Filter.Item>
120-
<Filter.Item label="适用语言" name="language">
121-
<SelectBorderless
122-
multiple
125+
<Filter.Item label="所属工具" name="checktool">
126+
<Select
127+
showSearch
128+
allowClear
129+
size='middle'
130+
placeholder='全部工具'
131+
style={{ minWidth: '150px' }}
132+
optionFilterProp='children'
133+
dropdownMatchSelectWidth={false}
134+
onChange={(value: any) => onChange('checktool', value)}
135+
>
136+
{
137+
checkTools.map((item: any) => (
138+
<Select.Option key={item.id} value={item.id}>{item.display_name}</Select.Option>
139+
))
140+
}
141+
</Select>
142+
{/* <SelectBorderless
123143
allowClear
124144
placeholder="全部"
125-
data={languages?.map((item: any) => ({
126-
value: item.name,
145+
data={checkTools?.map((item: any) => ({
146+
value: item.id,
127147
text: item.display_name,
128148
}))}
129-
onChange={(value: any) => value && onChange('language', value.join(','))
149+
onChange={(value: any) => value && onChange('checktool', value.join(','))
130150
}
131-
/>
151+
/> */}
132152
</Filter.Item>
153+
133154
<Filter.Item label="" name="real_name">
134155
<Input.Search
135156
size="middle"
136157
placeholder="规则名称"
158+
style={{ minWidth: '150px' }}
137159
onSearch={value => onChange('real_name', value)}
138160
/>
139161
</Filter.Item>
140162
{Object.keys(searchParams).some((key: string) => (isArray(searchParams[key])
141163
? !isEmpty(searchParams[key])
142164
: searchParams[key])) && (
143-
<Button type="link" onClick={onClear} style={{ height: '36px' }}>
165+
<Button type="link" onClick={onClear} style={{ height: '36px', marginRight: 10 }}>
144166
清空过滤
145167
</Button>
146168
)}
169+
{
170+
find(checkTools, { id: initialValues.checktool }) && (
171+
<Button type="link" style={{ height: '36px' }} onClick={() => addToolsRules(initialValues.checktool)}>
172+
一键添加 {find(checkTools, { id: initialValues.checktool })?.display_name} 工具的所有规则
173+
</Button>
174+
)
175+
}
147176
</Filter>
148177
);
149178
};

web/packages/tca-analysis/src/modules/schemes/code-lint/all-rules.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,19 @@ const AllRules = () => {
129129
});
130130
};
131131

132+
/**
133+
* 一键添加指定工具所有规则
134+
* @param toolId
135+
*/
136+
const addToolsRules = (toolId: number) => {
137+
addRule(orgSid, teamName, repoId, schemeId, {
138+
checktool: toolId,
139+
}).then(() => {
140+
message.success('批量添加成功');
141+
getListData(pageStart, pageSize);
142+
});
143+
};
144+
132145
const openRuleDetail = async (ruleId: number) => {
133146
setRuleDetailVsb(true);
134147
const res = await getRuleDetail(orgSid, teamName, repoId, schemeId, ruleId);
@@ -163,6 +176,7 @@ const AllRules = () => {
163176
}}
164177
searchParams={cloneDeep(searchParams)}
165178
loading={loading}
179+
addToolsRules={addToolsRules}
166180
callback={(params: any) => {
167181
getListData(DEFAULT_PAGER.pageStart, pageSize, params);
168182
}}
@@ -212,7 +226,7 @@ const AllRules = () => {
212226
<Column title="规则概要" dataIndex="rule_title" />
213227
<Column title="所属工具" dataIndex={['checktool', 'display_name']} />
214228
<Column title="分类" dataIndex="category_name" />
215-
<Column title="问题级别" dataIndex="severity_name" />
229+
<Column title="问题级别" dataIndex="severity_name" width={80}/>
216230
</Table>
217231
</div>
218232
<RuleDetail

web/packages/tca-analysis/src/modules/template/code-lint/all-rules-search.tsx

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,27 @@
55
// ==============================================================================
66

77
import React, { useEffect } from 'react';
8-
import { toNumber, isString, isEmpty, isArray, cloneDeep } from 'lodash';
9-
import { Input, Form, Button } from 'coding-oa-uikit';
8+
import { toNumber, isString, isEmpty, isArray, cloneDeep, find } from 'lodash';
9+
import { Input, Form, Button, Select } from 'coding-oa-uikit';
1010

1111
import SelectBorderless from '@src/components/select-borderless';
1212
import Filter from '@src/components/filter';
1313
import { SEVERITY } from '../../schemes/constants';
1414

15-
const numberParams = ['checkpackage', 'severity', 'category', 'checktool'];
15+
const numberParams = ['checkpackage', 'severity', 'category'];
1616
const arrayParams = ['language_name'];
1717

1818
interface SearchProps {
1919
filters: any;
2020
searchParams: any;
2121
loading: boolean;
22+
addToolsRules: (toolId: number) => void; // 一键添加工具所有规则
2223
callback: (params: any) => void;
2324
}
2425

2526
const Search = (props: SearchProps) => {
2627
const [form] = Form.useForm();
27-
const { searchParams, loading, filters, callback } = props;
28+
const { searchParams, loading, filters, addToolsRules, callback } = props;
2829
const { allPkgs = [], labels = [], languages = [], checkTools = [] } = filters as any;
2930

3031
const initialValues = cloneDeep(searchParams);
@@ -36,6 +37,10 @@ const Search = (props: SearchProps) => {
3637
.map((item: string) => toNumber(item));
3738
}
3839

40+
if (initialValues.checktool) {
41+
initialValues.checktool = toNumber(initialValues.checktool);
42+
}
43+
3944
if (arrayParams.includes(key) && isString(value)) {
4045
initialValues[key] = value.split(',');
4146
}
@@ -101,31 +106,47 @@ const Search = (props: SearchProps) => {
101106
}
102107
/>
103108
</Filter.Item>
104-
<Filter.Item label="所属工具" name="checktool">
109+
<Filter.Item label="适用语言" name="language_name">
105110
<SelectBorderless
106111
multiple
107112
allowClear
108113
placeholder="全部"
109-
data={checkTools?.map((item: any) => ({
110-
value: item.id,
114+
data={languages?.map((item: any) => ({
115+
value: item.name,
111116
text: item.display_name,
112117
}))}
113-
onChange={(value: any) => value && onChange('checktool', value.join(','))
118+
onChange={(value: any) => value && onChange('language_name', value.join(','))
114119
}
115120
/>
116121
</Filter.Item>
117-
<Filter.Item label="适用语言" name="language_name">
118-
<SelectBorderless
122+
<Filter.Item label="所属工具" name="checktool">
123+
<Select
124+
showSearch
125+
allowClear
126+
size='middle'
127+
placeholder='全部工具'
128+
style={{ minWidth: '150px' }}
129+
optionFilterProp='children'
130+
dropdownMatchSelectWidth={false}
131+
onChange={(value: any) => onChange('checktool', value)}
132+
>
133+
{
134+
checkTools.map((item: any) => (
135+
<Select.Option key={item.id} value={item.id}>{item.display_name}</Select.Option>
136+
))
137+
}
138+
</Select>
139+
{/* <SelectBorderless
119140
multiple
120141
allowClear
121142
placeholder="全部"
122-
data={languages?.map((item: any) => ({
123-
value: item.name,
143+
data={checkTools?.map((item: any) => ({
144+
value: item.id,
124145
text: item.display_name,
125146
}))}
126-
onChange={(value: any) => value && onChange('language_name', value.join(','))
147+
onChange={(value: any) => value && onChange('checktool', value.join(','))
127148
}
128-
/>
149+
/> */}
129150
</Filter.Item>
130151
<Filter.Item label="" name="real_name">
131152
<Input.Search
@@ -137,10 +158,17 @@ const Search = (props: SearchProps) => {
137158
{Object.keys(searchParams).some((key: string) => (isArray(searchParams[key])
138159
? !isEmpty(searchParams[key])
139160
: searchParams[key])) && (
140-
<Button type="link" onClick={onClear} style={{ height: '36px' }}>
161+
<Button type="link" onClick={onClear} style={{ height: '36px', marginRight: 10 }}>
141162
清空过滤
142163
</Button>
143164
)}
165+
{
166+
find(checkTools, { id: initialValues.checktool }) && (
167+
<Button type="link" style={{ height: '36px' }} onClick={() => addToolsRules(initialValues.checktool)}>
168+
一键添加 {find(checkTools, { id: initialValues.checktool })?.display_name} 工具的所有规则
169+
</Button>
170+
)
171+
}
144172
</Filter>
145173
);
146174
};

web/packages/tca-analysis/src/modules/template/code-lint/all-rules.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,19 @@ const AllRules = () => {
131131
});
132132
};
133133

134+
/**
135+
* 一键添加指定工具所有规则
136+
* @param toolId
137+
*/
138+
const addToolsRules = (toolId: number) => {
139+
addRule(orgSid, tmplId, {
140+
checktool: toolId,
141+
}).then(() => {
142+
message.success('批量添加成功');
143+
getListData(pageStart, pageSize);
144+
});
145+
};
146+
134147
const openRuleDetail = async (ruleId: number) => {
135148
setRuleDetailVsb(true);
136149
const res = await getRuleDetail(orgSid, tmplId, ruleId);
@@ -163,6 +176,7 @@ const AllRules = () => {
163176
}}
164177
searchParams={cloneDeep(searchParams)}
165178
loading={loading}
179+
addToolsRules={addToolsRules}
166180
callback={(params: any) => {
167181
getListData(DEFAULT_PAGER.pageStart, pageSize, params);
168182
}}

0 commit comments

Comments
 (0)