-
Notifications
You must be signed in to change notification settings - Fork 4
i15-1: display basic feedback from blueapi #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
noemifrisina
wants to merge
46
commits into
main
Choose a base branch
from
1539-i15_1-blueapi_feedback
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 17 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
e997c63
Add a blueapi status card
noemifrisina 38ff3ed
Add abort button
noemifrisina cb83b97
Tidy up
noemifrisina bec4ed7
Try adding a handler
noemifrisina 2e2e94d
Add a first snackbar
noemifrisina d4b9912
Get the msw handler to more or less show abort
noemifrisina 28b869f
Update the Trackable task from blueapi
noemifrisina de12c13
Add a snackbar to the run plan button
noemifrisina 85d7ab4
Move snackbar back
noemifrisina b717540
Add more snackbar and try to mock
noemifrisina cb84630
Fix the snackbar - now just need to poll
noemifrisina 78a005f
Try to see if it wait for sleep
noemifrisina c5738a4
An attempt at polling
noemifrisina a2ede88
Fix typing in test
noemifrisina fd020b7
Merge branch 'main' into 1539-i15_1-blueapi_feedback
jacob720 7a61e6a
Fix lint
jacob720 9e4c89d
Merge branch 'main' into 1539-i15_1-blueapi_feedback
jacob720 8a74ce6
Fix typecheck
jacob720 40377f0
Merge branch 'main' into 1539-i15_1-blueapi_feedback
noemifrisina 5093662
Rename parameter
noemifrisina c21fba7
Pull idle and aborting into constants
noemifrisina b7c65ec
Merge branch 'main' into 1539-i15_1-blueapi_feedback
noemifrisina 38ceb2e
Merge branch 'main' into 1539-i15_1-blueapi_feedback
noemifrisina fbd0420
Merge branch 'main' into 1539-i15_1-blueapi_feedback
noemifrisina 80630f9
Fix issues from bad merge in Robot
noemifrisina f2c4e53
Put the abort button back in
noemifrisina 77b99cf
Add more snackbars
noemifrisina 1dda9b3
Put the worker state back in
noemifrisina b9e529f
Get the polling to work
noemifrisina 59a9248
Fix the polling
noemifrisina a373950
Get mock for useBlueapi to work and add a test to check it
noemifrisina 83cc6cb
One more test
noemifrisina 94f04cf
Remove some extra comments
noemifrisina 0ffbf99
And maybe remember to update test
noemifrisina afd4c2e
Use correct utility
noemifrisina 3925bbd
Use act for rendering
noemifrisina 9975ef5
Try to fix it
noemifrisina 89eccf6
Check if other tests actually pass
noemifrisina 4c0658a
Check if other tests actually pass - part 2
noemifrisina 0d8027b
Try to fix broken tests one by one
noemifrisina b3880e9
Try to fix broken tests one by one - maybe mocking an actual missing …
noemifrisina 2b45039
See happy test
noemifrisina a2eb7af
Tidy up
noemifrisina d94080b
Add tests for abort button and tidy up
noemifrisina df555b5
Fix lint
noemifrisina 4adf11d
Try to disable warning since linter does not like the cast
noemifrisina File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,65 @@ | ||
| import { | ||
| Alert, | ||
| Button, | ||
| Snackbar, | ||
| Tooltip, | ||
| type SnackbarCloseReason, | ||
| } from "@mui/material"; | ||
|
|
||
| import type { WorkerStateRequest } from "@atlas/blueapi"; | ||
| import { useSetWorkerState } from "@atlas/blueapi-query"; | ||
| import React, { useState } from "react"; | ||
|
|
||
| export function AbortPlanButton() { | ||
| const workerState = useSetWorkerState(); | ||
| const [openSnackbar, setOpenSnackbar] = useState<boolean>(false); | ||
|
|
||
| const abortPlan = async () => { | ||
| const workerRequest: WorkerStateRequest = { | ||
| new_state: "ABORTING", | ||
| reason: "Abort button pressed", | ||
| }; | ||
| workerState.mutate(workerRequest); | ||
| }; | ||
|
|
||
| const handleClick = async () => { | ||
| setOpenSnackbar(true); | ||
| await abortPlan(); | ||
| }; | ||
|
|
||
| const handleSnackbarClose = ( | ||
| _event: React.SyntheticEvent | Event, | ||
| reason?: SnackbarCloseReason, | ||
| ) => { | ||
| if (reason === "clickaway") { | ||
| return; | ||
| } | ||
|
|
||
| setOpenSnackbar(false); | ||
| }; | ||
|
|
||
| return ( | ||
| <React.Fragment> | ||
| <Tooltip title="Abort current blueapi operation" placement="bottom"> | ||
| <Button | ||
| variant="contained" | ||
| color="error" | ||
| sx={{ width: "150px" }} | ||
| onClick={handleClick} | ||
| > | ||
| Abort | ||
| </Button> | ||
| </Tooltip> | ||
| <Snackbar | ||
| open={openSnackbar} | ||
| autoHideDuration={5000} | ||
| onClose={handleSnackbarClose} | ||
| anchorOrigin={{ vertical: "bottom", horizontal: "right" }} | ||
| > | ||
| <Alert onClose={handleSnackbarClose} severity="warning"> | ||
| Abort button pressed, will abort current plan ... | ||
| </Alert> | ||
| </Snackbar> | ||
| </React.Fragment> | ||
| ); | ||
| } |
This file contains hidden or 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,54 @@ | ||
| import { useGetWorkerState } from "@atlas/blueapi-query"; | ||
| import { | ||
| Card, | ||
| CardContent, | ||
| Stack, | ||
| Typography, | ||
| useTheme, | ||
| type Theme, | ||
| } from "@mui/material"; | ||
|
|
||
| function getStateColorMap(theme: Theme) { | ||
| return { | ||
| IDLE: theme.palette.info.main, | ||
| RUNNING: theme.palette.success.main, | ||
| PAUSING: theme.palette.warning.main, | ||
| PAUSED: theme.palette.warning.main, | ||
| HALTING: theme.palette.warning.main, | ||
| STOPPING: theme.palette.error.main, | ||
| ABORTING: theme.palette.error.main, | ||
| SUSPENDING: theme.palette.error.main, | ||
| PANICKED: theme.palette.error.main, | ||
| UNKNOWN: theme.palette.background.paper, | ||
| }; | ||
| } | ||
|
|
||
| export function BlueapiWorkerState() { | ||
| const theme = useTheme(); | ||
| const workerState = useGetWorkerState(); | ||
| const stateMap = getStateColorMap(theme); | ||
|
|
||
| return ( | ||
| <Card | ||
| variant="outlined" | ||
| sx={{ | ||
| minWidth: 250, | ||
| maxHeight: 100, | ||
| bgcolor: theme.palette.background.paper, | ||
| borderColor: theme.palette.text.primary, | ||
| }} | ||
| > | ||
| <CardContent> | ||
| <Stack direction={"column"} spacing={"1"}> | ||
| <Typography>Blueapi worker state: </Typography> | ||
| <Typography | ||
| variant="body1" | ||
| color={stateMap[workerState.data ? workerState.data : "UNKNOWN"]} | ||
| > | ||
| {workerState.data} | ||
| </Typography> | ||
| </Stack> | ||
| </CardContent> | ||
| </Card> | ||
| ); | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must: I think this is a duplicate of the existing card. Maybe a bad merge?