@@ -19,7 +19,7 @@ import { Allotment, AllotmentHandle } from "allotment"
19
19
import { Loading } from "@kui-shell/plugin-client-common"
20
20
import { Arguments , encodeComponent } from "@kui-shell/core"
21
21
import { defaultGuidebook as defaultGuidebookFromClient } from "@kui-shell/client/config.d/client.json"
22
- import { Button , EmptyState , EmptyStateBody , EmptyStatePrimary , Title , Tooltip } from "@patternfly/react-core"
22
+ import { Button , EmptyState , EmptyStateBody , EmptyStatePrimary , Flex , FlexItem , Title } from "@patternfly/react-core"
23
23
24
24
import respawn from "./respawn"
25
25
@@ -93,6 +93,9 @@ type State = Partial<Pick<BaseProps, "cmdline" | "env">> & {
93
93
94
94
/** Use this profile in the terminal execution */
95
95
selectedProfile ?: string
96
+
97
+ /** Hide terminal? */
98
+ hideTerminal ?: boolean
96
99
}
97
100
98
101
export class TaskTerminal extends React . PureComponent < Props , State > {
@@ -142,6 +145,7 @@ export class TaskTerminal extends React.PureComponent<Props, State> {
142
145
143
146
this . setState ( ( curState ) => ( {
144
147
cmdline,
148
+ hideTerminal : false ,
145
149
initCount : curState . initCount + 1 ,
146
150
env : Object . assign ( { } , env , { MWCLEAR_INITIAL : "true" } , this . state . extraEnv ) ,
147
151
} ) )
@@ -165,7 +169,7 @@ export class TaskTerminal extends React.PureComponent<Props, State> {
165
169
166
170
/** Event handler for switching to a different guidebook */
167
171
private readonly onSelectGuidebook = ( guidebook : string ) =>
168
- this . setState ( { guidebook, ifor : true , noninteractive : false } )
172
+ this . setState ( { hideTerminal : false , guidebook, ifor : true , noninteractive : false } )
169
173
170
174
public static getDerivedStateFromProps ( props : Props , state : State ) {
171
175
if ( ( props . defaultGuidebook && state . guidebook !== props . defaultGuidebook ) || props . extraEnv !== state . extraEnv ) {
@@ -203,8 +207,12 @@ export class TaskTerminal extends React.PureComponent<Props, State> {
203
207
}
204
208
}
205
209
210
+ private readonly _gotit = ( ) => {
211
+ this . setState ( { hideTerminal : true } )
212
+ }
213
+
206
214
private readonly _refresh = ( ) => {
207
- this . setState ( { guidebook : this . props . defaultGuidebook || defaultGuidebookFromClient } )
215
+ this . setState ( { hideTerminal : false , guidebook : this . props . defaultGuidebook || defaultGuidebookFromClient } )
208
216
}
209
217
210
218
private get vertical1 ( ) {
@@ -216,7 +224,7 @@ export class TaskTerminal extends React.PureComponent<Props, State> {
216
224
}
217
225
218
226
private noGuidebook ( ) {
219
- return < Empty refresh = { this . _refresh } />
227
+ return < Empty refresh = { this . _refresh } gotit = { this . _gotit } />
220
228
}
221
229
222
230
private readonly allotmentRef = React . createRef < AllotmentHandle > ( )
@@ -237,24 +245,26 @@ export class TaskTerminal extends React.PureComponent<Props, State> {
237
245
) : (
238
246
< Allotment
239
247
vertical
240
- defaultSizes = { ! this . props . aboveTerminal ? this . vertical1 : this . vertical2 }
248
+ defaultSizes = { this . state . hideTerminal || ! this . props . aboveTerminal ? this . vertical1 : this . vertical2 }
241
249
snap
242
250
ref = { this . allotmentRef }
243
251
>
244
252
{ this . props . aboveTerminal && < AllotmentFillPane > { this . props . aboveTerminal } </ AllotmentFillPane > }
245
- < AllotmentFillPane >
246
- { ! this . state . cmdline || ! this . state . env ? (
247
- this . noGuidebook ( )
248
- ) : (
249
- < SelectedProfileTerminal
250
- key = { this . state . initCount + "_" + this . state . cmdline + "-" + this . state . selectedProfile }
251
- cmdline = { this . state . cmdline }
252
- env = { this . state . env }
253
- { ...this . props }
254
- selectedProfile = { this . state . selectedProfile }
255
- />
256
- ) }
257
- </ AllotmentFillPane >
253
+ { ! this . state . hideTerminal && (
254
+ < AllotmentFillPane >
255
+ { ! this . state . cmdline || ! this . state . env ? (
256
+ this . noGuidebook ( )
257
+ ) : (
258
+ < SelectedProfileTerminal
259
+ key = { this . state . initCount + "_" + this . state . cmdline + "-" + this . state . selectedProfile }
260
+ cmdline = { this . state . cmdline }
261
+ env = { this . state . env }
262
+ { ...this . props }
263
+ selectedProfile = { this . state . selectedProfile }
264
+ />
265
+ ) }
266
+ </ AllotmentFillPane >
267
+ ) }
258
268
</ Allotment >
259
269
) }
260
270
</ AllotmentFillPane >
@@ -263,15 +273,22 @@ export class TaskTerminal extends React.PureComponent<Props, State> {
263
273
}
264
274
}
265
275
266
- class Empty extends React . PureComponent < { refresh ( ) : void } > {
276
+ class Empty extends React . PureComponent < { refresh ( ) : void ; gotit ( ) : void } > {
267
277
/** Run through all questions again */
268
278
private resubmit ( ) {
269
279
return (
270
- < Tooltip content = "Force a run through all constraints" >
271
- < Button variant = "primary" onClick = { this . props . refresh } >
272
- Walk through the constraints again
273
- </ Button >
274
- </ Tooltip >
280
+ < Flex >
281
+ < FlexItem >
282
+ < Button variant = "secondary" onClick = { this . props . gotit } >
283
+ Got it!
284
+ </ Button >
285
+ </ FlexItem >
286
+ < FlexItem >
287
+ < Button variant = "tertiary" onClick = { this . props . refresh } >
288
+ Walk through the constraints again
289
+ </ Button >
290
+ </ FlexItem >
291
+ </ Flex >
275
292
)
276
293
}
277
294
@@ -281,7 +298,7 @@ class Empty extends React.PureComponent<{ refresh(): void }> {
281
298
< Title size = "lg" headingLevel = "h4" >
282
299
All constraints satisfied
283
300
</ Title >
284
- < EmptyStateBody > Click here to walk through all of the constraints</ EmptyStateBody >
301
+ < EmptyStateBody > Your current Draft Specification already satisfies all constraints</ EmptyStateBody >
285
302
< EmptyStatePrimary > { this . resubmit ( ) } </ EmptyStatePrimary >
286
303
</ EmptyState >
287
304
)
0 commit comments