From 340a9f171b71fb4d0b9db181c238d3dcfa7633b2 Mon Sep 17 00:00:00 2001 From: Nick Mitchell Date: Tue, 5 May 2020 14:45:47 -0400 Subject: [PATCH] fix: clicking on certain links in kubectl help result in odd behavior Fixes #4473 --- .../src/components/Content/Markdown.tsx | 7 ++++++- plugins/plugin-kubectl/src/lib/util/help.ts | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/plugin-client-common/src/components/Content/Markdown.tsx b/plugins/plugin-client-common/src/components/Content/Markdown.tsx index 7bc34ff2874..293698e959a 100644 --- a/plugins/plugin-client-common/src/components/Content/Markdown.tsx +++ b/plugins/plugin-client-common/src/components/Content/Markdown.tsx @@ -72,7 +72,12 @@ export default class Markdown extends React.PureComponent { ? undefined : async () => { let file = props.href - if (props.href.charAt(0) === '#') { + if (props.href.startsWith('#kuiexec?command=')) { + const cmdline = decodeURIComponent(props.href.slice('#kuiexec?command='.length)) + if (cmdline) { + return this.props.repl.pexec(cmdline) + } + } else if (props.href.charAt(0) === '#') { const elt = this.props.tab.querySelector( `[data-markdown-anchor="${this.anchorFrom(props.href.slice(1))}"]` ) diff --git a/plugins/plugin-kubectl/src/lib/util/help.ts b/plugins/plugin-kubectl/src/lib/util/help.ts index 1eb757585ee..66a49f3f1be 100644 --- a/plugins/plugin-kubectl/src/lib/util/help.ts +++ b/plugins/plugin-kubectl/src/lib/util/help.ts @@ -115,7 +115,7 @@ const renderHelpUnsafe = ( .map(_ => _.replace( /"([^"]+)"/g, - (_, command) => `[${command}](kui://exec?command=${encodeURIComponent(command)} "Execute ${command}")` + (_, command) => `[${command}](#kuiexec?command=${encodeURIComponent(command)} "Execute ${command}")` ) ) // .map(_ => ` - ${_}`)