mirror of
https://github.com/discourse/discourse.git
synced 2026-08-10 04:58:31 -05:00
FIX: support nested descriptions in object settings (#37538)
Reported here: https://meta.discourse.org/t/labels-and-descriptions-missing-from-nested-object-settings/394685 Descriptions for nested object settings were not being displayed due to a mismatch in locale key formatting. Stripping `.schema.properties.` so that the locale keys from the serializer match the keys expected in the template fixes it Before: <img width="600" alt="image" src="https://github.com/user-attachments/assets/1e0ab4c6-e6eb-478d-97bc-76f16739135b" /> After: <img width="600" alt="image" src="https://github.com/user-attachments/assets/a9a9e64c-4efa-4807-94a1-dd853ffd9f04" />
This commit is contained in:
+14
-6
@@ -9,9 +9,17 @@ en:
|
||||
label: Name
|
||||
description: "Section Name"
|
||||
links:
|
||||
name:
|
||||
label: Name
|
||||
description: "Name of the link"
|
||||
url:
|
||||
label: URL
|
||||
description: "URL of the link"
|
||||
schema:
|
||||
properties:
|
||||
name:
|
||||
label: Name
|
||||
description: "Name of the link"
|
||||
url:
|
||||
label: URL
|
||||
description: "URL of the link"
|
||||
child_links:
|
||||
schema:
|
||||
properties:
|
||||
title:
|
||||
label: Title
|
||||
description: "Title of the child link"
|
||||
|
||||
@@ -1647,6 +1647,8 @@ RSpec.describe Admin::ThemesController do
|
||||
|
||||
expect(response.parsed_body["property_descriptions"]).to eq(
|
||||
{
|
||||
"links.child_links.title.description" => "Title of the child link",
|
||||
"links.child_links.title.label" => "Title",
|
||||
"links.name.description" => "Name of the link",
|
||||
"links.name.label" => "Name",
|
||||
"links.url.description" => "URL of the link",
|
||||
|
||||
@@ -21,13 +21,15 @@ RSpec.describe ThemeObjectsSettingMetadataSerializer do
|
||||
theme.save!
|
||||
end
|
||||
|
||||
it "should return a hash of the settings property descriptions" do
|
||||
it "should return a hash of the settings property descriptions with schema.properties segments stripped" do
|
||||
objects_setting_locale
|
||||
|
||||
payload = described_class.new(theme_setting[:objects_setting], root: false).as_json
|
||||
|
||||
expect(payload[:property_descriptions]).to eq(
|
||||
{
|
||||
"links.child_links.title.description" => "Title of the child link",
|
||||
"links.child_links.title.label" => "Title",
|
||||
"links.name.description" => "Name of the link",
|
||||
"links.name.label" => "Name",
|
||||
"links.url.description" => "URL of the link",
|
||||
@@ -36,6 +38,8 @@ RSpec.describe ThemeObjectsSettingMetadataSerializer do
|
||||
"name.label" => "Name",
|
||||
},
|
||||
)
|
||||
|
||||
expect(payload[:property_descriptions]).not_to have_key("links.schema.properties.name.label")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user