Skip to content

Remove unused codes from repository (#9489)#9490

Merged
msynk merged 8 commits intobitfoundation:developfrom
yasmoradi:9489-boilerplate-project-template-un-used-codes
Dec 15, 2024
Merged

Remove unused codes from repository (#9489)#9490
msynk merged 8 commits intobitfoundation:developfrom
yasmoradi:9489-boilerplate-project-template-un-used-codes

Conversation

@yasmoradi
Copy link
Member

@yasmoradi yasmoradi commented Dec 15, 2024

This closes #9489

Summary by CodeRabbit

  • New Features

    • Enhanced project creation commands with new flags for various test scenarios, improving functionality.
    • Added SignalR support in the CategoryController and ProductController, allowing for real-time updates.
  • Bug Fixes

    • Streamlined session management by removing unnecessary session revocation tracking.
  • Chores

    • Removed the ModalData class to simplify modal data management.
  • Documentation

    • Updated comments and documentation to reflect changes in session handling and SignalR integration.

@yasmoradi yasmoradi requested a review from msynk December 15, 2024 00:26
@coderabbitai
Copy link

coderabbitai bot commented Dec 15, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request introduces several modifications across different files in a .NET project. The changes primarily focus on enhancing project configuration in GitHub workflows, updating session management components, removing modal data services, and adding conditional SignalR support in product and category controllers. The modifications aim to improve project flexibility, streamline session handling, and provide more configurable project templates with additional feature flags.

Changes

File Change Summary
.github/workflows/bit.full.ci.yml Added various flags to project creation commands for different test scenarios, including --signalR, --sample, --offlineDb, --appInsights, --captcha, and --notification
src/Client/Boilerplate.Client.Core/Components/Pages/Authorized/Settings/SessionsSection.razor Removed <NavigationLock> component, preserved session rendering logic
src/Client/Boilerplate.Client.Core/Components/Pages/Authorized/Settings/SessionsSection.razor.cs Removed hasRevokedAnySession field and OnBeforeInternalNavigation method
src/Client/Boilerplate.Client.Core/Services/ModalData.cs Deleted entire ModalData class
src/Server/Boilerplate.Server.Api/Controllers/Categories/CategoryController.cs Added conditional SignalR compilation support, introduced appHubContext and PublishDashboardDataChanged method
src/Server/Boilerplate.Server.Api/Controllers/Products/ProductController.cs Added conditional SignalR compilation support, similar to CategoryController

Poem

🐰 In the realm of code, where rabbits hop and play,
Workflows dance with flags, SignalR leads the way!
Sessions trimmed, modal data takes flight,
Controllers flex with conditional might!
A boilerplate ballet of tech delight! 🚀


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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: 0

🔭 Outside diff range comments (2)
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Products/ProductController.cs (1)

Line range hint 91-97: Enhance error handling and configuration in SignalR publishing.

The PublishDashboardDataChanged method has several areas for improvement:

  1. The comment suggests excluding current user session, but the implementation doesn't reflect this
  2. No error handling for SignalR communication failures
  3. The group name "AuthenticatedClients" is hardcoded

Consider implementing these improvements:

 private async Task PublishDashboardDataChanged(CancellationToken cancellationToken)
 {
-    // Checkout AppHub's comments for more info.
-    // In order to exclude current user session, gets its signalR connection id from database and use GroupExcept instead.
-    await appHubContext.Clients.Group("AuthenticatedClients").SendAsync(SignalREvents.PUBLISH_MESSAGE, SharedPubSubMessages.DASHBOARD_DATA_CHANGED, cancellationToken);
+    const string GROUP_NAME = "AuthenticatedClients";
+    try
+    {
+        // TODO: Implement current session exclusion
+        var currentConnectionId = await GetCurrentUserConnectionId(cancellationToken);
+        await appHubContext.Clients.GroupExcept(GROUP_NAME, currentConnectionId)
+            .SendAsync(SignalREvents.PUBLISH_MESSAGE, 
+                      SharedPubSubMessages.DASHBOARD_DATA_CHANGED, 
+                      cancellationToken);
+    }
+    catch (Exception ex)
+    {
+        // Log the error but don't rethrow as this is a background notification
+        Logger.LogError(ex, "Failed to publish dashboard data change");
+    }
 }
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Categories/CategoryController.cs (1)

Line range hint 91-97: Extract shared SignalR publishing logic to avoid duplication.

The PublishDashboardDataChanged method is identical in both ProductController and CategoryController. This violates the DRY principle.

Consider extracting this shared functionality into a base class or service:

+ public interface IDashboardNotificationService
+ {
+     Task PublishDashboardDataChanged(CancellationToken cancellationToken);
+ }
+
+ public class DashboardNotificationService : IDashboardNotificationService
+ {
+     private readonly IHubContext<AppHub> _appHubContext;
+     private readonly ILogger<DashboardNotificationService> _logger;
+
+     public DashboardNotificationService(
+         IHubContext<AppHub> appHubContext,
+         ILogger<DashboardNotificationService> logger)
+     {
+         _appHubContext = appHubContext;
+         _logger = logger;
+     }
+
+     public async Task PublishDashboardDataChanged(CancellationToken cancellationToken)
+     {
+         // Implementation here
+     }
+ }

Then inject and use this service in both controllers:

- [AutoInject] private IHubContext<AppHub> appHubContext = default!;
+ [AutoInject] private IDashboardNotificationService dashboardNotifier = default!;

- await PublishDashboardDataChanged(cancellationToken);
+ await dashboardNotifier.PublishDashboardDataChanged(cancellationToken);
🧹 Nitpick comments (1)
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Products/ProductController.cs (1)

Line range hint 14-15: Consider making the hub context readonly.

The appHubContext field should be marked as readonly since it's only assigned once through dependency injection.

- [AutoInject] private IHubContext<AppHub> appHubContext = default!;
+ [AutoInject] private readonly IHubContext<AppHub> appHubContext = default!;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4b78ed7 and ed5fc8f.

📒 Files selected for processing (6)
  • .github/workflows/bit.full.ci.yml (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Authorized/Settings/SessionsSection.razor (0 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Authorized/Settings/SessionsSection.razor.cs (0 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Services/ModalData.cs (0 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Categories/CategoryController.cs (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Products/ProductController.cs (1 hunks)
💤 Files with no reviewable changes (3)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Services/ModalData.cs
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Authorized/Settings/SessionsSection.razor
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Authorized/Settings/SessionsSection.razor.cs
🔇 Additional comments (4)
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Products/ProductController.cs (1)

3-5: LGTM: SignalR imports are properly conditioned.

The SignalR-related imports are correctly wrapped in preprocessor directives, allowing for conditional compilation.

src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Categories/CategoryController.cs (1)

3-5: Maintain consistency with SignalR imports.

The SignalR-related imports are correctly wrapped in preprocessor directives, matching the implementation in ProductController.

.github/workflows/bit.full.ci.yml (2)

143-151: Verify framework version compatibility with new features

The changes look good, but there are some points to consider:

  1. The TestOther project uses net9.0 which is a future/preview version. Ensure all features (especially --sentry and --sample Todo) are compatible with this version.
  2. The combination of flags should be tested to ensure they work together (e.g., --sample Admin with --offlineDb).

Run the following script to check for any framework version constraints in the template:

✅ Verification successful

Based on the shell script results, I can now provide a definitive response about the framework version compatibility and feature flags:

Framework versions and features are properly configured

The codebase shows proper support for both net8.0 and net9.0 frameworks with appropriate feature flag handling:

  • The --signalR flag is supported in both frameworks with proper package references (Microsoft.AspNetCore.SignalR.Client v8.0.11 for net8.0 and v9.0.0 for net9.0)
  • The --sentry flag is framework-agnostic with consistent package versions (Sentry.AspNetCore v4.13.0)
  • The --offlineDb flag works across frameworks with proper EF Core package references
  • The --sample flag (Admin/Todo) is framework-independent with proper conditional compilation

The net9.0 framework includes additional features like:

  • Enhanced SignalR capabilities with StatefulReconnects
  • Improved color mode support for Windows apps
  • Static SSR pages support in Blazor apps
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for framework version constraints in the template configuration

# Look for framework version constraints in the template
rg -A 5 "net[89]\.0" "src/Templates/Boilerplate/Bit.Boilerplate"

# Look for feature flag definitions and their version requirements
rg -A 5 "(signalR|sentry|offlineDb|sample)" "src/Templates/Boilerplate/Bit.Boilerplate"

Length of output: 68272


157-161: Verify Azure service dependencies

The changes add Azure-specific features that may have dependencies:

  1. --appInsights with Local storage: Ensure Application Insights configuration is properly generated
  2. Azure Blob storage with net9.0: Verify compatibility of Azure SDK with this preview version

Run the following script to check for Azure-related dependencies and configurations:

✅ Verification successful

Based on the output, I can now generate the final response since I have sufficient information about the Azure service dependencies and configurations:

Azure service dependencies are properly configured

The codebase has appropriate configurations and dependencies for all Azure-specific features:

  • Application Insights:

    • Proper NuGet packages are included conditionally (Microsoft.ApplicationInsights.AspNetCore, BlazorApplicationInsights)
    • Configuration sections exist in appsettings.json for connection strings and logging
    • Telemetry initializers and services are properly registered
  • Azure Blob Storage:

    • FluentStorage.Azure.Blobs package is included conditionally
    • Configuration exists for blob storage SAS URL with emulator support
    • IBlobStorage service is properly registered with both emulator and production configurations
  • reCAPTCHA:

    • Integration is properly configured with site keys and secret keys
    • Client and server-side validation is implemented
    • Proper error handling and localization support exists

The use of net9.0 with Azure Blob Storage is safe as the storage SDK (FluentStorage.Azure.Blobs v5.3.0) is framework-agnostic and compatible with both net8.0 and net9.0.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for Azure service configurations and dependencies

# Look for Azure service configurations
rg -A 5 "(ApplicationInsights|BlobStorage|reCaptcha)" "src/Templates/Boilerplate/Bit.Boilerplate"

# Check for Azure SDK package references
fd -e csproj -x grep -l "Azure" {} \; -x cat {}

Length of output: 76360

@yasmoradi yasmoradi changed the title Remove unused codes from Boilerplate (#9489) Remove unused codes from repository (#9489) Dec 15, 2024
@msynk msynk merged commit 5faa892 into bitfoundation:develop Dec 15, 2024
@yasmoradi yasmoradi deleted the 9489-boilerplate-project-template-un-used-codes branch December 15, 2024 15:29
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.

Repository contains un-used codes

2 participants