Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Apr 1, 2025

Link issues

fixes #5761

Summary By Copilot

This pull request includes significant updates to the Layout and Tab components in the BootstrapBlazor library. The main changes involve adding support for displaying tabs in the header and refactoring the components to accommodate this new feature.

Enhancements to Layout component:

  • Added an id attribute to the <section> element to improve element identification. ([src/BootstrapBlazor/Components/Layout/Layout.razorL10-R10](https://github.com/dotnetcore/BootstrapBlazor/pull/5762/files#diff-297066f5ecfa138159913108bba960566925628f897ea9934a7c1795e70ebd15L10-R10))
  • Introduced a new ShowTabInHeader parameter to control the display of tabs in the header. ([src/BootstrapBlazor/Components/Layout/Layout.razor.csR348-R353](https://github.com/dotnetcore/BootstrapBlazor/pull/5762/files#diff-ee1b3a15db7c9d65a5090537d506dfa83ab3bab7627022c09ee627e33c43bb12R348-R353))
  • Modified the Layout component to include a RenderTabHeader method for rendering tab headers. ([src/BootstrapBlazor/Components/Layout/Layout.razor.csR637-R648](https://github.com/dotnetcore/BootstrapBlazor/pull/5762/files#diff-ee1b3a15db7c9d65a5090537d506dfa83ab3bab7627022c09ee627e33c43bb12R637-R648))

Enhancements to Tab component:

  • Updated the Tab component to render tab headers conditionally based on the presence of a TabHeader. ([[1]](https://github.com/dotnetcore/BootstrapBlazor/pull/5762/files#diff-41b1c5919c2aed658650a24a6b28ecd5763566ed708ff322a9fca34e4d5fac15L43-R73), [[2]](https://github.com/dotnetcore/BootstrapBlazor/pull/5762/files#diff-41b1c5919c2aed658650a24a6b28ecd5763566ed708ff322a9fca34e4d5fac15L171-L190))
  • Introduced a new Layout parameter and refactored the component to use LayoutInstance for better resource management. ([[1]](https://github.com/dotnetcore/BootstrapBlazor/pull/5762/files#diff-f16bfc11b19f5f5ca874276674010a254f12dcfbc065320a1be81bf91721de64R422-R429), [[2]](https://github.com/dotnetcore/BootstrapBlazor/pull/5762/files#diff-f16bfc11b19f5f5ca874276674010a254f12dcfbc065320a1be81bf91721de64R795-R796))
  • Modified the init function in Tab.razor.js to handle the new layout-based tab header rendering. ([[1]](https://github.com/dotnetcore/BootstrapBlazor/pull/5762/files#diff-c4788ebe88a1c4c5c925060e09c61872a94b53d25366a8d410b51f796136de83L174-R174), [[2]](https://github.com/dotnetcore/BootstrapBlazor/pull/5762/files#diff-c4788ebe88a1c4c5c925060e09c61872a94b53d25366a8d410b51f796136de83R183-L187))

New components and interfaces:

  • Added a new LayoutHeader class to manage the rendering of tab headers. ([src/BootstrapBlazor/Components/Layout/LayoutHeader.csR1-R37](https://github.com/dotnetcore/BootstrapBlazor/pull/5762/files#diff-aa8f27c0e11f1b6a07c3b570500b51176cab9e9f7f361e542abfbb3dee73c320R1-R37))
  • Introduced the ITabHeader interface to define the contract for tab header rendering. ([src/BootstrapBlazor/Components/Tab/ITabHeader.csR1-R18](https://github.com/dotnetcore/BootstrapBlazor/pull/5762/files#diff-561f696c2acceb79152500d8895304ccf7acd735d6a4d543a481bf53807368bfR1-R18))

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 support for displaying tabs in the header of the Layout component by introducing a new ShowTabInHeader parameter and refactoring the Tab and Layout components to enable flexible tab header rendering.

New Features:

  • Introduced a new ShowTabInHeader parameter in the Layout component to control tab header display
  • Added a new ITabHeader interface and LayoutHeader class to manage tab header rendering

Enhancements:

  • Refactored Tab component to support conditional tab header rendering
  • Modified Tab initialization to work with layout-based tab headers
  • Added support for rendering tabs in the layout header

@bb-auto bb-auto bot added the enhancement New feature or request label Apr 1, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Apr 1, 2025

Reviewer's Guide by Sourcery

This pull request introduces a new ShowTabInHeader parameter to the Layout component, allowing tabs to be displayed in the header. This change involved refactoring the Layout and Tab components, introducing a new LayoutHeader component and ITabHeader interface, and updating the associated JavaScript.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Added the ability to display tabs in the header of the Layout component.
  • Added a ShowTabInHeader parameter to the Layout component to control the display of tabs in the header.
  • Added a RenderTabHeader method to the Layout component for rendering tab headers.
  • Added a new LayoutHeader component to manage the rendering of tab headers.
  • Introduced the ITabHeader interface to define the contract for tab header rendering.
  • Modified the Tab component to render tab headers conditionally based on the presence of a TabHeader.
  • Refactored the Tab component to use LayoutInstance for better resource management.
  • Modified the init function in Tab.razor.js to handle the new layout-based tab header rendering.
src/BootstrapBlazor/Components/Layout/Layout.razor.cs
src/BootstrapBlazor/Components/Tab/Tab.razor
src/BootstrapBlazor/Components/Tab/Tab.razor.cs
src/BootstrapBlazor/Components/Layout/Layout.razor
src/BootstrapBlazor/Components/Tab/Tab.razor.js
src/BootstrapBlazor/Components/Layout/LayoutHeader.cs
src/BootstrapBlazor/Components/Tab/ITabHeader.cs
Added an id attribute to the <section> element in Layout.razor to improve element identification.
  • Added an id attribute to the <section> element.
src/BootstrapBlazor/Components/Layout/Layout.razor

Assessment against linked issues

Issue Objective Addressed Explanation
#5761 Add a ShowTabInHeader parameter to the Layout component to control the display of tabs in the header.

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!
  • 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.5.0 milestone Apr 1, 2025
sourcery-ai[bot]
sourcery-ai bot previously approved these changes Apr 1, 2025
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 demo to showcase the new ShowTabInHeader feature.
  • The LayoutHeader class seems very simple; consider if it's really needed or if its functionality could be merged elsewhere.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 2 issues found
  • 🟢 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.

/// <summary>
/// Gets or sets before popup context menu callback. Default is null.
/// </summary>
[Parameter]
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (complexity): Consider unifying the two layout sources into a single layout instance property to avoid branching logic in the LayoutInstance getter and simplify the code.

Consider unifying the two layout sources into a single “layout instance” property. For example, you can introduce an explicit parameter (e.g. ExplicitLayout) and a cascading parameter (e.g. CascadingLayout) and then consolidate them once per update cycle. This removes the need for a branching LayoutInstance getter. For instance:

```csharp
// Accept both sources
[Parameter]
public Layout? ExplicitLayout { get; set; }

[CascadingParameter]
public Layout? CascadingLayout { get; set; }

// Consolidated layout instance
private Layout? _layoutInstance;

protected override void OnParametersSet()
{
    // Use the explicit layout if provided; otherwise use the cascading layout.
    _layoutInstance = ExplicitLayout ?? CascadingLayout;
}

Then, in your component, replace references to Layout or LayoutInstance with _layoutInstance:

protected override Task InvokeInitAsync() =>
    InvokeVoidAsync("init", Id, Interop, nameof(DragItemCallback), _layoutInstance?.Id);

// In your RenderFragment
builder.AddAttribute(4, nameof(BootstrapBlazorAuthorizeView.Resource), _layoutInstance?.Resource);

This keeps functionality intact while removing the extra indirection and branching logic.

@ArgoZhang ArgoZhang merged commit 33cc7ce into main Apr 1, 2025
2 of 3 checks passed
@ArgoZhang ArgoZhang deleted the feat-layout branch April 1, 2025 10:58
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(Layout): add ShowTabInHeader parameter

2 participants