1
+ import { ContextKeyService } from '@theia/core/lib/browser/context-key-service' ;
1
2
import {
2
3
ContextMenuRenderer ,
3
4
RenderContextMenuOptions ,
@@ -60,6 +61,8 @@ export class CloudSketchbookContribution extends CloudSketchContribution {
60
61
private readonly configServiceClient : ConfigServiceClient ;
61
62
@inject ( ApplicationConnectionStatusContribution )
62
63
private readonly connectionStatus : ApplicationConnectionStatusContribution ;
64
+ @inject ( ContextKeyService )
65
+ private readonly contextKeyService : ContextKeyService ;
63
66
64
67
private readonly onDidChangeToolbarEmitter = new Emitter < void > ( ) ;
65
68
private readonly toDisposeBeforeNewContextMenu = new DisposableCollection ( ) ;
@@ -79,6 +82,17 @@ export class CloudSketchbookContribution extends CloudSketchContribution {
79
82
} ) ,
80
83
this . createFeatures . onDidChangeSession ( ( ) => this . fireToolbarChange ( ) ) ,
81
84
this . createFeatures . onDidChangeEnabled ( ( ) => this . fireToolbarChange ( ) ) ,
85
+ this . contextKeyService . onDidChange ( ( event ) => {
86
+ if (
87
+ event . affects ( {
88
+ has ( candidate : string ) {
89
+ return candidate === 'cloudSketchState' ;
90
+ } ,
91
+ } )
92
+ ) {
93
+ this . fireToolbarChange ( ) ;
94
+ }
95
+ } ) ,
82
96
] ) ;
83
97
}
84
98
@@ -101,13 +115,15 @@ export class CloudSketchbookContribution extends CloudSketchContribution {
101
115
tooltip : CloudSketchbookCommands . PULL_SKETCH__TOOLBAR . label ,
102
116
priority : - 2 ,
103
117
onDidChange : this . onDidChangeToolbar ,
118
+ when : 'cloudSketchState != pulling && cloudSketchState != pushing' ,
104
119
} ) ;
105
120
registry . registerItem ( {
106
121
id : CloudSketchbookCommands . PUSH_SKETCH__TOOLBAR . id ,
107
122
command : CloudSketchbookCommands . PUSH_SKETCH__TOOLBAR . id ,
108
123
tooltip : CloudSketchbookCommands . PUSH_SKETCH__TOOLBAR . label ,
109
124
priority : - 1 ,
110
125
onDidChange : this . onDidChangeToolbar ,
126
+ when : 'cloudSketchState != pulling && cloudSketchState != pushing' ,
111
127
} ) ;
112
128
}
113
129
0 commit comments