Skip to content

feat(CardUpload): add ShowConfirmButton parameter#7474

Merged
ArgoZhang merged 6 commits intodotnetcore:mainfrom
Tony-ST0754:tony
Jan 7, 2026
Merged

feat(CardUpload): add ShowConfirmButton parameter#7474
ArgoZhang merged 6 commits intodotnetcore:mainfrom
Tony-ST0754:tony

Conversation

@Tony-ST0754
Copy link
Copy Markdown
Collaborator

@Tony-ST0754 Tony-ST0754 commented Jan 7, 2026

cardupload增加删除确认属性

Link issues

fixes #7477

Summary By Copilot

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 an option for CardUpload to require a confirmation dialog before deleting files and demonstrate its usage in the upload cards sample.

New Features:

  • Introduce a ShowDeleteConfirmButton parameter to display a confirmation dialog before deleting files in CardUpload components.

Enhancements:

  • Update the UploadCards sample page and backing class to expose and default-enable the delete confirmation toggle for CardUpload.

cardupload增加删除确认属性
@bb-auto
Copy link
Copy Markdown

bb-auto Bot commented Jan 7, 2026

Thanks for your PR, @Tony-ST0754. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Jan 7, 2026

Reviewer's Guide

Adds an optional delete-confirmation behavior to CardUpload file deletion, wires it through the shared upload base component, and exposes a toggle for it in the UploadCards demo/sample page.

Sequence diagram for CardUpload deletion with optional confirmation

sequenceDiagram
    actor User
    participant UploadCards
    participant CardUpload_TValue_ as CardUpload
    participant PopConfirmButton

    User->>UploadCards: toggle _showDeleteConfirmButton
    UploadCards->>CardUpload: ShowDeleteConfirmButton = _showDeleteConfirmButton

    alt ShowDeleteConfirmButton is true
        User->>PopConfirmButton: click delete icon
        PopConfirmButton-->>User: show confirmation dialog
        User->>PopConfirmButton: confirm
        PopConfirmButton->>CardUpload: OnConfirm()
        CardUpload->>CardUpload: OnCardFileDelete(item)
    else ShowDeleteConfirmButton is false
        User->>CardUpload: click delete button
        CardUpload->>CardUpload: OnCardFileDelete(item)
    end
Loading

Class diagram for updated upload components with ShowDeleteConfirmButton

classDiagram
    class UploadBase_TValue_ {
    }

    class FileListUploadBase_TValue_ {
        +bool ShowDeleteButton
        +bool ShowDeleteConfirmButton
        +string RemoveIcon
    }

    class CardUpload_TValue_ {
        +bool ShowDeleteButton
        +bool ShowDeleteConfirmButton
        +Task OnCardFileDelete(UploadFile item)
        +bool GetDeleteButtonDisabledString(UploadFile item)
        +bool GetShowProgress(UploadFile item)
    }

    class UploadCards {
        -bool _showProgress
        -bool _showZoomButton
        -bool _showDeleteButton
        -bool _showDeleteConfirmButton
        -bool _showDownloadButton
    }

    class PopConfirmButton {
        +Placement Placement
        +Color Color
        +string ConfirmIcon
        +Color ConfirmButtonColor
        +string Content
        +string Icon
        +bool IsAsync
        +Task OnConfirm()
    }

    UploadBase_TValue_ <|-- FileListUploadBase_TValue_
    FileListUploadBase_TValue_ <|-- CardUpload_TValue_

    UploadCards --> CardUpload_TValue_ : configures
    CardUpload_TValue_ --> PopConfirmButton : uses when ShowDeleteConfirmButton

    class UploadFile {
    }

    class Placement {
    }

    class Color {
    }
Loading

File-Level Changes

Change Details Files
Add optional delete-confirmation button behavior to CardUpload component.
  • Wrap delete button rendering in a conditional on new ShowDeleteConfirmButton parameter.
  • Render a PopConfirmButton with danger styling, confirmation icon, text, and async OnConfirm handler when confirmation is enabled.
  • Fallback to existing plain delete button behavior when confirmation is disabled.
src/BootstrapBlazor/Components/Upload/CardUpload.razor
Plumb new ShowDeleteConfirmButton parameter through upload base class and sample demo.
  • Introduce ShowDeleteConfirmButton boolean parameter on FileListUploadBase with XML documentation.
  • Add backing field _showDeleteConfirmButton to UploadCards sample code-behind and default it to true.
  • Bind new _showDeleteConfirmButton switch in UploadCards sample UI and pass it to CardUpload via ShowDeleteConfirmButton attribute.
src/BootstrapBlazor/Components/Upload/FileListUploadBase.cs
src/BootstrapBlazor.Server/Components/Samples/UploadCards.razor
src/BootstrapBlazor.Server/Components/Samples/UploadCards.razor.cs

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 requested a review from ArgoZhang January 7, 2026 02:25
Copy link
Copy Markdown
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 - I've found 2 issues, and left some high level feedback:

  • Consider making the PopConfirmButton Content text localizable (or at least configurable via a parameter) instead of hard-coding "确定删除数据吗?" so it can be reused in non-Chinese environments.
  • The delete icon used in PopConfirmButton is hard-coded (fa-regular fa-trash-can) instead of reusing the existing RemoveIcon parameter; aligning these would keep icon behavior consistent between the confirm and non-confirm delete buttons.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider making the PopConfirmButton `Content` text localizable (or at least configurable via a parameter) instead of hard-coding `"确定删除数据吗?"` so it can be reused in non-Chinese environments.
- The delete icon used in `PopConfirmButton` is hard-coded (`fa-regular fa-trash-can`) instead of reusing the existing `RemoveIcon` parameter; aligning these would keep icon behavior consistent between the confirm and non-confirm delete buttons.

## Individual Comments

### Comment 1
<location> `src/BootstrapBlazor/Components/Upload/CardUpload.razor:70-79` </location>
<code_context>
-                                @onclick="() => OnCardFileDelete(item)">
-                            <i class="@RemoveIcon"></i>
-                        </button>
+                        @if (ShowDeleteConfirmButton)
+                        {
+                            <PopConfirmButton Placement="Placement.Top"
+                                              Color="Color.Danger"
+                                              ConfirmIcon="fa-solid fa-triangle-exclamation text-danger"
+                                              ConfirmButtonColor="Color.Danger"
+                                              Content="确定删除数据吗?"
+                                              Icon="fa-regular fa-trash-can"
+                                              IsAsync="true"
+                                              OnConfirm="@(async()=>await OnCardFileDelete(item))"/>
+                        }
+                        else
</code_context>

<issue_to_address>
**issue (bug_risk):** The confirm-button path drops the existing disabled logic on delete, which may regress UX/behavior.

In the non-confirm path, the delete button is bound to `GetDeleteButtonDisabledString(item)` so it can be disabled (e.g., during uploads or particular states). The new `PopConfirmButton` path has no equivalent disabled/`IsDisabled` binding, so users can still open the confirm dialog when the old button would have been disabled. Please pass through the same condition to `PopConfirmButton` (or otherwise share the enable/disable logic) to keep behavior consistent.
</issue_to_address>

### Comment 2
<location> `src/BootstrapBlazor/Components/Upload/CardUpload.razor:76` </location>
<code_context>
+                                              Color="Color.Danger"
+                                              ConfirmIcon="fa-solid fa-triangle-exclamation text-danger"
+                                              ConfirmButtonColor="Color.Danger"
+                                              Content="确定删除数据吗?"
+                                              Icon="fa-regular fa-trash-can"
+                                              IsAsync="true"
</code_context>

<issue_to_address>
**suggestion:** The confirmation text is hard-coded in Chinese, which may conflict with localization/globalization of the component.

Since this is part of the main library, a hard-coded Chinese `Content` string makes the component harder to reuse and localize. Please either expose this text as a parameter (e.g., `DeleteConfirmMessage`) for callers to supply localized content, or hook into whatever localization mechanism the rest of the library uses.

Suggested implementation:

```
                                              Content="@DeleteConfirmMessage"

```

In the backing class for `CardUpload` (either in `CardUpload.razor`’s `@code` block or in `CardUpload.razor.cs` if it’s a partial class), add a public parameter to expose the message:

- If using `@code` in `CardUpload.razor`:
  ```csharp
  @code {
      [Parameter]
      public string DeleteConfirmMessage { get; set; } = "确定删除数据吗?";

      // existing members...
  }
  ```

- If using a code-behind partial class (`CardUpload.razor.cs`):
  ```csharp
  public partial class CardUpload
  {
      [Parameter]
      public string DeleteConfirmMessage { get; set; } = "确定删除数据吗?";

      // existing members...
  }
  ```

If the library already has a localization mechanism (e.g., `IStringLocalizer` or a custom localization service), you should replace the hard-coded default `"确定删除数据吗?"` with a localized resource lookup, for example:
```csharp
public string DeleteConfirmMessage { get; set; }

protected override void OnInitialized()
{
    base.OnInitialized();
    DeleteConfirmMessage ??= Localizer["DeleteConfirmMessage"];
}
```
adjusting `Localizer` and the resource key to match your existing localization conventions.
</issue_to_address>

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.

Comment thread src/BootstrapBlazor/Components/Upload/CardUpload.razor Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (7099573) to head (225e9aa).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #7474   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          749       749           
  Lines        32922     32936   +14     
  Branches      4574      4576    +2     
=========================================
+ Hits         32922     32936   +14     
Flag Coverage Δ
BB 100.00% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ArgoZhang ArgoZhang changed the title cardupload增加删除确认属性 feat(CardUpload): add ShowConfirmButton parameter Jan 7, 2026
@bb-auto bb-auto Bot added the enhancement New feature or request label Jan 7, 2026
@bb-auto bb-auto Bot added this to the v10.2.0 milestone Jan 7, 2026
@ArgoZhang ArgoZhang merged commit b74ab70 into dotnetcore:main Jan 7, 2026
3 of 4 checks passed
@Tony-ST0754 Tony-ST0754 deleted the tony branch January 16, 2026 04:57
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(CardUpload): add ShowConfirmButton parameter

2 participants