Skip to content

Commit 89735ff

Browse files
committed
feat: allow WorkloadDesigner to hide ProfileExplorer
e.g. via `workload designer --left 0
1 parent 3f6832b commit 89735ff

File tree

2 files changed

+66
-48
lines changed

2 files changed

+66
-48
lines changed

Diff for: plugins/plugin-madwizard/components/src/WorkloadDesigner.tsx

+56-45
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,52 @@ import { Props as BaseProps } from "./RestartableTerminal"
3131
import "../../web/scss/components/Allotment/_index.scss"
3232
import "allotment/dist/style.css"
3333

34+
export type Props = Pick<BaseProps, "tab" | "REPL" | "onExit" | "searchable" | "fontSizeAdjust"> & {
35+
/** Default guidebook (if not given, we will take the value from the client definition); `null` means do not show anything */
36+
defaultGuidebook?: string | null
37+
38+
/** Run guidebook in non-interactive mode? */
39+
defaultNoninteractive?: boolean
40+
41+
/** Any extra env vars to add to the guidebook execution. These will be pre-joined with the default env. */
42+
extraEnv?: BaseProps["env"]
43+
44+
/** Callback when user selects a profile */
45+
onSelectProfile?(profile: string, profiles?: import("madwizard").Profiles.Profile[]): void
46+
47+
/** Content to place above the terminal */
48+
aboveTerminal?: React.ReactNode
49+
50+
/** Default left-right split */
51+
lrSplit?: [number, number]
52+
}
53+
54+
type State = Partial<Pick<BaseProps, "cmdline" | "env">> & {
55+
/** Number of times we have called this.init() */
56+
initCount: number
57+
58+
/** Internal error in rendering */
59+
error?: boolean
60+
61+
/** Use this guidebook in the terminal execution */
62+
guidebook?: string | null
63+
64+
/** Any extra env vars to add to the guidebook execution. These will be pre-joined with the default env. */
65+
extraEnv?: BaseProps["env"]
66+
67+
/** Run guidebook in non-interactive mode? */
68+
noninteractive?: boolean
69+
70+
/** Interactive only for the given guidebook? */
71+
ifor?: boolean
72+
73+
/** Use this profile in the terminal execution */
74+
selectedProfile?: string
75+
76+
/** Hide terminal? */
77+
hideTerminal?: boolean
78+
}
79+
3480
/**
3581
* ProfileExplorer | props.aboveTerminal?
3682
* | ----------
@@ -230,59 +276,24 @@ export default class WorkloadDesigner extends React.PureComponent<Props, State>
230276
}
231277
}
232278

279+
private get defaultSizes() {
280+
return this.props.lrSplit || this.splits.horizontal
281+
}
282+
283+
private get minSize() {
284+
return this.defaultSizes[0] === 0 ? 0 : 275
285+
}
286+
233287
public render() {
234288
if (this.state.error) {
235289
return "Internal Error"
236290
}
237291

238292
return (
239-
<Allotment snap defaultSizes={this.splits.horizontal}>
240-
<AllotmentFillPane minSize={400}>{this.left()}</AllotmentFillPane>
293+
<Allotment snap defaultSizes={this.defaultSizes} minSize={this.minSize}>
294+
<AllotmentFillPane minSize={this.minSize}>{this.left()}</AllotmentFillPane>
241295
<AllotmentFillPane>{this.right()}</AllotmentFillPane>
242296
</Allotment>
243297
)
244298
}
245299
}
246-
247-
export type Props = Pick<BaseProps, "tab" | "REPL" | "onExit" | "searchable" | "fontSizeAdjust"> & {
248-
/** Default guidebook (if not given, we will take the value from the client definition); `null` means do not show anything */
249-
defaultGuidebook?: string | null
250-
251-
/** Run guidebook in non-interactive mode? */
252-
defaultNoninteractive?: boolean
253-
254-
/** Any extra env vars to add to the guidebook execution. These will be pre-joined with the default env. */
255-
extraEnv?: BaseProps["env"]
256-
257-
/** Callback when user selects a profile */
258-
onSelectProfile?(profile: string, profiles?: import("madwizard").Profiles.Profile[]): void
259-
260-
/** Content to place above the terminal */
261-
aboveTerminal?: React.ReactNode
262-
}
263-
264-
type State = Partial<Pick<BaseProps, "cmdline" | "env">> & {
265-
/** Number of times we have called this.init() */
266-
initCount: number
267-
268-
/** Internal error in rendering */
269-
error?: boolean
270-
271-
/** Use this guidebook in the terminal execution */
272-
guidebook?: string | null
273-
274-
/** Any extra env vars to add to the guidebook execution. These will be pre-joined with the default env. */
275-
extraEnv?: BaseProps["env"]
276-
277-
/** Run guidebook in non-interactive mode? */
278-
noninteractive?: boolean
279-
280-
/** Interactive only for the given guidebook? */
281-
ifor?: boolean
282-
283-
/** Use this profile in the terminal execution */
284-
selectedProfile?: string
285-
286-
/** Hide terminal? */
287-
hideTerminal?: boolean
288-
}

Diff for: plugins/plugin-madwizard/components/src/designer.tsx

+10-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,16 @@
1515
*/
1616

1717
import React from "react"
18-
import { Arguments } from "@kui-shell/core"
18+
import { Arguments, ParsedOptions } from "@kui-shell/core"
1919
import WorkloadDesigner from "./WorkloadDesigner"
2020

21-
export default function designer(args: Arguments) {
22-
return <WorkloadDesigner REPL={args.REPL} tab={args.tab} />
21+
type Options = ParsedOptions & {
22+
left?: number
23+
}
24+
25+
export default function designer(args: Arguments<Options>) {
26+
const lrSplit: [number, number] | undefined =
27+
typeof args.parsedOptions.left === "number" ? [args.parsedOptions.left, 100 - args.parsedOptions.left] : undefined
28+
29+
return <WorkloadDesigner REPL={args.REPL} tab={args.tab} lrSplit={lrSplit} />
2330
}

0 commit comments

Comments
 (0)