Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit 63db72a

Browse files
committed
fix(plugins/plugin-kubectl): CurrentContext and CurrentNamespace widgets can emit console errors
part of #8155
1 parent 668d0e5 commit 63db72a

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

plugins/plugin-kubectl/components/src/CurrentContext.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,8 @@ export default class CurrentContext extends React.PureComponent<Props, State> {
210210
if (tab) {
211211
const { kubectl, getTabState } = await import('@kui-shell/plugin-kubectl')
212212

213-
const currentContextSpec = getTabState(tab, 'context')
214-
if (currentContextSpec) {
215-
const currentContext = currentContextSpec.metadata.name
216-
213+
const currentContext = getTabState(tab, 'context')
214+
if (currentContext) {
217215
this.setState(curState => ({
218216
currentContext,
219217
options: this.options(currentContext, curState.allContexts, kubectl),

plugins/plugin-kubectl/components/src/CurrentNamespace.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,21 @@ export default class CurrentNamespace extends React.PureComponent<Props, State>
8888
try {
8989
const { kubectl, getCurrentDefaultNamespace } = await import('@kui-shell/plugin-kubectl')
9090

91+
if (this.unmounted) {
92+
return
93+
}
94+
9195
const [currentNamespace, allNamespaces] = await Promise.all([
9296
getCurrentDefaultNamespace(tab),
9397
tab.REPL.qexec<string>(`${kubectl} get ns -o name`).then(_ =>
9498
_.split(/\n/).map(_ => _.replace(/^namespace\//, ''))
9599
)
96100
])
97101

102+
if (this.unmounted) {
103+
return
104+
}
105+
98106
if (currentNamespace) {
99107
this.setState({
100108
currentNamespace,
@@ -122,6 +130,9 @@ export default class CurrentNamespace extends React.PureComponent<Props, State>
122130
const { tab } = args
123131
if (tab) {
124132
const { getTabState } = await import('@kui-shell/plugin-kubectl')
133+
if (this.unmounted) {
134+
return
135+
}
125136
const currentNamespace = getTabState(tab, 'namespace')
126137
if (currentNamespace) {
127138
this.setState({

0 commit comments

Comments
 (0)