-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ae4ab7
commit 2ebb016
Showing
19 changed files
with
677 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import CloseIcon from '@mui/icons-material/Close' | ||
import TerminalIcon from '@mui/icons-material/Terminal' | ||
import { Badge, Box, Fab, Modal, Tab, Tabs, Typography } from '@mui/material' | ||
import { useTheme } from '@mui/material/styles' | ||
import React, { useContext, useState } from 'react' | ||
|
||
import { AppContext } from '../context/AppContext' | ||
import StatusBoxAction from './StatusBoxAction' | ||
|
||
const StatusBox: React.FC = () => { | ||
const { appState } = useContext(AppContext)! | ||
const [open, setOpen] = useState(false) | ||
const [selectedActionIndex, setSelectedActionIndex] = useState(0) | ||
const theme = useTheme() | ||
|
||
const handleOpen = () => setOpen(true) | ||
const handleClose = () => setOpen(false) | ||
const handleChange = (event: React.SyntheticEvent, newValue: number) => { | ||
setSelectedActionIndex(newValue) | ||
} | ||
|
||
if (appState.runningActions.length === 0) { | ||
return null | ||
} | ||
|
||
return ( | ||
<div> | ||
<Fab | ||
color="primary" | ||
aria-label="status" | ||
onClick={handleOpen} | ||
style={{ position: 'fixed', bottom: 16, right: 16, zIndex: 1000 }} | ||
> | ||
<Badge badgeContent={appState.runningActions.length} color="secondary"> | ||
<TerminalIcon /> | ||
</Badge> | ||
</Fab> | ||
<Modal | ||
open={open} | ||
onClose={handleClose} | ||
sx={{ | ||
top: 'auto', | ||
bottom: 0, | ||
height: '50vh', | ||
width: '100%', | ||
}} | ||
> | ||
<Box | ||
sx={{ | ||
color: theme.palette.text, | ||
backgroundColor: theme.palette.background.default, | ||
height: '100%', | ||
}} | ||
> | ||
<Box | ||
display="flex" | ||
justifyContent="space-between" | ||
alignItems="center" | ||
> | ||
<Tabs | ||
value={selectedActionIndex} | ||
onChange={handleChange} | ||
variant="scrollable" | ||
scrollButtons="auto" | ||
sx={{ backgroundColor: theme.palette.background.default }} | ||
> | ||
{appState.runningActions.map((action, index) => ( | ||
<Tab | ||
label={action.id || 'No Id'} | ||
key={action.id} | ||
sx={{ color: theme.palette.text.primary, fontSize: '10px' }} | ||
/> | ||
))} | ||
</Tabs> | ||
<Fab | ||
size="small" | ||
color="secondary" | ||
onClick={handleClose} | ||
sx={{ m: 1 }} | ||
> | ||
<CloseIcon /> | ||
</Fab> | ||
</Box> | ||
|
||
<StatusBoxAction | ||
action={appState.runningActions[selectedActionIndex]} | ||
/> | ||
</Box> | ||
</Modal> | ||
</div> | ||
) | ||
} | ||
|
||
export default StatusBox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Typography } from '@mui/material' | ||
import React from 'react' | ||
|
||
import { IAction } from '../types' | ||
|
||
interface IStatusBoxActionProps { | ||
action: IAction | ||
} | ||
|
||
const StatusBoxAction: React.FC<IStatusBoxActionProps> = ({ action }) => { | ||
return ( | ||
<> | ||
<Typography variant="caption">{action.title}</Typography> | ||
</> | ||
) | ||
} | ||
export default StatusBoxAction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.