Skip to content

Side Menu Changes #1172

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

Merged
merged 3 commits into from
May 20, 2025
Merged

Side Menu Changes #1172

merged 3 commits into from
May 20, 2025

Conversation

ammb-123
Copy link
Contributor

Description

Flag is added to on/off the side menu in the AI CORE app

Changes Made

ADMIN_ONLY_VIEW_MENU_BAR flag added

How to Test

  1. Login to the AI core app ,user can able to view the ai core page without side menu bar and catalog items .
  2. Config api has the adminOnlyViewMenuBarFlag : true
    Uploading AdminUser_updated.docx…

Notes

Monolith : SEMOSS/Monolith#129
Uploading AdminUser_updated.docx…

@ammb-123 ammb-123 requested a review from a team as a code owner May 19, 2025 13:55
Copy link

@CodiumAI-Agent /describe

@CodiumAI-Agent
Copy link

Title

Side Menu Changes


User description

Description

Flag is added to on/off the side menu in the AI CORE app

Changes Made

ADMIN_ONLY_VIEW_MENU_BAR flag added

How to Test

  1. Login to the AI core app ,user can able to view the ai core page without side menu bar and catalog items .
  2. Config api has the adminOnlyViewMenuBarFlag : true
    Uploading AdminUser_updated.docx…

Notes

Monolith : SEMOSS/Monolith#129
Uploading AdminUser_updated.docx…


PR Type

Enhancement


Description

  • Introduce adminOnlyViewMenuBarFlag in config store

  • Conditionally render sidebar for admin users

  • Enforce new flag on HomePage add button


Changes walkthrough 📝

Relevant files
Enhancement
HomePage.tsx
Enforce flag on add button                                                             

packages/client/src/pages/HomePage.tsx

  • Added adminOnlyViewMenuBarFlag check before "Add" button
  • Combined config flag with engine operation availability
  • +1/-1     
    NavigatorLayout.tsx
    Show sidebar only for admin                                                           

    packages/client/src/pages/NavigatorLayout.tsx

  • Imported useRootStore, useState, useEffect
  • Added coreApiFlag and adminOnlyFlag state
  • Wrapped sidebar JSX inside adminOnlyFlag check
  • +12/-0   
    Configuration changes
    config.store.ts
    Add adminOnlyViewMenuBarFlag config                                           

    packages/client/src/stores/config/config.store.ts

  • Defined adminOnlyViewMenuBarFlag in ConfigStoreInterface
  • Initialized flag default in store values
  • +5/-1     

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • Copy link

    @CodiumAI-Agent /review

    Copy link

    @CodiumAI-Agent /improve

    @CodiumAI-Agent
    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Infinite Render

    Calling setAdmingOnlyFlag inside the component body triggers a state update on every render, causing an infinite re-render loop. Move this logic into a useEffect or derive the value directly from the store.

     if(configStore.store.user.admin && coreApiFlag){
        setAdmingOnlyFlag(true);
    }
    Stale State

    The coreApiFlag state is initialized once and will not update when adminOnlyViewMenuBarFlag changes. Consider deriving the flag directly from the observable store instead of copying it to state.

    const [coreApiFlag ,setCoreApiFlag ] = useState(configStore.store.config.adminOnlyViewMenuBarFlag);
    Typo Variable

    The state variable admingOnlyFlag has a typo (adming vs admin), which can lead to confusion. Rename it for clarity.

    const [admingOnlyFlag ,setAdmingOnlyFlag ] = useState(false);

    @CodiumAI-Agent
    Copy link

    CodiumAI-Agent commented May 19, 2025

    PR Code Suggestions ✨

    Latest suggestions up to 8bb7bbc

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Derive admin flag directly

    Avoid calling state setters inside the render body to prevent infinite re-renders
    and simplify logic by deriving the flag directly. Also correct the typo in
    admingOnlyFlag to adminOnlyFlag for consistency.

    packages/client/src/pages/NavigatorLayout.tsx [87-92]

    -const [admingOnlyFlag ,setAdmingOnlyFlag ] = useState(false);
    -const [coreApiFlag ,setCoreApiFlag ] = useState(configStore.store.config.adminOnlyViewMenuBarFlag);
    +const adminOnlyFlag = configStore.store.user.admin && configStore.store.config.adminOnlyViewMenuBarFlag;
     
    - if(configStore.store.user.admin && coreApiFlag){
    -    setAdmingOnlyFlag(true);
    -}
    -
    Suggestion importance[1-10]: 9

    __

    Why: Deriving adminOnlyFlag directly avoids calling setAdmingOnlyFlag during render, preventing potential infinite re-renders and fixes the admingOnlyFlag typo for consistency.

    High

    Previous suggestions

    Suggestions up to commit 8bb7bbc
    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Derive flag without state

    Avoid setting state during render which causes infinite re-renders. Instead, derive
    adminOnlyFlag directly from store values and remove the useState and if block.

    packages/client/src/pages/NavigatorLayout.tsx [87-92]

    -const [admingOnlyFlag ,setAdmingOnlyFlag ] = useState(false);
    -const [coreApiFlag ,setCoreApiFlag ] = useState(configStore.store.config.adminOnlyViewMenuBarFlag);
    +const adminOnlyFlag = configStore.store.user.admin && configStore.store.config.adminOnlyViewMenuBarFlag;
     
    - if(configStore.store.user.admin && coreApiFlag){
    -    setAdmingOnlyFlag(true);
    -}
    -
    Suggestion importance[1-10]: 9

    __

    Why: The current code sets state during render causing infinite re-renders; deriving adminOnlyFlag directly from configStore fixes this critical issue.

    High

    @kunal0137
    Copy link
    Contributor

    image

    this does not work

    ammb-123 and others added 2 commits May 20, 2025 20:04

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    …y boolean
    @johbaxter johbaxter merged commit cc68378 into dev May 20, 2025
    3 checks passed
    @johbaxter johbaxter deleted the ammu_side_menu_semoss branch May 20, 2025 18:19
    Copy link

    @CodiumAI-Agent /update_changelog

    @CodiumAI-Agent
    Copy link

    Changelog updates: 🔄

    2025-05-20 *

    Changed

    • Added adminOnlyViewMenuBarFlag and updated side menu rendering based on flag and user role

    to commit the new content to the CHANGELOG.md file, please type:
    '/update_changelog --pr_update_changelog.push_changelog_changes=true'

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    None yet

    4 participants