Skip to content

Commit

Permalink
re-impliment UIEnabled Groups
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinJump committed May 28, 2024
1 parent 41215db commit 255870d
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 31 deletions.
6 changes: 3 additions & 3 deletions uSync.BackOffice/BackOfficeConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ public static class Groups
/// Icons for the well known handler groups.
/// </summary>
public static Dictionary<string, string> Icons = new Dictionary<string, string> {
{ Settings, "icon-settings-alt color-blue" },
{ Content, "icon-documents color-purple" },
{ Settings, "icon-settings-alt" },
{ Content, "icon-documents" },
{ Members, "icon-users" },
{ Users, "icon-users color-green"},
{ Users, "icon-users"},
{ Default, "icon-settings" },
{ Forms, "icon-umb-contour" },
{ Files, "icon-script-alt" }
Expand Down
94 changes: 69 additions & 25 deletions uSync.Backoffice.Management.Api/Services/uSyncManagementService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

using Microsoft.AspNetCore.SignalR;

using Umbraco.Extensions;

using uSync.Backoffice.Management.Api.Extensions;
using uSync.Backoffice.Management.Api.Models;
using uSync.BackOffice;
Expand All @@ -23,23 +25,29 @@ internal class uSyncManagementService : ISyncManagementService
private readonly IHubContext<SyncHub> _hubContext;
private readonly uSyncConfigService _configService;

private readonly SyncHandlerFactory _handlerFactory;

public uSyncManagementService(
ISyncActionService syncActionService,
uSyncConfigService configService,
ISyncManagementCache syncManagementCache,
IHubContext<SyncHub> hubContext)
IHubContext<SyncHub> hubContext,
SyncHandlerFactory handlerFactory)
{
_syncActionService = syncActionService;
_configService = configService;
_syncManagementCache = syncManagementCache;
_hubContext = hubContext;
_handlerFactory = handlerFactory;
}

/// <summary>
/// Gets the list of available actions
/// </summary>
public List<SyncActionGroup> GetActions()
{
// TODO: Load the actions based on the handlers, and the config, (so they can be turned on and off)

var defaultReport = new SyncActionButton()
{
Key = HandlerActions.Report.ToString(),
Expand Down Expand Up @@ -90,31 +98,67 @@ public List<SyncActionGroup> GetActions()
List<SyncActionButton> defaultButtons = [defaultReport, defaultImport, defaultExport];
List<SyncActionButton> everythingButtons = [defaultReport, defaultImport, everythingExport];

List<SyncActionGroup> actions = [
new SyncActionGroup
{
GroupName = "Settings",
Icon = "icon-settings-alt",
Key = "settings",
Buttons = defaultButtons
},
new SyncActionGroup
{
GroupName = "Content",
Icon = "icon-documents",
Key = "content",
Buttons = defaultButtons
},
new SyncActionGroup
{
GroupName = "Everything",
Icon = "icon-paper-plane-alt",
Key = "all",
Buttons = everythingButtons
}
];
List<SyncActionGroup> actionGroups = [];

var options = new SyncHandlerOptions(_configService.Settings.DefaultSet)
{
Group = _configService.Settings.UIEnabledGroups
};

var groups = _handlerFactory.GetValidHandlerGroupsAndIcons(options);

foreach(var group in groups)
{
actionGroups.Add(new SyncActionGroup
{
GroupName = $"{group.Key}",
Icon = group.Value,
Key = group.Key.ToLowerInvariant(),
Buttons = defaultButtons
});
}

if (string.IsNullOrWhiteSpace(_configService.Settings.UIEnabledGroups) ||
_configService.Settings.UIEnabledGroups.InvariantContains("all"))
{
actionGroups.Add(new SyncActionGroup
{
GroupName = "Everything",
Icon = "icon-paper-plane-alt",
Key = "all",
Buttons = everythingButtons
});
}

return actions;
return actionGroups;



// List<SyncActionGroup> actions = [
// new SyncActionGroup
// {
// GroupName = "Settings",
// Icon = "icon-settings-alt",
// Key = "settings",
// Buttons = defaultButtons
// },
// new SyncActionGroup
// {
// GroupName = "Content",
// Icon = "icon-documents",
// Key = "content",
// Buttons = defaultButtons
// },
// new SyncActionGroup
// {
// GroupName = "Everything",
// Icon = "icon-paper-plane-alt",
// Key = "all",
// Buttons = everythingButtons
// }
//];

// return actions;

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "../umbraco-package-schema.json",
"name": "uSync",
"id": "usync",
"version": "14.0.0-rc4.20240528.14",
"version": "14.0.0-rc4.20240528.15",
"allowTelemetry": true,
"extensions": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class uSyncActionBox extends LitElement {
<uui-box class="action-box ${this.disabled ? 'disabled' : ''}">
<div class="box-content">
<h2 class="box-heading">${this.group?.groupName}</h2>
<uui-icon name=${this.group?.icon}></uui-icon>
<umb-icon name=${this.group?.icon}></umb-icon>
<div class="box-buttons">${dropdownButtons}</div>
</div>
</uui-box>
Expand Down Expand Up @@ -88,7 +88,7 @@ export class uSyncActionBox extends LitElement {
margin: 0;
}
uui-icon {
umb-icon {
margin: var(--uui-size-space-6);
font-size: var(--uui-type-h2-size);
color: var(--uui-color-text-alt);
Expand Down

0 comments on commit 255870d

Please sign in to comment.