Skip to content

Add support for listening showMapMarkers and showRoadNames values from the App Config#553

Merged
matbmapspeople merged 7 commits intomainfrom
feature/extend_map_template_to_respect_showRoadNames_and_showMapMarkers_from_app_config
Aug 5, 2025
Merged

Add support for listening showMapMarkers and showRoadNames values from the App Config#553
matbmapspeople merged 7 commits intomainfrom
feature/extend_map_template_to_respect_showRoadNames_and_showMapMarkers_from_app_config

Conversation

@matbmapspeople
Copy link
Copy Markdown
Collaborator

@matbmapspeople matbmapspeople commented Aug 4, 2025

Added support of listening showMapMarkers and showRoadNames values from the App Config.

Summary by CodeRabbit

  • Bug Fixes
    • Improved the consistency of map display options by ensuring road names and map markers are always shown or hidden based on proper boolean values, regardless of how settings are provided.
    • Fixed an issue where changes in app configuration were not always reflected in map options.

… present and/or appConfig vlaues are present
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Aug 4, 2025

Walkthrough

The update adjusts the logic for setting showRoadNames and showMapMarkers in the mapOptions state within MapTemplate.jsx. These properties are now always coerced to booleans, using values from props or, if undefined, from appConfig.appSettings, with string values normalized to booleans. The effect also now depends on appConfig.

Changes

Cohort / File(s) Change Summary
Map options boolean normalization
packages/map-template/src/components/MapTemplate/MapTemplate.jsx
Ensures showRoadNames and showMapMarkers in mapOptions are always booleans, normalizing values from props or appConfig; adds appConfig as effect dependency.
Changelog update
packages/map-template/CHANGELOG.md
Adds version 1.81.2 changelog entry describing fixes for showRoadNames and showMapMarkers configurability via appConfig; refines description of showMapMarkers in 1.81.0.

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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Possibly related PRs

Suggested labels

minor

Suggested reviewers

  • Lucaci-Andrei

Poem

A hop and a skip, we toggle with care,
Road names and markers—now always fair.
Booleans ensured, no strings in disguise,
Map settings are clear, no need to revise.
With each config change, the map stays bright—
A rabbit’s delight, all toggles set right! 🐇🗺️

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2b9b60d and 6bde983.

📒 Files selected for processing (1)
  • packages/map-template/CHANGELOG.md (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/map-template/CHANGELOG.md
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/extend_map_template_to_respect_showRoadNames_and_showMapMarkers_from_app_config

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Aug 4, 2025

Walkthrough

The update refines how the mapOptions state is set in MapTemplate.jsx. It ensures that showRoadNames and showMapMarkers are always booleans by converting string values from appConfig.appSettings if necessary. The effect now also depends on appConfig, triggering updates when app configuration changes.

Changes

Cohort / File(s) Change Summary
Map options normalization
packages/map-template/src/components/MapTemplate/MapTemplate.jsx
Ensures showRoadNames and showMapMarkers are always booleans, converting string values as needed; adds appConfig to effect dependencies.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Poem

A hop, a leap, a Boolean tweak,
No strings attached, no values weak!
Map markers and roads now clear and true,
The config’s watched for something new.
With every change, the map will show
The rabbit’s code—onward we go! 🗺️🐇

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/extend_map_template_to_respect_showRoadNames_and_showMapMarkers_from_app_config

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9da5b9b and 3c3a97f.

📒 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 appConfig to the dependency array is essential since the effect now reads from appConfig.appSettings.showRoadNames and appConfig.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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9da5b9b and 3c3a97f.

📒 Files selected for processing (1)
  • packages/map-template/src/components/MapTemplate/MapTemplate.jsx (1 hunks)

@matbmapspeople matbmapspeople merged commit 6e51c23 into main Aug 5, 2025
1 check passed
@matbmapspeople matbmapspeople deleted the feature/extend_map_template_to_respect_showRoadNames_and_showMapMarkers_from_app_config branch August 5, 2025 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants