Add support for listening showMapMarkers and showRoadNames values from the App Config#553
Conversation
… present and/or appConfig vlaues are present
WalkthroughThe update adjusts the logic for setting Changes
Sequence Diagram(s)sequenceDiagram
participant ParentComponent
participant MapTemplate
participant AppConfig
ParentComponent->>MapTemplate: Pass showRoadNames, showMapMarkers props
MapTemplate->>AppConfig: Access appSettings if props are undefined
MapTemplate->>MapTemplate: Normalize values to booleans
MapTemplate->>MapTemplate: Set mapOptions state
Estimated code review effort🎯 2 (Simple) | ⏱️ ~7 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
WalkthroughThe update refines how the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~7 minutes Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/map-template/src/components/MapTemplate/MapTemplate.jsx (1)
504-516: Consider extracting boolean conversion logic for better readability.The boolean coercion logic is functionally correct and handles the string-to-boolean conversion properly. However, the nested ternary operators make it less readable.
Consider extracting a helper function to improve readability:
+// Helper function to convert config values to booleans +const toBooleanFromConfig = (propValue, configValue) => { + if (propValue !== undefined) return propValue; + return typeof configValue === 'string' + ? configValue.toLowerCase() === 'true' + : configValue; +}; + useEffect(() => { setMapOptions({ brandingColor: color, - // Ensure showRoadNames and showMapMarkers are booleans, even if appConfig.appSettings.showRoadNames/showMapMarkers is a string - showRoadNames: - showRoadNames !== undefined - ? showRoadNames - : (typeof appConfig?.appSettings?.showRoadNames === 'string' - ? appConfig.appSettings.showRoadNames.toLowerCase() === 'true' - : appConfig?.appSettings?.showRoadNames), - showMapMarkers: - showMapMarkers !== undefined - ? showMapMarkers - : (typeof appConfig?.appSettings?.showMapMarkers === 'string' - ? appConfig.appSettings.showMapMarkers.toLowerCase() === 'true' - : appConfig?.appSettings?.showMapMarkers), + showRoadNames: toBooleanFromConfig(showRoadNames, appConfig?.appSettings?.showRoadNames), + showMapMarkers: toBooleanFromConfig(showMapMarkers, appConfig?.appSettings?.showMapMarkers), miTransitionLevel: miTransitionLevel, minZoom: ZoomLevelValues.minZoom, })
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/map-template/src/components/MapTemplate/MapTemplate.jsx(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/map-template/src/components/MapTemplate/MapTemplate.jsx (3)
packages/map-template/src/components/MapWrapper/MapWrapper.jsx (1)
appConfig(84-84)packages/map-template/src/hooks/useCurrentVenue.js (1)
appConfig(24-24)packages/map-template/src/constants/zoomLevelValues.js (2)
ZoomLevelValues(1-3)ZoomLevelValues(1-3)
🔇 Additional comments (1)
packages/map-template/src/components/MapTemplate/MapTemplate.jsx (1)
520-520: LGTM! Correctly added appConfig as dependency.Adding
appConfigto the dependency array is essential since the effect now reads fromappConfig.appSettings.showRoadNamesandappConfig.appSettings.showMapMarkers. This enables the component to react to configuration changes dynamically, which aligns with the PR objective of listening to these values from the App Config.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/map-template/src/components/MapTemplate/MapTemplate.jsx (1)
504-520: Improve boolean conversion logic and readability.The implementation correctly handles string-to-boolean conversion from app config, but the nested ternary operators reduce readability. Consider extracting the boolean conversion logic into a helper function for better maintainability.
Apply this refactor to improve readability:
+ // Helper function to ensure boolean values from config + const ensureBoolean = (propValue, configValue) => { + if (propValue !== undefined) return propValue; + if (typeof configValue === 'string') { + return configValue.toLowerCase() === 'true'; + } + return Boolean(configValue); + }; + useEffect(() => { setMapOptions({ brandingColor: color, - // Ensure showRoadNames and showMapMarkers are booleans, even if appConfig.appSettings.showRoadNames/showMapMarkers is a string - showRoadNames: - showRoadNames !== undefined - ? showRoadNames - : (typeof appConfig?.appSettings?.showRoadNames === 'string' - ? appConfig.appSettings.showRoadNames.toLowerCase() === 'true' - : appConfig?.appSettings?.showRoadNames), - showMapMarkers: - showMapMarkers !== undefined - ? showMapMarkers - : (typeof appConfig?.appSettings?.showMapMarkers === 'string' - ? appConfig.appSettings.showMapMarkers.toLowerCase() === 'true' - : appConfig?.appSettings?.showMapMarkers), + showRoadNames: ensureBoolean(showRoadNames, appConfig?.appSettings?.showRoadNames), + showMapMarkers: ensureBoolean(showMapMarkers, appConfig?.appSettings?.showMapMarkers), miTransitionLevel: miTransitionLevel, minZoom: ZoomLevelValues.minZoom, }) }, [primaryColor, showRoadNames, miTransitionLevel, color, showMapMarkers, appConfig]);The helper function also adds explicit
Boolean()conversion for non-string config values, ensuring consistent boolean output.
…nd_map_template_to_respect_showRoadNames_and_showMapMarkers_from_app_config
Added support of listening showMapMarkers and showRoadNames values from the App Config.
Summary by CodeRabbit