Skip to content

Commit

Permalink
Merge pull request #1 from nwestfall/feature/net5
Browse files Browse the repository at this point in the history
Updated to .NET 5
  • Loading branch information
nwestfall authored Mar 14, 2021
2 parents 241c4b6 + b07d3f9 commit 84f9862
Show file tree
Hide file tree
Showing 48 changed files with 1,761 additions and 455 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on:
pull_request:
branches: [main, master]
types: [opened, synchronize, reopened, edited]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- name: Install dependencies
run: dotnet restore src/BlazorTenant/BlazorTenant.csproj
- name: Build
run: dotnet build --configuration Release --no-restore src/BlazorTenant/BlazorTenant.csproj
- name: Test
uses: zyborg/dotnet-tests-report@v1
with:
project_path: test/BlazorTenant.Tests
report_name: blazor_tenant_tests
report_title: Blazor Tenant Tests
github_token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/dotnet-core.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: .NET Core
name: Release

on:
push:
Expand All @@ -16,7 +16,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.101
dotnet-version: 5.0.x
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/\v/}
Expand Down
7 changes: 3 additions & 4 deletions example/BlazorTenant.Example/App.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<CascadingAuthenticationState>
<MultiTenantRouter AppAssembly="@typeof(Program).Assembly">
<CascadingAuthenticationState>
<MultiTenantRouter AppAssembly="@typeof(Program).Assembly" PreferExactMatches="@true">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
Expand All @@ -14,5 +14,4 @@
</LayoutView>
</NoTenant>
</MultiTenantRouter>
</CascadingAuthenticationState>

</CascadingAuthenticationState>
14 changes: 5 additions & 9 deletions example/BlazorTenant.Example/BlazorTenant.Example.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<RazorLangVersion>3.0</RazorLangVersion>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="3.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
<PackageReference Include="System.Net.Http.Json" Version="3.2.0-rc1.20217.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.4" PrivateAssets="all" />
<PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
22 changes: 0 additions & 22 deletions example/BlazorTenant.Example/Pages/Authentication.razor

This file was deleted.

2 changes: 1 addition & 1 deletion example/BlazorTenant.Example/Pages/Counter.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@page "/counter"
@page "/counter"

<h1>Counter</h1>

Expand Down
2 changes: 1 addition & 1 deletion example/BlazorTenant.Example/Pages/FetchData.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@page "/fetchdata"
@page "/fetchdata"
@inject HttpClient Http

<h1>Weather forecast</h1>
Expand Down
4 changes: 2 additions & 2 deletions example/BlazorTenant.Example/Pages/Index.razor
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@page "/"
@inject Tenant tenant

<h1>Hello, @tenant.Identifier!</h1>
<h1>Hello, world!</h1>

Welcome to your new app.

Expand All @@ -10,4 +10,4 @@ Welcome to your new app.
@foreach(var prop in tenant.Parameters)
{
<p><b>@prop.Key:</b> @prop.Value</p>
}
}
5 changes: 2 additions & 3 deletions example/BlazorTenant.Example/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
using Microsoft.AspNetCore.Components.Authorization;
Expand All @@ -23,7 +22,7 @@ public static async Task Main(string[] args)
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("app");

builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

var store = new InMemoryTenantStore();
var tenantSection = builder.Configuration.GetSection("Tenants");
Expand Down Expand Up @@ -57,7 +56,7 @@ public static async Task Main(string[] args)
options.ProviderOptions.DefaultScopes.Clear();
options.ProviderOptions.DefaultScopes.Add("openid profile offline_access api");
});

var build = builder.Build();
_sp = build.Services;
build.Services.AddServiceProviderToMultiTenantRoutes();
Expand Down
5 changes: 3 additions & 2 deletions example/BlazorTenant.Example/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:59832",
"sslPort": 44336
"applicationUrl": "http://localhost:45311",
"sslPort": 44360
}
},
"profiles": {
Expand All @@ -18,6 +18,7 @@
},
"BlazorTenant.Example": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
Expand Down
27 changes: 13 additions & 14 deletions example/BlazorTenant.Example/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
@inherits LayoutComponentBase
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
@inherits LayoutComponentBase
@inject Tenant tenant
@inject NavigationManager Navigation
@inject SignOutSessionStateManager SignOutManager

<div class="sidebar">
<NavMenu />
</div>

<div class="main">
<div class="top-row px-4">
<a href="http://blazor.net" target="_blank" class="ml-md-auto">@(tenant?.Identifier ?? "N/A")</a>
<div class="page">
<div class="sidebar">
<NavMenu />
</div>

<div class="content px-4">
@Body
<div class="main">
<div class="top-row px-4">
<a href="http://blazor.net" target="_blank" class="ml-md-auto">@(tenant?.Identifier ?? "N/A")</a>
</div>

<div class="content px-4">
@Body
</div>
</div>
</div>
</div>
70 changes: 70 additions & 0 deletions example/BlazorTenant.Example/Shared/MainLayout.razor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
.page {
position: relative;
display: flex;
flex-direction: column;
}

.main {
flex: 1;
}

.sidebar {
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
}

.top-row {
background-color: #f7f7f7;
border-bottom: 1px solid #d6d5d5;
justify-content: flex-end;
height: 3.5rem;
display: flex;
align-items: center;
}

.top-row ::deep a, .top-row .btn-link {
white-space: nowrap;
margin-left: 1.5rem;
}

.top-row a:first-child {
overflow: hidden;
text-overflow: ellipsis;
}

@media (max-width: 640.98px) {
.top-row:not(.auth) {
display: none;
}

.top-row.auth {
justify-content: space-between;
}

.top-row a, .top-row .btn-link {
margin-left: 0;
}
}

@media (min-width: 641px) {
.page {
flex-direction: row;
}

.sidebar {
width: 250px;
height: 100vh;
position: sticky;
top: 0;
}

.top-row {
position: sticky;
top: 0;
z-index: 1;
}

.main > div {
padding-left: 2rem !important;
padding-right: 1.5rem !important;
}
}
62 changes: 62 additions & 0 deletions example/BlazorTenant.Example/Shared/NavMenu.razor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
.navbar-toggler {
background-color: rgba(255, 255, 255, 0.1);
}

.top-row {
height: 3.5rem;
background-color: rgba(0,0,0,0.4);
}

.navbar-brand {
font-size: 1.1rem;
}

.oi {
width: 2rem;
font-size: 1.1rem;
vertical-align: text-top;
top: -2px;
}

.nav-item {
font-size: 0.9rem;
padding-bottom: 0.5rem;
}

.nav-item:first-of-type {
padding-top: 1rem;
}

.nav-item:last-of-type {
padding-bottom: 1rem;
}

.nav-item ::deep a {
color: #d7d7d7;
border-radius: 4px;
height: 3rem;
display: flex;
align-items: center;
line-height: 3rem;
}

.nav-item ::deep a.active {
background-color: rgba(255,255,255,0.25);
color: white;
}

.nav-item ::deep a:hover {
background-color: rgba(255,255,255,0.1);
color: white;
}

@media (min-width: 641px) {
.navbar-toggler {
display: none;
}

.collapse {
/* Never collapse the sidebar for wide screens */
display: block;
}
}
11 changes: 0 additions & 11 deletions example/BlazorTenant.Example/Shared/RedirectToLogin.razor

This file was deleted.

4 changes: 2 additions & 2 deletions example/BlazorTenant.Example/Shared/SurveyPrompt.razor
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<div class="alert alert-secondary mt-4" role="alert">
<div class="alert alert-secondary mt-4" role="alert">
<span class="oi oi-pencil mr-2" aria-hidden="true"></span>
<strong>@Title</strong>

<span class="text-nowrap">
Please take our
<a target="_blank" class="font-weight-bold" href="https://go.microsoft.com/fwlink/?linkid=2127014">brief survey</a>
<a target="_blank" class="font-weight-bold" href="https://go.microsoft.com/fwlink/?linkid=2137916">brief survey</a>
</span>
and tell us what you think.
</div>
Expand Down
1 change: 1 addition & 0 deletions example/BlazorTenant.Example/_Imports.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.AspNetCore.Components.WebAssembly.Http
@using Microsoft.AspNetCore.Components.Authorization
@using Microsoft.JSInterop
Expand Down
Loading

0 comments on commit 84f9862

Please sign in to comment.