Skip to content

Commit

Permalink
Bugfix for #11 and added support for v13
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew-Wise committed Dec 22, 2023
1 parent eecd558 commit 7e7cf90
Show file tree
Hide file tree
Showing 474 changed files with 23,483 additions and 333 deletions.
8 changes: 7 additions & 1 deletion src/Our.FeatureFlags.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Our.FeatureFlags", "Our.FeatureFlags\Our.FeatureFlags.csproj", "{2614C686-8BF8-41E5-8C7E-48E04DCD989C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DemoSite", "Site\DemoSite\DemoSite.csproj", "{C518920E-C0D4-40AB-8202-5E2E9E114F22}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DemoSiteV10", "Site\DemoSiteV10\DemoSiteV10.csproj", "{C518920E-C0D4-40AB-8202-5E2E9E114F22}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{BB0EA66F-4C6C-40D1-9396-4EBE22056039}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
..\umbraco-marketplace-my.package.json = ..\umbraco-marketplace-my.package.json
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DemoSiteV13", "Site\DemoSiteV13\DemoSiteV13.csproj", "{6CAC7383-4712-470C-AD1A-DD3D725EBC63}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -27,6 +29,10 @@ Global
{C518920E-C0D4-40AB-8202-5E2E9E114F22}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C518920E-C0D4-40AB-8202-5E2E9E114F22}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C518920E-C0D4-40AB-8202-5E2E9E114F22}.Release|Any CPU.Build.0 = Release|Any CPU
{6CAC7383-4712-470C-AD1A-DD3D725EBC63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6CAC7383-4712-470C-AD1A-DD3D725EBC63}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6CAC7383-4712-470C-AD1A-DD3D725EBC63}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6CAC7383-4712-470C-AD1A-DD3D725EBC63}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Our.FeatureFlags.Editor.Configuration;
using Our.FeatureFlags.Extensions;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Extensions;

Expand All @@ -26,20 +27,22 @@ public async Task HandleAsync(SendingContentNotification notification, Cancellat

foreach (var variant in notification.Content.Variants)
{
var tabsWithNoProperties = new List<Tab<ContentPropertyDisplay>>();
foreach (var tab in variant.Tabs)
{
if(tab.Properties == null)
if(tab.Properties == null || !tab.Properties.Any())
{
tabsWithNoProperties.Add(tab);
continue;
}

tab.Properties = tab.Properties.Where(prop =>
{
if (prop.PropertyEditor?.Alias.InvariantEquals(FeatureFlaggedEditor.AliasValue) == true &&
prop.Config?.TryGetValue("__ffconfig", out var tmp) == true &&
prop.ConfigNullable?.TryGetValue("__ffconfig", out var tmp) == true &&
tmp is FeatureFlaggedConfiguration config)
{
prop.Config.Remove("__ffconfig");
prop.ConfigNullable.Remove("__ffconfig");
var enabled = config.Requirement switch
{
Expand All @@ -63,6 +66,21 @@ public async Task HandleAsync(SendingContentNotification notification, Cancellat
tab.Type = string.Empty;
}
}

foreach(var tab in tabsWithNoProperties)
{
if (string.IsNullOrWhiteSpace(tab.Alias))
{
continue;
}

var groups = variant.Tabs.Where(t => t.Alias?.StartsWith(tab.Alias) == true && tab.Type != "tab");
if(groups.All(g => string.IsNullOrWhiteSpace(g.Type)))
{
tab.Type = string.Empty;
}
}

}
}
}
81 changes: 44 additions & 37 deletions src/Our.FeatureFlags/Our.FeatureFlags.csproj
Original file line number Diff line number Diff line change
@@ -1,40 +1,47 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>true</IsPackable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<ContentTargetFolders>.</ContentTargetFolders>
<Product>Our.FeatureFlags</Product>
<PackageId>Our.FeatureFlags</PackageId>
<Title>Our.FeatureFlags</Title>
<Description>Enables the use of feature flags to show/hide Umbraco properties</Description>
<PackageTags>umbraco plugin package FeatureManagement FeatureFlags AzureAppConfiguration feature management toggle umbraco-marketplace</PackageTags>
<RootNamespace>Our.FeatureFlags</RootNamespace>
<Authors>Matthew Wise</Authors>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/Matthew-Wise/feature-flagging-umbraco.git</RepositoryUrl>
<PackageProjectUrl>https://github.com/Matthew-Wise/feature-flagging-umbraco</PackageProjectUrl>
<PackageIcon>icon.png</PackageIcon>
<PackageReadmeFile>Readme.md</PackageReadmeFile>
</PropertyGroup>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>true</IsPackable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<ContentTargetFolders>.</ContentTargetFolders>
<Product>Our.FeatureFlags</Product>
<PackageId>Our.FeatureFlags</PackageId>
<Title>Our.FeatureFlags</Title>
<Description>Enables the use of feature flags to show/hide Umbraco properties</Description>
<PackageTags>umbraco plugin package FeatureManagement FeatureFlags AzureAppConfiguration feature management toggle umbraco-marketplace</PackageTags>
<RootNamespace>Our.FeatureFlags</RootNamespace>
<Authors>Matthew Wise</Authors>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/Matthew-Wise/feature-flagging-umbraco.git</RepositoryUrl>
<PackageProjectUrl>https://github.com/Matthew-Wise/feature-flagging-umbraco</PackageProjectUrl>
<PackageIcon>icon.png</PackageIcon>
<PackageReadmeFile>Readme.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.FeatureManagement.AspNetCore" Version="2.5.1" />
<PackageReference Include="Umbraco.Cms.Core" Version="10.0.1" />
<PackageReference Include="Umbraco.Cms.Web.BackOffice" Version="10.6.1" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.FeatureManagement.AspNetCore" Version="3.1.1" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'net8.0'">
<PackageReference Include="Umbraco.Cms.Core" Version="10.8.3" />
<PackageReference Include="Umbraco.Cms.Web.BackOffice" Version="10.8.3" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\Readme.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="..\..\images\icon.png">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
<PackageReference Include="Umbraco.Cms.Core" Version="13.*" />
<PackageReference Include="Umbraco.Cms.Web.BackOffice" Version="13.*" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\Readme.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="..\..\images\icon.png">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>
</Project>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.AppConfiguration.AspNetCore" Version="5.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="5.1.0" />
<PackageReference Include="Umbraco.Cms" Version="10.0.1" />
<PackageReference Include="Microsoft.Azure.AppConfiguration.AspNetCore" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="7.0.0" />
<PackageReference Include="Umbraco.Cms" Version="10.8.3" />
</ItemGroup>

<!-- Force Windows to use ICU. Otherwise Windows 10 2019H1+ will do it, but older Windows 10 and most, if not all, Windows Server editions will run NLS -->
<ItemGroup>
<PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="68.2.0.9" />
<PackageReference Include="Azure.Core" Version="1.20.0" />
<PackageReference Include="uSync" Version="10.2.1" />
<PackageReference Include="Azure.Core" Version="1.36.0" />
<PackageReference Include="uSync" Version="10.7.1" />
<RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="68.2.0.9" Condition="$(RuntimeIdentifier.StartsWith('linux')) or $(RuntimeIdentifier.StartsWith('win')) or ('$(RuntimeIdentifier)' == '' and !$([MSBuild]::IsOSPlatform('osx')))" />
</ItemGroup>

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// <auto-generated>
// This code was generated by a tool.
//
// Umbraco.ModelsBuilder.Embedded v10.0.1+fd0c4fd
// Umbraco.ModelsBuilder.Embedded v10.8.3+e04a41b
//
// Changes to this file will be lost if the code is regenerated.
// </auto-generated>
Expand All @@ -24,15 +24,15 @@ public partial class Article : PublishedContentModel, IArticleControls, IContent
{
// helpers
#pragma warning disable 0109 // new is redundant
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.0.1+fd0c4fd")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.8.3+e04a41b")]
public new const string ModelTypeAlias = "article";
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.0.1+fd0c4fd")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.8.3+e04a41b")]
public new const PublishedItemType ModelItemType = PublishedItemType.Content;
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.0.1+fd0c4fd")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.8.3+e04a41b")]
[return: global::System.Diagnostics.CodeAnalysis.MaybeNull]
public new static IPublishedContentType GetModelContentType(IPublishedSnapshotAccessor publishedSnapshotAccessor)
=> PublishedModelUtility.GetModelContentType(publishedSnapshotAccessor, ModelItemType, ModelTypeAlias);
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.0.1+fd0c4fd")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.8.3+e04a41b")]
[return: global::System.Diagnostics.CodeAnalysis.MaybeNull]
public static IPublishedPropertyType GetModelPropertyType<TValue>(IPublishedSnapshotAccessor publishedSnapshotAccessor, Expression<Func<Article, TValue>> selector)
=> PublishedModelUtility.GetModelPropertyType(GetModelContentType(publishedSnapshotAccessor), selector);
Expand All @@ -52,85 +52,85 @@ public Article(IPublishedContent content, IPublishedValueFallback publishedValue
///<summary>
/// Article Date: Enter the date for the article
///</summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.0.1+fd0c4fd")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.8.3+e04a41b")]
[ImplementPropertyType("articleDate")]
public virtual global::System.DateTime ArticleDate => global::Umbraco.Cms.Web.Common.PublishedModels.ArticleControls.GetArticleDate(this, _publishedValueFallback);

///<summary>
/// Author Name: Enter the name of the author
///</summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.0.1+fd0c4fd")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.8.3+e04a41b")]
[global::System.Diagnostics.CodeAnalysis.MaybeNull]
[ImplementPropertyType("authorName")]
public virtual string AuthorName => global::Umbraco.Cms.Web.Common.PublishedModels.ArticleControls.GetAuthorName(this, _publishedValueFallback);

///<summary>
/// Main Content: Enter the main content for the page
///</summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.0.1+fd0c4fd")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.8.3+e04a41b")]
[global::System.Diagnostics.CodeAnalysis.MaybeNull]
[ImplementPropertyType("mainContent")]
public virtual global::Newtonsoft.Json.Linq.JToken MainContent => global::Umbraco.Cms.Web.Common.PublishedModels.ContentControls.GetMainContent(this, _publishedValueFallback);

///<summary>
/// Subtitle: Enter a subtitle for this page
///</summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.0.1+fd0c4fd")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.8.3+e04a41b")]
[global::System.Diagnostics.CodeAnalysis.MaybeNull]
[ImplementPropertyType("subtitle")]
public virtual string Subtitle => global::Umbraco.Cms.Web.Common.PublishedModels.HeaderControls.GetSubtitle(this, _publishedValueFallback);

///<summary>
/// Title: Enter the title for the page. If this is empty the name of the page will be used.
///</summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.0.1+fd0c4fd")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.8.3+e04a41b")]
[global::System.Diagnostics.CodeAnalysis.MaybeNull]
[ImplementPropertyType("title")]
public virtual string Title => global::Umbraco.Cms.Web.Common.PublishedModels.HeaderControls.GetTitle(this, _publishedValueFallback);

///<summary>
/// Main Image: Choose the main image for this page
///</summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.0.1+fd0c4fd")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.8.3+e04a41b")]
[global::System.Diagnostics.CodeAnalysis.MaybeNull]
[ImplementPropertyType("mainImage")]
public virtual global::Umbraco.Cms.Core.Models.PublishedContent.IPublishedContent MainImage => global::Umbraco.Cms.Web.Common.PublishedModels.MainImageControls.GetMainImage(this, _publishedValueFallback);

///<summary>
/// Meta Description: Enter the meta description for this page
///</summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.0.1+fd0c4fd")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.8.3+e04a41b")]
[global::System.Diagnostics.CodeAnalysis.MaybeNull]
[ImplementPropertyType("metaDescription")]
public virtual string MetaDescription => global::Umbraco.Cms.Web.Common.PublishedModels.SEocontrols.GetMetaDescription(this, _publishedValueFallback);

///<summary>
/// Meta Keywords: Enter the keywords for this page
///</summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.0.1+fd0c4fd")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.8.3+e04a41b")]
[global::System.Diagnostics.CodeAnalysis.MaybeNull]
[ImplementPropertyType("metaKeywords")]
public virtual global::System.Collections.Generic.IEnumerable<string> MetaKeywords => global::Umbraco.Cms.Web.Common.PublishedModels.SEocontrols.GetMetaKeywords(this, _publishedValueFallback);

///<summary>
/// Meta Name: Enter the meta name for this page
///</summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.0.1+fd0c4fd")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.8.3+e04a41b")]
[global::System.Diagnostics.CodeAnalysis.MaybeNull]
[ImplementPropertyType("metaName")]
public virtual string MetaName => global::Umbraco.Cms.Web.Common.PublishedModels.SEocontrols.GetMetaName(this, _publishedValueFallback);

///<summary>
/// Hide From XML Sitemap: Tick this if you want to hide this page from the XML sitemap
///</summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.0.1+fd0c4fd")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.8.3+e04a41b")]
[ImplementPropertyType("hideFromXMLSitemap")]
public virtual bool HideFromXmlsitemap => global::Umbraco.Cms.Web.Common.PublishedModels.VisibilityControls.GetHideFromXmlsitemap(this, _publishedValueFallback);

///<summary>
/// Umbraco Navi Hide: Tick this box if you want to hide this page from the navigation and from search results
///</summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.0.1+fd0c4fd")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "10.8.3+e04a41b")]
[ImplementPropertyType("umbracoNaviHide")]
public virtual bool UmbracoNaviHide => global::Umbraco.Cms.Web.Common.PublishedModels.VisibilityControls.GetUmbracoNaviHide(this, _publishedValueFallback);
}
Expand Down
Loading

0 comments on commit 7e7cf90

Please sign in to comment.