Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Mar 28, 2025

Link issues

fixes #5738

Summary By Copilot

This pull request introduces several enhancements and bug fixes to the BootstrapBlazor project, focusing on the Tab component, context menu styling, and localization updates. The most important changes include adding a full-screen option to the tab context menu, updating the context menu styles, and modifying localization files to support the new full-screen option.

Enhancements to the Tab component:

  • Added a new parameter ShowContextMenuFullScreen to control the visibility of the full-screen button in the context menu, with a default value of true.
  • Introduced a new method OnFullScreen to handle the full-screen toggle action in the context menu.
  • Injected the FullScreenService to manage full-screen actions.
  • Added a new icon TabContextMenuFullScreenIcon to represent the full-screen action in the context menu. [1] [2] [3] [4]

Context menu styling updates:

  • Adjusted the margin of the .divider class in ContextMenu.razor.scss to improve spacing.

Localization updates:

  • Updated the English and Chinese localization files to include the new "Full screen" context menu option. [1] [2]

Bug fixes:

  • Removed the IsDisabled attribute from the TabItem in Tabs.razor to ensure proper functionality.
  • Fixed a minor issue with the GetIdByTabItem method by removing the nullable return type.

Testing updates:

  • Added a test case to verify the ShowContextMenuFullScreen parameter in TabTest.cs.

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

Add full-screen option to Tab component's context menu with new configuration parameters and service integration

New Features:

  • Introduce a new ShowContextMenuFullScreen parameter to control the visibility of the full-screen button in the Tab component's context menu

Bug Fixes:

  • Remove IsDisabled attribute from TabItem to ensure proper functionality
  • Fix GetIdByTabItem method by removing nullable return type

Enhancements:

  • Add ContextMenuFullScreenIcon parameter to customize the full-screen icon
  • Inject FullScreenService to manage full-screen actions for tabs

Tests:

  • Add test case to verify the ShowContextMenuFullScreen parameter

@ArgoZhang ArgoZhang requested a review from Copilot March 28, 2025 07:25
@bb-auto bb-auto bot added the enhancement New feature or request label Mar 28, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Mar 28, 2025

Reviewer's Guide by Sourcery

This pull request introduces a new ShowContextMenuFullScreen parameter to the Tab component, allowing users to control the visibility of a full-screen button in the tab context menu. It also includes styling updates for the context menu, localization updates for the new feature, and a bug fix related to the TabItem.

Sequence diagram for Tab context menu full screen toggle

sequenceDiagram
    participant User
    participant Tab Component
    participant Context Menu
    participant FullScreenService

    User->>Tab Component: Right-clicks on TabItem
    Tab Component->>Context Menu: Shows context menu with Full Screen option
    User->>Context Menu: Clicks Full Screen
    Context Menu->>Tab Component: Calls OnFullScreen
    Tab Component->>FullScreenService: ToggleById(TabItem ID)
    FullScreenService->>FullScreenService: Toggles full screen mode for TabItem
Loading

File-Level Changes

Change Details Files
Added a new parameter to the Tab component to control the visibility of the full-screen button in the context menu.
  • Added ShowContextMenuFullScreen parameter with a default value of true.
  • Introduced OnFullScreen method to handle the full-screen toggle action.
  • Injected FullScreenService to manage full-screen actions.
  • Added ContextMenuFullScreenIcon to represent the full-screen action.
src/BootstrapBlazor/Components/Tab/Tab.razor.cs
src/BootstrapBlazor/Components/Tab/Tab.razor
src/BootstrapBlazor/Enums/ComponentIcons.cs
src/BootstrapBlazor/Icons/BootstrapIcons.cs
src/BootstrapBlazor/Icons/FontAwesomeIcons.cs
src/BootstrapBlazor/Icons/MaterialDesignIcons.cs
src/BootstrapBlazor/Locales/en.json
src/BootstrapBlazor/Locales/zh.json
test/UnitTest/Components/TabTest.cs
Updated context menu styling to improve spacing.
  • Adjusted the margin of the .divider class.
src/BootstrapBlazor/Components/ContextMenu/ContextMenu.razor.scss
Fixed issues related to TabItem and GetIdByTabItem method.
  • Removed the IsDisabled attribute from the TabItem.
  • Removed the nullable return type from the GetIdByTabItem method.
src/BootstrapBlazor/Components/Tab/Tab.razor.cs
src/BootstrapBlazor.Server/Components/Samples/Tabs.razor

Assessment against linked issues

Issue Objective Addressed Explanation
#5738 Add a ShowContextFullScreenButton parameter to the Tab component to control the visibility of a full-screen button in the context menu.

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!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

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.4.0 milestone Mar 28, 2025
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 adds a full-screen option to the Tab component’s context menu while updating related icon mappings, localization files, and tests.

  • Introduces the ShowContextMenuFullScreen parameter and corresponding OnFullScreen handler in the Tab component.
  • Adds icon definitions for full-screen support in multiple icon sets and enum mappings.
  • Updates tests and sample files to reflect the new functionality and removes the deprecated IsDisabled attribute from TabItem.

Reviewed Changes

Copilot reviewed 8 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/UnitTest/Components/TabTest.cs Adds a test case to enable ShowContextMenuFullScreen and still sets IsDisabled on TabItem.
src/BootstrapBlazor/Icons/MaterialDesignIcons.cs Adds a full-screen icon mapping for Material Design icons.
src/BootstrapBlazor/Icons/FontAwesomeIcons.cs Adds a full-screen icon mapping for FontAwesome icons.
src/BootstrapBlazor/Icons/BootstrapIcons.cs Adds a full-screen icon mapping for Bootstrap icons.
src/BootstrapBlazor/Enums/ComponentIcons.cs Introduces a new enum value for the full-screen icon.
src/BootstrapBlazor/Components/Tab/Tab.razor.cs Introduces the new ShowContextMenuFullScreen parameter, adds the full-screen icon, injects FullScreenService, and updates GetIdByTabItem.
src/BootstrapBlazor/Components/Tab/Tab.razor Updates the context menu to conditionally render the full-screen option when enabled.
src/BootstrapBlazor.Server/Components/Samples/Tabs.razor Updates sample usage of the Tab component to align with the updated API.
Files not reviewed (3)
  • src/BootstrapBlazor/Components/ContextMenu/ContextMenu.razor.scss: Language not supported
  • src/BootstrapBlazor/Locales/en.json: Language not supported
  • src/BootstrapBlazor/Locales/zh.json: Language not supported
Comments suppressed due to low confidence (2)

src/BootstrapBlazor/Components/Tab/Tab.razor.cs:1036

  • Changing the return type from nullable to non-nullable assumes that ComponentIdGenerator.Generate always returns a non-null string. Verify that this assumption holds to avoid potential null reference exceptions.
private string GetIdByTabItem(TabItem item) => ComponentIdGenerator.Generate(item);

test/UnitTest/Components/TabTest.cs:39

  • The test case is still setting the 'IsDisabled' property on TabItem, but this property has been removed from the production code. Consider updating the test to reflect the current implementation.
pb.Add(a => a.IsDisabled, true);

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:

Overall Comments:

  • Consider adding a ShowFullScreen parameter to the TabItem component to allow individual tabs to control the full-screen option.
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.

pb.AddChildContent<Tab>(pb =>
{
pb.Add(a => a.ShowContextMenu, true);
pb.Add(a => a.ShowContextMenuFullScreen, true);
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): Test both true and false values for ShowContextMenuFullScreen

It's important to test both true and false values for the ShowContextMenuFullScreen parameter to ensure that the full-screen button is correctly shown or hidden in the context menu.

Suggested implementation:

            pb.AddChildContent<Tab>(pb =>
            {
                pb.Add(a => a.ShowContextMenu, true);
                pb.Add(a => a.ShowContextMenu, true);
                pb.Add(a => a.ShowContextMenuFullScreen, true);
                pb.AddChildContent<TabItem>(pb =>
                {
                    pb.Add(a => a.IsDisabled, true);
                });
            });

            // Additional test case to validate ShowContextMenuFullScreen with false value
            pb.AddChildContent<Tab>(pb =>
            {
                pb.Add(a => a.ShowContextMenu, true);
                pb.Add(a => a.ShowContextMenuFullScreen, false);
                pb.AddChildContent<TabItem>(pb =>
                {
                    pb.Add(a => a.IsDisabled, true);
                });
            });

The additional test case will allow you to verify that the full-screen button is correctly hidden when ShowContextMenuFullScreen is false. Adjust assertions (if any) in your test framework accordingly to validate the UI behavior.

@codecov
Copy link

codecov bot commented Mar 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (97d9b30) to head (fc025bc).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #5739   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          657       657           
  Lines        29907     29923   +16     
  Branches      4242      4245    +3     
=========================================
+ Hits         29907     29923   +16     

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

@ArgoZhang ArgoZhang merged commit 378e17b into main Mar 28, 2025
6 checks passed
@ArgoZhang ArgoZhang deleted the refactor-tab branch March 28, 2025 07:30
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(Tab): add ShowContextFullScreenButton parameter

2 participants