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

Commit 251e5c4

Browse files
committed
fix: TopNavSidecar does not always show updates
Fixes #4524
1 parent 6dfe7df commit 251e5c4

File tree

3 files changed

+39
-4
lines changed

3 files changed

+39
-4
lines changed

plugins/plugin-client-common/src/components/Content/KuiContent.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
import * as React from 'react'
18+
import { v4 as uuid } from 'uuid'
1819

1920
import { isFile } from '@kui-shell/plugin-bash-like/fs'
2021

@@ -82,11 +83,20 @@ export default class KuiMMRContent extends React.PureComponent<KuiMMRProps> {
8283
)
8384
}
8485
} else if (isCommandStringContent(mode)) {
86+
// re: key see https://github.com/IBM/kui/issues/4524
8587
return (
86-
<Eval tab={tab} command={mode.contentFrom} contentType={mode.contentType} response={response} args={args} />
88+
<Eval
89+
key={uuid()}
90+
tab={tab}
91+
command={mode.contentFrom}
92+
contentType={mode.contentType}
93+
response={response}
94+
args={args}
95+
/>
8796
)
8897
} else if (isFunctionContent(mode)) {
89-
return <Eval tab={tab} command={mode.content} response={response} args={args} />
98+
// re: key see https://github.com/IBM/kui/issues/4524
99+
return <Eval key={uuid()} tab={tab} command={mode.content} response={response} args={args} />
90100
} else if (isScalarContent(mode)) {
91101
if (isReactProvider(mode)) {
92102
return mode.react({ willUpdateToolbar })

plugins/plugin-client-common/src/components/Views/Sidecar/TopNavSidecar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ export default class TopNavSidecar extends BaseSidecar<MultiModalResponse, Histo
196196
handleTabClick={() => false}
197197
onMouseDown={event => event.preventDefault()}
198198
>
199-
{this.tabContent(idx)}
199+
{idx === this.current.currentTabIndex && this.tabContent(idx)}
200200
</Tab>
201201
))}
202202
</Tabs>

plugins/plugin-kubectl/src/test/k8s1/labels.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { Common, CLI, ReplExpect, Selectors } from '@kui-shell/test'
17+
import { Common, CLI, ReplExpect, SidecarExpect, Selectors } from '@kui-shell/test'
1818
import { waitForGreen, createNS, allocateNS, deleteNS } from '@kui-shell/plugin-kubectl/tests/lib/k8s/utils'
1919

2020
const synonyms = ['kubectl']
@@ -68,12 +68,37 @@ describe(`kubectl label handling ${process.env.MOCHA_RUN_TARGET || ''}`, functio
6868
.catch(Common.oops(this))
6969
})
7070

71+
const expectLabelInSidecar = (key: string, value: string) => {
72+
it(`should show label ${key}=${value} in the sidecar`, async () => {
73+
try {
74+
await CLI.command(`${kubectl} get pod nginx -o yaml ${inNamespace}`, this.app)
75+
.then(ReplExpect.justOK)
76+
.then(SidecarExpect.open)
77+
.then(SidecarExpect.showing('nginx', undefined, undefined, ns))
78+
79+
await this.app.client.waitForVisible(Selectors.SIDECAR_MODE_BUTTON('raw'))
80+
await this.app.client.click(Selectors.SIDECAR_MODE_BUTTON('raw'))
81+
await this.app.client.waitForVisible(Selectors.SIDECAR_MODE_BUTTON_SELECTED('raw'))
82+
83+
await SidecarExpect.yaml({ metadata: { labels: { [key]: value } } })
84+
} catch (err) {
85+
await Common.oops(this, true)
86+
}
87+
})
88+
}
89+
90+
expectLabelInSidecar('creepy', 'pasta')
91+
7192
it('should add another label that starts with "f" to that pod resource', () => {
7293
return CLI.command(`${kubectl} label pod nginx feels=life ${inNamespace}`, this.app)
7394
.then(ReplExpect.okWithPtyOutput('nginx'))
7495
.catch(Common.oops(this))
7596
})
7697

98+
// make sure the new label shows up in sidecar; see bug
99+
// https://github.com/IBM/kui/issues/4524
100+
expectLabelInSidecar('feels', 'life')
101+
77102
it('should NOT error with 404 for now-existent label variant 1', () => {
78103
return CLI.command(`${kubectl} get pod -l feels=life ${inNamespace}`, this.app)
79104
.then(ReplExpect.okWith('nginx'))

0 commit comments

Comments
 (0)