Skip to content

Commit 1dadf4a

Browse files
henryjumpCopilotKevinJump
authored
V16/history (#840)
* added history to v16 * added modal for viewing changes in history (finally) * Update uSync.History/history-client/vite.config.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update uSync.History/history-client/src/views/history-view.element.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update uSync.History/history-client/src/index.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update uSync.History/history-client/src/views/history-view.element.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update uSync.History/history-client/src/views/history-view.element.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * remove wwwroot files * remove files * Update uSync.History/uSyncHistoryComposer.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Kevin Jump <kevin@thejumps.co.uk>
1 parent b1f7235 commit 1dadf4a

39 files changed

Lines changed: 6327 additions & 884 deletions

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Ignore Visual Studio temporary files, build results, and
22
## files generated by popular Visual Studio add-ons.
33

4-
uSync.BackOffice.Assets/wwwroot/
4+
[Ww]wwroot/
55
uSyncSource.Site/App_Plugins/
66
*.zip
77

@@ -255,9 +255,9 @@ $RECYCLE.BIN/
255255

256256
/usync/test
257257
.idea
258-
/uSync.Backoffice.Management.Client/wwwroot/
259258

260259
# local solution (has website in it)
261260
/uSync.*.sln
262261
/uSync.Backoffice.Management.Client/usync-assets/tsconfig.dist.tsbuildinfo
263262
/uSync.Backoffice.Management.Client/usync-assets/.npmrc
263+

uSync.Backoffice.Management.Client/usync-assets/src/components/usync-results-view.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
property,
66
css,
77
state,
8+
nothing,
89
} from '@umbraco-cms/backoffice/external/lit';
910
import { ChangeType, USyncActionView } from '@jumoo/uSync';
1011
import { UmbElementMixin } from '@umbraco-cms/backoffice/element-api';
@@ -30,6 +31,12 @@ export class uSyncResultsView extends UmbElementMixin(LitElement) {
3031
@property({ type: Array })
3132
results: Array<USyncActionView> | undefined = [];
3233

34+
@property({ type: Boolean })
35+
hideResultBar: boolean = false;
36+
37+
@property({ type: Boolean })
38+
hideActions: boolean = false;
39+
3340
@state()
3441
showAll: boolean = false;
3542

@@ -48,9 +55,10 @@ export class uSyncResultsView extends UmbElementMixin(LitElement) {
4855
data: {
4956
item: e.action,
5057
showActions:
51-
e.action.change == ChangeType.CREATE ||
52-
e.action.change == ChangeType.UPDATE ||
53-
e.action.change == ChangeType.IMPORT,
58+
!this.hideActions &&
59+
(e.action.change == ChangeType.CREATE ||
60+
e.action.change == ChangeType.UPDATE ||
61+
e.action.change == ChangeType.IMPORT),
5462
},
5563
});
5664

@@ -104,6 +112,7 @@ export class uSyncResultsView extends UmbElementMixin(LitElement) {
104112
}
105113

106114
renderResultBar(count: number, changes: number) {
115+
if (this.hideResultBar) return nothing;
107116
const localKey = changes === 0 ? 'uSync_noChangeCount' : 'uSync_changeCount';
108117

109118
return html`<div class="result-header">

uSync.History/Controllers/uSyncHistoryController.cs

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,40 @@
1-
using Newtonsoft.Json;
1+
using Asp.Versioning;
2+
using Microsoft.AspNetCore.Authorization;
3+
using Microsoft.AspNetCore.Mvc;
4+
using Newtonsoft.Json;
5+
using Umbraco.Cms.Api.Common.Attributes;
6+
using Umbraco.Cms.Api.Common.Filters;
7+
using Umbraco.Cms.Core;
28
using Umbraco.Cms.Core.Hosting;
3-
using Umbraco.Cms.Infrastructure.Migrations.Expressions.Delete;
4-
using Umbraco.Cms.Web.BackOffice.Controllers;
5-
using Umbraco.Cms.Web.Common.Attributes;
6-
using uSync.BackOffice;
7-
using uSync.BackOffice.Configuration;
9+
using Umbraco.Cms.Web.Common.Filters;
10+
using uSync.Backoffice.Management.Api.Configuration;
11+
using uSync.BackOffice.Authorization;
812
using uSync.BackOffice.Services;
913

1014
namespace uSync.History.Controllers
1115
{
12-
[PluginController("uSync")]
13-
public class uSyncHistoryController : UmbracoAuthorizedApiController
16+
[ApiController]
17+
[uSyncVersionedRoute("history")]
18+
[Authorize(Policy = SyncAuthorizationPolicies.TreeAccessuSync)]
19+
[MapToApi("uSync.History")]
20+
[DisableBrowserCache]
21+
[JsonOptionsName(Constants.JsonOptionsNames.BackOffice)]
22+
[ApiVersion("1.0")]
23+
[ApiExplorerSettings(GroupName = "History")]
24+
public class uSyncHistoryController : ControllerBase
1425
{
1526
private readonly IHostingEnvironment _hostingEnvironment;
16-
private readonly SyncFileService _syncFileService;
27+
private readonly ISyncFileService _syncFileService;
1728

18-
public uSyncHistoryController(SyncFileService syncFileService, IHostingEnvironment hostingEnvironment)
29+
public uSyncHistoryController(ISyncFileService syncFileService, IHostingEnvironment hostingEnvironment)
1930
{
2031
_syncFileService = syncFileService;
2132
_hostingEnvironment = hostingEnvironment;
2233
}
2334

24-
public bool GetApi() => true;
25-
26-
public IEnumerable<HistoryInfo> GetHistory()
35+
[HttpGet("GetHistory")]
36+
[ProducesResponseType(200)]
37+
public async Task<IEnumerable<HistoryInfo>> GetHistory()
2738
{
2839
string historyFolder = GetHistoryFolder();
2940
var files = _syncFileService.GetFiles(historyFolder, "*.json")
@@ -32,19 +43,23 @@ public IEnumerable<HistoryInfo> GetHistory()
3243
var list = new List<HistoryInfo>();
3344
foreach (var file in files)
3445
{
35-
list.Add(LoadHistory(file));
46+
list.Add(await LoadHistoryAsync(file));
3647
}
3748

3849
return list.OrderByDescending(x => x.Date);
3950
}
4051

52+
[HttpGet("GetHistoryFolder")]
53+
[ProducesResponseType(200)]
4154
private string GetHistoryFolder()
4255
{
4356
var rootFolder = _syncFileService.GetAbsPath(_hostingEnvironment.LocalTempPath);
4457
var historyFolder = Path.GetFullPath(Path.Combine(rootFolder, "uSync", "history"));
4558
return historyFolder;
4659
}
4760

61+
[HttpGet("ClearHistory")]
62+
[ProducesResponseType(200)]
4863
public bool ClearHistory()
4964
{
5065
// 1. get history folder
@@ -60,11 +75,13 @@ public bool ClearHistory()
6075
return true;
6176
}
6277

63-
public HistoryInfo LoadHistory(string filePath)
78+
[HttpGet("HistoryInfo")]
79+
[ProducesResponseType(200)]
80+
public async Task<HistoryInfo> LoadHistoryAsync(string filePath)
6481
{
6582
string historyFolder = GetHistoryFolder();
6683
var fullPath = Path.Combine(historyFolder, filePath);
67-
string contents = _syncFileService.LoadContent(fullPath);
84+
string contents = await _syncFileService.LoadContentAsync(fullPath);
6885

6986
var actions = JsonConvert.DeserializeObject<HistoryInfo>(contents);
7087

uSync.History/HistoryInfo.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
using Newtonsoft.Json.Serialization;
22
using Newtonsoft.Json;
33
using uSync.BackOffice;
4+
using uSync.Backoffice.Management.Api.Models;
45

56
namespace uSync.History
67
{
78
[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
89

910
public class HistoryInfo
1011
{
11-
public IEnumerable<uSyncAction> Actions { get; set; }
12+
public IEnumerable<uSyncActionView> Actions { get; set; }
1213

1314
public DateTime Date { get; set; }
1415

@@ -17,7 +18,7 @@ public class HistoryInfo
1718
public string Method { get; set; }
1819

1920
public string FilePath { get; set; }
20-
21+
2122
public int Changes { get; set; }
2223

2324
public int Total { get; set; }
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@jumoo:registry=https://pkgs.dev.azure.com/jumoo/Public/_packaging/nightly/npm/registry/
2+
always-auth=true

0 commit comments

Comments
 (0)