Skip to content

Commit c133c93

Browse files
committed
fix: update madwizard to not show guidebook title in terminal section
Instead, display "Logs will appear here". Also, use 14px font size in terminal, now that it isn't a main source of user interaction.
1 parent f327967 commit c133c93

File tree

7 files changed

+75
-39
lines changed

7 files changed

+75
-39
lines changed

Diff for: package-lock.json

+34-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: plugins/plugin-codeflare/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"@patternfly/react-core": "^4.239.0",
2929
"allotment": "^1.17.0",
3030
"asciinema-player": "^3.0.1",
31+
"chalk": "^5.1.2",
3132
"chokidar": "^3.5.3",
3233
"json-diff": "^1.0.0",
3334
"needle": "^3.1.0",

Diff for: plugins/plugin-codeflare/src/components/AskingTerminal.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
import React from "react"
18+
import { Chalk } from "chalk"
1819
import stripAnsi from "strip-ansi"
1920
import { Prompts } from "madwizard"
2021
import { Job } from "@kui-shell/core"
@@ -219,10 +220,14 @@ export default class AskingTerminal extends React.PureComponent<Props, State> {
219220
}
220221
}
221222

223+
private readonly initialContent = new Chalk({ level: 2 }).dim.italic("Logs will appear here")
224+
222225
private terminal() {
223226
return (
224227
<SelectedProfileTerminal
225228
searchable={false}
229+
initialContent={this.initialContent}
230+
fontSizeAdjust={1 /* relative to 14px */}
226231
key={
227232
this.state.myInitCount +
228233
"_" +

Diff for: plugins/plugin-codeflare/src/components/RestartableTerminal.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ export default class RestartableTerminal extends React.PureComponent<Props, Stat
162162
key={key}
163163
searchable={this.props.searchable}
164164
fontSizeAdjust={this.props.fontSizeAdjust}
165+
initialContent={this.props.initialContent}
165166
/>
166167
</div>
167168
)

Diff for: plugins/plugin-codeflare/src/components/Terminal.tsx

+25-21
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ export type TerminalOptions = ClassName & {
5555

5656
/** Font size scaling factor from the stock font size from Kui [default: 16/14] */
5757
fontSizeAdjust?: number
58-
}
5958

60-
type Props = TerminalOptions & {
61-
/** If given, the initial terminal output to render */
59+
/** Initial content to display in the terminal */
6260
initialContent?: string
61+
}
6362

63+
type Props = TerminalOptions & {
6464
/**
6565
* Commence/recommence streaming. Will be invoked on mount.
6666
*/
@@ -82,13 +82,13 @@ interface State extends ClassName {
8282
}
8383

8484
export default class XTerm extends React.PureComponent<Props, State> {
85-
private terminal: Terminal = new Terminal({
85+
private readonly terminal: Terminal = new Terminal({
8686
convertEol: true,
8787
scrollback: 5000,
8888
allowProposedApi: true,
8989
})
9090

91-
private searchAddon = new SearchAddon()
91+
private readonly searchAddon = new SearchAddon()
9292

9393
private readonly cleaners: (() => void)[] = []
9494
private readonly container = React.createRef<HTMLDivElement>()
@@ -110,24 +110,24 @@ export default class XTerm extends React.PureComponent<Props, State> {
110110
}
111111

112112
public componentDidMount() {
113-
this.mountTerminal()
114-
115-
if (this.props.watch) {
116-
const streamer = this.props.watch()
117-
streamer.on("data", this.terminal.write.bind(this.terminal))
113+
if (this.mountTerminal()) {
114+
if (this.props.watch) {
115+
const streamer = this.props.watch()
116+
streamer.on("data", this.terminal.write.bind(this.terminal))
117+
118+
if (streamer.onInput) {
119+
// pass user input from the terminal to the watcher
120+
this.terminal.onData(streamer.onInput)
121+
this.terminal.focus()
122+
}
118123

119-
if (streamer.onInput) {
120-
// pass user input from the terminal to the watcher
121-
this.terminal.onData(streamer.onInput)
122-
this.terminal.focus()
123-
}
124+
if (streamer.onResize) {
125+
const onResize = streamer.onResize
126+
this.terminal.onResize(({ rows, cols }) => onResize(rows, cols))
127+
}
124128

125-
if (streamer.onResize) {
126-
const onResize = streamer.onResize
127-
this.terminal.onResize(({ rows, cols }) => onResize(rows, cols))
129+
this.setState({ streamer })
128130
}
129-
130-
this.setState({ streamer })
131131
}
132132
}
133133

@@ -150,7 +150,8 @@ export default class XTerm extends React.PureComponent<Props, State> {
150150
private mountTerminal() {
151151
const xtermContainer = this.container.current
152152
if (!xtermContainer) {
153-
return
153+
// no, we are not yet ready to initialize the terminal
154+
return false
154155
}
155156

156157
const fitAddon = new FitAddon()
@@ -203,6 +204,9 @@ export default class XTerm extends React.PureComponent<Props, State> {
203204
})
204205
observer.observe(xtermContainer)
205206
this.cleaners.push(() => observer.disconnect())
207+
208+
// yes, we have initialized the terminal
209+
return true
206210
}
207211

208212
/**

Diff for: plugins/plugin-codeflare/src/controller/terminal.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,14 @@ export class WorkloadDesigner extends React.PureComponent<Props, State> {
145145
cmdline,
146146
hideTerminal: false,
147147
initCount: curState.initCount + 1,
148-
env: Object.assign({}, env, { MWCLEAR_INITIAL: "true" }, this.state.extraEnv),
148+
env: Object.assign(
149+
{},
150+
env,
151+
{
152+
/* MWCLEAR_INITIAL: "true" */
153+
},
154+
this.state.extraEnv
155+
),
149156
}))
150157
} catch (error) {
151158
console.error("Error initializing command line", error)

Diff for: plugins/plugin-madwizard/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"access": "public"
2424
},
2525
"dependencies": {
26-
"madwizard": "^1.8.3",
26+
"madwizard": "^1.8.5",
2727
"@guidebooks/store": "^0.17.7"
2828
}
2929
}

0 commit comments

Comments
 (0)