Skip to content

Commit

Permalink
Merge pull request #3 from seangwright/feat/support-readonly-mode
Browse files Browse the repository at this point in the history
Feature: Support Xperience Page Builder readonly mode
  • Loading branch information
seangwright authored Oct 23, 2024
2 parents 06dc0f2 + 0392925 commit a331c52
Show file tree
Hide file tree
Showing 8 changed files with 356 additions and 345 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Copyright>Copyright © $(Company) $([System.DateTime]::Now.Year)</Copyright>
<Trademark>$(Company)™</Trademark>
<Product>XperienceCommunity.PreviewComponentOutlines</Product>
<VersionPrefix>3.0.0</VersionPrefix>
<VersionPrefix>4.0.0</VersionPrefix>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Title>$(Product)</Title>
<PackageProjectUrl>https://github.com/seangwright/xperience-community-preview-component-outlines</PackageProjectUrl>
Expand Down
10 changes: 5 additions & 5 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Kentico.Xperience.WebApp" Version="29.3.0" />
<PackageVersion Include="Kentico.Xperience.WebApp" Version="29.6.0" />

<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageVersion Include="NUnit" Version="4.1.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="NUnit" Version="4.2.2" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageVersion Include="NUnit.Analyzers" Version="4.3.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="Kentico.Xperience.Core.Tests" Version="29.3.0" />
<PackageVersion Include="Kentico.Xperience.Core.Tests" Version="29.6.0" />
<PackageVersion Include="NSubstitute" Version="5.1.0" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="FluentAssertions" Version="6.12.1" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ This can help marketers and content managers visualize how various Page Builder

| Xperience Version | Library Version |
| ----------------- | --------------- |
| >= 29.6.0 | 4.x |
| >= 29.3.0 | 3.x |
| >= 28.1.0 | 2.x |
| >= 25.0.0 | 1.x |
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.100",
"version": "8.0.403",
"rollForward": "latestMajor",
"allowPrerelease": false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ namespace XperienceCommunity.PreviewComponentOutlines;
/// in Page Builder Preview mode
/// </summary>
[HtmlTargetElement("*", Attributes = TAG_HELPER_ATTRIBUTE)]
public class OutlineTagHelper(IHttpContextAccessor accessor) : TagHelper
public class OutlineTagHelper(IHttpContextAccessor accessor, IPageBuilderDataContextRetriever contextRetriever) : TagHelper
{
public const string TAG_HELPER_ATTRIBUTE = "xpc-preview-outline";
public const string TAG_HELPER_OUTPUT_ATTRIBUTE = "data-xpc-preview-outline";

private readonly IHttpContextAccessor accessor = accessor;
private readonly IPageBuilderDataContextRetriever contextRetriever = contextRetriever;

[HtmlAttributeName(TAG_HELPER_ATTRIBUTE)]
public string? ComponentName { get; set; }
Expand All @@ -27,7 +28,8 @@ public override void Process(TagHelperContext context, TagHelperOutput output)

var httpContext = accessor.HttpContext;

bool isPreviewMode = !httpContext.Kentico().PageBuilder().EditMode && httpContext.Kentico().Preview().Enabled;
bool isPreviewMode = contextRetriever.Retrieve().GetMode() == PageBuilderMode.Off
&& httpContext.Kentico().Preview().Enabled;

if (!isPreviewMode || ComponentName is null)
{
Expand Down
Loading

0 comments on commit a331c52

Please sign in to comment.