Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented May 13, 2025

Link issues

fixes #6009

Summary By Copilot

This pull request introduces changes to enhance table export functionality in the BootstrapBlazor library, including the addition of a new method to filter export columns, removal of unused code, and updates to unit tests. The changes focus on improving the handling of export-related logic and ensuring proper test coverage.

Enhancements to Table Export Functionality:

  • Added GetExportColumns method to filter columns for export by excluding those marked with IgnoreWhenExport. This ensures only relevant columns are included during export operations. ([src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.csL1186-R1205](https://github.com/dotnetcore/BootstrapBlazor/pull/6018/files#diff-ca9e82d70b95de7204b56fbdace327d330eaef6777601f3d897b0e07c8c3eff8L1186-R1205))
  • Updated export methods (ExportAsync, ExportCsvAsync, ExportPdfAsync, ExportExcelAsync) to use the new GetExportColumns method instead of GetVisibleColumns. ([src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.csL1186-R1205](https://github.com/dotnetcore/BootstrapBlazor/pull/6018/files#diff-ca9e82d70b95de7204b56fbdace327d330eaef6777601f3d897b0e07c8c3eff8L1186-R1205))

Code Simplification:

  • Removed the unused GetIgnoreExport method from ITableColumnExtensions, as its functionality is now integrated into GetExportColumns. ([src/BootstrapBlazor/Extensions/ITableColumnExtensions.csL347-L348](https://github.com/dotnetcore/BootstrapBlazor/pull/6018/files#diff-6bf3ad236565623debfb28c7c18a2a21bdd089aa294538b56491d5db7dd5a2f5L347-L348))

Unit Test Updates:

  • Enhanced the ExportAsync_Ok test to verify that columns marked with IgnoreWhenExport are excluded during export. Added assertions to validate the behavior of the GetExportColumns method. ([[1]](https://github.com/dotnetcore/BootstrapBlazor/pull/6018/files#diff-3546a7a8520a1cc0576ca6a1077d468561e7b825b061c3d1aac2daae7a62a160R6996-R7001), [[2]](https://github.com/dotnetcore/BootstrapBlazor/pull/6018/files#diff-3546a7a8520a1cc0576ca6a1077d468561e7b825b061c3d1aac2daae7a62a160R7016-R7029), [[3]](https://github.com/dotnetcore/BootstrapBlazor/pull/6018/files#diff-3546a7a8520a1cc0576ca6a1077d468561e7b825b061c3d1aac2daae7a62a160R7040-R7042))
  • Removed the redundant IgnoreWhenExport_Ok test, as its logic is now covered in the updated ExportAsync_Ok test. ([test/UnitTest/Components/TableTest.csL8211-L8241](https://github.com/dotnetcore/BootstrapBlazor/pull/6018/files#diff-3546a7a8520a1cc0576ca6a1077d468561e7b825b061c3d1aac2daae7a62a160L8211-L8241))

Version Update:

  • Incremented the project version from 9.6.2-beta04 to 9.6.2-beta05 in the BootstrapBlazor.csproj file. ([src/BootstrapBlazor/BootstrapBlazor.csprojL4-R4](https://github.com/dotnetcore/BootstrapBlazor/pull/6018/files#diff-07918ce1b66955e76da5cd0ffa38512cce984fa2a09735a60e0db37b45235527L4-R4))

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 IgnoreWhenExport-based filtering for table exports and refactor related logic

Enhancements:

  • Add GetExportColumns method to exclude columns marked IgnoreWhenExport during export
  • Update all export methods to use GetExportColumns instead of GetVisibleColumns
  • Remove obsolete GetIgnoreExport extension method

Build:

  • Bump project version to 9.6.2-beta05

Tests:

  • Enhance ExportAsync_Ok test to assert ignored columns are excluded and consolidate IgnoreWhenExport_Ok logic
  • Remove redundant standalone IgnoreWhenExport_Ok unit test

@ArgoZhang ArgoZhang requested a review from Copilot May 13, 2025 06:16
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented May 13, 2025

Reviewer's Guide

This PR refactors the table export logic by introducing a new GetExportColumns method that respects the IgnoreWhenExport flag, updates all export routines to use it, removes the obsolete GetIgnoreExport extension, enhances unit tests to validate the new behavior, and bumps the package version.

Sequence Diagram: Table Export Column Processing

sequenceDiagram
    participant ExportHandler as "Table Export Handler (e.g., ExportExcelAsync)"
    participant GEC as "GetExportColumns()"
    participant GVC as "GetVisibleColumns()"
    participant Column as "ITableColumn"
    participant ExportUtil as "TableExport Utility"

    ExportHandler->>GEC: Request export columns
    GEC->>GVC: Get base visible columns
    GVC-->>GEC: list_of_visible_columns
    GEC->>GEC: Iterate list_of_visible_columns
    loop For each column in list_of_visible_columns
        GEC->>Column: Check IgnoreWhenExport property
        Column-->>GEC: IgnoreWhenExport_status
        alt IgnoreWhenExport is not true
            GEC->>GEC: Add column to final_export_columns
        end
    end
    GEC-->>ExportHandler: final_export_columns
    ExportHandler->>ExportUtil: PerformExport(data, final_export_columns)
Loading

File-Level Changes

Change Details Files
Introduce GetExportColumns filtering and remove legacy ignore logic
  • Add GetExportColumns method filtering out columns marked IgnoreWhenExport
  • Refactor all ExportAsync/Csv/Pdf/ExcelAsync methods to use GetExportColumns
  • Remove conditional check for GetIgnoreExport in GetVisibleColumns
  • Delete obsolete GetIgnoreExport extension method
src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs
src/BootstrapBlazor/Extensions/ITableColumnExtensions.cs
Update unit tests to cover IgnoreWhenExport behavior and remove redundancy
  • Enhance ExportAsync_Ok test to include an ignored column and assert exportContext.Columns
  • Capture and assert exportContext in OnExportAsync callback
  • Remove the standalone IgnoreWhenExport_Ok test now covered by updated test
test/UnitTest/Components/TableTest.cs
Increment project version
  • Bump version from 9.6.2-beta04 to 9.6.2-beta05
src/BootstrapBlazor/BootstrapBlazor.csproj

Assessment against linked issues

Issue Objective Addressed Explanation
#6009 Add a property to TableColumn to ignore the column during export.

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 the enhancement New feature or request label May 13, 2025
@bb-auto bb-auto bot added this to the v9.6.0 milestone May 13, 2025
@ArgoZhang ArgoZhang merged commit 051fdba into main May 13, 2025
3 checks passed
@ArgoZhang ArgoZhang deleted the fix-export branch May 13, 2025 06:16
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 refactors the table export logic to respect the IgnoreWhenExport flag, removes an obsolete extension method, updates related unit tests, and bumps the project version.

  • Introduced GetExportColumns to filter out columns marked IgnoreWhenExport in all export methods.
  • Removed the unused GetIgnoreExport extension.
  • Enhanced the ExportAsync_Ok test to assert that ignored columns are excluded; redundant test removed.
  • Bumped version to 9.6.2-beta05.

Reviewed Changes

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

File Description
test/UnitTest/Components/TableTest.cs Updated ExportAsync_Ok to include an ignored column, capture export context, add assertions, and removed the old redundant test.
src/BootstrapBlazor/Extensions/ITableColumnExtensions.cs Deleted the obsolete GetIgnoreExport method.
src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs Switched exports to use GetExportColumns, cleaned up GetVisibleColumns, and added the new filtering method.
src/BootstrapBlazor/BootstrapBlazor.csproj Incremented package version to 9.6.2-beta05.
Comments suppressed due to low confidence (1)

test/UnitTest/Components/TableTest.cs:7040

  • The test only covers the default export type; consider adding similar tests for Csv, Pdf, and Excel exports to ensure the new filtering logic applies across all export methods.
Assert.NotNull(exportContext);

/// <summary>
/// Gets the export column collection.
/// </summary>
/// <returns></returns>
Copy link

Copilot AI May 13, 2025

Choose a reason for hiding this comment

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

The XML doc tag is empty; please provide a meaningful description of the returned List to improve API documentation.

Suggested change
/// <returns></returns>
/// <returns>A list of <see cref="ITableColumn"/> objects representing the columns to be included in the export.
/// Columns marked with <c>IgnoreWhenExport</c> are excluded.</returns>

Copilot uses AI. Check for mistakes.
Comment on lines +7017 to +7021
// 可见列为 2 列
var columns = table.Instance.GetVisibleColumns();
Assert.Equal(2, columns.Count());

// 由于设置了 IgnoreWhenExport 为 true 所以导出时不包含 Address 列
Copy link

Copilot AI May 13, 2025

Choose a reason for hiding this comment

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

[nitpick] Inline comments should be in English for consistency; consider translating this comment to English.

Suggested change
// 可见列为 2 列
var columns = table.Instance.GetVisibleColumns();
Assert.Equal(2, columns.Count());
// 由于设置了 IgnoreWhenExport true 所以导出时不包含 Address
// The visible columns are 2
var columns = table.Instance.GetVisibleColumns();
Assert.Equal(2, columns.Count());
// Since IgnoreWhenExport is set to true, the Address column is not included during export

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

codecov bot commented May 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (e957946) to head (a50e075).
Report is 1 commits behind head on main.

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

☔ 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 and they look great!

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.

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(TableColumn): add IgnoreWhenExport parameter

2 participants