Skip to content

Commit

Permalink
tidy the UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinJump committed Sep 11, 2024
1 parent d824215 commit 4c680b0
Show file tree
Hide file tree
Showing 47 changed files with 1,237 additions and 147 deletions.
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<VersionPrefix>14.0.0</VersionPrefix>
<VersionPrefix>14.2.0</VersionPrefix>
<Authors>Kevin Jump</Authors>
<Company>Jumoo</Company>

Expand All @@ -11,7 +11,7 @@

<RepositoryUrl>https://github.com/KevinJump/uSync8/tree/core/main</RepositoryUrl>

<Copyright>Jumoo @ 2013-2023</Copyright>
<Copyright>Jumoo @ 2013-2024</Copyright>

<PackageIcon>usync-logo.png</PackageIcon>

Expand Down
6 changes: 0 additions & 6 deletions dist/build-package.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ Write-Host "Config :" $env
Write-Host "Folder :" $outFolder
"----------------------------------"; ""

"Stamp version in umbraco-package.json"
$umbracoPackagePath = '../uSync.BackOffice.Management.Client/usync-assets/public/umbraco-package.json'
$packageJson = Get-Content $umbracoPackagePath -Raw | ConvertFrom-Json
$packageJson.Version = $fullVersion
$packageJson | ConvertTo-Json -Depth 32 | Set-Content $umbracoPackagePath

$sln_name = "..\uSync.sln";

# ""; "##### Restoring project"; "--------------------------------"; ""
Expand Down
4 changes: 2 additions & 2 deletions uSync.BackOffice/Models/SyncActionResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ public SyncActionResult() { }
/// Construct a new SyncActionResult object
/// </summary>
/// <param name="actions">list of actions to include</param>
public SyncActionResult(IEnumerable<uSyncAction> actions)
public SyncActionResult(List<uSyncAction> actions)
{
this.Actions = actions;
}

/// <summary>
/// List of actions performed by process
/// </summary>
public IEnumerable<uSyncAction> Actions { get; set; } = [];
public List<uSyncAction> Actions { get; set; } = [];
}
2 changes: 1 addition & 1 deletion uSync.BackOffice/Services/SyncActionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public SyncActionResult ImportPost(SyncActionOptions options, uSyncCallbacks? ca

callbacks?.Update?.Invoke("Import Complete", 1, 1);

return new SyncActionResult(actions.Where(x => x.Change > Core.ChangeType.NoChange));
return new SyncActionResult(actions.Where(x => x.Change > Core.ChangeType.NoChange).ToList());
}

public SyncActionResult ExportHandler(SyncActionOptions options, uSyncCallbacks? callbacks)
Expand Down
4 changes: 2 additions & 2 deletions uSync.BackOffice/SyncHandlers/SyncHandlerRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ virtual public IEnumerable<uSyncAction> ImportElement(XElement node, string file
catch (Exception ex)
{
logger.LogWarning("[{alias}] ImportElement Failed : {exception}", this.Alias, ex.ToString());
return uSyncAction.Fail(Path.GetFileName(filename), this.handlerType, this.ItemType, ChangeType.Fail,
return uSyncAction.Fail(Path.GetFileName(filename), this.Alias, this.ItemType, ChangeType.Fail,
$"{this.Alias} Import Fail: {ex.Message}", new Exception(ex.Message))
.AsEnumerableOfOne();
}
Expand Down Expand Up @@ -1233,7 +1233,7 @@ public IEnumerable<uSyncAction> Report(string[] folders, HandlerSettings config,
actions.AddRange(ReportDeleteCheck(uSyncConfig.GetRootFolder(), validationActions));

CleanCaches(cacheKey);
callback?.Invoke("Done", 3, 3);
callback?.Invoke($"Done ({this.ItemType})", 3, 3);
return actions;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private string GetuSyncVersion()
try
{
var fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.GetAssemblyFile().FullName);
var productVersion = SemVersion.Parse(fileVersionInfo.ProductVersion ?? assembly.GetName()?.Version?.ToString(3) ?? "14.0");
var productVersion = SemVersion.Parse(fileVersionInfo.ProductVersion ?? assembly.GetName()?.Version?.ToString(3) ?? "14.2.0");
return productVersion.ToSemanticStringWithoutBuild();
}
catch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,23 @@ namespace uSync.Backoffice.Management.Api.Extensions;
public static class uSyncActionExtensions
{
public static uSyncActionView ToActionView(this uSyncAction action)
=> new uSyncActionView
{
var msg = string.IsNullOrWhiteSpace(action.Message) is false
? action.Message
: string.IsNullOrWhiteSpace(action.Exception?.Message) is false
? action.Exception.Message
: "An error message would go here, it could be quite long, but we'll just truncate it for now.";

return new uSyncActionView
{
Key = action.Key,
Name = action.Name,
Handler = action.HandlerAlias ?? "",
ItemType = action.ItemType,
Change = action.Change,
Success = action.Success,
Details = action.Details?.ToList() ?? []

Details = action.Details?.ToList() ?? [],
Message = msg
};
}
}
5 changes: 2 additions & 3 deletions uSync.Backoffice.Management.Api/Models/uSyncActionView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ public class uSyncActionView
{
public required Guid Key { get;set; }
public required string Name { get; set; }
public required string Handler { get; set; }
public required string ItemType { get; set; }
public required ChangeType Change { get; set; }

public bool Success { get; set; }

public List<uSyncChange> Details { get; set; } = [];


public string? Message { get; set; }
}
15 changes: 10 additions & 5 deletions uSync.Backoffice.Management.Api/Services/uSyncManagementService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public PerformActionResponse PerformAction(PerformActionRequest actionRequest)
RequestId = requestId.ToString(),
Actions = finalActions.Select(x => x.ToActionView()),
Complete = true,
Status = GetSummaries(handlers, actionRequest.StepNumber)
Status = GetSummaries(handlers, actionRequest.StepNumber, finalActions)
};
}

Expand All @@ -229,7 +229,7 @@ public PerformActionResponse PerformAction(PerformActionRequest actionRequest)
{
RequestId = requestId.ToString(),
Actions = results.Actions.Select(x => x.ToActionView()),
Status = GetSummaries(handlers, actionRequest.StepNumber),
Status = GetSummaries(handlers, actionRequest.StepNumber, results.Actions.ToList() ),
Complete = false
};
}
Expand All @@ -244,16 +244,21 @@ private Guid GetRequestId(PerformActionRequest actionRequest)
return requestId;
}

private IEnumerable<SyncHandlerSummary> GetSummaries(List<SyncHandlerView> handlers, int step)
private IEnumerable<SyncHandlerSummary> GetSummaries(List<SyncHandlerView> handlers, int step, List<uSyncAction> actions)
{
var nextStep = step + 1;
for (int n = 0; n < handlers.Count; n++)
{
var handlerActions = actions.Where(x => x.HandlerAlias?.Equals(handlers[n].Alias, StringComparison.OrdinalIgnoreCase) is true).ToList();

yield return new SyncHandlerSummary
{
Name = handlers[n].Name,
Icon = handlers[n].Icon,
Status = n < step ? HandlerStatus.Complete :
n == step ? HandlerStatus.Processing : HandlerStatus.Pending
Status = n < nextStep ? HandlerStatus.Complete :
n == nextStep ? HandlerStatus.Processing : HandlerStatus.Pending,
Changes = handlerActions.Count(x => x.Change > Core.ChangeType.NoChange),
InError = handlerActions.Any(x => x.Change >= Core.ChangeType.Fail)
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@
<Folder Include="usync-assets\pack\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Umbraco.Cms.Infrastructure" Version="14.2.0" />
</ItemGroup>


</Project>
68 changes: 68 additions & 0 deletions uSync.Backoffice.Management.Client/uSyncManifestReader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using Microsoft.Extensions.DependencyInjection;

using System.Diagnostics;
using System.Text.Json.Nodes;

using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.Manifest;
using Umbraco.Cms.Core.Semver;
using Umbraco.Cms.Infrastructure.Manifest;
using Umbraco.Extensions;

namespace uSync.Backoffice.Management.Client;

public class uSyncManifestComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
{
builder.Services.AddSingleton<IPackageManifestReader, uSyncManifestReader>();
}
}

internal sealed class uSyncManifestReader : IPackageManifestReader
{
public Task<IEnumerable<PackageManifest>> ReadPackageManifestsAsync()
{
var entrypoint = JsonObject.Parse(@"{""name"": ""usync.entrypoint"",
""alias"": ""uSync.EntryPoint"",
""type"": ""entryPoint"",
""js"": ""/App_Plugins/uSync/usync.js""}");

List<PackageManifest> manifest = [
new PackageManifest
{
Id = "uSync",
Name = "uSync",
AllowTelemetry = true,
Version = GetuSyncVersion(),
Extensions = [ entrypoint!],
Importmap = new PackageManifestImportmap
{
Imports = new Dictionary<string, string>
{
{ "@jumoo/uSync", "/App_Plugins/uSync/usync.js" },
{ "@jumoo/uSync/external/signalr", "/App_Plugins/uSync/usync.js" }
}
}
}
];

return Task.FromResult(manifest.AsEnumerable());
}

private string GetuSyncVersion()
{
var assembly = typeof(uSyncManifestReader).Assembly;
try
{
var fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.GetAssemblyFile().FullName);
var productVersion = SemVersion.Parse(fileVersionInfo.ProductVersion ?? assembly.GetName()?.Version?.ToString(3) ?? "14.2.0");
return productVersion.ToSemanticStringWithoutBuild();
}
catch
{
return assembly.GetName()?.Version?.ToString(3) ?? "14.0.0";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineConfig } from '@hey-api/openapi-ts';

export default defineConfig({
client: 'legacy/fetch',
input: 'http://localhost:16855/umbraco/swagger/uSync/swagger.json',
input: 'http://localhost:29792/umbraco/swagger/uSync/swagger.json',
output: {
format: 'prettier',
path: 'src/api',
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@jumoo/usync",
"license": "MPL-2.0",
"type": "module",
"version": "14.2.0-build.20240911.7",
"version": "14.2.0-rc01",
"main": "./dist/usync.js",
"types": "./dist/index.d.ts",
"module": "./dist/usync.js",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
export type ApiRequestOptions = {
readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH';
readonly url: string;
readonly path?: Record<string, unknown>;
export type ApiRequestOptions<T = unknown> = {
readonly body?: any;
readonly cookies?: Record<string, unknown>;
readonly errors?: Record<number | string, string>;
readonly formData?: Record<string, unknown> | any[] | Blob | File;
readonly headers?: Record<string, unknown>;
readonly query?: Record<string, unknown>;
readonly formData?: Record<string, unknown>;
readonly body?: any;
readonly mediaType?: string;
readonly method:
| 'DELETE'
| 'GET'
| 'HEAD'
| 'OPTIONS'
| 'PATCH'
| 'POST'
| 'PUT';
readonly path?: Record<string, unknown>;
readonly query?: Record<string, unknown>;
readonly responseHeader?: string;
readonly errors?: Record<number, string>;
readonly responseTransformer?: (data: unknown) => Promise<T>;
readonly url: string;
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ApiRequestOptions } from './ApiRequestOptions';

type Headers = Record<string, string>;
type Middleware<T> = (value: T) => T | Promise<T>;
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
type Resolver<T> = (options: ApiRequestOptions<T>) => Promise<T>;

export class Interceptors<T> {
_fns: Middleware<T>[];
Expand All @@ -11,17 +11,14 @@ export class Interceptors<T> {
this._fns = [];
}

eject(fn: Middleware<T>) {
eject(fn: Middleware<T>): void {
const index = this._fns.indexOf(fn);
if (index !== -1) {
this._fns = [
...this._fns.slice(0, index),
...this._fns.slice(index + 1),
];
this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)];
}
}

use(fn: Middleware<T>) {
use(fn: Middleware<T>): void {
this._fns = [...this._fns, fn];
}
}
Expand All @@ -36,8 +33,10 @@ export type OpenAPIConfig = {
USERNAME?: string | Resolver<string> | undefined;
VERSION: string;
WITH_CREDENTIALS: boolean;
interceptors: {request: Interceptors<RequestInit>;
response: Interceptors<Response>;};
interceptors: {
request: Interceptors<RequestInit>;
response: Interceptors<Response>;
};
};

export const OpenAPI: OpenAPIConfig = {
Expand All @@ -50,6 +49,8 @@ export const OpenAPI: OpenAPIConfig = {
USERNAME: undefined,
VERSION: 'Latest',
WITH_CREDENTIALS: false,
interceptors: {request: new Interceptors(),response: new Interceptors(),
interceptors: {
request: new Interceptors(),
response: new Interceptors(),
},
};
Loading

0 comments on commit 4c680b0

Please sign in to comment.