From 983f4550f840fee9c02876f20ac87caa100a826e Mon Sep 17 00:00:00 2001 From: Kevin Jump Date: Tue, 28 May 2024 12:06:57 +0100 Subject: [PATCH] Fix #643, don't clean up inherited tabs. --- .../Serializers/ContentTypeBaseSerializer.cs | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/uSync.Core/Serialization/Serializers/ContentTypeBaseSerializer.cs b/uSync.Core/Serialization/Serializers/ContentTypeBaseSerializer.cs index 78aca3ce..1d7d5b67 100644 --- a/uSync.Core/Serialization/Serializers/ContentTypeBaseSerializer.cs +++ b/uSync.Core/Serialization/Serializers/ContentTypeBaseSerializer.cs @@ -863,31 +863,29 @@ protected IEnumerable DeserializeTabs(TObject item, XElement node) if (TabClashesWithExisting(item, tab.Alias, tab.Type)) tab.Alias = SyncPropertyGroupHelpers.GetTempTabAlias(tab.Alias); + logger.LogInformation("Explicit Tabs : {list}", string.Join(",", item.PropertyGroups.Select(x => x.Alias))); + logger.LogInformation("Inherited Tabs : {list}", string.Join(",", item.CompositionPropertyGroups.Select(x => x.Alias))); + // v14: if the tab is a child (group) - then we might need to create a parent tab if (tab.Depth > 0) { var tabRoot = tab.Alias.Split('/')[0]; if (item.PropertyGroups.Contains(tabRoot)) { - logger.LogDebug("Parent Tab {tabRoot} already exists", tabRoot); + logger.LogInformation("Parent Tab {tabRoot} already exists", tabRoot); } else { - logger.LogDebug("Parent Tab {tabRoot} doesn't exist, creating", tabRoot); + logger.LogInformation("Parent Tab {tabRoot} doesn't exist, creating", tabRoot); var compositionParent = item.CompositionPropertyGroups.FirstOrDefault(x => x.Alias.InvariantEquals(tabRoot)); if (compositionParent != null) { - logger.LogDebug("Creating parent tab from inherited tab data, {alias} {name}", compositionParent.Alias, compositionParent.Name ?? compositionParent.Alias); - var parentPropertyGroup = new PropertyGroup(supportsPublishing) - { - Alias = tabRoot, - Name = compositionParent.Name ?? tabRoot, - Type = compositionParent.Type, - SortOrder = compositionParent.SortOrder, - }; - - item.PropertyGroups.Add(parentPropertyGroup); + logger.LogInformation("Creating parent tab from inherited tab data, {alias} {name}", compositionParent.Alias, compositionParent.Name ?? compositionParent.Alias); + + item.AddPropertyGroup(tabRoot, compositionParent.Name ?? tabRoot); + item.PropertyGroups[tabRoot].Type = compositionParent.Type; + item.PropertyGroups[tabRoot].SortOrder = compositionParent.SortOrder; } } } @@ -989,9 +987,14 @@ protected IEnumerable CleanTabs(TObject item, XElement node, SyncSe .Select(x => GetTabAliasFromTabGroup(x)) .ToList(); + var inheritedTabs =item.CompositionPropertyGroups.Select(x => x.Alias).ToList(); + List removals = []; foreach (var tab in item.PropertyGroups) { + // don't remove the inherited tabs + if (inheritedTabs.Contains(tab.Alias)) continue; + if (!newTabs.InvariantContains(tab.Alias)) { removals.Add(tab); @@ -1011,7 +1014,7 @@ protected IEnumerable CleanTabs(TObject item, XElement node, SyncSe } else { - logger.LogDebug("Removing tab : {alias}", tab.Alias); + logger.LogInformation("Removing tab : {alias}", tab.Alias); changes.Add(uSyncChange.Delete($"Tabs/{tab.Alias}", tab.Alias, tab.Alias)); item.PropertyGroups.Remove(tab); }