Skip to content

Commit fe5feec

Browse files
Merge branch 'release/13.0.0'
2 parents 20fc729 + c016a40 commit fe5feec

11 files changed

+103
-78
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<TargetFramework>net7.0</TargetFramework>
3+
<TargetFramework>net8.0</TargetFramework>
44
<Company>Umbraco HQ</Company>
55
<Authors>Umbraco</Authors>
66
<Copyright>Copyright © Umbraco $([System.DateTime]::Today.ToString('yyyy'))</Copyright>

Directory.Packages.props

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
77
<GlobalPackageReference Include="Nerdbank.GitVersioning" Version="3.5.119" />
88
<GlobalPackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435" />
9-
<GlobalPackageReference Include="Umbraco.Code" Version="2.0.0" />
9+
<GlobalPackageReference Include="Umbraco.Code" Version="2.1.0" />
1010
<GlobalPackageReference Include="Umbraco.GitVersioning.Extensions" Version="0.2.0" />
1111
</ItemGroup>
1212
<ItemGroup>
13-
<PackageVersion Include="Umbraco.Commerce.Cms.Startup" Version="[12.0.0, 13)" />
14-
<PackageVersion Include="Umbraco.Deploy.Infrastructure" Version="[12.0.0, 13)" />
15-
<PackageVersion Include="Umbraco.Deploy.Contrib" Version="[12.0.0, 13)" />
13+
<PackageVersion Include="Umbraco.Commerce.Cms.Startup" Version="13.0.0--preview.12" />
14+
<PackageVersion Include="Umbraco.Deploy.Infrastructure" Version="13.0.0-rc4" />
1615
</ItemGroup>
1716
</Project>

NuGet.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
<package pattern="*" />
1212
</packageSource>
1313
<packageSource key="Umbraco Prereleases">
14-
<package pattern="Umbraco.*" />
14+
<package pattern="Umbraco.Commerce.*" />
1515
</packageSource>
1616
<packageSource key="Umbraco Nightly">
17-
<package pattern="Umbraco.*" />
17+
<package pattern="Umbraco.Commerce.*" />
1818
</packageSource>
1919
</packageSourceMapping>
2020
</configuration>

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "7.0.100",
3+
"version": "8.0.100-rc.2.23502.2",
44
"rollForward": "latestFeature"
55
}
66
}

src/Umbraco.Commerce.Deploy/Composing/UmbracoCommerceDeployComponent.cs

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
using Umbraco.Extensions;
1111
using Umbraco.Cms.Core;
1212
using System.Linq;
13-
using Umbraco.Deploy.Core;
1413

1514
namespace Umbraco.Commerce.Deploy.Composing
1615
{
@@ -20,7 +19,8 @@ public partial class UmbracoCommerceDeployComponent : IComponent
2019
private readonly IServiceConnectorFactory _serviceConnectorFactory;
2120
private readonly ITransferEntityService _transferEntityService;
2221

23-
public UmbracoCommerceDeployComponent(IDiskEntityService diskEntityService,
22+
public UmbracoCommerceDeployComponent(
23+
IDiskEntityService diskEntityService,
2424
IServiceConnectorFactory serviceConnectorFactory,
2525
ITransferEntityService transferEntityService)
2626
{
@@ -70,19 +70,36 @@ private void InitializeIntegratedEntities()
7070
SupportsRestore = true,
7171
PermittedToRestore = true,
7272
SupportsPartialRestore = true,
73+
//SupportsImportExport = true,
74+
//SupportsExportOfDescendants = true
7375
},
7476
false,
7577
Cms.Constants.Trees.Stores.Alias,
7678
(string routePath, HttpContext httpContext) => MatchesRoutePath(routePath, "productattribute"),
7779
(string nodeId, HttpContext httpContext) => MatchesNodeId(
7880
nodeId,
7981
httpContext,
80-
new Cms.Constants.Trees.Stores.NodeType[]
81-
{
82+
[
8283
Cms.Constants.Trees.Stores.NodeType.ProductAttributes,
8384
Cms.Constants.Trees.Stores.NodeType.ProductAttribute
84-
}),
85-
(string nodeId, HttpContext httpContext, out Guid entityId) => Guid.TryParse(nodeId, out entityId));
85+
]),
86+
(string nodeId, HttpContext httpContext, out Guid entityId) =>
87+
{
88+
if (Guid.TryParse(nodeId, out entityId))
89+
{
90+
return true;
91+
}
92+
else if (int.TryParse(nodeId, out int id) && id == Cms.Constants.Trees.Stores.Ids[Cms.Constants.Trees.Stores.NodeType.ProductAttributes])
93+
{
94+
entityId = Guid.Empty;
95+
return true;
96+
}
97+
else
98+
{
99+
entityId = Guid.Empty;
100+
return false;
101+
}
102+
});
86103
// TODO: , new DeployTransferRegisteredEntityTypeDetail.RemoteTreeDetail(FormsTreeHelper.GetExampleTree, "example", "externalExampleTree"));
87104

88105
_transferEntityService.RegisterTransferEntityType<ProductAttributePresetReadOnly>(
@@ -95,19 +112,36 @@ private void InitializeIntegratedEntities()
95112
SupportsRestore = true,
96113
PermittedToRestore = true,
97114
SupportsPartialRestore = true,
115+
//SupportsImportExport = true,
116+
//SupportsExportOfDescendants = true
98117
},
99118
false,
100119
Cms.Constants.Trees.Stores.Alias,
101120
(string routePath, HttpContext httpContext) => MatchesRoutePath(routePath, "productattributepreset"),
102121
(string nodeId, HttpContext httpContext) => MatchesNodeId(
103122
nodeId,
104123
httpContext,
105-
new Cms.Constants.Trees.Stores.NodeType[]
106-
{
124+
[
107125
Cms.Constants.Trees.Stores.NodeType.ProductAttributePresets,
108126
Cms.Constants.Trees.Stores.NodeType.ProductAttributePreset
109-
}),
110-
(string nodeId, HttpContext httpContext, out Guid entityId) => Guid.TryParse(nodeId, out entityId));
127+
]),
128+
(string nodeId, HttpContext httpContext, out Guid entityId) =>
129+
{
130+
if (Guid.TryParse(nodeId, out entityId))
131+
{
132+
return true;
133+
}
134+
else if (int.TryParse(nodeId, out int id) && id == Cms.Constants.Trees.Stores.Ids[Cms.Constants.Trees.Stores.NodeType.ProductAttributePresets])
135+
{
136+
entityId = Guid.Empty;
137+
return true;
138+
}
139+
else
140+
{
141+
entityId = Guid.Empty;
142+
return false;
143+
}
144+
});
111145
// TODO: , new DeployTransferRegisteredEntityTypeDetail.RemoteTreeDetail(FormsTreeHelper.GetExampleTree, "example", "externalExampleTree"));
112146
}
113147

@@ -116,6 +150,17 @@ private static bool MatchesRoutePath(string routePath, string routePartPrefix)
116150

117151
private static bool MatchesNodeId(string nodeId, HttpContext httpContext, Cms.Constants.Trees.Stores.NodeType[] nodeTypes)
118152
{
153+
if (int.TryParse(nodeId, out int id))
154+
{
155+
foreach (var nt in nodeTypes)
156+
{
157+
if (Cms.Constants.Trees.Stores.Ids.ContainsKey(nt) && Cms.Constants.Trees.Stores.Ids[nt] == id)
158+
{
159+
return true;
160+
}
161+
}
162+
}
163+
119164
var nodeType = httpContext.Request.Query["nodeType"].ToString();
120165
return nodeTypes.Select(x => x.ToString()).InvariantContains(nodeType);
121166
}

src/Umbraco.Commerce.Deploy/Connectors/ValueConnectors/UmbracoCommercePriceValueConnector.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Newtonsoft.Json;
1+
using Newtonsoft.Json;
22
using System;
33
using System.Collections.Generic;
44
using Umbraco.Commerce.Core.Api;
@@ -23,7 +23,7 @@ public UmbracoCommercePriceValueConnector(IUmbracoCommerceApi umbracoCommerceApi
2323
_settingsAccessor = settingsAccessor;
2424
}
2525

26-
public string ToArtifact(object value, IPropertyType propertyType, ICollection<ArtifactDependency> dependencies)
26+
public string ToArtifact(object value, IPropertyType propertyType, ICollection<ArtifactDependency> dependencies, IContextCache contextCache)
2727
{
2828
var svalue = value as string;
2929

@@ -52,7 +52,7 @@ public string ToArtifact(object value, IPropertyType propertyType, ICollection<A
5252
return JsonConvert.SerializeObject(dstDict);
5353
}
5454

55-
public object FromArtifact(string value, IPropertyType propertyType, object currentValue)
55+
public object FromArtifact(string value, IPropertyType propertyType, object currentValue, IContextCache contextCache)
5656
{
5757
var svalue = value as string;
5858

src/Umbraco.Commerce.Deploy/Connectors/ValueConnectors/UmbracoCommerceStoreEntityPickerValueConnector.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public UmbracoCommerceStoreEntityPickerValueConnector(IDataTypeService dataTypeS
2929
_settingsAccessor = settingsAccessor;
3030
}
3131

32-
public string ToArtifact(object value, IPropertyType propertyType, ICollection<ArtifactDependency> dependencies)
32+
public string ToArtifact(object value, IPropertyType propertyType, ICollection<ArtifactDependency> dependencies, IContextCache contextCache)
3333
{
3434
var svalue = value as string;
3535

@@ -54,7 +54,7 @@ public string ToArtifact(object value, IPropertyType propertyType, ICollection<A
5454
return udi.ToString();
5555
}
5656

57-
public object FromArtifact(string value, IPropertyType propertyType, object currentValue)
57+
public object FromArtifact(string value, IPropertyType propertyType, object currentValue, IContextCache contextCache)
5858
{
5959
if (string.IsNullOrWhiteSpace(value) || !UdiHelper.TryParseGuidUdi(value, out var udi))
6060
return null;

src/Umbraco.Commerce.Deploy/Connectors/ValueConnectors/UmbracoCommerceStorePickerValueConnector.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using Umbraco.Commerce.Core.Api;
44
using Umbraco.Commerce.Deploy.Configuration;
@@ -21,7 +21,7 @@ public UmbracoCommerceStorePickerValueConnector(IUmbracoCommerceApi umbracoComme
2121
_settingsAccessor = settingsAccessor;
2222
}
2323

24-
public string ToArtifact(object value, IPropertyType propertyType, ICollection<ArtifactDependency> dependencies)
24+
public string ToArtifact(object value, IPropertyType propertyType, ICollection<ArtifactDependency> dependencies, IContextCache contextCache)
2525
{
2626
var svalue = value as string;
2727

@@ -42,7 +42,7 @@ public string ToArtifact(object value, IPropertyType propertyType, ICollection<A
4242
return udi.ToString();
4343
}
4444

45-
public object FromArtifact(string value, IPropertyType propertyType, object currentValue)
45+
public object FromArtifact(string value, IPropertyType propertyType, object currentValue, IContextCache contextCache)
4646
{
4747
if (string.IsNullOrWhiteSpace(value) || !UdiHelper.TryParseGuidUdi(value, out var udi) || udi.EntityType != UmbracoCommerceConstants.UdiEntityType.Store)
4848
return null;

src/Umbraco.Commerce.Deploy/Connectors/ValueConnectors/UmbracoCommerceVariantsEditorValueConnector.cs

Lines changed: 32 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Newtonsoft.Json;
2-
using Newtonsoft.Json.Linq;
1+
using Newtonsoft.Json;
32
using System;
43
using System.Collections.Generic;
54
using System.Linq;
@@ -10,95 +9,78 @@
109
using Umbraco.Cms.Core.Services;
1110
using Umbraco.Cms.Infrastructure.Serialization;
1211
using Umbraco.Deploy.Core.Connectors.ValueConnectors.Services;
13-
using Umbraco.Deploy.Contrib.ValueConnectors;
14-
using Umbraco.Extensions;
1512
using Microsoft.Extensions.Logging;
13+
using Umbraco.Deploy.Infrastructure.Connectors.ValueConnectors;
14+
using Umbraco.Cms.Core.Models.Blocks;
15+
using Umbraco.Deploy.Core.Migrators;
16+
using Umbraco.Deploy.Infrastructure.Extensions;
1617

1718
namespace Umbraco.Commerce.Deploy.Connectors.ValueConnectors
1819
{
1920
/// <summary>
2021
/// A Deploy connector for the Umbraco Commerce Variants Editor property editor
2122
/// </summary>
22-
public class UmbracoCommerceVariantsEditorValueConnector : BlockEditorValueConnector, IValueConnector2
23+
public class UmbracoCommerceVariantsEditorValueConnector : BlockValueConnectorBase, IValueConnector
2324
{
2425
private readonly IUmbracoCommerceApi _umbracoCommerceApi;
2526

2627
public override IEnumerable<string> PropertyEditorAliases => new[] { "Umbraco.Commerce.VariantsEditor" };
2728

28-
public UmbracoCommerceVariantsEditorValueConnector(IUmbracoCommerceApi umbracoCommerceApi,
29-
IContentTypeService contentTypeService,
29+
public UmbracoCommerceVariantsEditorValueConnector(
30+
IUmbracoCommerceApi umbracoCommerceApi,
31+
IContentTypeService contentTypeService,
3032
Lazy<ValueConnectorCollection> valueConnectors,
33+
PropertyTypeMigratorCollection propertyTypeMigrators,
3134
ILogger<UmbracoCommerceVariantsEditorValueConnector> logger)
32-
: base(contentTypeService, valueConnectors, logger)
35+
: base(contentTypeService, valueConnectors, propertyTypeMigrators, logger)
3336
{
3437
_umbracoCommerceApi = umbracoCommerceApi;
3538
}
3639

3740
public override string ToArtifact(object value, IPropertyType propertyType, ICollection<ArtifactDependency> dependencies, IContextCache contextCache)
3841
{
39-
var artifact = base.ToArtifact(value, propertyType, dependencies, contextCache);
40-
41-
if (string.IsNullOrWhiteSpace(artifact) || !artifact.DetectIsJson())
42-
return null;
43-
44-
// The base call to ToArtifact will have stripped off the storeId property
45-
// held in the root of the property value so we need to re-parse the original
46-
// value and extract the store ID. If one is present, then we need to append
47-
// this back into the artifact value but also then attempt to process any
48-
// product attributes that need deploying.
49-
50-
var originalVal = value is JObject
51-
? value.ToString()
52-
: value as string;
53-
54-
var baseValue = JsonConvert.DeserializeObject<BaseValue>(originalVal);
55-
if (baseValue != null && baseValue.StoreId.HasValue)
42+
if (value is string input && input.TryParseJson(out VariantsBlockEditorValue result) && result != null)
5643
{
57-
var blockEditorValue = JsonConvert.DeserializeObject<VariantsBlockEditorValue>(artifact);
58-
if (blockEditorValue == null)
59-
return null;
60-
61-
blockEditorValue.StoreId = baseValue.StoreId.Value;
44+
// Recursive
45+
result.Content = ToArtifact(result.Content, dependencies, contextCache).ToList();
46+
result.Settings = ToArtifact(result.Settings, dependencies, contextCache).ToList();
6247

63-
var productAttributeAliases = blockEditorValue.Layout.Items.SelectMany(x => x.Config.Attributes.Keys)
64-
.Distinct();
48+
var productAttributeAliases = result.Layout.Items.SelectMany(x => x.Config.Attributes.Keys)
49+
.Distinct();
6550

6651
foreach (var productAttributeAlias in productAttributeAliases)
6752
{
68-
var productAttribute = _umbracoCommerceApi.GetProductAttribute(blockEditorValue.StoreId.Value, productAttributeAlias);
53+
var productAttribute = _umbracoCommerceApi.GetProductAttribute(result.StoreId.Value, productAttributeAlias);
6954
if (productAttribute != null)
7055
{
7156
dependencies.Add(new UmbracoCommerceArtifactDependency(productAttribute.GetUdi()));
7257
}
7358
}
7459

75-
artifact = JsonConvert.SerializeObject(blockEditorValue);
60+
return JsonConvert.SerializeObject(result, Formatting.None);
7661
}
7762

78-
return artifact;
63+
return null;
7964
}
8065

81-
public override object FromArtifact(string value, IPropertyType propertyType, object currentValue, IContextCache contextCache)
66+
public override object FromArtifact(string value, IPropertyType propertyType, object currentValue, IDictionary<string, string> propertyEditorAliases, IContextCache contextCache)
8267
{
83-
var entity = base.FromArtifact(value, propertyType, currentValue, contextCache);
84-
85-
var jObj = entity as JObject;
86-
if (jObj != null && !string.IsNullOrWhiteSpace(value) && value.DetectIsJson())
68+
if (value is string input && input.TryParseJson(out VariantsBlockEditorValue result) && result != null)
8769
{
88-
var baseValue = JsonConvert.DeserializeObject<BaseValue>(value);
89-
if (baseValue != null && baseValue.StoreId.HasValue)
90-
{
91-
jObj["storeId"] = baseValue.StoreId.Value;
92-
}
70+
// Recursive
71+
result.Content = FromArtifact(result.Content, propertyEditorAliases, contextCache).ToList();
72+
result.Settings = FromArtifact(result.Settings, propertyEditorAliases, contextCache).ToList();
73+
74+
return JsonConvert.SerializeObject(result, Formatting.None);
9375
}
9476

95-
return jObj ?? entity;
77+
return null;
9678
}
9779

98-
object IValueConnector2.FromArtifact(string value, IPropertyType propertyType, object currentValue, IContextCache contextCache)
80+
object IValueConnector.FromArtifact(string value, IPropertyType propertyType, object currentValue, IContextCache contextCache)
9981
=> FromArtifact(value, propertyType, currentValue, contextCache);
10082

101-
string IValueConnector2.ToArtifact(object value, IPropertyType propertyType, ICollection<ArtifactDependency> dependencies, IContextCache contextCache)
83+
string IValueConnector.ToArtifact(object value, IPropertyType propertyType, ICollection<ArtifactDependency> dependencies, IContextCache contextCache)
10284
=> ToArtifact(value, propertyType, dependencies, contextCache);
10385

10486
public class BaseValue
@@ -113,10 +95,10 @@ public class VariantsBlockEditorValue : BaseValue
11395
public VariantsBlockEditorLayout Layout { get; set; }
11496

11597
[JsonProperty("contentData")]
116-
public IEnumerable<Block> Content { get; set; }
98+
public IEnumerable<BlockItemData> Content { get; set; }
11799

118100
[JsonProperty("settingsData")]
119-
public IEnumerable<Block> Settings { get; set; }
101+
public IEnumerable<BlockItemData> Settings { get; set; }
120102
}
121103

122104
public class VariantsBlockEditorLayout

src/Umbraco.Commerce.Deploy/Umbraco.Commerce.Deploy.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
<ItemGroup>
99
<PackageReference Include="Umbraco.Commerce.Cms.Startup" />
1010
<PackageReference Include="Umbraco.Deploy.Infrastructure" />
11-
<PackageReference Include="Umbraco.Deploy.Contrib" />
1211
</ItemGroup>
1312

1413
<!-- Workaround for this bug (replace the analyzer name with the one you need to exclude (filename only, no extension) -->

0 commit comments

Comments
 (0)