Skip to content

Commit 77b43d7

Browse files
linhewewoor
linhe
authored andcommitted
feat(statusbar): update status bar controller
#17
1 parent 5db28ec commit 77b43d7

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

src/controller/statusBar.tsx

+18-21
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,37 @@
11
import * as React from 'react';
22
import { IStatusBarItem, StatusBarEvent } from 'mo';
33
import { Controller } from 'mo/react/controller';
4-
import { statusBarService } from 'mo/services';
4+
import { panelService } from 'mo/services';
55
import { singleton } from 'tsyringe';
6+
import { PANEL_PROBLEMS } from 'mo/model/workbench/panel';
7+
import { STATUS_PROBLEMS } from 'mo/model/workbench/statusBar';
8+
69
export interface IStatusBarController {
710
onClick?: (e: React.MouseEvent, item: IStatusBarItem) => void;
811
}
9-
10-
const problems: IStatusBarItem = {
11-
id: 'MoProblems',
12-
sortIndex: 1,
13-
name: 'Problems',
14-
};
15-
16-
export const editorLineColumnItem: IStatusBarItem = {
17-
id: 'EditorCountInfo',
18-
sortIndex: 2,
19-
name: 'Go to Line/Column',
20-
render: () => <span>Ln 0, Col 0</span>,
21-
};
22-
2312
@singleton()
2413
export class StatusBarController
2514
extends Controller
2615
implements IStatusBarController {
2716
constructor() {
2817
super();
29-
this.initStatusBar();
3018
}
3119

3220
public onClick = (e: React.MouseEvent, item: IStatusBarItem) => {
21+
const { id } = item;
22+
switch (id) {
23+
case STATUS_PROBLEMS.id /** Problems */:
24+
const { current, hidden } = panelService.getState();
25+
if (hidden) {
26+
panelService.showHide();
27+
} else if (current?.id !== PANEL_PROBLEMS.id) {
28+
panelService.open(PANEL_PROBLEMS);
29+
} else {
30+
panelService.showHide();
31+
}
32+
break;
33+
default:
34+
}
3335
this.emit(StatusBarEvent.onClick, e, item);
3436
};
35-
36-
private initStatusBar() {
37-
statusBarService.appendLeftItem(problems);
38-
statusBarService.appendRightItem(editorLineColumnItem);
39-
}
4037
}

0 commit comments

Comments
 (0)