Skip to content
This repository has been archived by the owner on Jun 28, 2023. It is now read-only.

Commit

Permalink
Fixes crc-org#126 use updated Actions component
Browse files Browse the repository at this point in the history
  • Loading branch information
gbraad committed Feb 9, 2022
1 parent 057a3ba commit 1d00c19
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"homepage": ".",
"dependencies": {
"@code-ready/crc-react-components": "https://github.com/code-ready/crc-react-components/releases/download/0.9.8/crc-react-components-0.9.8.tgz",
"@code-ready/crc-react-components": "https://github.com/code-ready/crc-react-components/releases/download/0.9.9/crc-react-components-0.9.9.tgz",
"@patternfly/react-core": "^4.175.4",
"react": "^17.0.2",
"react-dom": "^17.0.2",
Expand Down
27 changes: 19 additions & 8 deletions frontend/src/components/MiniStatusWindow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,35 @@ export default class MiniStatusWindow extends React.Component {
super(props);
this.state = {
preset: "unknown",
vmstatus: "unknown"
};

this.control = React.createRef();
this.onPlayPause = this.onPlayPause.bind(this);
}

componentDidMount() {
window.api.onStatusChanged(async (event, status) => {
this.setState({preset: status.Preset})

// Toggle states of the button
if(status.CrcStatus === "Stopping") {
this.setState({vmstatus: "Starting"})
} else {
this.setState({vmstatus: status.CrcStatus})
}

this.control.current.updateStatus(status);
})
}

onStart() {
window.api.startInstance({})
}

onStop() {
window.api.stopInstance({})
onPlayPause() {
if(this.state.vmstatus === "Stopped") {
window.api.startInstance({})
}
if(this.state.vmstatus === "Running") {
window.api.stopInstance({})
}
}

onDelete() {
Expand All @@ -38,8 +49,8 @@ export default class MiniStatusWindow extends React.Component {
return (
<ControlCard ref={this.control}
preset={this.state.preset}
onStartClicked={this.onStart}
onStopClicked={this.onStop}
status={this.state.vmstatus}
onPlayPauseClicked={this.onPlayPause}
onDeleteClicked={this.onDelete} />
);
}
Expand Down

0 comments on commit 1d00c19

Please sign in to comment.