1
1
import * as React from 'react' ;
2
2
import {
3
3
activityBarService ,
4
- ActivityBarEvent ,
5
4
IActivityBarItem ,
6
5
sidebarService ,
7
6
} from 'mo' ;
@@ -10,40 +9,47 @@ import { Explorer } from './explore';
10
9
import { ExtensionService } from 'mo/services/extensionService' ;
11
10
import { IExtension } from 'mo/model/extension' ;
12
11
13
- function initActivityBar ( extensionCtx : ExtensionService ) {
14
- const activeId = 'active-explorer' ;
12
+ function init ( extensionCtx : ExtensionService ) {
15
13
const state = activityBarService . getState ( ) ;
16
- const folderFeat : IActivityBarItem = {
17
- id : activeId ,
14
+ const sideBarState = sidebarService . getState ( ) ;
15
+
16
+ const exploreActiveItem = {
17
+ id : 'active-explorer' ,
18
18
name : 'Explore' ,
19
19
iconName : 'codicon-files' ,
20
20
} ;
21
- // activityBarService.push(folderFeat);
22
- // state.data?.push(folderFeat);
23
- // state.selected = activeId;
24
- activityBarService . updateState ( {
25
- selected : activeId ,
26
- data : [ ...state . data , folderFeat ] ,
27
- } ) ;
28
21
29
- activityBarService . subscribe ( ActivityBarEvent . OnClick , ( data ) => {
30
- console . log ( 'Explore activityBar subscribe onClick:' , data ) ;
22
+ activityBarService . updateState ( {
23
+ selected : exploreActiveItem . id ,
24
+ data : [ ...state . data , exploreActiveItem ] ,
31
25
} ) ;
32
- }
33
26
34
- function initSidebar ( extensionCtx : ExtensionService ) {
35
- sidebarService . push ( {
27
+ const explorePane = {
36
28
id : 'explore' ,
37
- name : 'EXPLORER' ,
29
+ title : 'EXPLORER' ,
38
30
render ( ) {
39
31
return < Explorer /> ;
40
32
} ,
41
- } ) ;
33
+ } ;
34
+
35
+ // sidebarService.push(explorePane);
36
+ sidebarService . updateState ( {
37
+ current : explorePane . id ,
38
+ panes : [ ...sideBarState . panes , explorePane ]
39
+ } )
40
+
41
+ activityBarService . onSelect ( ( e , item : IActivityBarItem ) => {
42
+ console . log ( 'Search Pane onClick:' , e , item ) ;
43
+ if ( item . id === exploreActiveItem . id ) {
44
+ sidebarService . updateState ( {
45
+ current : explorePane . id
46
+ } )
47
+ }
48
+ } )
42
49
}
43
50
44
51
export const ExtendExplore : IExtension = {
45
52
activate : function ( extensionCtx : ExtensionService ) {
46
- initActivityBar ( extensionCtx ) ;
47
- initSidebar ( extensionCtx ) ;
53
+ init ( extensionCtx ) ;
48
54
} ,
49
55
} ;
0 commit comments