Skip to content

Commit

Permalink
feature/promote-nightly (#30)
Browse files Browse the repository at this point in the history
* Added Blazor configuration, and feature to promote Nightly when in production, and production when in Nightly.

* Fixed launch settings for environments.
  • Loading branch information
PolygeneLubricants authored Dec 31, 2023
1 parent d1251a9 commit 60c984d
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace PlanningPoker.Client.Configuration
{
public class NextEnvironmentConfiguration
{
public const string Path = "UI:Features:NextEnvironment";

public string RichText { get; set; }
}
}
17 changes: 16 additions & 1 deletion src/PlanningPoker.Client/Pages/Index.razor
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
@page "/"
@using Microsoft.AspNetCore.SignalR.Client
@using Microsoft.Extensions.Options
@using PlanningPoker.Client.Configuration
@using PlanningPoker.Client.Utilities
@using PlanningPoker.Hub.Client
@using PlanningPoker.Hub.Client.Abstractions
@using PlanningPoker.Hub.Client.Abstractions.ViewModels
@inject NavigationManager NavigationManager
@inject IJSRuntime JSRuntime
@inject IOptions<NextEnvironmentConfiguration> NextEnvironmentConfiguration

@if (string.IsNullOrWhiteSpace(CreatedServerAddress))
{
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-md-12">
<h2>Welcome to Just Planning Poker!</h2>
<h2>Welcome to Just Planning Poker!</h2>
<p>This is just a planning poker tool. No sign-up, no gathered user data, no fees.</p>
<p>The planning room has a default set of cards, but you can modify this set in the input below. Separate card values with ',' (comma).</p>
<div class="form-group">
Expand Down Expand Up @@ -48,6 +51,18 @@
</div>
</div>
</div>
@if (NextEnvironmentConfiguration?.Value != null && !string.IsNullOrWhiteSpace(NextEnvironmentConfiguration.Value.RichText))
{
<div class="card">
<div class="card-body">
<div class="row">
<div class="col">
<p>@((MarkupString)NextEnvironmentConfiguration.Value.RichText)</p>
</div>
</div>
</div>
</div>
}
}
else
{
Expand Down
1 change: 1 addition & 0 deletions src/PlanningPoker.Client/PlanningPoker.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<PackageReference Include="Blazored.SessionStorage" Version="2.4.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.10" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="7.0.10" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
7 changes: 5 additions & 2 deletions src/PlanningPoker.Client/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.Threading.Tasks;
using Blazored.SessionStorage;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using PlanningPoker.Client.Configuration;
using PlanningPoker.Client.Storage;

namespace PlanningPoker.Client
Expand All @@ -12,14 +14,15 @@ public static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.Services.AddBlazoredSessionStorage();
RegisterDependencies(builder.Services);
RegisterDependencies(builder.Services, builder.Configuration);
builder.RootComponents.Add<App>("app");
await builder.Build().RunAsync();
}

private static IServiceCollection RegisterDependencies(IServiceCollection services)
private static IServiceCollection RegisterDependencies(IServiceCollection services, IConfiguration configuration)
{
services.AddTransient<IServerSessionManager, ServerSessionManager>();
services.Configure<NextEnvironmentConfiguration>(configuration.GetSection(NextEnvironmentConfiguration.Path));
return services;
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/PlanningPoker.Client/wwwroot/appsettings.Nightly.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"UI": {
"Features": {
"NextEnvironment": {
"RichText": "Go to JustPlanningPoker <a href=\"https://justplanningpoker.com\">prod</a>, to use the stable release."
}
}
}
}
9 changes: 9 additions & 0 deletions src/PlanningPoker.Client/wwwroot/appsettings.Production.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"UI": {
"Features": {
"NextEnvironment": {
"RichText": "Go to JustPlanningPoker <a href=\"https://nightly.justplanningpoker.com\">Nightly</a>, for experimental features!"
}
}
}
}
2 changes: 2 additions & 0 deletions src/PlanningPoker.Client/wwwroot/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
12 changes: 12 additions & 0 deletions src/PlanningPoker.Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ public static IWebHost BuildWebHost(string[] args)
.AddCommandLine(args)
.Build())
.UseStartup<Startup>()

// Leaving commented code in the codebase is not a good idea,
// but I think this warrants an exception.
// Blazor does not allow local debugging where you set the ASPNETCORE_ENVIRONMENT to anything
// other than Development: https://github.com/dotnet/aspnetcore/issues/43110#issuecomment-1206573745.
// In order to test environment-specific configuration,
// the below line has to be added.
// Note, this line should *not* be added in production code,
// as it enables locally run code to get static assets from the build output.
// We don't want that behavior on an environment running on published files.
//.UseStaticWebAssets() // <-- This is the line to comment in to test environments.
// End comment block.
.Build();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/PlanningPoker.Server/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
app.UseWebAssemblyDebugging();
}

app.UseStaticFiles();
app.UseBlazorFrameworkFiles();
app.UseStaticFiles();

app.UseRouting();

Expand Down

0 comments on commit 60c984d

Please sign in to comment.