Skip to content

Commit 8fe10c6

Browse files
authored
feat: Create Global Sections Settings tab (#2845)
## What's the purpose of this pull request? It creates a new tab inside the Global Sections CMS. In the new Settings tab, it will be possible to configure settings related to regionalization, which will be used by components such as the Region Modal and Region Popover. This PR doesn't update all components/sections, it'll be done after. In this PR, there is an update to `FilterDesktop` so we can validate the change. ## How it works? The merchant will be able to configure their regionalization-related message in a single place (Global Sections Settings tab) instead of duplicate messages through sections. To avoid introducing breaking changes, I haven't removed the messages from the sections yet - this will be done in v4. I've added a deprecation notice in every field that was created in the Settings tab. In v3, the components/sections will use the messages defined in the sections CMS; if they're blank, they will use the messages in the Global Sections Settings tab. <img width="1227" alt="Screenshot 2025-05-15 at 10 30 42" src="https://github.com/user-attachments/assets/e1b9b32f-7270-43a7-8016-abb536c08272" /> ## How to test it? In the CMS of the vendemo store, I've added messages in the Global Sections Settings tab using a `[GS]` at the beginning of every message so we can identify the ones that are coming from this tab. - PLP I've only removed (left blank) the messages in `Product List Page > Product Gallery > Filter > Delivery Settings > **Delivery Section description**` and `Product List Page > Product Gallery > Filter > Delivery Settings > Delivery Custom labels > **Shipping label**`, those are the ones that should use the GS one. - Search page The messages from `Search Page > Product Gallery > Filter > Delivery Settings` were all left blank (we hadn't updated this page to add the messages -- so this page didn't have messages defined for those cases, and we hadn't noticed 😣). | PLP | Search Page | | ---- | ---- | | <img width="649" alt="Screenshot 2025-05-15 at 09 59 40" src="https://github.com/user-attachments/assets/199d8e0d-a638-4b3e-ade2-95bbeaaf3a86" /> | <img width="772" alt="Screenshot 2025-05-15 at 10 09 08" src="https://github.com/user-attachments/assets/8edc352e-bf44-46bd-92a2-f9232b407d77" /> | | <img width="1496" alt="Screenshot 2025-05-15 at 10 15 40" src="https://github.com/user-attachments/assets/17284640-fb0e-45d0-b44b-8c7db98fc7be" /> | <img width="1499" alt="Screenshot 2025-05-15 at 10 16 30" src="https://github.com/user-attachments/assets/97801ddd-3b87-4c1f-a166-f8ef7b8d6fcd" /> | | <img width="1495" alt="Screenshot 2025-05-15 at 10 17 37" src="https://github.com/user-attachments/assets/1eb5023c-b724-41f3-8b4f-8cc57f7c4b4c" /> | <img width="1495" alt="Screenshot 2025-05-15 at 10 18 05" src="https://github.com/user-attachments/assets/4457b88e-31a7-4aa2-83ed-8038290a1e2c" /> | ### Starters Deploy Preview - Vendemo [[PR](dp-faststore-org/vendemo-dp#17) / [preview](https://vendemo-cm9sir9v900u7z6llkl62l70j-7sfv6u49l.b.vtex.app/)] ## References - [Slack discussion thread](https://vtex.slack.com/archives/C03L3CRCDC4/p1747248599365189)
1 parent 3334890 commit 8fe10c6

File tree

13 files changed

+250
-58
lines changed

13 files changed

+250
-58
lines changed

packages/core/cms/faststore/content-types.json

Lines changed: 125 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,131 @@
33
"id": "globalSections",
44
"name": "Global Sections",
55
"scopes": ["global"],
6-
"configurationSchemaSets": [],
6+
"configurationSchemaSets": [
7+
{
8+
"name": "Settings",
9+
"configurations": [
10+
{
11+
"name": "regionalization",
12+
"schema": {
13+
"title": "Regionalization",
14+
"description": "Regionalization options",
15+
"type": "object",
16+
"properties": {
17+
"inputField": {
18+
"title": "Postal Code Input Field",
19+
"type": "object",
20+
"properties": {
21+
"label": {
22+
"title": "Label",
23+
"type": "string",
24+
"default": "Postal Code"
25+
},
26+
"errorMessage": {
27+
"title": "Error message",
28+
"type": "string",
29+
"default": "You entered an invalid Postal Code"
30+
},
31+
"noProductsAvailableErrorMessage": {
32+
"title": "Error message for the scenario of no products available for a given location",
33+
"type": "string",
34+
"default": "There are no products available for %s.",
35+
"description": "The '%s' will be replaced by the postal code value."
36+
},
37+
"buttonActionText": {
38+
"title": "Action label to apply the postal code",
39+
"type": "string",
40+
"default": "Apply"
41+
}
42+
}
43+
},
44+
"idkPostalCodeLink": {
45+
"title": "I don't know my postal code link",
46+
"type": "object",
47+
"properties": {
48+
"text": {
49+
"type": "string",
50+
"title": "Link Text",
51+
"default": "I don't know my Postal Code"
52+
},
53+
"to": {
54+
"type": "string",
55+
"title": "Action link"
56+
},
57+
"icon": {
58+
"title": "Icon",
59+
"type": "object",
60+
"properties": {
61+
"icon": {
62+
"title": "Icon",
63+
"type": "string",
64+
"enumNames": ["Arrow Square Out"],
65+
"enum": ["ArrowSquareOut"],
66+
"default": "ArrowSquareOut"
67+
},
68+
"alt": {
69+
"title": "Alternative Label",
70+
"type": "string",
71+
"default": "Arrow Square Out icon"
72+
}
73+
}
74+
}
75+
}
76+
},
77+
"deliverySettings": {
78+
"title": "PLP/Search Filter: Delivery Settings",
79+
"type": "object",
80+
"required": ["title", "description"],
81+
"properties": {
82+
"title": {
83+
"title": "Title",
84+
"type": "string",
85+
"default": "Delivery"
86+
},
87+
"description": {
88+
"title": "Description",
89+
"type": "string",
90+
"default": "Offers and delivery options vary based on region."
91+
},
92+
"setLocationButtonLabel": {
93+
"title": "Call to Action label",
94+
"type": "string",
95+
"default": "Set Location"
96+
},
97+
"deliveryCustomLabels": {
98+
"title": "Filter options labels",
99+
"type": "object",
100+
"properties": {
101+
"delivery": {
102+
"title": "Shipping label",
103+
"type": "string",
104+
"default": "Shipping to"
105+
},
106+
"pickupInPoint": {
107+
"title": "Pickup in point label",
108+
"type": "string",
109+
"default": "Pickup at"
110+
},
111+
"pickupNearby": {
112+
"title": "Pickup Nearby label",
113+
"type": "string",
114+
"default": "Pickup Nearby"
115+
},
116+
"pickupAll": {
117+
"title": "Pickup Anywhere label",
118+
"type": "string",
119+
"default": "Pickup Anywhere"
120+
}
121+
}
122+
}
123+
}
124+
}
125+
}
126+
}
127+
}
128+
]
129+
}
130+
],
7131
"isSingleton": true
8132
},
9133
{

packages/core/cms/faststore/sections.json

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,46 +1917,45 @@
19171917
"deliverySettings": {
19181918
"title": "Delivery Settings",
19191919
"type": "object",
1920-
"required": ["title", "description"],
19211920
"properties": {
19221921
"title": {
19231922
"title": "Delivery section title",
1924-
"type": "string",
1925-
"default": "Delivery"
1923+
"description": "[Deprecated] Use the fields from the Settings tab in Global Sections",
1924+
"type": "string"
19261925
},
19271926
"description": {
19281927
"title": "Delivery section description",
1929-
"type": "string",
1930-
"default": "Offers and delivery options vary based on region."
1928+
"description": "[Deprecated] Use the fields from the Settings tab in Global Sections",
1929+
"type": "string"
19311930
},
19321931
"setLocationButtonLabel": {
19331932
"title": "Call to Action label",
1934-
"type": "string",
1935-
"default": "Set Location"
1933+
"description": "[Deprecated] Use the fields from the Settings tab in Global Sections",
1934+
"type": "string"
19361935
},
19371936
"deliveryCustomLabels": {
19381937
"title": "Delivery Custom labels",
19391938
"type": "object",
19401939
"properties": {
19411940
"delivery": {
19421941
"title": "Shipping label",
1943-
"type": "string",
1944-
"default": "Shipping to"
1942+
"description": "[Deprecated] Use the fields from the Settings tab in Global Sections",
1943+
"type": "string"
19451944
},
19461945
"pickupInPoint": {
19471946
"title": "Pickup in point label",
1948-
"type": "string",
1949-
"default": "Pickup at"
1947+
"description": "[Deprecated] Use the fields from the Settings tab in Global Sections",
1948+
"type": "string"
19501949
},
19511950
"pickupNearby": {
19521951
"title": "Pickup Nearby label",
1953-
"type": "string",
1954-
"default": "Pickup Nearby"
1952+
"description": "[Deprecated] Use the fields from the Settings tab in Global Sections",
1953+
"type": "string"
19551954
},
19561955
"pickupAll": {
19571956
"title": "Pickup Anywhere label",
1958-
"type": "string",
1959-
"default": "Pickup Anywhere"
1957+
"description": "[Deprecated] Use the fields from the Settings tab in Global Sections",
1958+
"type": "string"
19601959
}
19611960
}
19621961
}
@@ -2267,24 +2266,23 @@
22672266
"properties": {
22682267
"label": {
22692268
"title": "Input field label",
2270-
"type": "string",
2271-
"default": "Postal Code"
2269+
"description": "[Deprecated] Use the fields from the Settings tab in Global Sections",
2270+
"type": "string"
22722271
},
22732272
"errorMessage": {
22742273
"title": "Input field error message",
2275-
"type": "string",
2276-
"default": "You entered an invalid Postal Code"
2274+
"description": "[Deprecated] Use the fields from the Settings tab in Global Sections",
2275+
"type": "string"
22772276
},
22782277
"noProductsAvailableErrorMessage": {
22792278
"title": "Input field error message for the scenario of no products available for a given location",
2280-
"type": "string",
2281-
"default": "There are no products available for %s.",
2282-
"description": "The '%s' will be replaced by the postal code value."
2279+
"description": "[Deprecated] Use the fields from the Settings tab in Global Sections The '%s' is replaced by the postal code value.",
2280+
"type": "string"
22832281
},
22842282
"buttonActionText": {
22852283
"title": "Input field action button label",
2286-
"type": "string",
2287-
"default": "Apply"
2284+
"description": "[Deprecated] Use the fields from the Settings tab in Global Sections",
2285+
"type": "string"
22882286
}
22892287
}
22902288
},
@@ -2295,27 +2293,28 @@
22952293
"text": {
22962294
"type": "string",
22972295
"title": "Link Text",
2298-
"default": "I don't know my Postal Code"
2296+
"description": "[Deprecated] Use the fields from the Settings tab in Global Sections"
22992297
},
23002298
"to": {
23012299
"type": "string",
2302-
"title": "Action link"
2300+
"title": "Action link",
2301+
"description": "[Deprecated] Use the fields from the Settings tab in Global Sections"
23032302
},
23042303
"icon": {
23052304
"title": "Icon",
23062305
"type": "object",
23072306
"properties": {
23082307
"icon": {
23092308
"title": "Icon",
2309+
"description": "[Deprecated] Use the fields from the Settings tab in Global Sections",
23102310
"type": "string",
23112311
"enumNames": ["Arrow Square Out"],
2312-
"enum": ["ArrowSquareOut"],
2313-
"default": "ArrowSquareOut"
2312+
"enum": ["ArrowSquareOut"]
23142313
},
23152314
"alt": {
23162315
"title": "Alternative Label",
2317-
"type": "string",
2318-
"default": "Arrow Square Out icon"
2316+
"description": "[Deprecated] Use the fields from the Settings tab in Global Sections",
2317+
"type": "string"
23192318
}
23202319
}
23212320
}
@@ -2348,24 +2347,23 @@
23482347
"properties": {
23492348
"label": {
23502349
"title": "Input field label",
2351-
"type": "string",
2352-
"default": "Postal Code"
2350+
"description": "[Deprecated] Use the fields from the Settings tab in Global Sections",
2351+
"type": "string"
23532352
},
23542353
"errorMessage": {
23552354
"title": "Input field error message",
2356-
"type": "string",
2357-
"default": "You entered an invalid Postal Code"
2355+
"description": "[Deprecated] Use the fields from the Settings tab in Global Sections",
2356+
"type": "string"
23582357
},
23592358
"noProductsAvailableErrorMessage": {
23602359
"title": "Input field error message for the scenario of no products available for a given location",
2361-
"type": "string",
2362-
"default": "There are no products available for %s.",
2363-
"description": "The '%s' will be replaced by the postal code value."
2360+
"description": "[Deprecated] Use the fields from the Settings tab in Global Sections The '%s' is replaced by the postal code value.",
2361+
"type": "string"
23642362
},
23652363
"buttonActionText": {
23662364
"title": "Input field action button label",
2367-
"type": "string",
2368-
"default": "Apply"
2365+
"description": "[Deprecated] Use the fields from the Settings tab in Global Sections",
2366+
"type": "string"
23692367
}
23702368
}
23712369
},
@@ -2393,27 +2391,28 @@
23932391
"text": {
23942392
"type": "string",
23952393
"title": "Link Text",
2396-
"default": "I don't know my Postal Code"
2394+
"description": "[Deprecated] Use the fields from the Settings tab in Global Sections"
23972395
},
23982396
"to": {
23992397
"type": "string",
2400-
"title": "Action link"
2398+
"title": "Action link",
2399+
"description": "[Deprecated] Use the fields from the Settings tab in Global Sections"
24012400
},
24022401
"icon": {
24032402
"title": "Icon",
24042403
"type": "object",
24052404
"properties": {
24062405
"icon": {
24072406
"title": "Icon",
2407+
"description": "[Deprecated] Use the fields from the Settings tab in Global Sections",
24082408
"type": "string",
24092409
"enumNames": ["Arrow Square Out"],
2410-
"enum": ["ArrowSquareOut"],
2411-
"default": "ArrowSquareOut"
2410+
"enum": ["ArrowSquareOut"]
24122411
},
24132412
"alt": {
24142413
"title": "Alternative Label",
2415-
"type": "string",
2416-
"default": "Arrow Square Out icon"
2414+
"description": "[Deprecated] Use the fields from the Settings tab in Global Sections",
2415+
"type": "string"
24172416
}
24182417
}
24192418
}

packages/core/src/components/cms/GlobalSections.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const GLOBAL_SECTIONS_FOOTER_CONTENT_TYPE = 'globalFooterSections'
1010

1111
export type GlobalSectionsData = {
1212
sections: Section[]
13+
settings?: Record<string, unknown>
1314
}
1415

1516
export const getGlobalSectionsByType = async (

packages/core/src/components/search/Filter/FilterDesktop.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import type { useFilter } from 'src/sdk/search/useFilter'
1616
import type { FilterSliderProps } from './FilterSlider'
1717

1818
import { sessionStore } from 'src/sdk/session'
19+
import { getRegionalizationSettings } from 'src/utils/globalSettings'
1920
import FilterDeliveryOption from './FilterDeliveryOption'
2021

2122
interface FilterDesktopProps
@@ -34,9 +35,11 @@ function FilterDesktop({
3435
}: FilterDesktopProps & ReturnType<typeof useFilter>) {
3536
const { resetInfiniteScroll, state, setState } = useSearch()
3637

37-
const deliveryLabel = deliverySettings?.title ?? 'Delivery'
38-
const { postalCode } = sessionStore.read()
38+
const { deliverySettings: deliverySettingsData } =
39+
getRegionalizationSettings(deliverySettings)
40+
const deliveryLabel = deliverySettingsData?.title ?? 'Delivery'
3941

42+
const { postalCode } = sessionStore.read()
4043
const shouldDisplayDeliveryButton = deliveryPromise.enabled && !postalCode
4144
const filteredFacets = deliveryPromise.enabled
4245
? facets
@@ -58,7 +61,7 @@ function FilterDesktop({
5861
index={0}
5962
type=""
6063
label={deliveryLabel}
61-
description={deliverySettings?.description}
64+
description={deliverySettingsData?.description}
6265
>
6366
<UIButton
6467
data-fs-filter-list-delivery-button
@@ -68,7 +71,7 @@ function FilterDesktop({
6871
}}
6972
icon={<UIIcon name="MapPin" />}
7073
>
71-
{deliverySettings?.setLocationButtonLabel ?? 'Set Location'}
74+
{deliverySettingsData?.setLocationButtonLabel ?? 'Set Location'}
7275
</UIButton>
7376
</UIFilterFacets>
7477
)}
@@ -86,7 +89,7 @@ function FilterDesktop({
8689
type={type}
8790
label={isDeliveryFacet ? deliveryLabel : label}
8891
description={
89-
isDeliveryFacet ? deliverySettings.description : undefined
92+
isDeliveryFacet ? deliverySettingsData.description : undefined
9093
}
9194
>
9295
{type === 'StoreFacetBoolean' && isExpanded && (
@@ -117,7 +120,7 @@ function FilterDesktop({
117120
<FilterDeliveryOption
118121
item={item}
119122
deliveryCustomLabels={
120-
deliverySettings.deliveryCustomLabels
123+
deliverySettingsData.deliveryCustomLabels
121124
}
122125
/>
123126
) : (

0 commit comments

Comments
 (0)