feat(InputUpload ): 增加删除前确认属性ShowDeleteConfirmButton#8028
Conversation
feat(InputUpload ): 增加删除前确认属性ShowDeleteConfirmButton
|
Thanks for your PR, @Tony-ST0754. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
Reviewer's GuideAdds an optional delete-confirmation workflow to the InputUpload component by introducing a ShowDeleteConfirmButton flag and associated PopConfirmButton configuration parameters, while preserving existing delete behavior when the flag is disabled. Sequence diagram for InputUpload delete with optional confirmationsequenceDiagram
actor User
participant InputUpload
participant PopConfirmButton
participant Button
participant TriggerDeleteFile
User->>InputUpload: click delete
alt [ShowDeleteButton && ShowDeleteConfirmButton]
InputUpload->>PopConfirmButton: render PopConfirmButton
User->>PopConfirmButton: click confirm
PopConfirmButton->>TriggerDeleteFile: OnConfirm async ()=>TriggerDeleteFile()
else [ShowDeleteButton && !ShowDeleteConfirmButton]
InputUpload->>Button: render Button
User->>Button: click
Button->>TriggerDeleteFile: OnClick TriggerDeleteFile
end
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 2 issues, and left some high level feedback:
- In the PopConfirmButton usage,
ConfirmButtonColor="DeleteConfirmButtonColor"is missing the@prefix, so it will not bind to the component parameter and instead pass a literal string; this should beConfirmButtonColor="@DeleteConfirmButtonColor"to work as intended. - Since
TriggerDeleteFileis already asynchronous (as implied by theawaitandIsAsync="true"), you can simplifyOnConfirm="@(async () => await TriggerDeleteFile())"toOnConfirm="TriggerDeleteFile"for cleaner markup and to avoid an extra async lambda allocation.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In the PopConfirmButton usage, `ConfirmButtonColor="DeleteConfirmButtonColor"` is missing the `@` prefix, so it will not bind to the component parameter and instead pass a literal string; this should be `ConfirmButtonColor="@DeleteConfirmButtonColor"` to work as intended.
- Since `TriggerDeleteFile` is already asynchronous (as implied by the `await` and `IsAsync="true"`), you can simplify `OnConfirm="@(async () => await TriggerDeleteFile())"` to `OnConfirm="TriggerDeleteFile"` for cleaner markup and to avoid an extra async lambda allocation.
## Individual Comments
### Comment 1
<location path="src/BootstrapBlazor/Components/Upload/InputUpload.razor" line_range="19" />
<code_context>
+ {
+ <PopConfirmButton Placement="Placement.Top" class="@RemoveButtonClassString"
+ ConfirmIcon="@DeleteConfirmButtonIcon"
+ ConfirmButtonColor="DeleteConfirmButtonColor"
+ ConfirmButtonText="@DeleteConfirmButtonText"
+ CloseButtonText="@DeleteCloseButtonText"
</code_context>
<issue_to_address>
**issue (bug_risk):** Bind `ConfirmButtonColor` as a parameter instead of passing the literal string.
Using `ConfirmButtonColor="DeleteConfirmButtonColor"` passes the string value, not the `DeleteConfirmButtonColor` parameter. To bind the parameter, use `ConfirmButtonColor="@DeleteConfirmButtonColor"`.
</issue_to_address>
### Comment 2
<location path="test/UnitTest/Components/UploadInputTest.cs" line_range="101-105" />
<code_context>
+ pb.Add(a => a.DeleteCloseButtonText, "cancel");
+ });
+
+ var button = cut.FindComponent<PopConfirmButton>();
+ Assert.NotNull(button);
+ Assert.NotNull(button.Instance.OnConfirm);
+
+ await cut.InvokeAsync(button.Instance.OnConfirm);
+ }
+
</code_context>
<issue_to_address>
**issue (testing):** Assert the actual delete behavior after invoking OnConfirm, not just the presence of the PopConfirmButton.
This test only checks that `PopConfirmButton` renders and `OnConfirm` is set, but not the effect of triggering it. After invoking `OnConfirm`, please assert that the delete behavior actually occurred (e.g., the file/filename is no longer rendered, and any delete callback or bound value change was invoked as expected). Otherwise the test may still pass even if the delete logic stops working.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| var button = cut.FindComponent<PopConfirmButton>(); | ||
| Assert.NotNull(button); | ||
| Assert.NotNull(button.Instance.OnConfirm); | ||
|
|
||
| await cut.InvokeAsync(button.Instance.OnConfirm); |
There was a problem hiding this comment.
issue (testing): Assert the actual delete behavior after invoking OnConfirm, not just the presence of the PopConfirmButton.
This test only checks that PopConfirmButton renders and OnConfirm is set, but not the effect of triggering it. After invoking OnConfirm, please assert that the delete behavior actually occurred (e.g., the file/filename is no longer rendered, and any delete callback or bound value change was invoked as expected). Otherwise the test may still pass even if the delete logic stops working.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8028 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 766 766
Lines 34122 34134 +12
Branches 4692 4693 +1
=========================================
+ Hits 34122 34134 +12
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:
|
Signed-off-by: Tony-ST0754 <6914529@qq.com>
feat(InputUpload ): 增加删除前确认属性ShowDeleteConfirmButton
Link issues
fixes #8027
问题描述 / Problem Description
InputUpload组件目前删除时,没有提示是否确认删除,会直接执行删除回调代码,通过新增ShowDeleteConfirmButton后控制在删除前给予确认提示?(原则上,任何删除前必须给予用户确认交互,以防止误点删除)解决方案 / Solution
新增
ShowDeleteConfirmButton给予用户确认交互,该属性依赖于ShowDeleteButton属性,当ShowDeleteButton属性为true时ShowDeleteConfirmButton属性才会生交影响范围 / Impact
对老版本用户无任何影响
Summary by Sourcery
Add optional delete confirmation support to the InputUpload component to prevent accidental file removal.
New Features:
Tests: