Skip to content

Commit

Permalink
Fixed issue in disabling the side menu items
Browse files Browse the repository at this point in the history
  • Loading branch information
tahierhussain committed Feb 4, 2025
1 parent cc56b29 commit dbd24b2
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions frontend/src/components/navigations/side-nav-bar/SideNavBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ try {
// Plugin unavailable.
}

let selectedProductStore;
let selectedProduct;
try {
selectedProductStore = require("../../../plugins/llm-whisperer/store/select-product-store.js");
} catch {
// Ignore if hook not available
}

const SideNavBar = ({ collapsed }) => {
const navigate = useNavigate();
const { sessionDetails } = useSessionStore();
Expand All @@ -62,6 +70,12 @@ const SideNavBar = ({ collapsed }) => {
// Do nothing
}

if (selectedProductStore?.useSelectedProductStore) {
selectedProduct = selectedProductStore.useSelectedProductStore(
(state) => state?.selectedProduct
);
}

let menu;
if (sideMenu) {
menu = sideMenu.useSideMenu();
Expand Down Expand Up @@ -193,7 +207,12 @@ const SideNavBar = ({ collapsed }) => {
}

const shouldDisableAll = useMemo(() => {
if (!unstractSubscriptionPlan || !UNSTRACT_SUBSCRIPTION_PLANS) {
const isUnstract = !(selectedProduct && selectedProduct !== "unstract");
if (
!unstractSubscriptionPlan ||
!UNSTRACT_SUBSCRIPTION_PLANS ||
!isUnstract
) {
return false;
}

Expand All @@ -203,13 +222,11 @@ const SideNavBar = ({ collapsed }) => {
);
}, [unstractSubscriptionPlan]);

if (shouldDisableAll) {
data.forEach((mainMenuItem) => {
mainMenuItem.subMenu.forEach((subMenuItem) => {
subMenuItem.disable = true;
});
data.forEach((mainMenuItem) => {
mainMenuItem.subMenu.forEach((subMenuItem) => {
subMenuItem.disable = shouldDisableAll;
});
}
});

return (
<Sider
Expand Down

0 comments on commit dbd24b2

Please sign in to comment.