Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented May 18, 2025

Link issues

fixes #6035

Summary By Copilot

This pull request introduces a new ShowSwal parameter to the Select<TValue> component, allowing developers to control whether a Swal confirmation popup is displayed during item selection. Additionally, associated localization strings have been added, and the project version has been updated.

Feature Addition: ShowSwal Parameter

Localization Updates

Code Example Updates

Project Version Update

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

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

Add a ShowSwal parameter to the Select component for optional display of confirmation popups, update related sample metadata and localization, and bump the project version.

New Features:

  • Introduce ShowSwal parameter to Select component to toggle Swal confirmation popup

Enhancements:

  • Update item click handler to respect ShowSwal setting
  • Add ShowSwal attribute to sample component metadata

Build:

  • Bump project version to 9.6.4-beta03

Documentation:

  • Add localization strings for ShowSwal parameter in English and Chinese

@ArgoZhang ArgoZhang requested a review from Copilot May 18, 2025 06:23
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented May 18, 2025

Reviewer's Guide

Adds a configurable ShowSwal flag to the Select component to control confirmation popups, updates sample attributes and localization entries for the new parameter, and bumps the project version.

Sequence diagram for the OnClickItem interaction with ShowSwal

sequenceDiagram
    participant User
    participant SelectComponent as Select<TValue>
    participant SwalService

    User->>SelectComponent: Clicks on an item
    SelectComponent->>SelectComponent: OnClickItem(item)
    alt OnBeforeSelectedItemChange is not null
        SelectComponent->>+OnBeforeSelectedItemChange: Call(item)
        OnBeforeSelectedItemChange-->>-SelectComponent: Return confirmationRequired (true/false)
        alt confirmationRequired is true AND ShowSwal is true
            SelectComponent->>+SwalService: ShowModal(option)
            SwalService-->>-SelectComponent: Return userConfirmed (true/false)
            alt userConfirmed is true
                SelectComponent->>SelectComponent: Update SelectedValue
                SelectComponent->>SelectComponent: Invoke OnSelectedItemChanged
            end
        else confirmationRequired is true AND ShowSwal is false
            SelectComponent->>SelectComponent: Update SelectedValue
            SelectComponent->>SelectComponent: Invoke OnSelectedItemChanged
        else confirmationRequired is false
            SelectComponent->>SelectComponent: Do nothing further
        end
    else OnBeforeSelectedItemChange is null
        SelectComponent->>SelectComponent: Update SelectedValue
        SelectComponent->>SelectComponent: Invoke OnSelectedItemChanged
    end
Loading

Updated class diagram for the Select component

classDiagram
class Select_TValue_ {
    +bool ShowSwal
    +Func<SelectedItem, Task<bool>> OnBeforeSelectedItemChange
    +Task OnClickItem(SelectedItem item)
}
Loading

File-Level Changes

Change Details Files
Introduce ShowSwal parameter and integrate into selection logic
  • Add new [Parameter] ShowSwal with default true
  • Modify OnClickItem to only invoke Swal when ShowSwal is true
  • Remove redundant early return branch in selection flow
src/BootstrapBlazor/Components/Select/Select.razor.cs
Expose ShowSwal in sample component metadata
  • Append ShowSwal entry in GetAttributes with name, description, type, value list, and default
src/BootstrapBlazor.Server/Components/Samples/Selects.razor.cs
Add localization strings for ShowSwal
  • Define SelectsShowSwal key in en-US.json
  • Add corresponding Chinese entry in zh-CN.json
src/BootstrapBlazor.Server/Locales/en-US.json
src/BootstrapBlazor.Server/Locales/zh-CN.json
Update project version
  • Increment version from 9.6.4-beta02 to 9.6.4-beta03
src/BootstrapBlazor/BootstrapBlazor.csproj

Assessment against linked issues

Issue Objective Addressed Explanation
#6035 Allow developers to customize the content and appearance of the confirmation popup displayed during item selection in the Select component. The PR introduces a ShowSwal parameter to control whether the Swal popup is displayed, but it does not allow customization of the popup's content or appearance. The original issue requested a way to dynamically change the popup content based on the selected value.

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. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the 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 exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

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 May 18, 2025
@bb-auto bb-auto bot added this to the v9.6.0 milestone May 18, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new ShowSwal toggle for the Select<TValue> component, letting consumers disable the Swal confirmation popup, and updates related localization, samples, and versioning.

  • Added ShowSwal parameter and adjusted the OnClickItem logic.
  • Added SelectsShowSwal entries in both en-US and zh-CN locales.
  • Updated the sample attribute list and bumped the project version.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/BootstrapBlazor/Components/Select/Select.razor.cs Added ShowSwal parameter and updated click logic
src/BootstrapBlazor.Server/Locales/zh-CN.json Added Chinese translation for SelectsShowSwal
src/BootstrapBlazor.Server/Locales/en-US.json Added English string for SelectsShowSwal
src/BootstrapBlazor.Server/Components/Samples/Selects.razor.cs Included ShowSwal in sample attribute list
src/BootstrapBlazor/BootstrapBlazor.csproj Bumped version to 9.6.4-beta03
Comments suppressed due to low confidence (2)

src/BootstrapBlazor.Server/Locales/en-US.json:3271

  • [nitpick] Consider changing this to "Whether to show the Swal confirmation popup" for grammatical correctness and consistent capitalization of "Swal".
"SelectsShowSwal": "Whether show the swal confirm popup"

src/BootstrapBlazor/Components/Select/Select.razor.cs:65

  • Add unit tests to verify that when ShowSwal is false, SwalService.ShowModal is not invoked, and that selection logic still proceeds correctly.
public bool ShowSwal { get; set; } = true;

@codecov
Copy link

codecov bot commented May 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (521f95a) to head (5013da4).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #6053   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          701       701           
  Lines        30957     30956    -1     
  Branches      4378      4378           
=========================================
- Hits         30957     30956    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

sourcery-ai[bot]
sourcery-ai bot previously approved these changes May 18, 2025
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 and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Testing: all looks good
  • 🟢 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 97bd421 into main May 18, 2025
3 checks passed
@ArgoZhang ArgoZhang deleted the refactor-select branch May 18, 2025 06:27
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(Select): 下拉变更前判断优化:自由决定弹框内容。

2 participants