1- import { Domain , getIcon , localize } from '@opensumi/ide-core-browser' ;
2- import { ComponentContribution , ComponentRegistry } from '@opensumi/ide-core-browser/lib/layout' ;
1+ import { Domain , getIcon , localize , SlotLocation } from '@opensumi/ide-core-browser' ;
2+ import {
3+ ComponentContribution ,
4+ ComponentRegistry ,
5+ ClientAppContribution ,
6+ } from '@opensumi/ide-core-browser' ;
7+ import { Autowired } from '@opensumi/di' ;
38
49import { MergeRequestSummary } from './mr-summary' ;
510import { MergeRequestExplorerId } from './common' ;
611import { ChangeTreeView } from './changes-tree' ;
712import { WebSCMView } from './web-scm' ;
813import { MenuContribution , IMenuRegistry } from '@opensumi/ide-core-browser/lib/menu/next' ;
14+ import { LayoutState , LAYOUT_STATE } from '@opensumi/ide-core-browser/lib/layout/layout-state' ;
15+ import { IMainLayoutService } from '@opensumi/ide-main-layout' ;
16+
17+ @Domain ( ComponentContribution , MenuContribution , ClientAppContribution )
18+ // @ts -ignore
19+ export class MergeRequestContribution
20+ implements ComponentContribution , MenuContribution , ClientAppContribution
21+ {
22+ @Autowired ( IMainLayoutService )
23+ layoutService : IMainLayoutService ;
24+
25+ @Autowired ( ComponentRegistry )
26+ componentRegistry : ComponentRegistry ;
27+
28+ @Autowired ( )
29+ private layoutState : LayoutState ;
930
10- @Domain ( ComponentContribution , MenuContribution )
11- export class MergeRequestContribution implements ComponentContribution , MenuContribution {
12- // MR Explorer
1331 registerComponent ( registry : ComponentRegistry ) {
1432 registry . register ( MergeRequestExplorerId , [ ChangeTreeView , WebSCMView ] , {
1533 titleComponent : MergeRequestSummary ,
@@ -19,6 +37,27 @@ export class MergeRequestContribution implements ComponentContribution, MenuCont
1937 } ) ;
2038 }
2139
40+ onDidStart ( ) {
41+ const tabbarService = this . layoutService . getTabbarService ( SlotLocation . left ) ;
42+ const componentRegistry =
43+ this . componentRegistry . getComponentRegistryInfo ( MergeRequestExplorerId ) ;
44+ if ( componentRegistry ) {
45+ tabbarService . registerContainer ( MergeRequestExplorerId , componentRegistry ) ;
46+ const state = this . layoutState . getState ( LAYOUT_STATE . MAIN , { } ) ;
47+ let currentId : string ,
48+ size : number = 0 ,
49+ show = true ;
50+ for ( const key in state ) {
51+ if ( key === SlotLocation . left ) {
52+ currentId = state [ key ] ?. currentId ;
53+ size = state [ key ] ?. size || 0 ;
54+ show = currentId ? true : false ;
55+ }
56+ }
57+ this . layoutService . toggleSlot ( SlotLocation . left , show , size ) ;
58+ }
59+ }
60+
2261 registerMenus ( menus : IMenuRegistry ) {
2362 // 卸载左侧面板的右键菜单
2463 menus . unregisterMenuId ( `accordion/${ MergeRequestExplorerId } ` ) ;
0 commit comments