Skip to content

Commit

Permalink
feat(panel): add intitial service, model and controller
Browse files Browse the repository at this point in the history
  • Loading branch information
wewoor committed Dec 30, 2020
1 parent 57597f1 commit 2c4eac3
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/model/workbench/panel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { container, inject, injectable } from 'tsyringe';

export interface IPanelItem {
id: string;
title?: string;
render?: () => React.ReactNode;
}

export enum PanelEvent {
onClick = 'panel.onClick',
}

export interface IPanel {
current: string;
panes?: IPanelItem[];
}

@injectable()
export class PanelModel implements IPanel {
public current: string;
public panes: IPanelItem[];

constructor(
@inject('PanelItems') panes: IPanelItem[] = [],
@inject('CurrentPanel') current: string = ''
) {
this.panes = panes;
this.current = current;
}
}

container.register('PanelItems', { useValue: [] });
container.register('CurrentPanel', { useValue: '' });
12 changes: 12 additions & 0 deletions src/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { container } from 'tsyringe';
export * from './extensionService';
export * from './theme/colorThemeService';
export * from './workbench';
export * from './settingsService';

import {
ColorThemeService,
Expand All @@ -23,7 +24,10 @@ import {
StatusBarService,
EditorService,
IEditorService,
IPanelService,
PanelService,
} from './workbench';
import { ISettingsService, SettingsService } from './settingsService';

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

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

/**
* Settings service
*/
const settingsService = container.resolve<ISettingsService>(SettingsService);

export {
activityBarService,
explorerService,
sidebarService,
menuBarService,
statusBarService,
panelService,
editorService,
extensionService,
colorThemeService,
settingsService,
};
1 change: 1 addition & 0 deletions src/services/workbench/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from './sidebarService';
export * from './editorService';
export * from './statusBarService';
export * from './explorerService';
export * from './panelService';
15 changes: 15 additions & 0 deletions src/services/workbench/panelService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { IPanel, PanelModel } from 'mo/model/workbench/panel';
import { Component } from 'mo/react';
import { singleton, container } from 'tsyringe';

export interface IPanelService extends Component<IPanel> {}

@singleton()
export class PanelService extends Component<IPanel> implements IPanelService {
protected state: IPanel;

constructor() {
super();
this.state = container.resolve(PanelModel);
}
}

0 comments on commit 2c4eac3

Please sign in to comment.