Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration of custom URL patterns #249

Merged
merged 4 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions KVA/Migration.Toolkit.Source/Contexts/SourceInstanceContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,16 @@ public async Task<bool> RequestSourceInstanceInfo()

throw new InvalidOperationException($"No info was loaded for site '{siteName}'");
}

public IList<PageModel> GetNodeUrls(int nodeId, string siteName)
{
if (cachedInfos.TryGetValue(siteName, out var info) && info?.PageModels is { Count: > 0 } pageModels)
{
return pageModels.Where(pm => pm.NodeId == nodeId).ToList();
}
else
{
return [];
}
}
}
301 changes: 129 additions & 172 deletions KVA/Migration.Toolkit.Source/Handlers/MigratePagesCommandHandler.cs

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion KVA/Migration.Toolkit.Source/Helpers/Printer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using CMS.MediaLibrary;
using CMS.Membership;
using CMS.Modules;

using CMS.Websites;
using Migration.Toolkit.Common.Helpers;
using Migration.Toolkit.Common.Services;
using Migration.Toolkit.KXP.Models;
Expand Down Expand Up @@ -61,6 +61,7 @@ string FormatModel(string inner) => printType
UserInfo item => FormatModel($"ID={item.UserID}, Guid={item.UserGUID} Name={item.UserName}"),
RoleInfo item => FormatModel($"ID={item.RoleID}, Guid={item.RoleGUID} Name={item.RoleName}"),
MemberInfo item => FormatModel($"ID={item.MemberID}, Guid={item.MemberGuid} Name={item.MemberName}"),
WebPageFormerUrlPathInfo item => FormatModel($"ID={item.WebPageFormerUrlPathID}, Guid=N/A Name={item.WebPageFormerUrlPath}"),

CmsForm item => FormatModel($"ID={item.FormId}, GUID={item.FormGuid}, Name={item.FormName}"),
CmsUser item => FormatModel($"ID={item.UserId}, GUID={item.UserGuid}, Name={item.UserName}"),
Expand Down
5 changes: 5 additions & 0 deletions KVA/Migration.Toolkit.Source/ModelFacade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ public bool TrySelectGuid<T>(int? id, out Guid? objectGuid) where T : ISourceMod

public SemanticVersion SelectVersion()
{
if (semanticVersion != null)
{
return semanticVersion;
}

using var conn = GetConnection();
conn.Open();

Expand Down
22 changes: 19 additions & 3 deletions KX13.Extensions/ToolkitApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
using System.Linq;
using System.Net;
using System.Reflection;
using CMS.Core;
using CMS.DocumentEngine;
using CMS.SiteProvider;
using Kentico.Content.Web.Mvc;
using Kentico.Forms.Web.Mvc;
using Kentico.PageBuilder.Web.Mvc;
using Kentico.PageBuilder.Web.Mvc.PageTemplates;
Expand All @@ -12,7 +15,7 @@
public class ToolkitApiController : Controller
{
// TODO configure your own secret
private const string Secret = "";
private const string Secret = "secret_used_for_http_posts_to_source_instance_change_to_random_key";

private readonly IHttpContextAccessor _httpContextAccessor;

Expand All @@ -26,7 +29,7 @@ public class ToolkitInfo
public Dictionary<string, List<EditingFormControlModel>> WidgetProperties { get; set; }
public Dictionary<string, List<EditingFormControlModel>> PageTemplateProperties { get; set; }
public Dictionary<string, List<EditingFormControlModel>> SectionProperties { get; set; }

public List<object> PageModels { get; set; }
public string SiteName { get; set; }
}

Expand Down Expand Up @@ -157,6 +160,19 @@ public IActionResult GetAllDefinitions([FromBody] BodyModel body)
}
}

var allFormComponents = new ComponentDefinitionProvider<FormComponentDefinition>().GetAll();
result.PageModels = Service.Resolve<IPageRetriever>().RetrieveMultiple(q => q.AllCultures()).Select(x => (object)new
{
x.NodeSiteName,
x.DocumentID,
x.DocumentCulture,
x.DocumentGUID,
x.NodeGUID,
x.NodeID,
CultureUrl = DocumentURLProvider.GetUrlForCulture(x, x.DocumentCulture),
Url = DocumentURLProvider.GetUrl(x),
}).ToList();

return Ok(result);
}

Expand Down Expand Up @@ -227,4 +243,4 @@ public class EditingFormControlModel

public string PropertyName { get; set; }
}
}
}
19 changes: 17 additions & 2 deletions KX13.NET48.Extensions/ToolkitApiController.NET48.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
using System.Linq;
using System.Reflection;
using System.Web.Mvc;
using CMS.Core;
using CMS.DocumentEngine;
using CMS.SiteProvider;
using Kentico.Content.Web.Mvc;
using Kentico.Forms.Web.Mvc;
using Kentico.PageBuilder.Web.Mvc;
using Kentico.PageBuilder.Web.Mvc.PageTemplates;
Expand All @@ -20,7 +23,7 @@ public class ToolkitInfo
public Dictionary<string, List<EditingFormControlModel>> WidgetProperties { get; set; }
public Dictionary<string, List<EditingFormControlModel>> PageTemplateProperties { get; set; }
public Dictionary<string, List<EditingFormControlModel>> SectionProperties { get; set; }

public List<object> PageModels { get; set; }
public string SiteName { get; set; }
}

Expand Down Expand Up @@ -151,6 +154,18 @@ public ActionResult GetAllDefinitions(BodyModel body)
}
}

result.PageModels = Service.Resolve<IPageRetriever>().RetrieveMultiple(q => q.AllCultures()).Select(x => (object)new
{
x.NodeSiteName,
x.DocumentID,
x.DocumentCulture,
x.DocumentGUID,
x.NodeGUID,
x.NodeID,
CultureUrl = DocumentURLProvider.GetUrlForCulture(x, x.DocumentCulture),
Url = DocumentURLProvider.GetUrl(x),
}).ToList();

return ToJsonResult(result);
}

Expand Down Expand Up @@ -219,4 +234,4 @@ public class EditingFormControlModel

public string PropertyName { get; set; }
}
}
}
14 changes: 14 additions & 0 deletions Migration.Toolkit.Common/Services/Ipc/Model.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
// ReSharper disable InconsistentNaming
namespace Migration.Toolkit.Common.Services.Ipc;

public class SourceInstanceDiscoveredInfo
{
public Dictionary<string, List<EditingFormControlModel>>? WidgetProperties { get; set; }
public Dictionary<string, List<EditingFormControlModel>>? PageTemplateProperties { get; set; }
public Dictionary<string, List<EditingFormControlModel>>? SectionProperties { get; set; }
public List<PageModel> PageModels { get; set; } = [];
public string SiteName { get; set; }
}

public record PageModel(
int? NodeId,
string NodeSiteName,
int DocumentID,
string DocumentCulture,
Guid DocumentGUID,
Guid NodeGUID,
string CultureUrl,
string Url
);


public class EditingFormControlModel
{
/// <summary>
Expand Down
Loading