laconic-console/packages/console-app/src/components/BotControls.js
Egor Gripasov 3c731b3b2b
fix: Add running bots tab. (#56)
* fix: Add bots resolver.

* minot fix.

* test commit.

* add bot kill

* Integration.

* add refetch.

* Lint.

* Formatting fix.

* Better error handling.
2020-12-02 05:32:49 -05:00

41 lines
963 B
JavaScript

//
// Copyright 2020 DXOS.org
//
import React, { useState } from 'react';
import StopIcon from '@material-ui/icons/HighlightOff';
import CircularProgress from '@material-ui/core/CircularProgress';
import IconButton from '@material-ui/core/IconButton';
import { makeStyles } from '@material-ui/core/styles';
const useStyles = makeStyles(theme => ({
stop: {
color: theme.palette.error.main
}
}));
const BotControls = ({ onStop }) => {
const [stopPressed, setStopPressed] = useState(false);
const classes = useStyles();
const stopBot = () => {
if (!stopPressed) {
setStopPressed(true);
onStop();
}
};
return (
<div>
{onStop && (
<IconButton onClick={stopBot} title='Stop'>
{!stopPressed && (<StopIcon className={classes.stop} />)}
{stopPressed && (<CircularProgress className={classes.stop} size={24} />)}
</IconButton>
)}
</div>
);
};
export default BotControls;