diff --git a/src/Umbraco.Cms.Api.Management/Controllers/Document/ConfigurationDocumentController.cs b/src/Umbraco.Cms.Api.Management/Controllers/Document/ConfigurationDocumentController.cs index 4008498e56..a900477296 100644 --- a/src/Umbraco.Cms.Api.Management/Controllers/Document/ConfigurationDocumentController.cs +++ b/src/Umbraco.Cms.Api.Management/Controllers/Document/ConfigurationDocumentController.cs @@ -12,11 +12,16 @@ public class ConfigurationDocumentController : DocumentControllerBase { private readonly GlobalSettings _globalSettings; private readonly ContentSettings _contentSettings; + private readonly SegmentSettings _segmentSettings; - public ConfigurationDocumentController(IOptionsSnapshot globalSettings, IOptionsSnapshot contentSettings) + public ConfigurationDocumentController( + IOptionsSnapshot globalSettings, + IOptionsSnapshot contentSettings, + IOptionsSnapshot segmentSettings) { _contentSettings = contentSettings.Value; _globalSettings = globalSettings.Value; + _segmentSettings = segmentSettings.Value; } [HttpGet("configuration")] @@ -30,7 +35,9 @@ public class ConfigurationDocumentController : DocumentControllerBase DisableUnpublishWhenReferenced = _contentSettings.DisableUnpublishWhenReferenced, SanitizeTinyMce = _globalSettings.SanitizeTinyMce, AllowEditInvariantFromNonDefault = _contentSettings.AllowEditInvariantFromNonDefault, + AllowNonExistingSegmentsCreation = _segmentSettings.AllowCreation, }; + return Task.FromResult(Ok(responseModel)); } } diff --git a/src/Umbraco.Cms.Api.Management/Controllers/DocumentType/ConfigurationDocumentTypeController.cs b/src/Umbraco.Cms.Api.Management/Controllers/DocumentType/ConfigurationDocumentTypeController.cs index 8ca204017b..ee04389885 100644 --- a/src/Umbraco.Cms.Api.Management/Controllers/DocumentType/ConfigurationDocumentTypeController.cs +++ b/src/Umbraco.Cms.Api.Management/Controllers/DocumentType/ConfigurationDocumentTypeController.cs @@ -13,11 +13,16 @@ public class ConfigurationDocumentTypeController : DocumentTypeControllerBase { private readonly UmbracoFeatures _umbracoFeatures; private readonly DataTypesSettings _dataTypesSettings; + private readonly SegmentSettings _segmentSettings; - public ConfigurationDocumentTypeController(UmbracoFeatures umbracoFeatures, IOptionsSnapshot dataTypesSettings) + public ConfigurationDocumentTypeController( + UmbracoFeatures umbracoFeatures, + IOptionsSnapshot dataTypesSettings, + IOptionsSnapshot segmentSettings) { _umbracoFeatures = umbracoFeatures; _dataTypesSettings = dataTypesSettings.Value; + _segmentSettings = segmentSettings.Value; } [HttpGet("configuration")] @@ -29,7 +34,9 @@ public class ConfigurationDocumentTypeController : DocumentTypeControllerBase { DataTypesCanBeChanged = _dataTypesSettings.CanBeChanged, DisableTemplates = _umbracoFeatures.Disabled.DisableTemplates, + UseSegments = _segmentSettings.Enabled, }; + return Task.FromResult(Ok(responseModel)); } } diff --git a/src/Umbraco.Cms.Api.Management/OpenApi.json b/src/Umbraco.Cms.Api.Management/OpenApi.json index 40367c29f7..b37246c780 100644 --- a/src/Umbraco.Cms.Api.Management/OpenApi.json +++ b/src/Umbraco.Cms.Api.Management/OpenApi.json @@ -34216,6 +34216,7 @@ "DocumentConfigurationResponseModel": { "required": [ "allowEditInvariantFromNonDefault", + "allowNonExistingSegmentsCreation", "disableDeleteWhenReferenced", "disableUnpublishWhenReferenced", "sanitizeTinyMce" @@ -34233,6 +34234,9 @@ }, "allowEditInvariantFromNonDefault": { "type": "boolean" + }, + "allowNonExistingSegmentsCreation": { + "type": "boolean" } }, "additionalProperties": false @@ -34506,7 +34510,8 @@ "DocumentTypeConfigurationResponseModel": { "required": [ "dataTypesCanBeChanged", - "disableTemplates" + "disableTemplates", + "useSegments" ], "type": "object", "properties": { @@ -34515,6 +34520,9 @@ }, "disableTemplates": { "type": "boolean" + }, + "useSegments": { + "type": "boolean" } }, "additionalProperties": false diff --git a/src/Umbraco.Cms.Api.Management/ViewModels/Document/DocumentConfigurationResponseModel.cs b/src/Umbraco.Cms.Api.Management/ViewModels/Document/DocumentConfigurationResponseModel.cs index e6bd12e476..626a294eb3 100644 --- a/src/Umbraco.Cms.Api.Management/ViewModels/Document/DocumentConfigurationResponseModel.cs +++ b/src/Umbraco.Cms.Api.Management/ViewModels/Document/DocumentConfigurationResponseModel.cs @@ -9,4 +9,6 @@ public class DocumentConfigurationResponseModel public required bool DisableUnpublishWhenReferenced { get; set; } public required bool AllowEditInvariantFromNonDefault { get; set; } + + public required bool AllowNonExistingSegmentsCreation { get; set; } } diff --git a/src/Umbraco.Cms.Api.Management/ViewModels/DocumentType/DocumentTypeConfigurationResponseModel.cs b/src/Umbraco.Cms.Api.Management/ViewModels/DocumentType/DocumentTypeConfigurationResponseModel.cs index d4cd9e1c49..c575cc7bc1 100644 --- a/src/Umbraco.Cms.Api.Management/ViewModels/DocumentType/DocumentTypeConfigurationResponseModel.cs +++ b/src/Umbraco.Cms.Api.Management/ViewModels/DocumentType/DocumentTypeConfigurationResponseModel.cs @@ -7,4 +7,6 @@ public class DocumentTypeConfigurationResponseModel public required DataTypeChangeMode DataTypesCanBeChanged { get; set; } public required bool DisableTemplates { get; set; } + + public required bool UseSegments { get; set; } } diff --git a/src/Umbraco.Core/Configuration/Models/SegmentSettings.cs b/src/Umbraco.Core/Configuration/Models/SegmentSettings.cs new file mode 100644 index 0000000000..e6fc90995a --- /dev/null +++ b/src/Umbraco.Core/Configuration/Models/SegmentSettings.cs @@ -0,0 +1,23 @@ +using System.ComponentModel; + +namespace Umbraco.Cms.Core.Configuration.Models; + +/// +/// Typed configuration options for segment settings. +/// +public class SegmentSettings +{ + private const bool StaticEnabled = false; + private const bool StaticAllowCreation = true; + + /// + /// Gets or sets a value indicating whether the usage of segments is enabled. + /// + [DefaultValue(StaticEnabled)] + public bool Enabled { get; set; } = StaticEnabled; + + /// + /// Gets or sets a value indicating whether the creation of non-existing segments is allowed. + /// + public bool AllowCreation { get; set; } = StaticAllowCreation; +}