Skip to content

Commit

Permalink
[GH-348] Fix crash when accessing admin page from self-hosted UI
Browse files Browse the repository at this point in the history
Summary: LiveRouteContext isn't available outside the live views, and the sidebar was ignoring that. Not sure how we didn't trigger this before now.

Test Plan: Visit the admin pages. On main, that crashes the UI. With this, it doesn't.

Reviewers: michelle, vihang

Reviewed By: vihang

Subscribers: nserrino

Signed-off-by: Nick Lanam <nlanam@pixielabs.ai>

Differential Revision: https://phab.corp.pixielabs.ai/D10134
  • Loading branch information
NickLanam committed Nov 9, 2021
1 parent f1bccde commit b895683
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/ui/src/containers/App/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,14 @@ const SideBarExternalLinkItem = React.memo<LinkItemProps>(function SideBarExtern
export const SideBar: React.FC<{ open: boolean }> = React.memo(({ open }) => {
const classes = useStyles();
const selectedClusterName = React.useContext(ClusterContext)?.selectedClusterName ?? '';
const { embedState } = React.useContext(LiveRouteContext);

// If we're not in the live view, LiveViewContext is null.
const embedState = React.useContext(LiveRouteContext)?.embedState ?? null;

const { user } = React.useContext(UserContext);

const navItems = React.useMemo(() => {
if (!selectedClusterName) {
if (!selectedClusterName || !embedState) {
return [];
}
return [{
Expand All @@ -177,7 +179,7 @@ export const SideBar: React.FC<{ open: boolean }> = React.memo(({ open }) => {
text: 'Namespaces',
}];
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [selectedClusterName]);
}, [selectedClusterName, embedState]);

const drawerClasses = React.useMemo(
() => ({ paper: open ? classes.drawerOpen : classes.drawerClose }),
Expand Down

0 comments on commit b895683

Please sign in to comment.