Skip to content
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

Show ThemeToggler on supported themes only #17243

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/OrchardCore.Modules/OrchardCore.Themes/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.Admin.Models;
using OrchardCore.Deployment;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.DisplayManagement.Theming;
Expand Down Expand Up @@ -31,7 +30,6 @@ public override void ConfigureServices(IServiceCollection services)
services.AddScoped<IThemeService, ThemeService>();
services.AddScoped<ThemeTogglerService>();
services.AddDeployment<ThemesDeploymentSource, ThemesDeploymentStep, ThemesDeploymentStepDriver>();
services.AddDisplayDriver<Navbar, ToggleThemeNavbarDisplayDriver>();
services.AddDisplayDriver<ThemeEntry, ThemeEntryDisplayDriver>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using OrchardCore.DisplayManagement.Views;
using OrchardCore.Settings;

namespace OrchardCore.Themes.Drivers;
namespace OrchardCore.Themes.TheAdmin.Drivers;

public sealed class ToggleThemeNavbarDisplayDriver : DisplayDriver<Navbar>
{
Expand All @@ -18,7 +18,6 @@ public override IDisplayResult Display(Navbar model, BuildDisplayContext context
{
return View("ToggleTheme", model)
.RenderWhen(async () => (await _siteService.GetSettingsAsync<AdminSettings>()).DisplayThemeToggler)
.Location("Detail", "Content:10")
.Location("DetailAdmin", "Content:10");
}
}
4 changes: 4 additions & 0 deletions src/OrchardCore.Themes/TheAdmin/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.Admin.Models;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.DisplayManagement.Html;
using OrchardCore.Environment.Shell.Configuration;
using OrchardCore.Modules;
using OrchardCore.Themes.TheAdmin.Drivers;

namespace OrchardCore.Themes.TheAdmin;

Expand All @@ -16,6 +19,7 @@ public Startup(IShellConfiguration configuration)

public override void ConfigureServices(IServiceCollection services)
{
services.AddDisplayDriver<Navbar, ToggleThemeNavbarDisplayDriver>();
services.AddResourceConfiguration<ResourceManagementOptionsConfiguration>();
services.Configure<TheAdminThemeOptions>(_configuration.GetSection("TheAdminTheme:StyleSettings"));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using OrchardCore.Admin.Models;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.DisplayManagement.Views;
using OrchardCore.Themes.Services;

namespace TheTheme.Drivers;

public sealed class ToggleThemeNavbarDisplayDriver : DisplayDriver<Navbar>
{
private readonly ISiteThemeService _siteThemeService;

public ToggleThemeNavbarDisplayDriver(ISiteThemeService siteThemeService)
{
_siteThemeService = siteThemeService;
}

public override IDisplayResult Display(Navbar model, BuildDisplayContext context)
{
return View("ToggleTheme", model)
.RenderWhen(async () => await _siteThemeService.GetSiteThemeNameAsync() == "TheTheme")
.Location("Detail", "Content:10");
}
}
6 changes: 5 additions & 1 deletion src/OrchardCore.Themes/TheTheme/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.Admin.Models;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.Modules;
using TheTheme.Drivers;

namespace OrchardCore.Themes.TheTheme;

public sealed class Startup : StartupBase
{
public override void ConfigureServices(IServiceCollection serviceCollection)
public override void ConfigureServices(IServiceCollection services)
{
services.AddDisplayDriver<Navbar, ToggleThemeNavbarDisplayDriver>();
}
}
Loading