Skip to content

Commit

Permalink
feat: update ProfileExplorer to have a reset button
Browse files Browse the repository at this point in the history
this will reset the profile to its initial state. this PR also removes (for now) the Boot, Shutdown, and Dashboard buttons
  • Loading branch information
starpit committed Sep 28, 2022
1 parent b9aade6 commit 3571e5d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 15 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 13 additions & 6 deletions plugins/plugin-codeflare/src/components/ProfileExplorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ import {
} from "@patternfly/react-core"

import ProfileSelect from "./ProfileSelect"
import DashboardSelect from "./DashboardSelect"
// import DashboardSelect from "./DashboardSelect"
import ProfileWatcher from "../tray/watchers/profile/list"
import ProfileStatusWatcher from "../tray/watchers/profile/status"
import UpdateFunction from "../tray/update"
import { handleBoot, handleShutdown } from "../controller/profile/actions"
import { handleReset } from "../controller/profile/actions"

import "../../web/scss/components/Dashboard/Description.scss"
import "../../web/scss/components/ProfileExplorer/_index.scss"
Expand Down Expand Up @@ -210,8 +210,9 @@ class ProfileCard extends React.PureComponent<ProfileCardProps, ProfileCardState
isOpen: false,
}
}
private readonly _handleBoot = () => handleBoot(this.props.profile)
private readonly _handleShutdown = () => handleShutdown(this.props.profile)
private readonly _handleReset = () => handleReset(this.props.profile)
// private readonly _handleBoot = () => handleBoot(this.props.profile)
// private readonly _handleShutdown = () => handleShutdown(this.props.profile)
private readonly _onToggle = () => this.setState({ isOpen: !this.state.isOpen })

private title() {
Expand Down Expand Up @@ -384,8 +385,14 @@ class ProfileCard extends React.PureComponent<ProfileCardProps, ProfileCardState
private footer() {
return (
<Flex>
<FlexItem flex={{ default: "flex_1" }}></FlexItem>
<FlexItem>
<Button variant="link" isSmall className="codeflare--profile-explorer--boot-btn" onClick={this._handleBoot}>
<Button variant="link" isSmall className="codeflare--profile-explorer--reset-btn" onClick={this._handleReset}>
Reset
</Button>
</FlexItem>
{/*<FlexItem>
<Button variant="link" isSmall className="codeflare--profile-explorer--boot-btn" onClick={this._handleBoot}>
Boot
</Button>
<Button
Expand All @@ -399,7 +406,7 @@ class ProfileCard extends React.PureComponent<ProfileCardProps, ProfileCardState
</FlexItem>
<FlexItem flex={{ default: "flex_1" }}>
<DashboardSelect selectedProfile={this.props.profile} />
</FlexItem>
</FlexItem>*/}
</Flex>
)
}
Expand Down
7 changes: 7 additions & 0 deletions plugins/plugin-codeflare/src/controller/profile/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ export async function openWindow(title: string, initialTabTitle: string, argv: (
)
}

export async function handleReset(selectedProfile: string | undefined) {
if (selectedProfile) {
const { Profiles } = await import("madwizard")
await Profiles.reset({}, selectedProfile)
}
}

export function handleBoot(selectedProfile: string | undefined) {
openWindow(`Booting ${selectedProfile}`, "Booting", [
"codeflare",
Expand Down
2 changes: 1 addition & 1 deletion plugins/plugin-madwizard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"access": "public"
},
"dependencies": {
"madwizard": "^1.1.0",
"madwizard": "^1.2.0",
"@guidebooks/store": "^0.14.3"
}
}

0 comments on commit 3571e5d

Please sign in to comment.