Skip to content

Commit

Permalink
feat: .NET 8 version
Browse files Browse the repository at this point in the history
BREAKING CHANGE: .NET 8 only
  • Loading branch information
SonicGD committed Dec 7, 2023
1 parent 9f28184 commit 302cee1
Show file tree
Hide file tree
Showing 68 changed files with 685 additions and 358 deletions.
30 changes: 30 additions & 0 deletions Sitko.Blockly.sln
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sitko.Blockly.HtmlParser.Te
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sitko.Blockly.MudBlazor", "src\Sitko.Blockly.MudBlazor\Sitko.Blockly.MudBlazor.csproj", "{4B682521-01D4-4A3E-9F15-16DBA1FB91C9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sitko.Blockly.Demo.Client", "apps\Sitko.Blockly.Demo.Client\Sitko.Blockly.Demo.Client.csproj", "{4C374AF7-0748-4915-988D-0338996B6AF9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sitko.Blockly.Data", "apps\Sitko.Blockly.Data\Sitko.Blockly.Data.csproj", "{88B081A7-F838-4E90-BB2E-581BAFAECEA6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -175,6 +179,30 @@ Global
{4B682521-01D4-4A3E-9F15-16DBA1FB91C9}.Release|x64.Build.0 = Release|Any CPU
{4B682521-01D4-4A3E-9F15-16DBA1FB91C9}.Release|x86.ActiveCfg = Release|Any CPU
{4B682521-01D4-4A3E-9F15-16DBA1FB91C9}.Release|x86.Build.0 = Release|Any CPU
{4C374AF7-0748-4915-988D-0338996B6AF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4C374AF7-0748-4915-988D-0338996B6AF9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4C374AF7-0748-4915-988D-0338996B6AF9}.Debug|x64.ActiveCfg = Debug|Any CPU
{4C374AF7-0748-4915-988D-0338996B6AF9}.Debug|x64.Build.0 = Debug|Any CPU
{4C374AF7-0748-4915-988D-0338996B6AF9}.Debug|x86.ActiveCfg = Debug|Any CPU
{4C374AF7-0748-4915-988D-0338996B6AF9}.Debug|x86.Build.0 = Debug|Any CPU
{4C374AF7-0748-4915-988D-0338996B6AF9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4C374AF7-0748-4915-988D-0338996B6AF9}.Release|Any CPU.Build.0 = Release|Any CPU
{4C374AF7-0748-4915-988D-0338996B6AF9}.Release|x64.ActiveCfg = Release|Any CPU
{4C374AF7-0748-4915-988D-0338996B6AF9}.Release|x64.Build.0 = Release|Any CPU
{4C374AF7-0748-4915-988D-0338996B6AF9}.Release|x86.ActiveCfg = Release|Any CPU
{4C374AF7-0748-4915-988D-0338996B6AF9}.Release|x86.Build.0 = Release|Any CPU
{88B081A7-F838-4E90-BB2E-581BAFAECEA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{88B081A7-F838-4E90-BB2E-581BAFAECEA6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{88B081A7-F838-4E90-BB2E-581BAFAECEA6}.Debug|x64.ActiveCfg = Debug|Any CPU
{88B081A7-F838-4E90-BB2E-581BAFAECEA6}.Debug|x64.Build.0 = Debug|Any CPU
{88B081A7-F838-4E90-BB2E-581BAFAECEA6}.Debug|x86.ActiveCfg = Debug|Any CPU
{88B081A7-F838-4E90-BB2E-581BAFAECEA6}.Debug|x86.Build.0 = Debug|Any CPU
{88B081A7-F838-4E90-BB2E-581BAFAECEA6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{88B081A7-F838-4E90-BB2E-581BAFAECEA6}.Release|Any CPU.Build.0 = Release|Any CPU
{88B081A7-F838-4E90-BB2E-581BAFAECEA6}.Release|x64.ActiveCfg = Release|Any CPU
{88B081A7-F838-4E90-BB2E-581BAFAECEA6}.Release|x64.Build.0 = Release|Any CPU
{88B081A7-F838-4E90-BB2E-581BAFAECEA6}.Release|x86.ActiveCfg = Release|Any CPU
{88B081A7-F838-4E90-BB2E-581BAFAECEA6}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{0367FAD9-C3FD-4E07-9CBE-103A17666A1D} = {DA312F56-FDB4-4853-A7A1-A8B2527399FC}
Expand All @@ -187,5 +215,7 @@ Global
{33DD2E49-9A55-4648-8D97-81FB4FDFB4CC} = {DA312F56-FDB4-4853-A7A1-A8B2527399FC}
{C46F1161-7FFC-47DC-9140-463A02FD6DEC} = {BE2C5E4A-BFBD-4645-AE0A-8B57A9EC1CB2}
{4B682521-01D4-4A3E-9F15-16DBA1FB91C9} = {DA312F56-FDB4-4853-A7A1-A8B2527399FC}
{4C374AF7-0748-4915-988D-0338996B6AF9} = {32D6C989-DF2C-4C06-BD48-C322E72888B9}
{88B081A7-F838-4E90-BB2E-581BAFAECEA6} = {32D6C989-DF2C-4C06-BD48-C322E72888B9}
EndGlobalSection
EndGlobal
19 changes: 19 additions & 0 deletions apps/Sitko.Blockly.Data/Entities/Post.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.ComponentModel.DataAnnotations;
using Sitko.Core.Repository;

namespace Sitko.Blockly.Data.Entities;

public abstract record BaseEntityRecord : EntityRecord<Guid>
{
public override Guid Id { get; set; } = Guid.NewGuid();
public DateTimeOffset DateAdded { get; set; } = DateTimeOffset.UtcNow;
public DateTimeOffset DateUpdated { get; set; } = DateTimeOffset.UtcNow;
public object GetId() => Id;
}

public record Post : BaseEntityRecord
{
public string Title { get; set; } = "";
public List<ContentBlock> Blocks { get; set; } = new();
public List<ContentBlock> SecondaryBlocks { get; set; } = new();
}
16 changes: 16 additions & 0 deletions apps/Sitko.Blockly.Data/Sitko.Blockly.Data.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Sitko.Core.Repository" Version="11.0.0-beta.4"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Sitko.Blockly\Sitko.Blockly.csproj" />
</ItemGroup>
</Project>
3 changes: 3 additions & 0 deletions apps/Sitko.Blockly.Data/TestMetadata.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace Sitko.Blockly.Data;

public record TestMetadata(Guid Id, string Type);
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Sitko.Blockly.Data.Entities;
using Sitko.Core.Repository.Remote;

namespace Sitko.Blockly.Demo.Client.Data.Repositories;

public class PostRemoteRepository : BaseRemoteRepository<Post, Guid>
{
public PostRemoteRepository(RemoteRepositoryContext<Post, Guid> repositoryContext) : base(repositoryContext)
{
}
}
34 changes: 34 additions & 0 deletions apps/Sitko.Blockly.Demo.Client/Layout/MainAppDrawerBar.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@inject IJSRuntime JSRuntime
<MudAppBar>
<MudIconButton Icon="@Icons.Material.Filled.Menu" Color="Color.Inherit" Edge="Edge.Start" OnClick="@((e) => ToggleDrawer())"/>
My Application
</MudAppBar>
<MudDrawer Class="mud-drawer-fixed" Open=_isDrawerOpen>
<NavMenu />
</MudDrawer>

@code {
private bool _isDrawerOpen = true;
private bool _shouldHandleDrawerToggled = false;
private IJSObjectReference? _jsModule;

void ToggleDrawer()
{
_isDrawerOpen = !_isDrawerOpen;
_shouldHandleDrawerToggled = true;
}

protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
_jsModule = await JSRuntime.InvokeAsync<IJSObjectReference>("import", "./Layout/MainAppDrawerBar.razor.js");
}
if (_shouldHandleDrawerToggled)
{
await _jsModule!.InvokeVoidAsync("HandleDrawerToggled", _isDrawerOpen);
_shouldHandleDrawerToggled = false;
}
}

}
11 changes: 11 additions & 0 deletions apps/Sitko.Blockly.Demo.Client/Layout/MainAppDrawerBar.razor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//MainAppDrawerBar.razor.js
export function HandleDrawerToggled(isOpen) {
const layoutElement = document.querySelector(".mud-layout");
if (isOpen) {
layoutElement.classList.replace("mud-drawer-close-responsive-md-left", "mud-drawer-open-responsive-md-left");
console.log("Open");
} else {
layoutElement.classList.replace("mud-drawer-open-responsive-md-left", "mud-drawer-close-responsive-md-left");
console.log("Close");
}
}
58 changes: 58 additions & 0 deletions apps/Sitko.Blockly.Demo.Client/Layout/PageLayout.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
@using Sitko.Core.App
<PageTitle>@PageTitle</PageTitle>
<MudMainContent>
<MudHidden Breakpoint="Breakpoint.SmAndDown">
@if (Extra is not null || Breadcrumbs.Count > 0)
{
<MudToolBar DisableGutters="true" Class="px-4">
<MudBreadcrumbs Items="Breadcrumbs"></MudBreadcrumbs>
@if (Extra is not null)
{
<MudSpacer/>
@Extra
}
</MudToolBar>
}
</MudHidden>
@if (!string.IsNullOrEmpty(Title) || !string.IsNullOrEmpty(Description))
{
<MudContainer MaxWidth="MaxWidth.False" Class="mb-10">
@if (!string.IsNullOrEmpty(Title))
{
<MudText Typo="Typo.h3" Class="mb-2">@Title</MudText>
}
@if (!string.IsNullOrEmpty(Description))
{
<MudText Typo="Typo.subtitle1">@Description</MudText>
}
</MudContainer>
}
<MudContainer MaxWidth="MaxWidth.False" Class="pb-10">
@ChildContent
</MudContainer>
</MudMainContent>

@code{

[Parameter] public RenderFragment? Extra { get; set; }

[Parameter] public List<BreadcrumbItem> Breadcrumbs { get; set; } = new();

[Parameter] public string Title { get; set; } = "";

private string PageTitle
{
get
{
var prefix = $" {PageTitleSeparator} {ApplicationContext.Name}";
return $"{Title}{prefix}";
}
}

[Parameter] public string Description { get; set; } = "";
[Parameter] public string PageTitleSeparator { get; set; } = "/";
[Inject] protected IApplicationContext ApplicationContext { get; set; } = null!;

[EditorRequired] [Parameter] public RenderFragment ChildContent { get; set; } = null!;

}
6 changes: 6 additions & 0 deletions apps/Sitko.Blockly.Demo.Client/Pages/Add.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@page "/Posts/Add"
@inherits BaseComponent
@rendermode InteractiveAuto
<PageLayout Title="@LocalizationProvider["Add Post"]">
<PostFormComponent></PostFormComponent>
</PageLayout>
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
@page "/Posts/{PostId:guid}/Edit"
@rendermode InteractiveAuto
@inherits BaseComponent
@{
var title = $"Edit post {PostId}";
}
<MudPageLayout Title="@title">
<PageLayout Title="@title">
<PostFormComponent PostId="PostId"></PostFormComponent>
</MudPageLayout>
</PageLayout>

@code {

Expand Down
42 changes: 42 additions & 0 deletions apps/Sitko.Blockly.Demo.Client/Pages/Index.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
@page "/"
@using Sitko.Blockly.Display
@using Sitko.Core.Storage
@using Sitko.Blockly.Data.Entities
@using Sitko.Core.Repository
@inherits BaseComponent
<PageLayout Title="@LocalizationProvider["Posts"]">
<Extra>
<MudButton Color="Color.Primary" Variant="Variant.Filled" Link="/Posts/Add">Add</MudButton>
</Extra>
<ChildContent>
@foreach (var post in Posts)
{
<MudCard>
<MudCardHeader>
<MudText Typo="Typo.h6">@post.Title</MudText>
</MudCardHeader>
<MudCardActions>
<MudButton Link="@($"/Posts/{post.Id}/Edit")" Variant="Variant.Text" Color="Color.Primary">Edit</MudButton>
</MudCardActions>
<MudCardContent>
<MudBlocksList
EntityBlocks="post.Blocks" Options="@(new MudBlazorBlocklyListOptions(BlocksListMode.Preview, GetService<IStorage>(), $"Posts/{post.Id}"))">
</MudBlocksList>
</MudCardContent>
</MudCard>
}
</ChildContent>
</PageLayout>

@code{

protected override async Task InitializeAsync()
{
await base.InitializeAsync();
var posts = await GetRequiredService<IRepository<Post, Guid>>().GetAllAsync();
Posts = posts.items;
}

private Post[] Posts { get; set; } = Array.Empty<Post>();

}
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
using System;
using System.Collections.Generic;
using FluentValidation;
using Sitko.Blockly.Demo.Data.Entities;
using FluentValidation;
using KellermanSoftware.CompareNetObjects;
using Sitko.Blockly.Blazor.Extensions;
using Sitko.Blockly.Data.Entities;
using Sitko.Blockly.Validation;
using Sitko.Core.Blazor.Forms;
using Sitko.Core.Blazor.MudBlazorComponents;
using Sitko.Core.Repository;

namespace Sitko.Blockly.Demo.Pages;

using Blazor.Extensions;
using Data.Repositories;
using KellermanSoftware.CompareNetObjects;
using Microsoft.AspNetCore.Components;
namespace Sitko.Blockly.Demo.Client.Pages;

public class PostForm : BaseMudRepositoryForm<Post, Guid, PostsRepository>
public class PostForm : BaseMudRepositoryForm<Post, Guid, IRepository<Post, Guid>>
{
[Parameter] public RenderFragment<PostForm> ChildContent { get; set; } = null!;

protected override RenderFragment ChildContentFragment => ChildContent(this);

protected override void ConfigureComparer(ComparisonConfig comparisonConfig)
{
base.ConfigureComparer(comparisonConfig);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
@using Sitko.Blockly.Demo.Data.Entities
@using Sitko.Blockly.Blocks
@using Sitko.Blockly.Blocks
@using Sitko.Blockly.Blazor
@using Sitko.Blockly.Blazor.Forms
@using Sitko.Core.Storage
@using Sitko.Blazor.CKEditor.Bundle
@using Sitko.Blockly.Data
@using Sitko.Blockly.Data.Entities

@inherits BaseComponent
<PostForm EntityId="PostId" OnAfterCreate="post => GoToPost(post)">
<PostForm EntityId="PostId" OnAfterCreate="post => GoToPost(post)" Debug="true">
<MudItem>
<MudTextField Label="Title" @bind-Value="context.Entity.Title" For="() => context.Entity.Title"/>
</MudItem>
<MudBlocklyForm Label="Blocks" @bind-Value="context.Entity.Blocks" Options="blocksOptions"></MudBlocklyForm>
<MudBlocklyForm @bind-Value="context.Entity.Blocks" Options="blocksOptions"></MudBlocklyForm>
<MudBlocklyForm Label="Secondary blocks" @bind-Value="context.Entity.SecondaryBlocks" Options="secondaryBlocksOptions"></MudBlocklyForm>
<MudButton Disabled="@(!context.CanSave())" >Save</MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Primary" Disabled="@(!context.Form.CanSave())" OnClick="@context.Form.SaveEntityAsync">Save</MudButton>
<MudButton Variant="Variant.Outlined" Color="Color.Secondary" Disabled="@(!context.Form.HasChanges)" OnClick="@context.Form.ResetAsync">Reset</MudButton>
</PostForm>


@code {

[Parameter]
public Guid PostId { get; set; }
[Parameter] public Guid PostId { get; set; }

private Task GoToPost(Post post)
{
Expand Down Expand Up @@ -58,7 +60,7 @@
ckEditorConfig.Language = "ru";
blocksOptions = new MudBlazorBlocklyFormOptions
{
Storage = GetService<IStorage<BlocklyStorageOptions>>(),
Storage = GetService<IStorage>(),
ImagesOptions = imagesStorageOptions,
FilesOptions = filesStorageOptions, CKEditorConfig = ckEditorConfig
};
Expand All @@ -67,7 +69,7 @@

secondaryBlocksOptions = new MudBlazorBlocklyFormOptions
{
MaxBlocks = 5, Storage = GetService<IStorage<BlocklyStorageOptions>>(),
MaxBlocks = 5, Storage = GetService<IStorage>(),
ImagesOptions = imagesStorageOptions,
FilesOptions = filesStorageOptions
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
@using Sitko.Core.Storage
@using Sitko.Blockly.Display
@inherits BaseComponent
<MudPageLayout Title="@Post.Title">
<PageTitle>@Post.Title</PageTitle>
<PageLayout Title="@Post.Title">
<Extra>
<MudButton Color="Color.Primary" Variant="Variant.Filled" Link="@($"/Posts/{Post.Id}/Edit/")">Edit</MudButton>
</Extra>
<ChildContent>
<MudBlocksList EntityBlocks="Post.Blocks" Options="@(new MudBlazorBlocklyListOptions(BlocksListMode.Full, GetService<IStorage<BlocklyStorageOptions>>()))"></MudBlocksList>
<MudBlocksList EntityBlocks="Post.Blocks" Options="@(new MudBlazorBlocklyListOptions(BlocksListMode.Full, GetService<IStorage>()))"></MudBlocksList>
</ChildContent>
</MudPageLayout>
</PageLayout>
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using Sitko.Blockly.Demo.Data.Entities;
using Sitko.Blockly.Demo.Data.Repositories;
using Microsoft.AspNetCore.Components;
using Sitko.Blockly.Data.Entities;
using Sitko.Core.Repository;

namespace Sitko.Blockly.Demo.Pages;
namespace Sitko.Blockly.Demo.Client.Pages;

public partial class Show
{
Expand All @@ -13,7 +11,7 @@ public partial class Show
protected override async Task InitializeAsync()
{
await base.InitializeAsync();
var post = await GetRequiredService<PostsRepository>().GetByIdAsync(PostId);
var post = await GetRequiredService<IRepository<Post, Guid>>().GetByIdAsync(PostId);
if (post is null)
{
NavigationManager.NavigateTo("/404");
Expand Down
Loading

0 comments on commit 302cee1

Please sign in to comment.