Skip to content
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

Fix several small issues across Boilerplate (#9083) #9084

Conversation

ysmoradi
Copy link
Member

@ysmoradi ysmoradi commented Nov 1, 2024

This closes #9083

Summary by CodeRabbit

  • New Features

    • Enhanced the About page to display web view information.
    • Improved two-factor authentication functionality with better error handling and state management.
  • Bug Fixes

    • Updated logging configurations for App Center and Application Insights to include scopes for better traceability.
  • Chores

    • Removed the AppCenterLoggerProvider configuration from development settings.

@ysmoradi ysmoradi requested a review from msynk November 1, 2024 16:33
Copy link

coderabbitai bot commented Nov 1, 2024

Walkthrough

The changes in this pull request involve updates to various configuration files and components within the boilerplate project template. Key modifications include changing the ServerAddress in the configuration file to an absolute URL, adding a web view display in the About page, enhancing logging configurations to include scopes, and implementing improvements to the two-factor authentication logic in the UserController. These updates aim to refine the project template and address specific issues identified in the linked issue.

Changes

File Change Summary
src/Client/Boilerplate.Client.Core/appsettings.json Updated ServerAddress from "/" to "http://localhost:5030/".
src/Client/Boilerplate.Client.Maui/Components/Pages/AboutPage.razor Added <BitText>Web View: <b>@webView</b></BitText> to display web view information.
src/Client/Boilerplate.Client.Maui/Components/Pages/AboutPage.razor.cs Added private field webView and modified OnInitAsync to assign telemetryContext.WebView.
src/Client/Boilerplate.Client.Maui/MauiProgram.Services.cs Updated logging configuration to include scopes for App Center and Application Insights.
src/Client/Boilerplate.Client.Maui/appsettings.Development.json Added new "Logging" section with AppCenterLoggerProvider and log level configuration.
src/Client/Boilerplate.Client.Windows/Components/Pages/AboutPage.razor Added <BitText>Web View: <b>@webView</b></BitText> to display web view information.
src/Client/Boilerplate.Client.Windows/Components/Pages/AboutPage.razor.cs Added private field webView and modified OnInitAsync to assign telemetryContext.WebView.
src/Client/Boilerplate.Client.Windows/Program.Services.cs Updated logging configuration to include scopes for App Center.
src/Server/Boilerplate.Server.Api/Controllers/Identity/UserController.cs Enhanced two-factor authentication logic and added methods for key formatting and QR code generation.
src/Shared/appsettings.Development.json Removed AppCenterLoggerProvider configuration section.

Assessment against linked issues

Objective Addressed Explanation
Update ServerAddress to http://localhost:5030/ (9083)
Display web view version in its own row on About page (9083)
Fix logging configuration issues (9083)
Call GenerateNewAuthenticatorKey instead of ResetAuthenticatorKeyAsync (9083) No changes related to GenerateNewAuthenticatorKey were made.

🐰 In the code, changes hop and leap,
🐇 New paths for logging, secrets to keep.
🌟 Web views now shine, bright on display,
🌈 With configs refined, we pave the way!
🥕 Two-factor's strong, no need to fear,
🐇 In our boilerplate, the future is clear!


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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 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

@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: 3

🧹 Outside diff range and nitpick comments (1)
src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/MauiProgram.Services.cs (1)

Line range hint 82-84: Incorrect Application Insights scopes configuration

Similar to the AppCenter configuration, the Application Insights logging also needs to have IncludeScopes set to false to align with the PR requirements.

Apply this fix:

-            {
-                options.IncludeScopes = true;
-            });
+            {
+                options.IncludeScopes = false;
+            });
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 2ee4888 and 162e709.

📒 Files selected for processing (10)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/appsettings.json (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/Components/Pages/AboutPage.razor (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/Components/Pages/AboutPage.razor.cs (2 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/MauiProgram.Services.cs (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/appsettings.Development.json (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Windows/Components/Pages/AboutPage.razor (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Windows/Components/Pages/AboutPage.razor.cs (2 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Windows/Program.Services.cs (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Identity/UserController.cs (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/appsettings.Development.json (0 hunks)
💤 Files with no reviewable changes (1)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/appsettings.Development.json
🧰 Additional context used
🪛 Biome
src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/appsettings.json

[error] 3-3: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 3-3: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 3-3: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 3-13: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)

src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/appsettings.Development.json

[error] 3-3: Expected a property but instead found '//#if (appCenter == true)'.

Expected a property here.

(parse)


[error] 4-4: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 4-4: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 4-8: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 9-10: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)

🔇 Additional comments (13)
src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/appsettings.Development.json (2)

2-10: LGTM! Clean implementation of conditional logging configuration.

The structure is well-organized and properly uses preprocessor directives to conditionally include AppCenter logging configuration. This aligns with the PR objective to relocate AppCenter's development configuration from the shared directory.

🧰 Tools
🪛 Biome

[error] 3-3: Expected a property but instead found '//#if (appCenter == true)'.

Expected a property here.

(parse)


[error] 4-4: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 4-4: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 4-8: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 9-10: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


4-8: ⚠️ Potential issue

Verify logging configuration completeness.

While the log level configuration looks good, the PR objectives mention setting "include scopes" to false. This setting appears to be missing from the configuration.

Let's check if this setting is configured elsewhere:

Consider adding the scopes configuration:

     "AppCenterLoggerProvider": {
         "LogLevel": {
             "Default": "Information"
-        }
+        },
+        "IncludeScopes": false
     }
🧰 Tools
🪛 Biome

[error] 4-4: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 4-4: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 4-8: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)

src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/appsettings.json (2)

3-3: LGTM! ServerAddress updated as requested.

The change from relative path ("/") to absolute URL ("http://localhost:5030/") aligns with the requirements specified in issue #9083.

🧰 Tools
🪛 Biome

[error] 3-3: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 3-3: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 3-3: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 3-13: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


3-3: Verify the impact on different deployment scenarios.

While the absolute URL works for local development, please ensure this change doesn't affect:

  1. Containerized deployments where the server might be on a different host/port
  2. Production deployments with different URLs
  3. Development scenarios using different ports

Consider documenting the need to update this value in deployment guides.

🧰 Tools
🪛 Biome

[error] 3-3: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 3-3: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 3-3: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 3-13: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)

src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Windows/Components/Pages/AboutPage.razor.cs (2)

16-16: LGTM: Clean field declaration.

The new webView field follows the established pattern with proper initialization using default!.


25-26: LGTM: Clean separation of OS and WebView information.

The separation of OS and WebView information into distinct assignments directly addresses the PR objective of displaying the web view version in its own row.

src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Windows/Components/Pages/AboutPage.razor (1)

18-18: LGTM! Successfully implements web view display requirement.

The addition of the web view information follows the established pattern and effectively addresses the PR objective of displaying the web view version in its own row.

src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/Components/Pages/AboutPage.razor (1)

18-18: LGTM! The web view information is properly displayed.

The implementation follows the existing pattern and successfully addresses the PR objective to display the web view version in its own row.

Let's verify the code-behind implementation:

✅ Verification successful

The code-behind implementation is properly synchronized with the UI changes

The verification confirms that the webView field is correctly initialized from telemetryContext.WebView in both MAUI and Windows client implementations, ensuring consistent behavior across platforms.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the webView field initialization in the code-behind file

# Test: Check if webView field is properly initialized from telemetryContext
rg -A 5 "webView.*=.*telemetryContext\.WebView" --type cs

Length of output: 1765

src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/Components/Pages/AboutPage.razor.cs (2)

17-17: LGTM: New field follows consistent patterns

The new webView field follows the established patterns in the class for field declarations and initialization.


27-28: LGTM: Clean separation of OS and web view information

The separation of OS and web view assignments improves code clarity and aligns with the PR objective to display the web view version in its own row.

src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Windows/Program.Services.cs (2)

Line range hint 9-89: Well-structured service registration

The service registration follows best practices with proper scoping, clear separation of concerns, and appropriate configuration validation.


Line range hint 15-19: Verify ServerAddress configuration value

The PR objectives mention that ServerAddress should be "http://localhost:5030/" instead of "/". While this code correctly uses the configuration value, we should verify the actual configuration setting.

✅ Verification successful

Based on the search results, I found the ServerAddress configuration in src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/appsettings.json:

    "ServerAddress": "http://localhost:5030/",

This matches the expected value mentioned in the PR objectives. Therefore, I can generate the final response:

ServerAddress configuration is correctly set

The ServerAddress configuration in appsettings.json is already set to "http://localhost:5030/" as required.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find and verify ServerAddress configuration
# Expected: Should find ServerAddress set to "http://localhost:5030/"

# Search for ServerAddress in all json, yaml, or cs files
rg -g '*.{json,yaml,yml,cs}' -i 'ServerAddress'

Length of output: 29069

src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/MauiProgram.Services.cs (1)

66-68: Verify AppCenter configuration location

The PR objectives mention that AppCenter's development configuration should not be in the shared directory. Let's verify its current location.

✅ Verification successful

Based on the search results, I can now generate the final response:

AppCenter configuration is correctly placed in client-specific projects

The AppCenter configuration is properly structured and not in the shared directory:

  • Configuration files are in client-specific projects (Boilerplate.Client.Maui and Boilerplate.Client.Windows)
  • AppCenter packages are correctly referenced only in the client projects
  • The configuration follows the recommended pattern of keeping platform-specific monitoring in the respective client apps, as evidenced by comments in MauiExceptionHandler.cs and WindowsExceptionHandler.cs
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for AppCenter configuration files
echo "Searching for AppCenter configuration files..."
fd -e json -e config "appsettings\..*" | xargs rg -l "AppCenter"

# Search for any AppCenter related settings
echo "Searching for AppCenter related code..."
rg -g "!*.{md,txt}" "AppCenter" -C 3

Length of output: 22799

@msynk msynk merged commit 309a73f into bitfoundation:develop Nov 1, 2024
3 checks passed
@ysmoradi ysmoradi deleted the 9083-several-small-issues-across-boilerplate-project-template branch November 3, 2024 09:28
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.

Several small issues across boilerplate project template
2 participants