Skip to content

Commit 2c4eac3

Browse files
committed
feat(panel): add intitial service, model and controller
1 parent 57597f1 commit 2c4eac3

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed

src/model/workbench/panel.ts

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { container, inject, injectable } from 'tsyringe';
2+
3+
export interface IPanelItem {
4+
id: string;
5+
title?: string;
6+
render?: () => React.ReactNode;
7+
}
8+
9+
export enum PanelEvent {
10+
onClick = 'panel.onClick',
11+
}
12+
13+
export interface IPanel {
14+
current: string;
15+
panes?: IPanelItem[];
16+
}
17+
18+
@injectable()
19+
export class PanelModel implements IPanel {
20+
public current: string;
21+
public panes: IPanelItem[];
22+
23+
constructor(
24+
@inject('PanelItems') panes: IPanelItem[] = [],
25+
@inject('CurrentPanel') current: string = ''
26+
) {
27+
this.panes = panes;
28+
this.current = current;
29+
}
30+
}
31+
32+
container.register('PanelItems', { useValue: [] });
33+
container.register('CurrentPanel', { useValue: '' });

src/services/index.ts

+12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { container } from 'tsyringe';
44
export * from './extensionService';
55
export * from './theme/colorThemeService';
66
export * from './workbench';
7+
export * from './settingsService';
78

89
import {
910
ColorThemeService,
@@ -23,7 +24,10 @@ import {
2324
StatusBarService,
2425
EditorService,
2526
IEditorService,
27+
IPanelService,
28+
PanelService,
2629
} from './workbench';
30+
import { ISettingsService, SettingsService } from './settingsService';
2731

2832
/**
2933
* The Services of Workbench
@@ -37,6 +41,7 @@ const sidebarService = container.resolve<ISidebarService>(SidebarService);
3741
const menuBarService = container.resolve<IMenuBarService>(MenuBarService);
3842
const editorService = container.resolve<IEditorService>(EditorService);
3943
const statusBarService = container.resolve<IStatusBarService>(StatusBarService);
44+
const panelService = container.resolve<IPanelService>(PanelService);
4045

4146
/**
4247
* The ColorTheme service,
@@ -51,13 +56,20 @@ const colorThemeService = container.resolve<IColorThemeService>(
5156
*/
5257
const extensionService = container.resolve<IExtensionService>(ExtensionService);
5358

59+
/**
60+
* Settings service
61+
*/
62+
const settingsService = container.resolve<ISettingsService>(SettingsService);
63+
5464
export {
5565
activityBarService,
5666
explorerService,
5767
sidebarService,
5868
menuBarService,
5969
statusBarService,
70+
panelService,
6071
editorService,
6172
extensionService,
6273
colorThemeService,
74+
settingsService,
6375
};

src/services/workbench/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ export * from './sidebarService';
44
export * from './editorService';
55
export * from './statusBarService';
66
export * from './explorerService';
7+
export * from './panelService';
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { IPanel, PanelModel } from 'mo/model/workbench/panel';
2+
import { Component } from 'mo/react';
3+
import { singleton, container } from 'tsyringe';
4+
5+
export interface IPanelService extends Component<IPanel> {}
6+
7+
@singleton()
8+
export class PanelService extends Component<IPanel> implements IPanelService {
9+
protected state: IPanel;
10+
11+
constructor() {
12+
super();
13+
this.state = container.resolve(PanelModel);
14+
}
15+
}

0 commit comments

Comments
 (0)