@@ -23,7 +23,7 @@ import TextWithIconWidget, {
23
23
Options as TextWithIconWidgetOptions
24
24
} from '@kui-shell/plugin-client-common/mdist/components/Client/StatusStripe/TextWithIconWidget'
25
25
26
- import { Events , i18n , getTab , Tab , TabState , pexecInCurrentTab } from '@kui-shell/core'
26
+ import { Events , CommandCompleteEvent , i18n , getTab , Tab , TabState , pexecInCurrentTab } from '@kui-shell/core'
27
27
28
28
import { KubeContext } from '@kui-shell/plugin-kubectl'
29
29
@@ -42,6 +42,7 @@ const strings = i18n('plugin-kubectl')
42
42
43
43
export default class CurrentNamespace extends React . PureComponent < Props , State > {
44
44
private readonly handler = this . reportCurrentNamespace . bind ( this )
45
+ private readonly handlerForCommandComplete = this . reportCurrentNamespaceFromCommandComplete . bind ( this )
45
46
private readonly handlerNotCallingKubectl = this . getCurrentNamespaceFromTab . bind ( this )
46
47
47
48
public constructor ( props : Props ) {
@@ -69,6 +70,10 @@ export default class CurrentNamespace extends React.PureComponent<Props, State>
69
70
return last && now - last < 250
70
71
}
71
72
73
+ private async reportCurrentNamespaceFromCommandComplete ( evt : CommandCompleteEvent ) {
74
+ this . reportCurrentNamespace ( evt . tab )
75
+ }
76
+
72
77
private async reportCurrentNamespace ( idx ?: Tab | number | string ) {
73
78
if ( this . unmounted ) {
74
79
return
@@ -172,7 +177,7 @@ export default class CurrentNamespace extends React.PureComponent<Props, State>
172
177
}
173
178
Events . eventBus . on ( '/tab/switch/request/done' , this . handlerNotCallingKubectl )
174
179
175
- Events . eventBus . onAnyCommandComplete ( this . handler )
180
+ Events . eventBus . onAnyCommandComplete ( this . handlerForCommandComplete )
176
181
import ( '@kui-shell/plugin-kubectl' ) . then ( _ => _ . onKubectlConfigChangeEvents ( this . handler ) )
177
182
}
178
183
@@ -192,7 +197,7 @@ export default class CurrentNamespace extends React.PureComponent<Props, State>
192
197
Events . eventBus . off ( '/tab/new' , this . handler )
193
198
Events . eventBus . off ( '/tab/switch/request/done' , this . handlerNotCallingKubectl )
194
199
195
- Events . eventBus . offAnyCommandComplete ( this . handler )
200
+ Events . eventBus . offAnyCommandComplete ( this . handlerForCommandComplete )
196
201
import ( '@kui-shell/plugin-kubectl' ) . then ( _ => _ . offKubectlConfigChangeEvents ( this . handler ) )
197
202
}
198
203
0 commit comments