Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

fix(sidebar): don't crash org pages for non-admin members

Carl-Gerhard Lindesvärd2d4f21e2ba7f
diff --git a/apps/start/src/components/sidebar-organization-menu.tsx b/apps/start/src/components/sidebar-organization-menu.tsx
index b4551fe2f..6585c7f31 100644
--- a/apps/start/src/components/sidebar-organization-menu.tsx
+++ b/apps/start/src/components/sidebar-organization-menu.tsx
@@ -123,14 +123,25 @@ export function ActionCTAButton() {
];
const [currentActionIndex, setCurrentActionIndex] = useState(0);
+ const actionCount = ACTIONS.length;
useEffect(() => {
+ if (actionCount === 0) {
+ return;
+ }
const interval = setInterval(() => {
- setCurrentActionIndex((prevIndex) => (prevIndex + 1) % ACTIONS.length);
+ setCurrentActionIndex((prevIndex) => (prevIndex + 1) % actionCount);
}, 2000);
return () => clearInterval(interval);
- }, []);
+ }, [actionCount]);
+
+ // Members (non-admins) have no org-level actions; render nothing instead of
+ // indexing into an empty list.
+ const currentAction = ACTIONS[currentActionIndex];
+ if (!currentAction) {
+ return null;
+ }
return (
<div className="mb-4">
@@ -161,7 +172,7 @@ export function ActionCTAButton() {
duration: 0.3,
}}
>
- {ACTIONS[currentActionIndex].label}
+ {currentAction.label}
</motion.span>
</AnimatePresence>
</div>