Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented May 12, 2025

Link issues

fixes #6016

Summary By Copilot

This pull request introduces a new skipValidate parameter to the CreateComponentByFieldType method and applies it across various components to enhance flexibility in validation logic. Additionally, it updates the project version and adjusts related unit tests.

Feature Enhancements:

  • CreateComponentByFieldType Method Update:
    • Added a new optional skipValidate parameter to control validation behavior dynamically.
    • Included logic to add the SkipValidate attribute to components when skipValidate is set to true.
    • Modified validation logic to exclude validation when skipValidate is enabled.

Code Integration:

  • Components Update:
    • Updated RenderEditTemplate and SetDynamicEditTemplate methods in Table.razor.cs to utilize the new skipValidate parameter. [1] [2]

Testing and Validation:

  • Unit Test Update:
    • Modified the CreateComponentByFieldType_Ok test to include the skipValidate parameter, ensuring the new functionality is tested.

Versioning:

  • Project Version Update:
    • Updated the project version in BootstrapBlazor.csproj from 9.6.2-beta03 to 9.6.2-beta04.

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

Introduce an optional skipValidate parameter to allow conditional skipping of validation in dynamically generated components, apply this behavior to table edit templates, update tests accordingly, and increment the project version to 9.6.2-beta04.

New Features:

  • Add optional skipValidate parameter to CreateComponentByFieldType to control validation dynamically
  • Apply skipValidate flag to table edit templates to bypass validation during editing

Build:

  • Bump project version from 9.6.2-beta03 to 9.6.2-beta04

Tests:

  • Update CreateComponentByFieldType unit test to include skipValidate parameter

@ArgoZhang ArgoZhang requested a review from Copilot May 12, 2025 12:06
@bb-auto bb-auto bot added the enhancement New feature or request label May 12, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented May 12, 2025

Reviewer's Guide

This PR introduces an optional skipValidate flag in the component creation utility to dynamically disable validation, applies it in Table rendering paths, updates the related unit test, and bumps the project version.

File-Level Changes

Change Details Files
Introduce skipValidate parameter and adjust validation logic in utility
  • Extended CreateComponentByFieldType signature to accept skipValidate
  • Added conditional SkipValidate attribute when skipValidate is true
  • Bypass default validation registration when skipValidate is true
src/BootstrapBlazor/Utils/Utility.cs
Propagate skipValidate in Table rendering methods
  • Modified RenderEditTemplate to call CreateComponentByFieldType with skipValidate:true
  • Updated SetDynamicEditTemplate to pass skipValidate:true
src/BootstrapBlazor/Components/Table/Table.razor.cs
Update unit test to cover skipValidate behavior
  • Adjusted CreateComponentByFieldType_Ok test to include skipValidate parameter
test/UnitTest/Utils/UtilityTest.cs
Bump project version
  • Updated BootstrapBlazor.csproj version from 9.6.2-beta03 to 9.6.2-beta04
src/BootstrapBlazor/BootstrapBlazor.csproj

Assessment against linked issues

Issue Objective Addressed Explanation
#6016 Skip validation on Excel model in the Table component.

Possibly linked issues


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 added this to the v9.6.0 milestone May 12, 2025
@ArgoZhang ArgoZhang merged commit e957946 into main May 12, 2025
3 checks passed
@ArgoZhang ArgoZhang deleted the refactor-excel branch May 12, 2025 12:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new optional skipValidate parameter to the CreateComponentByFieldType method, enabling components to bypass validation when needed. Key changes include updating the method signature and logic in Utility.cs, modifying the corresponding unit test to include the parameter, and adjusting the Table.razor.cs component rendering to utilize the new functionality.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
test/UnitTest/Utils/UtilityTest.cs Updated test to pass skipValidate: true to validate the new behavior
src/BootstrapBlazor/Utils/Utility.cs Added the skipValidate parameter to CreateComponentByFieldType and adjusted attribute-setting logic accordingly
src/BootstrapBlazor/Components/Table/Table.razor.cs Updated component rendering calls to include skipValidate: true
src/BootstrapBlazor/BootstrapBlazor.csproj Updated the project version from 9.6.2-beta03 to 9.6.2-beta04

builder.AddAttribute(150, nameof(Select<SelectedItem>.ShowSearch), item.ShowSearchWhenSelect);
}

// 设置 SkipValidate 参数
Copy link

Copilot AI May 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider adding an inline comment clarifying the decision to skip adding the SkipValidate attribute when skipValidate is true, to assist future maintainers.

Suggested change
// 设置 SkipValidate 参数
// 设置 SkipValidate 参数
// Add the SkipValidate attribute only if skipValidate is false and the component type is valid.
// This ensures that validation is skipped only when explicitly allowed by the conditions.

Copilot uses AI. Check for mistakes.
{
builder.AddAttribute(70, nameof(ValidateBase<string>.ShowLabelTooltip), item.ShowLabelTooltip);
}

Copy link

Copilot AI May 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document that a null value for skipValidate is treated as false to ensure API consumers understand the default behavior.

Suggested change
// If skipValidate is null, it is treated as false by default.

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented May 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (316eca5) to head (455fda0).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #6017   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          670       670           
  Lines        30653     30657    +4     
  Branches      4362      4363    +1     
=========================================
+ Hits         30653     30657    +4     

☔ 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.

Copy link
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 @ArgoZhang - I've reviewed your changes - here's some feedback:

  • Update the CreateComponentByFieldType_Ok unit test to assert that the SkipValidate attribute is actually rendered when skipValidate=true.
  • Consider changing skipValidate from a nullable bool to a non-nullable bool with default false to simplify the conditional logic.
  • Please double-check the sequence numbers of the new AddAttribute calls to ensure they don’t collide and maintain the correct render order.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

var fragment = new RenderFragment(builder => builder.CreateComponentByFieldType(new BootstrapBlazorRoot(), editor, new Foo() { Name = "Test-Component" }));
var fragment = new RenderFragment(builder => builder.CreateComponentByFieldType(new BootstrapBlazorRoot(), editor, new Foo() { Name = "Test-Component" }, skipValidate: true));
var cut = Context.Render(builder => builder.AddContent(0, fragment));
Assert.Contains("value=\"Test-Component\"", cut.Markup);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (testing): Enhance assertion to verify SkipValidate attribute presence.

Update the assertion to verify the rendered markup includes the SkipValidate attribute or that the component instance’s skipValidate parameter is true.

Suggested change
Assert.Contains("value=\"Test-Component\"", cut.Markup);
Assert.Contains("value=\"Test-Component\"", cut.Markup);
// Verify that SkipValidate attribute is rendered
Assert.Contains("skip-validate", cut.Markup);

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(Table): skip validate on Excel model

2 participants