Skip to content

Commit 3426500

Browse files
committed
chore: code cleanup in ProfileExplorer
1 parent c1d2d00 commit 3426500

File tree

1 file changed

+49
-36
lines changed

1 file changed

+49
-36
lines changed

plugins/plugin-codeflare/src/controller/terminal.tsx

Lines changed: 49 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -233,48 +233,61 @@ export class TaskTerminal extends React.PureComponent<Props, State> {
233233

234234
private readonly allotmentRef = React.createRef<AllotmentHandle>()
235235

236+
private left() {
237+
return <ProfileExplorer onSelectProfile={this.onSelectProfile} onSelectGuidebook={this.onSelectGuidebook} />
238+
}
239+
240+
private rightTop() {
241+
return this.props.aboveTerminal
242+
}
243+
244+
private rightBottom(selectedProfile: string, guidebook: string) {
245+
return !this.state.cmdline || !this.state.env ? (
246+
this.noGuidebook()
247+
) : (
248+
<AskingTerminal
249+
initCount={this.state.initCount}
250+
guidebook={guidebook}
251+
cmdline={this.state.cmdline}
252+
env={this.state.env}
253+
selectedProfile={selectedProfile}
254+
terminalProps={this.props}
255+
home={this._home}
256+
noninteractive={this.state.noninteractive}
257+
/>
258+
)
259+
}
260+
261+
private right() {
262+
const { aboveTerminal } = this.props
263+
const { hideTerminal, selectedProfile, guidebook } = this.state
264+
265+
if (!selectedProfile || !guidebook) {
266+
return <Loading />
267+
} else {
268+
return (
269+
<Allotment
270+
snap
271+
vertical
272+
defaultSizes={hideTerminal || !aboveTerminal ? this.vertical1 : this.vertical2}
273+
ref={this.allotmentRef}
274+
>
275+
{aboveTerminal && <AllotmentFillPane>{this.rightTop()}</AllotmentFillPane>}
276+
{!hideTerminal && <AllotmentFillPane>{this.rightBottom(selectedProfile, guidebook)}</AllotmentFillPane>}
277+
</Allotment>
278+
)
279+
}
280+
}
281+
236282
public render() {
237283
if (this.state.error) {
238284
return "Internal Error"
239285
}
240286

241287
return (
242-
<Allotment defaultSizes={this.splits.horizontal} snap>
243-
<AllotmentFillPane minSize={400}>
244-
<ProfileExplorer onSelectProfile={this.onSelectProfile} onSelectGuidebook={this.onSelectGuidebook} />
245-
</AllotmentFillPane>
246-
<AllotmentFillPane>
247-
{!this.state.selectedProfile || !this.state.guidebook ? (
248-
<Loading />
249-
) : (
250-
<Allotment
251-
vertical
252-
defaultSizes={this.state.hideTerminal || !this.props.aboveTerminal ? this.vertical1 : this.vertical2}
253-
snap
254-
ref={this.allotmentRef}
255-
>
256-
{this.props.aboveTerminal && <AllotmentFillPane>{this.props.aboveTerminal}</AllotmentFillPane>}
257-
{!this.state.hideTerminal && (
258-
<AllotmentFillPane>
259-
{!this.state.cmdline || !this.state.env ? (
260-
this.noGuidebook()
261-
) : (
262-
<AskingTerminal
263-
initCount={this.state.initCount}
264-
guidebook={this.state.guidebook}
265-
cmdline={this.state.cmdline}
266-
env={this.state.env}
267-
selectedProfile={this.state.selectedProfile}
268-
terminalProps={this.props}
269-
home={this._home}
270-
noninteractive={this.state.noninteractive}
271-
/>
272-
)}
273-
</AllotmentFillPane>
274-
)}
275-
</Allotment>
276-
)}
277-
</AllotmentFillPane>
288+
<Allotment snap defaultSizes={this.splits.horizontal}>
289+
<AllotmentFillPane minSize={400}>{this.left()}</AllotmentFillPane>
290+
<AllotmentFillPane>{this.right()}</AllotmentFillPane>
278291
</Allotment>
279292
)
280293
}

0 commit comments

Comments
 (0)