@@ -23,7 +23,7 @@ import TextWithIconWidget, {
2323 Options as TextWithIconWidgetOptions
2424} from '@kui-shell/plugin-client-common/mdist/components/Client/StatusStripe/TextWithIconWidget'
2525
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'
2727
2828import { KubeContext } from '@kui-shell/plugin-kubectl'
2929
@@ -42,6 +42,7 @@ const strings = i18n('plugin-kubectl')
4242
4343export default class CurrentNamespace extends React . PureComponent < Props , State > {
4444 private readonly handler = this . reportCurrentNamespace . bind ( this )
45+ private readonly handlerForCommandComplete = this . reportCurrentNamespaceFromCommandComplete . bind ( this )
4546 private readonly handlerNotCallingKubectl = this . getCurrentNamespaceFromTab . bind ( this )
4647
4748 public constructor ( props : Props ) {
@@ -69,6 +70,10 @@ export default class CurrentNamespace extends React.PureComponent<Props, State>
6970 return last && now - last < 250
7071 }
7172
73+ private async reportCurrentNamespaceFromCommandComplete ( evt : CommandCompleteEvent ) {
74+ this . reportCurrentNamespace ( evt . tab )
75+ }
76+
7277 private async reportCurrentNamespace ( idx ?: Tab | number | string ) {
7378 if ( this . unmounted ) {
7479 return
@@ -172,7 +177,7 @@ export default class CurrentNamespace extends React.PureComponent<Props, State>
172177 }
173178 Events . eventBus . on ( '/tab/switch/request/done' , this . handlerNotCallingKubectl )
174179
175- Events . eventBus . onAnyCommandComplete ( this . handler )
180+ Events . eventBus . onAnyCommandComplete ( this . handlerForCommandComplete )
176181 import ( '@kui-shell/plugin-kubectl' ) . then ( _ => _ . onKubectlConfigChangeEvents ( this . handler ) )
177182 }
178183
@@ -192,7 +197,7 @@ export default class CurrentNamespace extends React.PureComponent<Props, State>
192197 Events . eventBus . off ( '/tab/new' , this . handler )
193198 Events . eventBus . off ( '/tab/switch/request/done' , this . handlerNotCallingKubectl )
194199
195- Events . eventBus . offAnyCommandComplete ( this . handler )
200+ Events . eventBus . offAnyCommandComplete ( this . handlerForCommandComplete )
196201 import ( '@kui-shell/plugin-kubectl' ) . then ( _ => _ . offKubectlConfigChangeEvents ( this . handler ) )
197202 }
198203
0 commit comments