fix(ButtonUpload): add ShowDeleteButton parameter#7590
Conversation
Reviewer's GuideAdds a configurable ShowDeleteButton parameter to upload components and wires it through to the shared UploadPreviewList so consumers can toggle visibility of the per-file delete action across ButtonUpload, CardUpload, and DropUpload. Class diagram for ShowDeleteButton in upload componentsclassDiagram
direction LR
class UploadBase_TValue_ {
}
class FileListUploadBase_TValue_ {
}
class ButtonUpload_TValue_ {
+bool ShowDeleteButton
}
class CardUpload_TValue_ {
+bool ShowDeleteButton
}
class DropUpload {
+bool ShowDeleteButton
}
class UploadPreviewList {
+bool ShowDownloadButton
+bool ShowDeleteButton
}
UploadBase_TValue_ <|-- FileListUploadBase_TValue_
FileListUploadBase_TValue_ <|-- ButtonUpload_TValue_
FileListUploadBase_TValue_ <|-- CardUpload_TValue_
ButtonUpload_TValue_ --> UploadPreviewList : passes_ShowDeleteButton
DropUpload --> UploadPreviewList : passes_ShowDeleteButton
CardUpload_TValue_ --> UploadPreviewList : uses_internally_for_delete
Flow diagram for ShowDeleteButton propagation to UploadPreviewListflowchart LR
A[Parent component sets ShowDeleteButton on ButtonUpload or DropUpload] --> B[ButtonUpload_TValue_ or DropUpload receives ShowDeleteButton parameter]
B --> C[ButtonUpload_TValue_ or DropUpload renders UploadPreviewList]
C --> D[ShowDeleteButton parameter is forwarded to UploadPreviewList]
D --> E[UploadPreviewList evaluates ShowDeleteButton]
E -->|ShowDeleteButton == true| F[Render delete icon with OnFileDelete handler]
E -->|ShowDeleteButton == false| G[Do not render delete icon]
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The new
ShowDeleteButtonparameter onCardUpload<TValue>is never passed through toUploadPreviewListinCardUpload.razor, so setting it onCardUploadcurrently has no effect; consider bindingShowDeleteButtonon the preview list as done forButtonUploadandDropUpload. - With
ShowDeleteButtonnow defined on multiple upload components, consider centralizing this parameter (e.g., in a shared base class or interface) to avoid duplication and keep behavior consistent across the different upload variants.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `ShowDeleteButton` parameter on `CardUpload<TValue>` is never passed through to `UploadPreviewList` in `CardUpload.razor`, so setting it on `CardUpload` currently has no effect; consider binding `ShowDeleteButton` on the preview list as done for `ButtonUpload` and `DropUpload`.
- With `ShowDeleteButton` now defined on multiple upload components, consider centralizing this parameter (e.g., in a shared base class or interface) to avoid duplication and keep behavior consistent across the different upload variants.
## Individual Comments
### Comment 1
<location> `src/BootstrapBlazor/Components/Upload/UploadPreviewList.razor.cs:99-104` </location>
<code_context>
/// </summary>
public partial class ButtonUpload<TValue>
{
+ /// <summary>
+ /// <para lang="zh">获得/设置 是否显示删除按钮,默认 true</para>
+ /// <para lang="en">Gets or sets whether to display the delete button. Default is true</para>
</code_context>
<issue_to_address>
**question:** The effective default for ShowDeleteButton differs between UploadPreviewList and the higher-level upload components; is that divergence intentional?
Here it defaults to `false` via the CLR default, matching the XML docs, while `ButtonUpload` and `DropUpload` now set `ShowDeleteButton { get; set; } = true;` and pass that through. So `UploadPreviewList` used directly hides delete by default, but via `ButtonUpload`/`DropUpload` it shows delete by default. Please either align these defaults or, if the difference is intentional, ensure the public API docs clearly describe the distinct behaviors.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7590 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 749 749
Lines 32982 32988 +6
Branches 4577 4578 +1
=========================================
+ Hits 32982 32988 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #7587 where the ShowDeleteButton parameter in ButtonUpload component was not working. The delete button was always displayed in UploadPreviewList regardless of the parameter value.
Changes:
- Added conditional rendering for the delete button in UploadPreviewList based on ShowDeleteButton parameter
- Moved ShowDeleteButton parameter from FileListUploadBase to individual upload components (ButtonUpload, DropUpload, CardUpload) for better control
- Set default value to true for ButtonUpload and DropUpload to maintain backward compatibility with existing buggy behavior (button always showed)
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/BootstrapBlazor/Components/Upload/UploadPreviewList.razor.cs | Added ShowDeleteButton parameter (default false) to control delete button visibility |
| src/BootstrapBlazor/Components/Upload/UploadPreviewList.razor | Wrapped delete button rendering in conditional check using ShowDeleteButton parameter |
| src/BootstrapBlazor/Components/Upload/FileListUploadBase.cs | Removed ShowDeleteButton parameter from base class to allow individual components to define their own defaults |
| src/BootstrapBlazor/Components/Upload/DropUpload.razor.cs | Added ShowDeleteButton parameter with default true for backward compatibility |
| src/BootstrapBlazor/Components/Upload/DropUpload.razor | Passed ShowDeleteButton parameter to UploadPreviewList component |
| src/BootstrapBlazor/Components/Upload/CardUpload.razor.cs | Added ShowDeleteButton parameter with default false (CardUpload has its own delete button implementation) |
| src/BootstrapBlazor/Components/Upload/CardUpload.razor | Minor whitespace cleanup |
| src/BootstrapBlazor/Components/Upload/ButtonUpload.razor.cs | Added ShowDeleteButton parameter with default true for backward compatibility |
| src/BootstrapBlazor/Components/Upload/ButtonUpload.razor | Passed ShowDeleteButton parameter to UploadPreviewList component |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Link issues
fixes #7587
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Add configurable delete button visibility to upload components and centralize its handling in the preview list.
New Features:
Enhancements: