-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(panel): add intitial service, model and controller
- Loading branch information
Showing
4 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: '' }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |