changed disabled flag for menu items to only work in production envir…#893
changed disabled flag for menu items to only work in production envir…#893charming-wicket-5502 wants to merge 1 commit intodevelopfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the Sidebar menu-item disabling logic so that Create/Import entries are only conditionally disabled (based on access rights) when the UI is running in production mode, allowing unrestricted behavior in non-production environments.
Changes:
- Introduces a production-environment guard (
import.meta.env.MODE === ...) around the Create/Import disabled-state logic. - Keeps existing access-rights evaluation (
hasCreateAccess) but applies it only when the production guard is true.
|
|
||
| // // Handle disabled state based on access rights | ||
| if (isCreateItem || isImportItem) { | ||
| const isProduction = import.meta.env.MODE === 'production'; |
There was a problem hiding this comment.
This introduces single quotes for the MODE comparison, but the UI is formatted with Prettier configured for double quotes (ui/.prettierrc.json sets singleQuote: false). This will cause pnpm run check (prettier --check) to fail unless the string literal is switched to double quotes (or the file is reformatted).
| const isProduction = import.meta.env.MODE === 'production'; | |
| const isProduction = import.meta.env.MODE === "production"; |
| const isProduction = import.meta.env.MODE === 'production'; | ||
|
|
||
| // Handle disabled state based on access rights | ||
| if (isProduction && (isCreateItem || isImportItem)) { | ||
| newItem.disabled = !hasCreateAccess; |
There was a problem hiding this comment.
isProduction is invariant for all menu items but is recomputed inside items.map(...) (and again for each recursive child). Consider computing it once outside processItems (or at least once per processMenuItems call) to avoid unnecessary repeated work and to make the intent clearer.
| // Handle disabled state based on access rights | ||
| if (isProduction && (isCreateItem || isImportItem)) { |
There was a problem hiding this comment.
The inline comment "Handle disabled state based on access rights" is now slightly inaccurate because the disabled state is only applied in production. Update the comment to reflect the production-only behavior to avoid confusion during local development/debugging.
No description provided.