Skip to content

Commit 547635d

Browse files
committed
feat: propagate onSelectProfile handler from terminal to ProfileExplorer
1 parent 469f85b commit 547635d

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

Diff for: plugins/plugin-codeflare/src/components/ProfileExplorer.tsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import "../../web/scss/components/Dashboard/Description.scss"
5050
import "../../web/scss/components/ProfileExplorer/_index.scss"
5151

5252
type Props = {
53-
onSelectProfile?(profile: string): void
53+
onSelectProfile?(profile: string, profiles?: import("madwizard").Profiles.Profile[]): void
5454
onSelectGuidebook?(guidebook: string): void
5555
}
5656

@@ -105,7 +105,7 @@ export default class ProfileExplorer extends React.PureComponent<Props, State> {
105105
this.setState({ selectedProfile })
106106

107107
if (this.props.onSelectProfile) {
108-
this.props.onSelectProfile(selectedProfile)
108+
this.props.onSelectProfile(selectedProfile, this.state.profiles)
109109
}
110110
}
111111
}
@@ -174,6 +174,11 @@ export default class ProfileExplorer extends React.PureComponent<Props, State> {
174174
)
175175
}
176176

177+
const profForEvent = selectedProfile || curState.selectedProfile
178+
if (profForEvent && this.props.onSelectProfile) {
179+
this.props.onSelectProfile(profForEvent, profiles)
180+
}
181+
177182
return {
178183
profiles,
179184
profilesDiff,
@@ -517,7 +522,7 @@ class ProfileCard extends React.PureComponent<ProfileCardProps, ProfileCardState
517522
<FlexItem>
518523
<Tooltip content="Reset the choices in this profile">
519524
<Button variant="link" className="codeflare--profile-explorer--reset-btn" onClick={this._handleReset}>
520-
Reset
525+
<Icons icon="Clear" />
521526
</Button>
522527
</Tooltip>
523528
<Tooltip content="Delete this profile">

Diff for: plugins/plugin-codeflare/src/components/RestartableTerminal.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ export default class RestartableTerminal extends React.PureComponent<Props, Stat
6969
tab: this.props.tab,
7070
env: this.props.env,
7171
quiet: true, // strange i know, but this forces PTY execution
72-
onExit: () => {
72+
onExit: async () => {
7373
if (this.mounted) {
7474
// restart, if still mounted
75+
await new Promise((resolve) => setTimeout(resolve, 50000))
7576
this.initPty()
7677
}
7778
},

Diff for: plugins/plugin-codeflare/src/controller/terminal.tsx

+11-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ export async function shell(args: Arguments) {
4343
}
4444
}
4545

46-
type Props = Pick<BaseProps, "tab" | "repl">
46+
type Props = Pick<BaseProps, "tab" | "repl"> & {
47+
onSelectProfile?(profile: string, profiles?: import("madwizard").Profiles.Profile[]): void
48+
}
49+
4750
type State = Partial<Pick<BaseProps, "cmdline" | "env">> & {
4851
/** Internal error in rendering */
4952
error?: boolean
@@ -93,7 +96,13 @@ export class TaskTerminal extends React.PureComponent<Props, State> {
9396
}
9497

9598
/** Event handler for switching to a different profile */
96-
private readonly onSelectProfile = (selectedProfile: string) => this.setState({ selectedProfile })
99+
private readonly onSelectProfile = (selectedProfile: string, profiles?: import("madwizard").Profiles.Profile[]) => {
100+
this.setState({ selectedProfile })
101+
102+
if (this.props.onSelectProfile) {
103+
this.props.onSelectProfile(selectedProfile, profiles)
104+
}
105+
}
97106

98107
/** Event handler for switching to a different guidebook */
99108
private readonly onSelectGuidebook = (guidebook: string) => this.init(guidebook)

0 commit comments

Comments
 (0)