From eaacdc051470b3427a6e2b87f3899bfa30a65f96 Mon Sep 17 00:00:00 2001 From: Stephan Date: Tue, 28 Aug 2018 15:00:45 +0200 Subject: [PATCH 1/3] Deal with fixmes in IContent IsCultureSomething --- src/Umbraco.Core/Models/Content.cs | 18 ++++++++++------- src/Umbraco.Core/Models/IContent.cs | 7 +++++-- .../Implement/DocumentRepository.cs | 5 ++++- src/Umbraco.Web/Editors/ContentController.cs | 2 +- .../Mapping/ContentSavedStateResolver.cs | 20 +++++++++---------- 5 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/Umbraco.Core/Models/Content.cs b/src/Umbraco.Core/Models/Content.cs index caa7a2a3e4..dd379e02f8 100644 --- a/src/Umbraco.Core/Models/Content.cs +++ b/src/Umbraco.Core/Models/Content.cs @@ -32,6 +32,7 @@ namespace Umbraco.Core.Models /// Name of the content /// Parent object /// ContentType for the current Content object + /// An optional culture. public Content(string name, IContent parent, IContentType contentType, string culture = null) : this(name, parent, contentType, new PropertyCollection(), culture) { } @@ -43,6 +44,7 @@ namespace Umbraco.Core.Models /// Parent object /// ContentType for the current Content object /// Collection of properties + /// An optional culture. public Content(string name, IContent parent, IContentType contentType, PropertyCollection properties, string culture = null) : base(name, parent, contentType, properties, culture) { @@ -57,6 +59,7 @@ namespace Umbraco.Core.Models /// Name of the content /// Id of the Parent content /// ContentType for the current Content object + /// An optional culture. public Content(string name, int parentId, IContentType contentType, string culture = null) : this(name, parentId, contentType, new PropertyCollection(), culture) { } @@ -68,6 +71,7 @@ namespace Umbraco.Core.Models /// Id of the Parent content /// ContentType for the current Content object /// Collection of properties + /// An optional culture. public Content(string name, int parentId, IContentType contentType, PropertyCollection properties, string culture = null) : base(name, parentId, contentType, properties, culture) { @@ -213,23 +217,23 @@ namespace Umbraco.Core.Models [IgnoreDataMember] public IEnumerable PublishedCultures => _publishInfos?.Keys ?? Enumerable.Empty(); - //fixme should this return false if ID == 0? - //fixme should this return false if IsCultureAvailable(culture) is false? /// public bool IsCulturePublished(string culture) + // just check _publishInfos + // a non-available culture could not become published anyways => _publishInfos != null && _publishInfos.ContainsKey(culture); - //fixme should this return false if ID == 0? - //fixme should this return false if IsCultureAvailable(culture) is false? /// public bool WasCulturePublished(string culture) + // just check _publishInfosOrig - a copy of _publishInfos + // a non-available culture could not become published anyways => _publishInfosOrig != null && _publishInfosOrig.ContainsKey(culture); - //fixme should this return false if ID == 0? - //fixme should this return false if IsCultureAvailable(culture) is false? /// public bool IsCultureEdited(string culture) - => !IsCulturePublished(culture) || (_editedCultures != null && _editedCultures.Contains(culture)); + => IsCultureAvailable(culture) && // is available, and + (!IsCulturePublished(culture) || // is not published, or + (_editedCultures != null && _editedCultures.Contains(culture))); // is edited /// [IgnoreDataMember] diff --git a/src/Umbraco.Core/Models/IContent.cs b/src/Umbraco.Core/Models/IContent.cs index 9e79a75e25..5910d01d34 100644 --- a/src/Umbraco.Core/Models/IContent.cs +++ b/src/Umbraco.Core/Models/IContent.cs @@ -87,6 +87,8 @@ namespace Umbraco.Core.Models /// A culture becomes published whenever values for this culture are published, /// and the content published name for this culture is non-null. It becomes non-published /// whenever values for this culture are unpublished. + /// A culture becomes published as soon as PublishCulture has been invoked, + /// even though the document might now have been saved yet (and can have no identity). /// bool IsCulturePublished(string culture); @@ -107,8 +109,9 @@ namespace Umbraco.Core.Models /// Gets a value indicated whether a given culture is edited. /// /// - /// A culture is edited when it is not published, or when it is published but - /// it has changes. + /// A culture is edited when it is available, and not published or published but + /// with changes. + /// A culture can be edited even though the document might now have been saved yet (and can have no identity). /// bool IsCultureEdited(string culture); diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/DocumentRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/DocumentRepository.cs index 093723cea5..28c0b0dec6 100644 --- a/src/Umbraco.Core/Persistence/Repositories/Implement/DocumentRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/Implement/DocumentRepository.cs @@ -1073,7 +1073,10 @@ namespace Umbraco.Core.Persistence.Repositories.Implement NodeId = content.Id, LanguageId = LanguageRepository.GetIdByIsoCode(culture) ?? throw new InvalidOperationException("Not a valid culture."), Culture = culture, - Edited = !content.IsCulturePublished(culture) || (editedCultures != null && editedCultures.Contains(culture)) // if not published, always edited + + // if not published, always edited + // no need to check for availability: it *is* available since it is in content.CultureNames + Edited = !content.IsCulturePublished(culture) || (editedCultures != null && editedCultures.Contains(culture)) }; } diff --git a/src/Umbraco.Web/Editors/ContentController.cs b/src/Umbraco.Web/Editors/ContentController.cs index f1fbfe7940..8c3cc5f557 100644 --- a/src/Umbraco.Web/Editors/ContentController.cs +++ b/src/Umbraco.Web/Editors/ContentController.cs @@ -745,7 +745,7 @@ namespace Umbraco.Web.Editors //Check if a mandatory language is missing from being published var variant = cultureVariants.First(x => x.Culture == lang.IsoCode); - var isPublished = contentItem.PersistedContent.IsCultureAvailable(lang.IsoCode) && contentItem.PersistedContent.IsCulturePublished(lang.IsoCode); + var isPublished = contentItem.PersistedContent.IsCulturePublished(lang.IsoCode); var isPublishing = variant.Publish; if (!isPublished && !isPublishing) diff --git a/src/Umbraco.Web/Models/Mapping/ContentSavedStateResolver.cs b/src/Umbraco.Web/Models/Mapping/ContentSavedStateResolver.cs index 1c9af34388..4fb4d3370a 100644 --- a/src/Umbraco.Web/Models/Mapping/ContentSavedStateResolver.cs +++ b/src/Umbraco.Web/Models/Mapping/ContentSavedStateResolver.cs @@ -28,8 +28,7 @@ namespace Umbraco.Web.Models.Mapping ? PublishedState.Published : PublishedState.Unpublished; - //it can only be 'edited' if the content item is persisted and if the variant has a name and it's flagged as edited - isEdited = source.Id > 0 && source.IsCultureAvailable(culture) && source.IsCultureEdited(culture); + isEdited = source.IsCultureEdited(culture); } else { @@ -37,17 +36,16 @@ namespace Umbraco.Web.Models.Mapping ? PublishedState.Unpublished : PublishedState.Published; - isEdited = source.Id > 0 && source.Edited; + isEdited = source.Edited; } - //now we can calculate the content state - if (!isEdited && publishedState == PublishedState.Unpublished) - return ContentSavedState.NotCreated; - if (isEdited && publishedState == PublishedState.Unpublished) - return ContentSavedState.Draft; - if (!isEdited && publishedState == PublishedState.Published) - return ContentSavedState.Published; - return ContentSavedState.PublishedPendingChanges; + if (publishedState == PublishedState.Unpublished) + return isEdited && source.Id > 0 ? ContentSavedState.Draft : ContentSavedState.NotCreated; + + if (publishedState == PublishedState.Published) + return isEdited ? ContentSavedState.PublishedPendingChanges : ContentSavedState.Published; + + throw new NotSupportedException($"PublishedState {publishedState} is not supported."); } } } From f7911988177068e02e6bd828cf27cfaad2469814 Mon Sep 17 00:00:00 2001 From: Stephan Date: Tue, 28 Aug 2018 18:45:37 +0200 Subject: [PATCH 2/3] Version 8.0.0-alpha.49 for ModelsBuilder --- src/SolutionInfo.cs | 2 +- src/Umbraco.Core/Configuration/UmbracoVersion.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SolutionInfo.cs b/src/SolutionInfo.cs index 77bd21b673..e6118de937 100644 --- a/src/SolutionInfo.cs +++ b/src/SolutionInfo.cs @@ -19,4 +19,4 @@ using System.Resources; // these are FYI and changed automatically [assembly: AssemblyFileVersion("8.0.0")] -[assembly: AssemblyInformationalVersion("8.0.0-alpha.44")] +[assembly: AssemblyInformationalVersion("8.0.0-alpha.49")] diff --git a/src/Umbraco.Core/Configuration/UmbracoVersion.cs b/src/Umbraco.Core/Configuration/UmbracoVersion.cs index 9c0ad4c7c4..8fb650510b 100644 --- a/src/Umbraco.Core/Configuration/UmbracoVersion.cs +++ b/src/Umbraco.Core/Configuration/UmbracoVersion.cs @@ -22,7 +22,7 @@ namespace Umbraco.Core.Configuration /// /// Gets the version comment of the executing code (eg "beta"). /// - public static string CurrentComment => "alpha.44"; + public static string CurrentComment => "alpha.49"; /// /// Gets the assembly version of Umbraco.Code.dll. From c743ac760d5cad83349a99bf3db3bd9a8edafe6d Mon Sep 17 00:00:00 2001 From: Stephan Date: Tue, 28 Aug 2018 20:02:25 +0200 Subject: [PATCH 3/3] Update ModelsBuilder to -alpha.22 --- build/NuSpecs/UmbracoCms.nuspec | 2 +- .../Umbraco.Tests.Benchmarks.csproj | 2 +- src/Umbraco.Web.UI/Umbraco.Web.UI.csproj | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build/NuSpecs/UmbracoCms.nuspec b/build/NuSpecs/UmbracoCms.nuspec index 6bc5d45e82..1deec235f8 100644 --- a/build/NuSpecs/UmbracoCms.nuspec +++ b/build/NuSpecs/UmbracoCms.nuspec @@ -22,7 +22,7 @@ not want this to happen as the alpha of the next major is, really, the next major already. --> - + diff --git a/src/Umbraco.Tests.Benchmarks/Umbraco.Tests.Benchmarks.csproj b/src/Umbraco.Tests.Benchmarks/Umbraco.Tests.Benchmarks.csproj index 19236e0163..7c8968d93b 100644 --- a/src/Umbraco.Tests.Benchmarks/Umbraco.Tests.Benchmarks.csproj +++ b/src/Umbraco.Tests.Benchmarks/Umbraco.Tests.Benchmarks.csproj @@ -61,7 +61,7 @@ - + diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index 7a6a6bcc19..08bee948ee 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -94,10 +94,10 @@ - + - - All + + all @@ -107,7 +107,7 @@ - 8.0.0-alpha.20 + 8.0.0-alpha.22