refactor(Table): add RenderLoader method reuse code snippet#7860
refactor(Table): add RenderLoader method reuse code snippet#7860
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideRefactors the Table component’s loading UI by extracting the duplicated loading markup into a reusable RenderLoader RenderFragment, and then using this helper in the two call sites that display spinners while data is loading. Class diagram for refactored Table loading UIclassDiagram
class Table {
+RenderFragment LoadingTemplate
+bool ShowLoadingInFirstRender
+RenderFragment RenderPagination
+RenderFragment RenderRowContent
+RenderFragment ValidateForm
+RenderFragment~string~ RenderLoader(cssString)
}
class Spinner {
+Color Color
}
class Color {
<<enumeration>>
Primary
}
Table ..> Spinner : uses
Table ..> RenderFragment : defines
Spinner ..> Color : uses
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 left some high level feedback:
- Consider replacing the
RenderLoaderparameter from a plainstringto a more specific type or constants (e.g., an enum or named constants for"table-loading"/"table-loader") to avoid stringly-typed CSS class values scattered through the markup. - For consistency and readability, you might want to define
RenderLoaderas a method (e.g.,RenderLoader(string cssClass)) rather than an expression-bodiedRenderFragment<string>property, which can be harder to follow in Razor. - The null check style for
LoadingTemplatechanged fromis not nullto!= null; aligning these checks to a single style across the component would improve consistency.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider replacing the `RenderLoader` parameter from a plain `string` to a more specific type or constants (e.g., an enum or named constants for `"table-loading"` / `"table-loader"`) to avoid stringly-typed CSS class values scattered through the markup.
- For consistency and readability, you might want to define `RenderLoader` as a method (e.g., `RenderLoader(string cssClass)`) rather than an expression-bodied `RenderFragment<string>` property, which can be harder to follow in Razor.
- The null check style for `LoadingTemplate` changed from `is not null` to `!= null`; aligning these checks to a single style across the component would improve consistency.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Pull request overview
Refactors the Table component to reuse a single loader rendering fragment instead of duplicating the same loading markup in multiple places (addresses #7859).
Changes:
- Replaced duplicated loading markup blocks with a shared
RenderLoaderfragment. - Introduced a parameterized
RenderFragment<string> RenderLoaderto render the loader with a provided CSS class.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| else | ||
| { | ||
| <Spinner Color="Color.Primary"></Spinner> |
There was a problem hiding this comment.
Spinner is rendered with an explicit open/close tag here. Elsewhere in the codebase (and even earlier in this file) Spinner is typically self-closing (e.g., <Spinner ... />). For consistency and to avoid accidental whitespace/child-content semantics, consider switching this to a self-closing component tag.
| <Spinner Color="Color.Primary"></Spinner> | |
| <Spinner Color="Color.Primary" /> |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7860 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 764 764
Lines 34176 34166 -10
Branches 4705 4704 -1
=========================================
- Hits 34176 34166 -10
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:
|
Link issues
fixes #7859
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Enhancements: