-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Page Embedding Feature (aka Hybrid UI) #23161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
Introduces a RenderLayout property to IPageLayout and PageLayout, allowing conditional rendering of the menu, toolbar, and footer in the Application layout. Updates Application.cshtml to respect this property, enabling more flexible page layouts.
Introduces the RenderLayoutElements property to IPageLayout and updates usage throughout the codebase. This allows pages to control whether navigation, toolbar, and other layout elements are rendered, providing more flexibility for special pages like error or embedded content. Documentation is updated to explain the new property and its usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds the ability to toggle the rendering of navigation, toolbar, and other surrounding layout elements in MVC Razor views via a new RenderLayoutElements
flag on IPageLayout
.
- Introduces
RenderLayoutElements
property onIPageLayout
andPageLayout
(defaulting totrue
). - Updates
Application.cshtml
andAccount.cshtml
to checkPageLayout.RenderLayoutElements
before rendering the main navbar and to adjust container width. - Extends documentation to cover the new
RenderLayoutElements
setting.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
modules/basic-theme/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Application.cshtml | Conditionally render navbar and adjust containerClass based on new flag |
modules/basic-theme/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Account.cshtml | Inject IPageLayout and wrap navbar in conditional block |
framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Layout/PageLayout.cs | Added RenderLayoutElements auto-property and initializer for Content |
framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Layout/IPageLayout.cs | Added RenderLayoutElements to interface |
docs/en/framework/ui/mvc-razor-pages/page-header.md | Documented RenderLayoutElements usage |
Comments suppressed due to low confidence (3)
framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Layout/PageLayout.cs:9
- No unit or integration tests were added to verify that toggling
RenderLayoutElements
properly hides or shows layout elements. Consider adding tests around this new behavior.
public bool RenderLayoutElements { get; set; } = true;
docs/en/framework/ui/mvc-razor-pages/page-header.md:22
- Duplicate word
pages
in the description. It should read: "useful for public pages, error pages, or embedded content..."
* This is useful for pages public pages, error pages, or embedded content where you want a clean layout without navigation.
modules/basic-theme/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Application.cshtml:21
PageLayout
is referenced here but not injected in this view. Add@inject IPageLayout PageLayout
at the top ofApplication.cshtml
to prevent a runtime error.
var containerClass = ViewBag.FluidLayout == true || PageLayout.RenderLayoutElements == false ? "container-fluid" : "container"; //TODO: Better and type-safe options
...sic-theme/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Application.cshtml
Show resolved
Hide resolved
Introduces the PageEmbedding feature, allowing ABP MVC pages to be embedded in other UI technologies like iframes by conditionally disabling layout elements. This includes new classes and interfaces for embedding services, options for configuration, and automatic iframe detection. Updates to the PageLayout class ensure compatibility with the new embedding logic. Documentation is added to explain usage and configuration options.
Included 'Volo.Abp.AspNetCore.Mvc.UI.Embedding' in the list of projects for packaging. This ensures the Embedding module is built and packaged with the rest of the framework.
Updated the CSS for the abp-embedding component to improve iframe presentation. Added important flags to various properties to ensure consistent rendering across browsers, including border, outline, background, and shadow styles. This change aims to enhance the visual integration of embedded content.
Introduces an auto-height capability to the aspnetcore.mvc.ui.embedding web component, allowing iframes to automatically resize to fit their content. Adds supporting documentation, example demos, a new iframe-side script for height measurement and communication, and updates CSS and JS to support configuration, events, and programmatic control of auto-height.
Introduced EmbeddedScriptViewComponent and its view to inject an embedding script when the page is embedded. Updated EmbeddingPageLayout to expose IsEmbedded property and set it based on the request. Registered the view component to render at the end of the body via layout hooks.
Simplifies the ABP embedding iframe script and web component by removing bidirectional messaging, URL sync, and complex height measurement strategies. The iframe now only reports its height to the parent, and the parent component updates the iframe height accordingly. CSS is updated to remove default and auto-height-related height rules, delegating all height management to JavaScript for more predictable behavior.
Introduces logic to synchronize the browser's URL fragment with the navigation state of the embedded iframe, allowing back/forward navigation and deep linking. Only one instance manages history to prevent conflicts, and cross-origin navigation is handled gracefully.
Introduces URL change monitoring in abp-embedding-iframe.js, reporting navigation events to the parent window via postMessage. Updates abp-embedding.js to handle 'url-change' messages from the iframe and dispatches a custom 'iframe-loaded' event. Also sets a minimum height for embedded iframes in abp-embedding.css to improve user experience.
Description
Resolves #23102
This PR adds a couple of features. Here is the list and explaination:
Controlling LayoutElements via IPageLayout
Embedding Library
Introduced a new package named:
Volo.Abp.AspNetCore.Mvc.UI.Embedding
.When this package added, it replaces the original PageLayout with
EmbeddingPageLayout
and controls layout elements according to options:How It Works
PageLayout.RenderLayoutElements
property is automatically set tofalse
when embedding conditions are metPageEmbeddingService
evaluates multiple factors:AlwaysEmbedIFrameRequests = true
):Sec-Fetch-Dest: iframe
header (most reliable)Sec-Fetch-Site
+Sec-Fetch-Mode
headersX-Frame-Request
,X-Iframe-Request
, etc.)X-Requested-With
header?embed=true
)ABP Embedding Web Component (npm package)
A framework-agnostic web component for embedding iframe content with data passing capabilities.
Features
Installation
Usage
Basic HTML Usage
Iframe Content Setup
Include this script in your iframe content to enable height communication:
The iframe script automatically:
Auto-Height Events
Configuration Options
URL Synchronization
The web component supports URL synchronization between the parent page and iframe content. When enabled, the component will:
?embed=1
parameter to all iframe URLsExample URL Mapping
Enable URL Sync
Iframe Implementation for URL Sync
Your iframe application needs to implement URL change notifications:
URL Sync Events