Skip to content

Commit

Permalink
chore: make content app optional
Browse files Browse the repository at this point in the history
  • Loading branch information
bielu1 committed Apr 2, 2024
1 parent e81682f commit 87cc495
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class BieluCdnOptions
{
public bool DevMode { get; set; }
public bool Auditing { get; set; } = true;
public bool DisableContentApp = true;
public bool Preview { get; set; }
[SchemaPrefix]
[JsonIgnore]
Expand Down
18 changes: 17 additions & 1 deletion src/bielu.Umbraco.Cdn.Core/ContentApp/BieluCDNApp.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
using Umbraco.Cms.Core.Models;
using bielu.Umbraco.Cdn.Core.Configuration;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Cms.Core.Models.Membership;

namespace bielu.Umbraco.Cdn.Core.ContentApp;

public class BieluCdnApp : IContentAppFactory
{
private BieluCdnOptions _options;

public BieluCdnApp(IOptionsMonitor<BieluCdnOptions> options)
{
_options = options.CurrentValue;
options.OnChange(x =>
{
_options = x;
});

}

public global::Umbraco.Cms.Core.Models.ContentEditing.ContentApp? GetContentAppFor(object source, IEnumerable<IReadOnlyUserGroup> userGroups)
{
if(_options.DisableContentApp)
return null;
// Can implement some logic with userGroups if needed
// Allowing us to display the content app with some restrictions for certain groups
if (userGroups.All(x => x.Alias.ToLowerInvariant() != global::Umbraco.Cms.Core.Constants.Security.AdminGroupAlias))
Expand Down

0 comments on commit 87cc495

Please sign in to comment.