Skip to content

Commit 16be69c

Browse files
authored
feat: improve problems panel (#242)
* feat: problem panel support to render more informations * feat: panel container support to focus
1 parent 0a770c5 commit 16be69c

File tree

9 files changed

+83
-12
lines changed

9 files changed

+83
-12
lines changed

src/components/tree/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,13 @@ const TreeView = ({
108108
// take id as backup
109109
key = id || `${index}_${indent}`,
110110
icon,
111-
children,
111+
children = [],
112112
isLeaf: itemIsLeaf,
113113
} = item;
114114
const isLeaf =
115115
typeof itemIsLeaf === 'boolean'
116116
? itemIsLeaf
117-
: item.fileType === FileTypes.File;
117+
: item.fileType === FileTypes.File || children.length === 0;
118118
const IconComponent =
119119
typeof icon === 'string' ? <Icon type={icon} /> : icon;
120120
return (

src/extensions/theme-defaults/themes/dark_defaults.json

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"list.inactiveSelectionBackground": "#37373D",
1616
"list.focusOutline": "#007FD4",
1717
"activityBarBadge.background": "#007ACC",
18+
"activityBar.inactiveForeground": "#ffffff66",
1819
"sidebarTitle.foreground": "#BBBBBB",
1920
"sideBarSectionHeader.border": "#ccc3",
2021
"input.placeholderForeground": "#A6A6A6",

src/extensions/theme-defaults/themes/light_defaults.json

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"editor.selectionHighlightBackground": "#ADD6FF80",
1212
"editorSuggestWidget.background": "#F3F3F3",
1313
"activityBarBadge.background": "#007ACC",
14+
"activityBar.inactiveForeground": "#ffffff66",
1415
"sidebarTitle.foreground": "#6F6F6F",
1516
"sideBarSectionHeader.border": "#61616130",
1617
"list.hoverBackground": "#E8E8E8",

src/i18n/source/en.ts

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ export default {
5252
'panel.toolbox.closePanel': 'Close Panel',
5353
'panel.toolbox.maximize': 'Maximize Panel Size',
5454
'panel.problems.title': 'Problems',
55+
'panel.problems.empty':
56+
'No problems have been detected in the workspace.',
5557
'notification.title': 'Notifications',
5658
'notification.title.no': 'No new notifications',
5759
'editor.closeToRight': 'Close To Right',

src/i18n/source/zh-CN.json

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"toolbar.collapseAll": "折叠所有",
4949
"panel.output.title": "输出",
5050
"panel.problems.title": "问题",
51+
"panel.problems.empty": "未在工作区检测到问题",
5152
"panel.toolbox.closePanel": "关闭面板",
5253
"panel.toolbox.maximize": "最大化面板",
5354
"notification.title": "通知",

src/workbench/panel/panel.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ export function Panel(props: IPanel & IPanelController) {
3636
onClick={onToolbarClick}
3737
/>
3838
</div>
39-
<div className={panelContainerClassName}>{content}</div>
39+
<div className={panelContainerClassName} tabIndex={0}>
40+
{content}
41+
</div>
4042
</div>
4143
);
4244
}

src/workbench/panel/style.scss

+6
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,18 @@
3838
}
3939

4040
&__container {
41+
border: 1px solid transparent;
4142
bottom: 0;
43+
box-sizing: border-box;
4244
left: 0;
4345
position: absolute;
4446
right: 0;
4547
top: 35px;
4648
width: 100%;
49+
50+
&:focus {
51+
border-color: var(--list-focusOutline);
52+
}
4753
}
4854

4955
&__toolbar {

src/workbench/problems/paneView/index.tsx

+39-9
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,53 @@
11
import * as React from 'react';
2-
import { prefixClaName } from 'mo/common/className';
2+
import { getBEMElement, prefixClaName } from 'mo/common/className';
33
import TreeView from 'mo/components/tree';
4+
import { localize } from 'mo/i18n/localize';
45

56
const defaultClassName = prefixClaName('problems');
7+
const treeClassName = getBEMElement(defaultClassName, 'treeview');
8+
const treeNodeClassName = getBEMElement(treeClassName, 'treeNode');
9+
const treeNodeBadgeClassName = getBEMElement(treeNodeClassName, 'badge');
10+
const treeLeafClassName = getBEMElement(treeClassName, 'treeLeaf');
11+
const treeLeafSubInfoClassName = getBEMElement(treeLeafClassName, 'subInfo');
612

713
function ProblemsPaneView(props: any) {
814
const { data } = props;
9-
const renderTitle = (item: any): any => {
10-
const { name, children, value } = item;
15+
if (!data?.length)
1116
return (
12-
<span>
13-
{children && children.length ? name : value.code}{' '}
14-
<span>({children.length})</span>
15-
</span>
17+
<div style={{ margin: '0 18px', userSelect: 'none' }}>
18+
{localize(
19+
'panel.problems.empty',
20+
'No problems have been detected in the workspace.'
21+
)}
22+
</div>
1623
);
17-
};
24+
1825
return (
1926
<div className={defaultClassName}>
20-
<TreeView data={data} renderTitle={renderTitle} />
27+
<TreeView
28+
className={treeClassName}
29+
data={data}
30+
renderTitle={({ children, name, value }, _, isLeaf) => {
31+
return !isLeaf ? (
32+
<span className={treeNodeClassName}>
33+
{value.code}
34+
<span className={treeNodeBadgeClassName}>
35+
{children?.length}
36+
</span>
37+
</span>
38+
) : (
39+
<span className={treeLeafClassName}>
40+
{value.message}
41+
<span className={treeLeafSubInfoClassName}>
42+
{value.code}
43+
</span>
44+
<span className={treeLeafSubInfoClassName}>
45+
[{value.startLineNumber}, {value.startColumn}]
46+
</span>
47+
</span>
48+
);
49+
}}
50+
/>
2151
</div>
2252
);
2353
}

src/workbench/problems/style.scss

+28
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
@import 'mo/style/common';
22

3+
$badge-size: 18px;
4+
35
#{$problems} {
46
margin: 0 18px;
7+
8+
&__treeview {
9+
&__treeNode {
10+
align-items: center;
11+
display: flex;
12+
13+
&__badge {
14+
background: var(--badge-background);
15+
border-radius: 50%;
16+
color: var(--badge-foreground);
17+
display: inline-block;
18+
height: $badge-size;
19+
line-height: $badge-size;
20+
margin-left: 10px;
21+
text-align: center;
22+
width: $badge-size;
23+
}
24+
}
25+
26+
&__treeLeaf {
27+
&__subInfo {
28+
color: var(--activityBar-inactiveForeground);
29+
margin-left: 5px;
30+
}
31+
}
32+
}
533
}

0 commit comments

Comments
 (0)