-
Notifications
You must be signed in to change notification settings - Fork 0
DESK-1692: Admin pages #1013
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
base: main
Are you sure you want to change the base?
DESK-1692: Admin pages #1013
Conversation
…dd registration code and product id.
# Conflicts: # frontend/src/models/products.ts # frontend/src/services/graphQLDeviceProducts.ts
|
This pull request is automatically being deployed by Amplify Hosting (learn more). |
|
@codex can you assist with review |
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ad9c8e96a9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| setLoading(true) | ||
| const result = await graphQLAdminPartner(partnerId) | ||
| if (result !== 'ERROR' && result?.data?.data?.admin?.partners?.[0]) { | ||
| setPartner(result.data.data.admin.partners[0]) | ||
| } |
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.
Clear stale partner when admin lookup fails
If graphQLAdminPartner returns ERROR or no partner for a new partnerId, partner is left unchanged, so navigating from a valid partner to an invalid/deleted ID keeps showing the previous partner and the “Partner not found” branch never triggers. Consider setting partner to null when starting the fetch or when no results are returned to avoid stale data.
Useful? React with 👍 / 👎.
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.
fixed
| setLoading(true) | ||
| const result = await graphQLAdminUser(userId) | ||
| if (result !== 'ERROR' && result?.data?.data?.admin?.users?.items?.[0]) { | ||
| setUser(result.data.data.admin.users.items[0]) | ||
| } |
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.
Clear stale user when admin lookup fails
If the admin user lookup fails or returns no items, user is never cleared, so switching from a valid user to an invalid/deleted ID keeps rendering the previous user and skips the “User not found” state. Resetting user to null on fetch start or when no results are returned prevents showing stale details.
Useful? React with 👍 / 👎.
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.
fixed
JamieRuderman
left a comment
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.
It's nice an cleanly implemented - I just have some comments. Let me know if you wanna discuss. Thanks!
| const useStyles = makeStyles(({ palette }) => ({ | ||
| list: { | ||
| position: 'static', | ||
| '& .MuiListItemIcon-root': { color: palette.grayDark.main }, | ||
| '& .MuiListItemText-primary': { color: palette.grayDarkest.main }, | ||
| '& .MuiListItemButton-root:hover .MuiListItemText-primary': { color: palette.black.main }, | ||
| '& .Mui-selected, & .Mui-selected:hover': { | ||
| backgroundColor: palette.primaryLighter.main, | ||
| '& .MuiListItemIcon-root': { color: palette.grayDarker.main }, | ||
| '& .MuiListItemText-primary': { color: palette.black.main, fontWeight: 500 }, | ||
| }, | ||
| }, | ||
| })) |
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.
This is the old way we were styling, trying to convert to the sx prop styles for all future work. With AI now might be simple to convert all.
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.
fixed
| const handleBack = () => { | ||
| history.push('/admin/partners') | ||
| } |
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.
Back buttons maybe should use "useMobileBack" hook?
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.
fixed
|
|
||
| const fetchPartner = async () => { | ||
| setLoading(true) | ||
| const result = await graphQLAdminPartner(partnerId) |
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.
I would usually create a model class for something like Partner I understand if you think not worth it for an internal tool.
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.
fixed
| header={ | ||
| <Gutters> | ||
| <Stack direction="row" spacing={1} alignItems="center"> | ||
| <IconButton |
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.
We should have the hamburger menu here too... really I'm not sure removing the normal header is a good idea, but i guess dosen't matter too much for internal tool, but you can't get out of admin mode on mobile currently.
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.
put the normal header on admin pages
| const maxPanels = layout.singlePanel ? 1 : (containerWidth >= THREE_PANEL_WIDTH ? 3 : 2) | ||
|
|
||
| useEffect(() => { | ||
| const updateWidth = () => { | ||
| if (containerRef.current) { | ||
| setContainerWidth(containerRef.current.offsetWidth) | ||
| } | ||
| } | ||
|
|
||
| updateWidth() | ||
|
|
||
| const resizeObserver = new ResizeObserver(updateWidth) | ||
| if (containerRef.current) { | ||
| resizeObserver.observe(containerRef.current) | ||
| } | ||
|
|
||
| return () => resizeObserver.disconnect() | ||
| }, []) | ||
|
|
||
| const onLeftMove = useCallback((event: MouseEvent) => { | ||
| const fullWidth = containerRef.current?.offsetWidth || 1000 | ||
| leftHandleRef.current += event.clientX - leftMoveRef.current | ||
| leftMoveRef.current = event.clientX | ||
| if (leftHandleRef.current > MIN_WIDTH && leftHandleRef.current < fullWidth - MIN_WIDTH - rightWidth) { | ||
| setLeftWidth(leftHandleRef.current) | ||
| } | ||
| }, [rightWidth]) | ||
|
|
||
| const onLeftUp = useCallback((event: MouseEvent) => { | ||
| setLeftGrab(false) | ||
| event.preventDefault() | ||
| window.removeEventListener('mousemove', onLeftMove) | ||
| window.removeEventListener('mouseup', onLeftUp) | ||
| }, [onLeftMove]) | ||
|
|
||
| const onLeftDown = (event: React.MouseEvent) => { | ||
| setLeftGrab(true) | ||
| leftMoveRef.current = event.clientX | ||
| leftHandleRef.current = leftPrimaryRef.current?.offsetWidth || leftWidth | ||
| event.preventDefault() | ||
| window.addEventListener('mousemove', onLeftMove) | ||
| window.addEventListener('mouseup', onLeftUp) | ||
| } | ||
|
|
||
| const onRightMove = useCallback((event: MouseEvent) => { | ||
| const fullWidth = containerRef.current?.offsetWidth || 1000 | ||
| rightHandleRef.current -= event.clientX - rightMoveRef.current | ||
| rightMoveRef.current = event.clientX | ||
| if (rightHandleRef.current > MIN_WIDTH && rightHandleRef.current < fullWidth - MIN_WIDTH - leftWidth) { | ||
| setRightWidth(rightHandleRef.current) | ||
| } | ||
| }, [leftWidth]) |
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.
Seems like the panel width stuff is duplicated here - we would want to re-use the existing logic I would think.
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.
fixed
| badge={licenseIndicator} | ||
| onClick={handleClose} | ||
| /> | ||
| {adminMode ? ( |
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.
I'm not sure we need a new boolean to track admin mode since we already have TestUI mode. We could rename testUI mode to admin mode and trigger that menu's visibility from the admin attribute on the user. And then just always show the admin menu items... maybe under the "more" menu? Having it integrated instead of separated? Maybe there is a reason to do it how you have it. This just seems simpler.
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.
I'd pref to keep it as its own pages and not nested. It also does not fit well into the multi account of the main page.
Changes