Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Oct 29, 2024

redesign AjaxService

Summary of the changes (Less than 80 chars)

简单描述你更改了什么, 不超过80个字符;如果有关联 Issue 请在下方填写相关编号

Description

fixes #4569

Regression?

  • Yes
  • No

[If yes, specify the version the behavior has regressed from]

[是否影响老版本]

Risk

  • High
  • Medium
  • Low

[Justify the selection above]

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Redesign the AjaxService by introducing a new class to manage Ajax requests and page navigation, removing the Ajax component from the BootstrapBlazorRoot, and adding a test case for the new Goto method.

New Features:

  • Introduce a new AjaxService class to handle Ajax requests and page navigation.

Enhancements:

  • Remove the Ajax component from the BootstrapBlazorRoot component rendering.

Tests:

  • Add a new test case for the Goto method in the AjaxService.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Oct 29, 2024

Reviewer's Guide by Sourcery

The PR redesigns the AjaxService by moving it from a component-based implementation to a dedicated service class. The new implementation uses JS module loading for Ajax functionality and removes the need for a separate Ajax component.

Sequence diagram for AjaxService InvokeAsync method

sequenceDiagram
    participant Client
    participant AjaxService
    participant JSModule
    Client->>AjaxService: InvokeAsync(option, token)
    AjaxService->>JSModule: LoadModule()
    JSModule-->>AjaxService: JSModule instance
    AjaxService->>JSModule: InvokeAsync("execute", token, option)
    JSModule-->>AjaxService: JsonDocument?
    AjaxService-->>Client: JsonDocument?
Loading

Sequence diagram for AjaxService Goto method

sequenceDiagram
    participant Client
    participant AjaxService
    participant JSModule
    Client->>AjaxService: Goto(url, token)
    AjaxService->>JSModule: LoadModule()
    JSModule-->>AjaxService: JSModule instance
    AjaxService->>JSModule: InvokeVoidAsync("goto", token, url)
    JSModule-->>AjaxService: void
Loading

Class diagram for redesigned AjaxService

classDiagram
    class AjaxService {
        +Task<JSModule> LoadModule()
        +Task<JsonDocument?> InvokeAsync(AjaxOption option, CancellationToken token)
        +Task Goto(string url, CancellationToken token)
        -JSModule _module
    }
    class JSModule {
        +Task<T> InvokeAsync<T>(string method, CancellationToken token, params object[] args)
        +Task InvokeVoidAsync(string method, CancellationToken token, params object[] args)
    }
Loading

File-Level Changes

Change Details Files
Migrate Ajax functionality from component-based to service-based architecture
  • Create new AjaxService class with IJSRuntime dependency injection
  • Implement JS module loading mechanism for Ajax operations
  • Add InvokeAsync method for making Ajax requests
  • Add Goto method for page navigation
  • Remove old component-based Ajax implementation
src/BootstrapBlazor/Services/AjaxService.cs
src/BootstrapBlazor/Components/Ajax/AjaxService.cs
src/BootstrapBlazor/Components/Ajax/Ajax.cs
Update component registration and test cases
  • Remove Ajax component registration from BootstrapBlazorRoot
  • Split Ajax test cases into separate methods
  • Add dedicated test for Goto functionality
src/BootstrapBlazor/Components/BaseComponents/BootstrapBlazorRoot.razor.cs
test/UnitTest/Components/AjaxTest.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#4569 Redesign the AjaxService component

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@bb-auto bb-auto bot added the enhancement New feature or request label Oct 29, 2024
@bb-auto bb-auto bot added this to the v9.0.0 milestone Oct 29, 2024
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @ArgoZhang - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Please complete the PR template with a proper risk assessment and verification steps, as this appears to be a significant architectural change to the Ajax functionality.
Here's what I looked at during the review
  • 🟡 General issues: 3 issues found
  • 🟢 Security: all looks good
  • 🟡 Testing: 3 issues found
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@ArgoZhang ArgoZhang merged commit f384e6c into main Oct 29, 2024
2 of 3 checks passed
@ArgoZhang ArgoZhang deleted the refactor-ajax branch October 29, 2024 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(AjaxService): redesign AjaxService

2 participants