-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Admin panel init #8742
base: main
Are you sure you want to change the base?
Admin panel init #8742
Conversation
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.
PR Summary
This PR introduces an admin panel with user impersonation and feature flag management capabilities, along with necessary routing and state management changes.
- Added
useImpersonate
hook in/settings/admin/hooks/useImpersonate.ts
for user impersonation but missinglastVisitedView
clearing (Clear lastVisitedView when impersonating #7090) - Added feature flag management table in
/settings/admin/components/SettingsAdminFeatureFlags.tsx
without loading/error states - Added admin panel access control via
canImpersonate
flag inAppRouter.tsx
andSettingsNavigationDrawerItems.tsx
- Refactored
clearSession
inuseAuth.ts
to support both sign-out and impersonation flows - Added admin panel route with conditional rendering based on user permissions in
SettingsRoutes.tsx
11 file(s) reviewed, 12 comment(s)
Edit PR Review Bot Settings | Greptile
@@ -69,6 +69,49 @@ export const useAuth = () => { | |||
|
|||
const setDateTimeFormat = useSetRecoilState(dateTimeFormatState); | |||
|
|||
const clearSession = useRecoilCallback( |
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.
logic: clearSession preserves UI states but doesn't clear lastVisitedView from localStorage as required by issue #7090
margin-top: ${({ theme }) => theme.spacing(0.5)}; | ||
`; | ||
|
||
const StyledTableHeaderRow = styled(Table)` |
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.
logic: StyledTableHeaderRow extends Table instead of TableRow, which could cause layout issues
<TableHeader>Value</TableHeader> | ||
</TableRow> | ||
</StyledTableHeaderRow> | ||
{currentWorkspace?.featureFlags?.map((flag) => ( |
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.
style: No handling of empty/undefined featureFlags array - should show empty state message
`; | ||
|
||
export const SettingsAdminFeatureFlags = () => { | ||
const currentWorkspace = useRecoilValue(currentWorkspaceState); |
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.
style: No loading or error state handling when fetching currentWorkspace
<Section> | ||
<H2Title title="Feature Flags" description="Manage feature flags." /> | ||
|
||
<Table> |
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.
style: Table structure creates new Table component for each row instead of reusing one table with multiple rows
setCurrentUser(user); | ||
setTokenPair(tokens); | ||
await sleep(0); | ||
window.location.href = AppPath.Index; |
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.
logic: setIsLoading(false) missing before redirect - loading state will remain true if navigation fails
await clearSession(); | ||
setCurrentUser(user); | ||
setTokenPair(tokens); |
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.
logic: lastVisitedView in localStorage needs to be cleared here per issue #7090
await clearSession(); | ||
setCurrentUser(user); | ||
setTokenPair(tokens); | ||
await sleep(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.
style: sleep(0) used without clear purpose - could be removed
const currentUser = useRecoilValue(currentUserState); | ||
const isAdminPageEnabled = currentUser?.canImpersonate; |
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.
style: Consider adding a more explicit name like isAdminEnabled instead of isAdminPageEnabled to match the naming pattern of other feature flags
|
||
export const SettingsAdmin = () => { | ||
return ( | ||
<SubMenuTopBarContainer title="Admin Panel" links={[{ children: 'Admin' }]}> |
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.
style: Consider adding a more descriptive breadcrumb trail (e.g. Settings > Admin Panel) for better navigation context
WIP
Related issues -
#7090
#8547
Master issue -
#4499