@@ -26,10 +26,21 @@ import ProfileExplorer from "../components/ProfileExplorer"
26
26
import SelectedProfileTerminal from "../components/SelectedProfileTerminal"
27
27
import Terminal , { Props as BaseProps } from "../components/RestartableTerminal"
28
28
29
+ import "../../web/scss/components/Allotment/_index.scss"
29
30
import "allotment/dist/style.css"
30
31
31
32
// codeflare -p ${SELECTED_PROFILE}
32
33
34
+ class AllotmentFillPane extends React . PureComponent < { minSize ?: number } > {
35
+ public render ( ) {
36
+ return (
37
+ < Allotment . Pane className = "flex-fill flex-layout flex-align-stretch" minSize = { this . props . minSize } >
38
+ { this . props . children }
39
+ </ Allotment . Pane >
40
+ )
41
+ }
42
+ }
43
+
33
44
/**
34
45
* This is a command handler that opens up a plain terminal that shows a login session using the user's $SHELL.
35
46
*/
@@ -44,7 +55,11 @@ export async function shell(args: Arguments) {
44
55
}
45
56
46
57
type Props = Pick < BaseProps , "tab" | "repl" > & {
58
+ /** Callback when user selects a profile */
47
59
onSelectProfile ?( profile : string , profiles ?: import ( "madwizard" ) . Profiles . Profile [ ] ) : void
60
+
61
+ /** Content to place below the terminal */
62
+ belowTerminal ?: React . ReactNode
48
63
}
49
64
50
65
type State = Partial < Pick < BaseProps , "cmdline" | "env" > > & {
@@ -59,8 +74,12 @@ type State = Partial<Pick<BaseProps, "cmdline" | "env">> & {
59
74
}
60
75
61
76
export class TaskTerminal extends React . PureComponent < Props , State > {
62
- /** Allotment initial split sizes */
63
- private readonly sizes = [ 40 , 60 ]
77
+ /** Allotment initial split ... allotments */
78
+ private readonly splits = {
79
+ horizontal : [ 35 , 65 ] ,
80
+ vertical1 : [ 100 ] , // no `this.props.belowTerminal`
81
+ vertical2 : [ 50 , 50 ] , // yes
82
+ }
64
83
65
84
private readonly tasks = [ { label : "Run a Job" , argv : [ "codeflare" , "-p" , "${SELECTED_PROFILE}" ] } ]
66
85
@@ -122,23 +141,32 @@ export class TaskTerminal extends React.PureComponent<Props, State> {
122
141
}
123
142
124
143
return (
125
- < Allotment defaultSizes = { this . sizes } snap >
126
- < Allotment . Pane className = "flex-fill flex-layout flex-align-stretch" minSize = { 400 } >
144
+ < Allotment defaultSizes = { this . splits . horizontal } snap >
145
+ < AllotmentFillPane minSize = { 400 } >
127
146
< ProfileExplorer onSelectProfile = { this . onSelectProfile } onSelectGuidebook = { this . onSelectGuidebook } />
128
- </ Allotment . Pane >
129
- < Allotment . Pane className = "flex-fill flex-layout flex-align-stretch" >
147
+ </ AllotmentFillPane >
148
+ < AllotmentFillPane >
130
149
{ ! this . state . selectedProfile ? (
131
150
< Loading />
132
151
) : (
133
- < SelectedProfileTerminal
134
- key = { this . state . cmdline + "-" + this . state . selectedProfile }
135
- cmdline = { this . state . cmdline }
136
- env = { this . state . env }
137
- { ...this . props }
138
- selectedProfile = { this . state . selectedProfile }
139
- />
152
+ < Allotment
153
+ vertical
154
+ defaultSizes = { ! this . props . belowTerminal ? this . splits . vertical1 : this . splits . vertical2 }
155
+ snap
156
+ >
157
+ < AllotmentFillPane >
158
+ < SelectedProfileTerminal
159
+ key = { this . state . cmdline + "-" + this . state . selectedProfile }
160
+ cmdline = { this . state . cmdline }
161
+ env = { this . state . env }
162
+ { ...this . props }
163
+ selectedProfile = { this . state . selectedProfile }
164
+ />
165
+ </ AllotmentFillPane >
166
+ { this . props . belowTerminal && < AllotmentFillPane > { this . props . belowTerminal } </ AllotmentFillPane > }
167
+ </ Allotment >
140
168
) }
141
- </ Allotment . Pane >
169
+ </ AllotmentFillPane >
142
170
</ Allotment >
143
171
)
144
172
}
0 commit comments