Skip to content

Commit 7c1a08d

Browse files
linhewewoor
linhe
authored andcommitted
feat(problems and notification): modify problems and notification styles and rename panel
1 parent 6c9e308 commit 7c1a08d

File tree

15 files changed

+46
-37
lines changed

15 files changed

+46
-37
lines changed

src/controller/notification.tsx

+9-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
import { select } from 'mo/common/dom';
1515
import { ID_APP } from 'mo/common/id';
1616
import {
17-
NotificationPanel,
17+
NotificationPane,
1818
NotificationStatusBarView,
1919
} from 'mo/workbench/notification';
2020
import {
@@ -53,11 +53,11 @@ export class NotificationController
5353
}
5454
};
5555

56-
private _notificationPanel: HTMLDivElement | undefined = undefined;
56+
private _notificationPane: HTMLDivElement | undefined = undefined;
5757

5858
private showHideNotifications() {
59-
if (!this._notificationPanel) {
60-
this.renderNotificationPanel();
59+
if (!this._notificationPane) {
60+
this.renderNotificationPane();
6161
}
6262
this.notificationService.showHideNotifications();
6363
}
@@ -91,21 +91,21 @@ export class NotificationController
9191
this.statusBarService.appendRightItem(notificationItem);
9292
}
9393

94-
public renderNotificationPanel() {
95-
const NotificationPanelView = connect(
94+
public renderNotificationPane() {
95+
const NotificationPaneView = connect(
9696
this.notificationService,
97-
NotificationPanel
97+
NotificationPane
9898
);
9999
const root = select('#' + ID_APP);
100100
const container = document.createElement('div');
101101
root?.appendChild(container);
102102
ReactDOM.render(
103-
<NotificationPanelView
103+
<NotificationPaneView
104104
onActionBarClick={this.onActionBarClick}
105105
onCloseNotification={this.onCloseNotification}
106106
/>,
107107
container
108108
);
109-
this._notificationPanel = container;
109+
this._notificationPane = container;
110110
}
111111
}

src/controller/problems.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,13 @@ export class ProblemsController
2929
const { current, hidden } = this.panelService.getState();
3030
if (hidden) {
3131
this.panelService.showHide();
32-
} else if (current?.id !== PANEL_PROBLEMS.id) {
3332
this.panelService.open(PANEL_PROBLEMS);
3433
} else {
35-
this.panelService.showHide();
34+
if (current?.id !== PANEL_PROBLEMS.id) {
35+
this.panelService.open(PANEL_PROBLEMS);
36+
} else {
37+
this.panelService.showHide();
38+
}
3639
}
3740
}
3841

src/model/problems.tsx

+2-5
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import * as React from 'react';
22
import { injectable } from 'tsyringe';
33
import { IStatusBarItem } from 'mo/model/workbench/statusBar';
44
import { IPanelItem } from 'mo/model/workbench/panel';
5-
import {
6-
ProblemsStatusBarView,
7-
ProblemsPanelView,
8-
} from 'mo/workbench/problems';
5+
import { ProblemsStatusBarView, ProblemsPaneView } from 'mo/workbench/problems';
96

107
export enum MarkerSeverity {
118
Hint = 1,
@@ -50,7 +47,7 @@ export const PANEL_PROBLEMS: IPanelItem = {
5047
id: 'ProblemsPane',
5148
name: 'problems',
5249
data: null,
53-
renderPane: (item) => <ProblemsPanelView {...item} />,
50+
renderPane: (item) => <ProblemsPaneView {...item} />,
5451
};
5552

5653
@injectable()

src/services/notificationService.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class NotificationService
7272
}
7373

7474
public addNotifications<T>(
75-
items: INotificationItem<any>[]
75+
items: INotificationItem<T>[]
7676
): null | INotificationItem<T>[] {
7777
const { data = [] } = this.state;
7878

src/services/problemsService.ts

+12-8
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ import {
88
} from 'mo/model/problems';
99
import { IPanelItem } from 'mo/model/workbench/panel';
1010
import { IStatusBarItem } from 'mo/model/workbench/statusBar';
11-
import { PanelService, StatusBarService } from 'mo/services';
11+
import {
12+
PanelService,
13+
IPanelService,
14+
StatusBarService,
15+
IStatusBarService,
16+
} from 'mo/services';
1217
import { Component } from 'mo/react';
1318
import { singleton, container } from 'tsyringe';
1419
import { searchById } from './helper';
15-
const panelService = container.resolve(PanelService);
16-
const statusBarService = container.resolve(StatusBarService);
1720
export interface IProblemsService extends Component<IProblems> {
1821
updateStatus<T>(item: IStatusBarItem<T>): void;
1922
updatePanel<T>(item: IStatusBarItem<T>): void;
@@ -31,10 +34,13 @@ export class ProblemsService
3134
extends Component<IProblems>
3235
implements IProblemsService {
3336
protected state: IProblems;
34-
37+
private readonly panelService: IPanelService;
38+
private readonly statusBarService: IStatusBarService;
3539
constructor() {
3640
super();
3741
this.state = container.resolve(ProblemsModel);
42+
this.panelService = container.resolve(PanelService);
43+
this.statusBarService = container.resolve(StatusBarService);
3844
}
3945

4046
public showHideProblems(): void {
@@ -116,18 +122,17 @@ export class ProblemsService
116122
this.updatePanel(Object.assign(PANEL_PROBLEMS, { data }));
117123
}
118124
public updateStatus<T>(item: IStatusBarItem<T>): void {
119-
statusBarService.updateItem(item);
125+
this.statusBarService.updateItem(item);
120126
}
121127
public updatePanel<T>(item: IPanelItem<T>): void {
122-
panelService.update(item);
128+
this.panelService.update(item);
123129
}
124130
public getProblemsMarkers = (
125131
data: IProblemsItem[]
126132
): { warnings: number; errors: number; infos: number } => {
127133
let warnings = 0;
128134
let errors = 0;
129135
let infos = 0;
130-
// let hint = 0;
131136
const loopTreeNode = (tree: IProblemsItem[]) => {
132137
tree.forEach((element: IProblemsItem) => {
133138
switch (element.value.status) {
@@ -141,7 +146,6 @@ export class ProblemsService
141146
warnings += 1;
142147
break;
143148
default:
144-
// hint += 1;
145149
}
146150
if (element.children && element.children.length) {
147151
loopTreeNode(element.children);

src/style/common.scss

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ $statusBar: prefix('statusBar');
4040
$workbench: prefix('workbench');
4141
$mainBench: prefix('mainBench');
4242
$notification: prefix('notification');
43+
$problems: prefix('problems');
4344

4445
// The Naming of BEM Element
4546
@function bem-ele($block, $element) {

src/style/mo.scss

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@
3131
@import 'mo/workbench/settings/style';
3232
@import 'mo/workbench/sidebar/style';
3333
@import 'mo/workbench/statusBar/style';
34-
// @import 'mo/workbench/statusBar/notification/style';
34+
@import 'mo/workbench/notification/style';
3535
@import 'mo/workbench/sidebar/explore/style';
36+
@import 'mo/workbench/problems/style';
3637

3738
.#{$prefix} {
3839
bottom: 0;

src/workbench/notification/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import NotificationPanel from './notificationPanel';
1+
import NotificationPane from './notificationPane';
22
import NotificationStatusBarView from './statusBarView';
33

4-
export { NotificationPanel, NotificationStatusBarView };
4+
export { NotificationPane, NotificationStatusBarView };

src/workbench/notification/notificationPanel/index.tsx src/workbench/notification/notificationPane/index.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
import ActionBar from 'mo/components/actionBar';
1111
import { shadowClassName } from 'mo/components/contextView';
1212
import { Icon } from 'mo/components/icon';
13-
import './style.scss';
1413

1514
const defaultNotificationClassName = prefixClaName('notification');
1615
const notificationHeaderClassName = getBEMElement(
@@ -26,7 +25,7 @@ const notificationCloseClassName = getBEMModifier(
2625
'close'
2726
);
2827

29-
export function NotificationPanel(
28+
export function NotificationPane(
3029
props: INotification & INotificationController
3130
) {
3231
const {
@@ -70,4 +69,4 @@ export function NotificationPanel(
7069
</div>
7170
);
7271
}
73-
export default React.memo(NotificationPanel);
72+
export default React.memo(NotificationPane);

src/workbench/problems/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import ProblemsStatusBarView from './statusBarView';
2-
import ProblemsPanelView from './panelView';
2+
import ProblemsPaneView from './paneView';
33

4-
export { ProblemsStatusBarView, ProblemsPanelView };
4+
export { ProblemsStatusBarView, ProblemsPaneView };
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import * as React from 'react';
22
import { prefixClaName } from 'mo/common/className';
33
import TreeView from 'mo/components/tree';
4-
import './style.scss';
54

65
const defaultClassName = prefixClaName('problems');
76

8-
function ProblemsPanelView(props: any) {
7+
function ProblemsPaneView(props: any) {
98
const { data } = props;
109
const renderTitle = (item: any): any => {
1110
const { name, children, value } = item;
@@ -17,10 +16,10 @@ function ProblemsPanelView(props: any) {
1716
);
1817
};
1918
return (
20-
<div className={defaultClassName} style={{ margin: '0 18px' }}>
19+
<div className={defaultClassName}>
2120
<TreeView data={data} renderTitle={renderTitle} />
2221
</div>
2322
);
2423
}
2524

26-
export default React.memo(ProblemsPanelView);
25+
export default React.memo(ProblemsPaneView);

src/workbench/problems/panelView/style.scss

Whitespace-only changes.

src/workbench/problems/statusBarView/style.scss

Whitespace-only changes.

src/workbench/problems/style.scss

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@import 'mo/style/common';
2+
3+
#{$problems} {
4+
margin: 0 18px;
5+
}

0 commit comments

Comments
 (0)