@@ -19,7 +19,7 @@ import { Allotment, AllotmentHandle } from "allotment"
1919import { Loading } from "@kui-shell/plugin-client-common"
2020import { Arguments , encodeComponent } from "@kui-shell/core"
2121import { 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"
2323
2424import respawn from "./respawn"
2525
@@ -93,6 +93,9 @@ type State = Partial<Pick<BaseProps, "cmdline" | "env">> & {
9393
9494 /** Use this profile in the terminal execution */
9595 selectedProfile ?: string
96+
97+ /** Hide terminal? */
98+ hideTerminal ?: boolean
9699}
97100
98101export class TaskTerminal extends React . PureComponent < Props , State > {
@@ -142,6 +145,7 @@ export class TaskTerminal extends React.PureComponent<Props, State> {
142145
143146 this . setState ( ( curState ) => ( {
144147 cmdline,
148+ hideTerminal : false ,
145149 initCount : curState . initCount + 1 ,
146150 env : Object . assign ( { } , env , { MWCLEAR_INITIAL : "true" } , this . state . extraEnv ) ,
147151 } ) )
@@ -165,7 +169,7 @@ export class TaskTerminal extends React.PureComponent<Props, State> {
165169
166170 /** Event handler for switching to a different guidebook */
167171 private readonly onSelectGuidebook = ( guidebook : string ) =>
168- this . setState ( { guidebook, ifor : true , noninteractive : false } )
172+ this . setState ( { hideTerminal : false , guidebook, ifor : true , noninteractive : false } )
169173
170174 public static getDerivedStateFromProps ( props : Props , state : State ) {
171175 if ( ( props . defaultGuidebook && state . guidebook !== props . defaultGuidebook ) || props . extraEnv !== state . extraEnv ) {
@@ -203,8 +207,12 @@ export class TaskTerminal extends React.PureComponent<Props, State> {
203207 }
204208 }
205209
210+ private readonly _gotit = ( ) => {
211+ this . setState ( { hideTerminal : true } )
212+ }
213+
206214 private readonly _refresh = ( ) => {
207- this . setState ( { guidebook : this . props . defaultGuidebook || defaultGuidebookFromClient } )
215+ this . setState ( { hideTerminal : false , guidebook : this . props . defaultGuidebook || defaultGuidebookFromClient } )
208216 }
209217
210218 private get vertical1 ( ) {
@@ -216,7 +224,7 @@ export class TaskTerminal extends React.PureComponent<Props, State> {
216224 }
217225
218226 private noGuidebook ( ) {
219- return < Empty refresh = { this . _refresh } />
227+ return < Empty refresh = { this . _refresh } gotit = { this . _gotit } />
220228 }
221229
222230 private readonly allotmentRef = React . createRef < AllotmentHandle > ( )
@@ -237,24 +245,26 @@ export class TaskTerminal extends React.PureComponent<Props, State> {
237245 ) : (
238246 < Allotment
239247 vertical
240- defaultSizes = { ! this . props . aboveTerminal ? this . vertical1 : this . vertical2 }
248+ defaultSizes = { this . state . hideTerminal || ! this . props . aboveTerminal ? this . vertical1 : this . vertical2 }
241249 snap
242250 ref = { this . allotmentRef }
243251 >
244252 { 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+ ) }
258268 </ Allotment >
259269 ) }
260270 </ AllotmentFillPane >
@@ -263,15 +273,22 @@ export class TaskTerminal extends React.PureComponent<Props, State> {
263273 }
264274}
265275
266- class Empty extends React . PureComponent < { refresh ( ) : void } > {
276+ class Empty extends React . PureComponent < { refresh ( ) : void ; gotit ( ) : void } > {
267277 /** Run through all questions again */
268278 private resubmit ( ) {
269279 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 >
275292 )
276293 }
277294
@@ -281,7 +298,7 @@ class Empty extends React.PureComponent<{ refresh(): void }> {
281298 < Title size = "lg" headingLevel = "h4" >
282299 All constraints satisfied
283300 </ Title >
284- < EmptyStateBody > Click here to walk through all of the constraints</ EmptyStateBody >
301+ < EmptyStateBody > Your current Draft Specification already satisfies all constraints</ EmptyStateBody >
285302 < EmptyStatePrimary > { this . resubmit ( ) } </ EmptyStatePrimary >
286303 </ EmptyState >
287304 )
0 commit comments