Add missing new Icon parameters to BitFileUpload (#12209)#12210
Add missing new Icon parameters to BitFileUpload (#12209)#12210msynk wants to merge 2 commits intobitfoundation:developfrom
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughAdded custom icon rendering support to the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can use Trivy to scan for security misconfigurations and secrets in Infrastructure as Code files.Add a .trivyignore file to your project to customize which findings Trivy reports. |
There was a problem hiding this comment.
Pull request overview
Adds missing icon customization parameters to BitFileUpload so consumers can use either built-in Fluent UI icon names or external icon libraries via BitIconInfo, aligning this component with the newer “Icon/IconName” pattern used elsewhere in Bit.BlazorUI.
Changes:
- Introduces
UploadIcon/PauseIcon/CancelIcon/RemoveIcon(BitIconInfo?) and*IconName(string?) parameters onBitFileUpload. - Updates
_BitFileUploadItemto resolve and render the effective icons usingBitIconInfo.From(...). - Updates the demo page and adds basic tests covering the new parameters’ presence.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/BlazorUI/Bit.BlazorUI/Components/Inputs/FileUpload/BitFileUpload.razor.cs | Adds new Icon/IconName parameters for upload/pause/cancel/remove actions. |
| src/BlazorUI/Bit.BlazorUI/Components/Inputs/FileUpload/_BitFileUploadItem.razor | Uses BitIconInfo.From(...) to render the resolved action icons. |
| src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/FileUpload/BitFileUploadDemo.razor | Adds an “External Icons” demo example showing FontAwesome/Bootstrap usage. |
| src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/FileUpload/BitFileUploadDemo.razor.cs | Documents new parameters and adds sample code strings for external icon usage. |
| src/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Inputs/FileUpload/BitFileUploadTests.cs | Adds tests ensuring the new parameters are accepted by the component. |
src/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Inputs/FileUpload/BitFileUploadTests.cs
Outdated
Show resolved
Hide resolved
src/BlazorUI/Bit.BlazorUI/Components/Inputs/FileUpload/_BitFileUploadItem.razor
Show resolved
Hide resolved
src/BlazorUI/Bit.BlazorUI/Components/Inputs/FileUpload/_BitFileUploadItem.razor
Show resolved
Hide resolved
src/BlazorUI/Bit.BlazorUI/Components/Inputs/FileUpload/_BitFileUploadItem.razor
Show resolved
Hide resolved
src/BlazorUI/Bit.BlazorUI/Components/Inputs/FileUpload/_BitFileUploadItem.razor
Show resolved
Hide resolved
src/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Inputs/FileUpload/BitFileUploadTests.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/FileUpload/BitFileUploadDemo.razor (1)
176-176: Consider moving CDN links to the page head or a shared location.Placing
<link>elements inline within the demo content means they may be loaded multiple times if the component re-renders, and they're not in the conventional<head>location. Consider documenting that users should add these links to theirindex.htmlor_Host.cshtmlinstead, or use a component that ensures single registration.Also applies to: 196-196
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/FileUpload/BitFileUploadDemo.razor` at line 176, The BitFileUploadDemo.razor currently injects a Font Awesome CDN <link> inline which can be duplicated on re-render and is not in the document head; update the demo so the CDN stylesheet is referenced from a shared location instead—either add a note in the BitFileUploadDemo (or its README) instructing users to include the Font Awesome <link> in index.html/_Host.cshtml, or implement a single-registration helper component (e.g., a HeadLinkRegistrar used by BitFileUploadDemo) that ensures the stylesheet is only added once to the document head rather than rendering the <link> directly in the component markup.src/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Inputs/FileUpload/BitFileUploadTests.cs (1)
81-223: Tests verify parameter acceptance but not rendered output.These tests confirm that the component accepts the new icon parameters without throwing, but they don't verify that the icons are actually rendered with the correct CSS classes. Consider adding assertions that check for the presence of the icon element with the expected CSS class in the rendered markup.
For example:
[TestMethod] public void BitFileUploadShouldRenderUploadIconWithCustomCssClass() { var com = RenderComponent<BitFileUpload>(parameters => { parameters.Add(p => p.UploadIcon, BitIconInfo.Css("fa-solid fa-upload")); // Add file to trigger icon rendering }); var icon = com.Find(".fa-solid.fa-upload"); Assert.IsNotNull(icon); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Inputs/FileUpload/BitFileUploadTests.cs` around lines 81 - 223, The tests currently named like BitFileUploadShouldAcceptUploadIconParameter, BitFileUploadShouldAcceptPauseIconParameter, BitFileUploadShouldAcceptCancelIconParameter, BitFileUploadShouldAcceptRemoveIconParameter (and the *Name/*BitInfo variants) only verify parameters don't throw — update each to also assert the rendered icon element appears by: set the appropriate parameter (e.g., UploadIcon / PauseIcon / CancelIcon / RemoveIcon or the *Name versions), ensure any preconditions that make the icon render (simulate adding a file or toggling the upload state if required by BitFileUpload), and then use com.Find with the expected CSS selector (e.g., ".fa-solid.fa-upload", ".fa-solid.fa-pause", ".fa-solid.fa-xmark", ".fa-solid.fa-trash" or the equivalent classes for BitIconInfo.Bi/Fa) and Assert.IsNotNull on the result so the test verifies actual DOM output.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/FileUpload/BitFileUploadDemo.razor`:
- Line 176: The BitFileUploadDemo.razor currently injects a Font Awesome CDN
<link> inline which can be duplicated on re-render and is not in the document
head; update the demo so the CDN stylesheet is referenced from a shared location
instead—either add a note in the BitFileUploadDemo (or its README) instructing
users to include the Font Awesome <link> in index.html/_Host.cshtml, or
implement a single-registration helper component (e.g., a HeadLinkRegistrar used
by BitFileUploadDemo) that ensures the stylesheet is only added once to the
document head rather than rendering the <link> directly in the component markup.
In
`@src/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Inputs/FileUpload/BitFileUploadTests.cs`:
- Around line 81-223: The tests currently named like
BitFileUploadShouldAcceptUploadIconParameter,
BitFileUploadShouldAcceptPauseIconParameter,
BitFileUploadShouldAcceptCancelIconParameter,
BitFileUploadShouldAcceptRemoveIconParameter (and the *Name/*BitInfo variants)
only verify parameters don't throw — update each to also assert the rendered
icon element appears by: set the appropriate parameter (e.g., UploadIcon /
PauseIcon / CancelIcon / RemoveIcon or the *Name versions), ensure any
preconditions that make the icon render (simulate adding a file or toggling the
upload state if required by BitFileUpload), and then use com.Find with the
expected CSS selector (e.g., ".fa-solid.fa-upload", ".fa-solid.fa-pause",
".fa-solid.fa-xmark", ".fa-solid.fa-trash" or the equivalent classes for
BitIconInfo.Bi/Fa) and Assert.IsNotNull on the result so the test verifies
actual DOM output.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 6ad8c7e6-9e9e-43c6-a1af-525a69f0d0d0
📒 Files selected for processing (5)
src/BlazorUI/Bit.BlazorUI/Components/Inputs/FileUpload/BitFileUpload.razor.cssrc/BlazorUI/Bit.BlazorUI/Components/Inputs/FileUpload/_BitFileUploadItem.razorsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/FileUpload/BitFileUploadDemo.razorsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/FileUpload/BitFileUploadDemo.razor.cssrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Inputs/FileUpload/BitFileUploadTests.cs
closes #12209
Summary by CodeRabbit