diff --git a/frontend/src/Components/Form/ProviderFieldFormGroup.js b/frontend/src/Components/Form/ProviderFieldFormGroup.js index 2b32e0e38..878e3a7ce 100644 --- a/frontend/src/Components/Form/ProviderFieldFormGroup.js +++ b/frontend/src/Components/Form/ProviderFieldFormGroup.js @@ -67,6 +67,7 @@ function ProviderFieldFormGroup(props) { name, label, helpText, + helpTextWarning, helpLink, placeholder, value, @@ -100,6 +101,7 @@ function ProviderFieldFormGroup(props) { name={name} label={label} helpText={helpText} + helpTextWarning={helpTextWarning} helpLink={helpLink} placeholder={placeholder} value={value} @@ -126,6 +128,7 @@ ProviderFieldFormGroup.propTypes = { name: PropTypes.string.isRequired, label: PropTypes.string, helpText: PropTypes.string, + helpTextWarning: PropTypes.string, helpLink: PropTypes.string, placeholder: PropTypes.string, value: PropTypes.any, diff --git a/src/NzbDrone.Core/Annotations/FieldDefinitionAttribute.cs b/src/NzbDrone.Core/Annotations/FieldDefinitionAttribute.cs index bb56e1a02..d35409c0b 100644 --- a/src/NzbDrone.Core/Annotations/FieldDefinitionAttribute.cs +++ b/src/NzbDrone.Core/Annotations/FieldDefinitionAttribute.cs @@ -15,6 +15,7 @@ namespace NzbDrone.Core.Annotations public string Label { get; set; } public string Unit { get; set; } public string HelpText { get; set; } + public string HelpTextWarning { get; set; } public string HelpLink { get; set; } public FieldType Type { get; set; } public bool Advanced { get; set; } diff --git a/src/Prowlarr.Api.V1.Test/ClientSchemaTests/SchemaBuilderFixture.cs b/src/Prowlarr.Api.V1.Test/ClientSchemaTests/SchemaBuilderFixture.cs index 049deb3df..16b54921f 100644 --- a/src/Prowlarr.Api.V1.Test/ClientSchemaTests/SchemaBuilderFixture.cs +++ b/src/Prowlarr.Api.V1.Test/ClientSchemaTests/SchemaBuilderFixture.cs @@ -27,19 +27,47 @@ namespace NzbDrone.Api.Test.ClientSchemaTests var schema = SchemaBuilder.ToSchema(model); - schema.Should().Contain(c => c.Order == 1 && c.Name == "lastName" && c.Label == "Last Name" && c.HelpText == "Your Last Name" && (string)c.Value == "Poop"); - schema.Should().Contain(c => c.Order == 0 && c.Name == "firstName" && c.Label == "First Name" && c.HelpText == "Your First Name" && (string)c.Value == "Bob"); + schema.Should().Contain(c => c.Order == 1 && c.Name == "lastName" && c.Label == "Last Name" && c.HelpText == "Your Last Name" && c.HelpTextWarning == "Mandatory Last Name" && (string)c.Value == "Poop"); + schema.Should().Contain(c => c.Order == 0 && c.Name == "firstName" && c.Label == "First Name" && c.HelpText == "Your First Name" && c.HelpTextWarning == "Mandatory First Name" && (string)c.Value == "Bob"); + } + + [Test] + public void schema_should_have_nested_fields() + { + var model = new NestedTestModel + { + Name = + { + FirstName = "Bob", + LastName = "Poop" + } + }; + + var schema = SchemaBuilder.ToSchema(model); + + schema.Should().Contain(c => c.Order == 0 && c.Name == "name.firstName" && c.Label == "First Name" && c.HelpText == "Your First Name" && c.HelpTextWarning == "Mandatory First Name" && (string)c.Value == "Bob"); + schema.Should().Contain(c => c.Order == 1 && c.Name == "name.lastName" && c.Label == "Last Name" && c.HelpText == "Your Last Name" && c.HelpTextWarning == "Mandatory Last Name" && (string)c.Value == "Poop"); + schema.Should().Contain(c => c.Order == 2 && c.Name == "quote" && c.Label == "Quote" && c.HelpText == "Your Favorite Quote"); } } public class TestModel { - [FieldDefinition(0, Label = "First Name", HelpText = "Your First Name")] + [FieldDefinition(0, Label = "First Name", HelpText = "Your First Name", HelpTextWarning = "Mandatory First Name")] public string FirstName { get; set; } - [FieldDefinition(1, Label = "Last Name", HelpText = "Your Last Name")] + [FieldDefinition(1, Label = "Last Name", HelpText = "Your Last Name", HelpTextWarning = "Mandatory Last Name")] public string LastName { get; set; } public string Other { get; set; } } + + public class NestedTestModel + { + [FieldDefinition(0)] + public TestModel Name { get; set; } = new TestModel(); + + [FieldDefinition(1, Label = "Quote", HelpText = "Your Favorite Quote")] + public string Quote { get; set; } + } } diff --git a/src/Prowlarr.Http/ClientSchema/Field.cs b/src/Prowlarr.Http/ClientSchema/Field.cs index 1e6f58ff4..0ef510ca6 100644 --- a/src/Prowlarr.Http/ClientSchema/Field.cs +++ b/src/Prowlarr.Http/ClientSchema/Field.cs @@ -10,6 +10,7 @@ namespace Prowlarr.Http.ClientSchema public string Label { get; set; } public string Unit { get; set; } public string HelpText { get; set; } + public string HelpTextWarning { get; set; } public string HelpLink { get; set; } public object Value { get; set; } public string Type { get; set; } diff --git a/src/Prowlarr.Http/ClientSchema/SchemaBuilder.cs b/src/Prowlarr.Http/ClientSchema/SchemaBuilder.cs index 3f36760af..424ea27bc 100644 --- a/src/Prowlarr.Http/ClientSchema/SchemaBuilder.cs +++ b/src/Prowlarr.Http/ClientSchema/SchemaBuilder.cs @@ -99,6 +99,7 @@ namespace Prowlarr.Http.ClientSchema Label = fieldAttribute.Label, Unit = fieldAttribute.Unit, HelpText = fieldAttribute.HelpText, + HelpTextWarning = fieldAttribute.HelpTextWarning, HelpLink = fieldAttribute.HelpLink, Order = fieldAttribute.Order, Advanced = fieldAttribute.Advanced,