Skip to content

Commit fd58121

Browse files
committed
feat(button): refactor
1 parent ac769e1 commit fd58121

File tree

67 files changed

+334
-280
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+334
-280
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,5 @@ CHANGELOG.md
193193
/TELBlazor.Components/wwwroot/css/nhsuk.css
194194
/TELBlazor.Components/wwwroot/css/nhsuk.css
195195
/TELBlazor.Components.ShowCase.Shared/wwwroot/css/nhsuk.css
196+
/TELBlazor.Components.ShowCase.E2ETests/Reports/*.zip
197+

Directory.Build.props

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
<Import Project="PackageSettings.props" />
44
<Import Project="PackageSettings.props.local" Condition="Exists('PackageSettings.props.local')"/>
55
<PropertyGroup>
6-
<!-- coverlet.msbuild, specifically msbuild props -->
6+
7+
<!-- coverlet.msbuild, specifically msbuild props here we set when cicd testing fails on coverage -->
78
<CollectCoverage>true</CollectCoverage>
89
<CoverletOutputFormat>cobertura</CoverletOutputFormat>
910
<Threshold>50</Threshold>
@@ -12,7 +13,7 @@
1213
<ThresholdBranch>50</ThresholdBranch>
1314
<ThresholdMethod>50</ThresholdMethod>
1415

15-
<!-- Additional properties carried over from runsettings -->
16+
<!-- What to test -->
1617
<Include>[TELBlazor.Components]*</Include>
1718
<ExcludeByAttribute>ExcludeFromCodeCoverage</ExcludeByAttribute>
1819
<ExcludeByFile>**/Program.cs,**/Components/TestComponents/*.*</ExcludeByFile>

PackageSettings.props

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<!--Overwrite with PackageSettings.props.local-->
34
<PropertyGroup>
4-
<!-- Define the output path where the package will be stored -->
5-
6-
<!-- being set in csproj directly in cicd at the moment -->
5+
6+
<!-- Define the output path where the package will be stored -->
77
<NupkgOutputPath>$(NupkgOutputPath)</NupkgOutputPath>
8+
9+
<!--can be local folder-->
810
<TELBlazorPackageSource>$(TELBlazorPackageSource)</TELBlazorPackageSource>
9-
11+
12+
<!--Use project reference for faster iteration in development-->
1013
<UseTELBlazorComponentsProjectReference Condition="'$(UseTELBlazorComponentsProjectReference)' == '' ">false</UseTELBlazorComponentsProjectReference>
1114
<UseTELBlazorComponentsProjectReference Condition="'$(UseTELBlazorComponentsProjectReference)' != '' ">$(UseTELBlazorComponentsProjectReference)</UseTELBlazorComponentsProjectReference>
12-
15+
16+
<!--manually change this to build and use local packages, or add the project automated generation e.g. msbuild number-->
1317
<TELBlazorPackageVersion>$(TELBlazorPackageVersion)</TELBlazorPackageVersion>
14-
18+
19+
<!--Building the components project makes the package publish isnt needed-->
1520
<DisablePackageGeneration>$(DisablePackageGeneration)</DisablePackageGeneration>
16-
21+
22+
<!--Testing settings-->
1723
<E2ETracingEnabled Condition="'$(E2ETracingEnabled)' == ''">false</E2ETracingEnabled>
1824
<E2ETracingEnabled Condition="'$(E2ETracingEnabled)' != ''">$(E2ETracingEnabled)</E2ETracingEnabled>
1925
<HeadlessTesting Condition="'$(HeadlessTesting)' == ''">true</HeadlessTesting>
@@ -22,3 +28,4 @@
2228
</PropertyGroup>
2329

2430
</Project>
31+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
5+
<!--your local system environment variables-->
6+
<TELBlazorPackageSource>$(LocalPackagePath)</TELBlazorPackageSource>
7+
<NupkgOutputPath>$(LocalPackagePath)</NupkgOutputPath>
8+
9+
<!--for faster iteration-->
10+
<UseTELBlazorComponentsProjectReference>true</UseTELBlazorComponentsProjectReference>
11+
12+
<!--manually change this to build and use local packages, or add the project automated generation e.g. msbuild number-->
13+
<TELBlazorPackageVersion>10.9.9</TELBlazorPackageVersion>
14+
15+
<!--Building the components project makes the package publish isnt needed-->
16+
<DisablePackageGeneration>true</DisablePackageGeneration>
17+
18+
<!--Testing settings-->
19+
<E2ETracingEnabled>true</E2ETracingEnabled>
20+
<HeadlessTesting>true</HeadlessTesting>
21+
22+
</PropertyGroup>
23+
</Project>

TELBlazor.Components.ShowCase.E2ETests.WasmServerHost/TELBlazor.Components.ShowCase.E2ETests.WasmServerHost.Client/Program.cs

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,40 @@
1+
// Microsoft namespaces
2+
using Microsoft.AspNetCore.Components;
13
using Microsoft.AspNetCore.Components.Web;
24
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
5+
using Microsoft.Extensions.DependencyInjection;
6+
using Microsoft.Extensions.Http;
7+
using Microsoft.Extensions.Logging;
8+
using Microsoft.Extensions.Options;
9+
10+
// Serilog core (used via appsettings, do not delete even if vs marks not in use)
11+
using Serilog;
12+
using Serilog.Configuration;
313
using Serilog.Core;
414
using Serilog.Events;
5-
using Serilog;
6-
using TELBlazor.Components.Core.Configuration;
7-
using TELBlazor.Components.Core.Services.HelperServices;
8-
using TELBlazor.Components.ShowCase.Shared.Services.HelperServices;
9-
/*Are used via appsetting*/
15+
16+
// Serilog extensions and sinks (used via appsettings, do not delete even if vs marks not in use)
1017
using Serilog.Extensions.Logging;
11-
using Serilog.Configuration;
12-
using Microsoft.Extensions.Logging;
13-
using Microsoft.Extensions.DependencyInjection;
14-
using Serilog.Sinks.BrowserConsole;
1518
using Serilog.Formatting.Compact;
1619
using Serilog.Settings.Configuration;
17-
using Microsoft.Extensions.Http;
20+
using Serilog.Sinks.BrowserConsole;
1821

19-
/*qqqq setup*/
22+
// Still required server side even if not used so components dont fail
2023
using Blazored.LocalStorage;
2124

25+
// TELBlazor components
26+
using TELBlazor.Components.Core.Configuration;
27+
using TELBlazor.Components.Core.Services.HelperServices;
28+
using TELBlazor.Components.ShowCase.E2ETests.WasmServerHost;
29+
using TELBlazor.Components.ShowCase.Shared.Services.HelperServices;
30+
2231

2332
var builder = WebAssemblyHostBuilder.CreateDefault(args);
2433

2534
var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Development";
26-
Console.WriteLine($"!!!!!!!! !!!!!!!!!!!!!!! !!!!!!!!!!!!! !!!!!!!!!!!! client qqqqEnvironment: {Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}");
35+
2736
builder.Configuration.AddJsonFile($"appsettings.{environment}.json", optional: false, reloadOnChange: true);
28-
//builder.Configuration.AddJsonFile($"appsettings.{builder.HostEnvironment.Environment}.json", optional: false, reloadOnChange: true);
29-
//builder.Configuration.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
37+
3038
builder.Logging.ClearProviders();
3139
// Read default logging level from configuration
3240
var logLevelString = builder.Configuration["Serilog:MinimumLevel:Default"];
@@ -49,6 +57,7 @@
4957
//for really bad fails
5058
try
5159
{
60+
// Candidates for DI collection
5261
builder.Services.AddSingleton<ITELBlazorBaseComponentConfiguration>(sp =>
5362
{
5463
return new TELBlazorBaseComponentConfiguration
@@ -58,7 +67,7 @@
5867
};
5968
});
6069

61-
// qqqq to DI
70+
6271
builder.Services.AddBlazoredLocalStorage();
6372

6473
//Scoped because being consumed with storage where singleton doesnt survive mvc page teardown

TELBlazor.Components.ShowCase.E2ETests.WasmServerHost/TELBlazor.Components.ShowCase.E2ETests.WasmServerHost.Client/TELBlazor.Components.ShowCase.E2ETests.WasmServerHost.Client.csproj

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,31 @@
1212

1313
</PropertyGroup>
1414
<ItemGroup>
15+
<!-- Logging -->
1516
<PackageReference Include="Serilog" />
1617
<PackageReference Include="Serilog.Extensions.Logging" />
17-
<PackageReference Include="Blazored.LocalStorage" />
18-
<PackageReference Include="Microsoft.Extensions.Http" />
1918
<PackageReference Include="Serilog.Formatting.Compact" />
2019
<PackageReference Include="Serilog.Settings.Configuration" />
2120
<PackageReference Include="Serilog.Sinks.BrowserConsole" />
2221
<PackageReference Include="Serilog.Sinks.Http" />
23-
</ItemGroup>
24-
<ItemGroup>
25-
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" />
26-
</ItemGroup>
2722

28-
<ItemGroup>
29-
<ProjectReference Include="..\..\TELBlazor.Components.ShowCase.Shared\TELBlazor.Components.ShowCase.Shared.csproj" />
23+
<!-- Utilities -->
24+
<PackageReference Include="Blazored.LocalStorage" />
25+
<PackageReference Include="Microsoft.Extensions.Http" />
26+
</ItemGroup>
27+
28+
<ItemGroup>
29+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" />
30+
</ItemGroup>
31+
32+
<ItemGroup>
33+
<ProjectReference Include="..\..\TELBlazor.Components.ShowCase.Shared\TELBlazor.Components.ShowCase.Shared.csproj" />
3034
</ItemGroup>
3135

3236
<ItemGroup>
3337
<Content Update="wwwroot\appsettings.Production.json">
3438
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
3539
</Content>
3640
</ItemGroup>
37-
<!--<ItemGroup>
38-
<None Update="appsettings.ci.json">
39-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
40-
</None>
41-
</ItemGroup>-->
4241

4342
</Project>
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
11
@using Microsoft.AspNetCore.Components.Routing
22
@using Microsoft.AspNetCore.Components.Web
33
@using static Microsoft.AspNetCore.Components.Web.RenderMode
4-
5-
@* @using System.Net.Http
6-
@using System.Net.Http.Json
7-
@using Microsoft.AspNetCore.Components.Forms
8-
@using Microsoft.AspNetCore.Components.Web.Virtualization
9-
@using Microsoft.JSInterop
10-
@using TELBlazor.Components.ShowCase.E2ETests.WasmServerHost.Client
11-
qqqq rcl should hanle all this stuff*@

TELBlazor.Components.ShowCase.E2ETests.WasmServerHost/TELBlazor.Components.ShowCase.E2ETests.WasmServerHost/App.razor

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<link rel="icon" type="image/png" href="_content/TELBlazor.Components.ShowCase.Shared/favicon.png" />
88
<title>TELBlazor.Components.ShowCase.E2ETests</title>
9-
@* <base href="/" /> qqqq why comment out *@
10-
@*intention is to get nhsuk from shared and the scoped css from it too i expect we could have piped them together but dont want to
11-
qqqq need to check getting all css *@
9+
@* <base href="/" /> requires programmatic route insertion *@
10+
1211

1312
<!--scoped css from the nuget package via shared pages project reference-->
1413
<link rel="stylesheet" href="TELBlazor.Components.ShowCase.E2ETests.WasmServerHost.styles.css" />

TELBlazor.Components.ShowCase.E2ETests.WasmServerHost/TELBlazor.Components.ShowCase.E2ETests.WasmServerHost/Program.cs

Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
1-
using Serilog.Core;
2-
using Serilog.Events;
3-
using Serilog;
4-
using TELBlazor.Components.Core.Configuration;
5-
using TELBlazor.Components.Core.Services.HelperServices;
6-
using TELBlazor.Components.ShowCase.E2ETests.WasmServerHost;
7-
using TELBlazor.Components.ShowCase.Shared.Services.HelperServices;
8-
9-
using Microsoft.Extensions.Http;
10-
11-
1+
// Microsoft namespaces
2+
using Microsoft.AspNetCore.Components;
123
using Microsoft.AspNetCore.Components.Web;
134
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
14-
using Microsoft.Extensions.Options;
155
using Microsoft.Extensions.DependencyInjection;
16-
/*Are used via appsetting*/
17-
using Serilog.Extensions.Logging;
18-
using Serilog.Configuration;
6+
using Microsoft.Extensions.Http;
197
using Microsoft.Extensions.Logging;
20-
using Microsoft.Extensions.DependencyInjection;
21-
using Serilog.Sinks.BrowserConsole;
8+
using Microsoft.Extensions.Options;
9+
10+
// Serilog core (used via appsettings, do not delete even if vs marks not in use)
11+
using Serilog;
12+
using Serilog.Configuration;
13+
using Serilog.Core;
14+
using Serilog.Events;
15+
16+
// Serilog extensions and sinks (used via appsettings, do not delete even if vs marks not in use)
17+
using Serilog.Extensions.Logging;
2218
using Serilog.Formatting.Compact;
2319
using Serilog.Settings.Configuration;
24-
using Microsoft.AspNetCore.Components;
25-
/*qqqq setup*/
20+
using Serilog.Sinks.BrowserConsole;
21+
22+
// Still required server side even if not used so components dont fail
2623
using Blazored.LocalStorage;
2724

25+
// TELBlazor components
26+
using TELBlazor.Components.Core.Configuration;
27+
using TELBlazor.Components.Core.Services.HelperServices;
28+
using TELBlazor.Components.ShowCase.E2ETests.WasmServerHost;
29+
using TELBlazor.Components.ShowCase.Shared.Services.HelperServices;
2830

2931
var builder = WebApplication.CreateBuilder(args);
3032

@@ -57,39 +59,28 @@
5759
// Add services to the container.
5860
builder.Services.AddRazorComponents()
5961
.AddInteractiveWebAssemblyComponents();
60-
//qqqq for di?
61-
builder.Services.AddBlazoredLocalStorage();
62-
63-
//qqqq cant remember what for
64-
//builder.Services.AddHttpContextAccessor();
65-
//builder.Services.AddSession(options =>
66-
//{
6762

68-
// options.IdleTimeout = TimeSpan.FromMinutes(20); // Set the timeout for the session
69-
// options.Cookie.HttpOnly = true; // Session cookie is only accessible via HTTP
70-
// options.Cookie.IsEssential = true; // Session cookie is essential for application
71-
//});
63+
// Future candidates for DI collection
64+
builder.Services.AddBlazoredLocalStorage();
7265

7366
builder.Services.AddSingleton<ITELBlazorBaseComponentConfiguration>(provider =>
7467
{
75-
// qqqq cant rmeember purpose
76-
//In here we would get our appsettings etc and configure - but then we have an object to pass it
77-
//var httpContextAccessor = provider.GetRequiredService<IHttpContextAccessor>();
78-
////For this to work well for blazor pages as well we would probably want to set up session storage (which takes js anyway to set up and most blazor application use it i presume)
79-
//var session = httpContextAccessor.HttpContext?.Session;
80-
81-
8268
return new TELBlazorBaseComponentConfiguration
8369
{
8470
JSEnabled = true, //if we are inject the client then it is true
8571
HostType = $"{builder.Configuration["Properties:Environment"]} {builder.Configuration["Properties:Application"]}"
8672
};
8773
});
74+
8875
//Scoped because being consumed with storage where singleton doesnt survive mvc page teardown
8976
builder.Services.AddScoped<LoggingLevelSwitch>(sp => levelSwitch);
9077
builder.Services.AddScoped<ILogLevelSwitcherService, SerilogLogLevelSwitcherService>();
78+
79+
9180
var app = builder.Build();
92-
app.UseSerilogRequestLogging();
81+
// This is less blazor more endpoint logging
82+
//app.UseSerilogRequestLogging();
83+
9384
// Configure the HTTP request pipeline.
9485
if (app.Environment.IsDevelopment())
9586
{
@@ -107,6 +98,7 @@
10798
app.UseStaticFiles();
10899
app.UseAntiforgery();
109100

101+
//We want everything from the blazor project so we add by assembly and put all using statements in the imports
110102
app.MapRazorComponents<App>()
111103
.AddInteractiveWebAssemblyRenderMode()
112104
.AddAdditionalAssemblies(typeof(TELBlazor.Components.ShowCase.E2ETests.WasmServerHost.Client._Imports).Assembly)

TELBlazor.Components.ShowCase.E2ETests.WasmServerHost/TELBlazor.Components.ShowCase.E2ETests.WasmServerHost/TELBlazor.Components.ShowCase.E2ETests.WasmServerHost.csproj

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@
2828
<ProjectReference Include="..\TELBlazor.Components.ShowCase.E2ETests.WasmServerHost.Client\TELBlazor.Components.ShowCase.E2ETests.WasmServerHost.Client.csproj" />
2929
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" />
3030
</ItemGroup>
31-
<!--<ItemGroup>
32-
<None Update="appsettings.ci.json">
33-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
34-
</None>
35-
</ItemGroup>-->
31+
3632
<ItemGroup>
3733
<Folder Include="Logs\" />
3834
</ItemGroup>

0 commit comments

Comments
 (0)