Skip to content

Commit

Permalink
fix(plugins/plugin-kubectl): kubectl Logs/Events/Terminal tabs do not…
Browse files Browse the repository at this point in the history
… reflow on sidecar maximize

Fixes #5417
  • Loading branch information
starpit committed Aug 20, 2020
1 parent 92b17c3 commit 5e3ee7a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions plugins/plugin-kubectl/src/lib/view/modes/ExecIntoPod.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
ToolbarText,
i18n,
getPrimaryTabId,
eventBus,
eventChannelUnsafe
} from '@kui-shell/core'

Expand Down Expand Up @@ -124,22 +125,28 @@ export class Terminal<S extends TerminalState = TerminalState> extends Container

this.updateToolbar(this.state.isLive)

// tab uuid
const uuid = getPrimaryTabId(this.props.tab)

const focus = () => {
this.doFocus()
this.doXon()
}
const focusOnEvent = `/mode/focus/on/tab/${getPrimaryTabId(this.props.tab)}/mode/terminal`
const focusOnEvent = `/mode/focus/on/tab/${uuid}/mode/terminal`
eventChannelUnsafe.on(focusOnEvent, focus)
this.cleaners.push(() => eventChannelUnsafe.off(focusOnEvent, focus))

const xoff = this.doXoff.bind(this)
const focusOffEvent = `/mode/focus/off/tab/${getPrimaryTabId(this.props.tab)}/mode/terminal`
const focusOffEvent = `/mode/focus/off/tab/${uuid}/mode/terminal`
eventChannelUnsafe.on(focusOffEvent, xoff)
this.cleaners.push(() => eventChannelUnsafe.off(focusOffEvent, xoff))

const resizeListener = this.onResize.bind(this)
window.addEventListener('resize', resizeListener)
this.cleaners.push(() => window.removeEventListener('resize', resizeListener))

eventBus.onTabLayoutChange(uuid, resizeListener)
this.cleaners.push(() => eventBus.offTabLayoutChange(uuid, resizeListener))
}

/** Which container should we focus on by default? */
Expand Down

0 comments on commit 5e3ee7a

Please sign in to comment.