Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 30 additions & 15 deletions springfield/cms/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1001,16 +1001,19 @@ def ButtonBlock(themes=None, **kwargs):
themes: List of theme strings to include in the button settings.
"""

class _ButtonBlock(blocks.StructBlock):
class _ButtonBlock(LabelSourceMixin, blocks.StructBlock):
settings = BaseButtonSettings(themes=themes)
label = blocks.CharBlock(label="Button Text")
link = SpringfieldLinkBlock()

class Meta:
template = "cms/blocks/button.html"
label = "Button"
label_format = "Button - {label}"
label_format = "{custom_label}"
value_class = BaseButtonValue
form_layout = blocks.BlockGroup(
children=["pretranslated_label", "custom_label", "link"],
settings=["settings"],
)

return _ButtonBlock(**kwargs)

Expand All @@ -1027,49 +1030,58 @@ def theme_class(self) -> str:


def UITourButtonBlock(themes=None, **kwargs):
class _UITourButtonBlock(blocks.StructBlock):
class _UITourButtonBlock(LabelSourceMixin, blocks.StructBlock):
settings = BaseButtonSettings(themes=themes)
button_type = blocks.ChoiceBlock(
default=UITOUR_BUTTON_NEW_TAB,
choices=UITOUR_BUTTON_CHOICES,
inline_form=True,
)
label = blocks.CharBlock(label="Button Text")

class Meta:
template = "cms/blocks/uitour_button.html"
label = "UI Tour Button"
label_format = "UI Tour Button - {label}"
label_format = "{custom_label}"
value_class = UITourButtonValue
form_layout = blocks.BlockGroup(
children=["pretranslated_label", "custom_label", "button_type"],
settings=["settings"],
)

return _UITourButtonBlock(**kwargs)


def FXAccountButtonBlock(themes=None, **kwargs):
class _FXAccountButtonBlock(blocks.StructBlock):
class _FXAccountButtonBlock(LabelSourceMixin, blocks.StructBlock):
settings = BaseButtonSettings(themes=themes)
label = blocks.CharBlock(label="Button Text")

class Meta:
template = "cms/blocks/fxa_button.html"
label = "Firefox Account Button"
label_format = "Firefox Account Button"
label_format = "{custom_label}"
value_class = BaseButtonValue
form_layout = blocks.BlockGroup(
children=["pretranslated_label", "custom_label"],
settings=["settings"],
)

return _FXAccountButtonBlock(**kwargs)


def SetAsDefaultButtonBlock(themes=None, **kwargs):
class _SetAsDefaultButtonBlock(blocks.StructBlock):
class _SetAsDefaultButtonBlock(LabelSourceMixin, blocks.StructBlock):
settings = BaseButtonSettings(themes=themes)
label = blocks.CharBlock(label="Button Text")
snippet = LocalizedLiveSnippetChooserBlock("cms.SetAsDefaultSnippet", label="Set as Default Snippet")

class Meta:
template = "cms/blocks/set_as_default_button.html"
label = "Set As Default Button"
label_format = "Set As Default Button"
label_format = "{custom_label}"
value_class = BaseButtonValue
form_layout = blocks.BlockGroup(
children=["pretranslated_label", "custom_label", "snippet"],
settings=["settings"],
)

return _SetAsDefaultButtonBlock(**kwargs)

Expand Down Expand Up @@ -1169,9 +1181,8 @@ class Meta:


def FirefoxFocusButtonBlock(themes=None, **kwargs):
class _FirefoxFocusButtonBlock(blocks.StructBlock):
class _FirefoxFocusButtonBlock(LabelSourceMixin, blocks.StructBlock):
settings = BaseButtonSettings(themes=themes)
label = blocks.CharBlock(label="Button Text", default="Get Firefox Focus")
store = blocks.ChoiceBlock(
choices=[
("android", "Android (Google Play)"),
Expand All @@ -1182,9 +1193,13 @@ class _FirefoxFocusButtonBlock(blocks.StructBlock):

class Meta:
label = "Firefox Focus Button"
label_format = "Firefox Focus Button - {label}"
label_format = "{custom_label}"
template = "cms/blocks/firefox-focus-button.html"
value_class = BaseButtonValue
form_layout = blocks.BlockGroup(
children=["pretranslated_label", "custom_label", "store"],
settings=["settings"],
)

return _FirefoxFocusButtonBlock(**kwargs)

Expand Down
51 changes: 34 additions & 17 deletions springfield/cms/fixtures/button_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def get_button_variants(full=False) -> dict[str, dict]:
"icon_position": "right",
"analytics_id": "c4c4c73d-a612-452d-b1af-f4c0810fb441",
},
"label": "Button",
"pretranslated_label": None,
"custom_label": "Button",
"link": {
"link_to": "custom_url",
"page": None,
Expand All @@ -51,7 +52,8 @@ def get_button_variants(full=False) -> dict[str, dict]:
"icon_position": "right",
"analytics_id": "cfdf0d2c-7eee-49c2-8747-80450e22dbdd",
},
"label": "Button",
"pretranslated_label": None,
"custom_label": "Button",
"link": {
"link_to": "custom_url",
"page": None,
Expand All @@ -75,7 +77,8 @@ def get_button_variants(full=False) -> dict[str, dict]:
"icon_position": "left",
"analytics_id": "83b0d9d6-2b49-4704-b06a-1300704e12fc",
},
"label": "Button",
"pretranslated_label": None,
"custom_label": "Button",
"link": {
"link_to": "custom_url",
"page": None,
Expand All @@ -99,7 +102,8 @@ def get_button_variants(full=False) -> dict[str, dict]:
"icon_position": "left",
"analytics_id": "83b0d9d6-2b49-4704-b06a-1300704e12fc",
},
"label": "Button",
"pretranslated_label": None,
"custom_label": "Button",
"link": {
"link_to": "custom_url",
"page": None,
Expand Down Expand Up @@ -147,7 +151,8 @@ def get_button_variants(full=False) -> dict[str, dict]:
"icon_position": "right",
"analytics_id": "83b0d9d6-2b49-4704-b06a-1300704e12fc",
},
"label": "Learn more",
"pretranslated_label": None,
"custom_label": "Learn more",
"link": {
"link_to": "custom_url",
"page": None,
Expand All @@ -166,7 +171,8 @@ def get_button_variants(full=False) -> dict[str, dict]:
"type": "button",
"value": {
"settings": {"theme": "", "icon": "", "icon_position": "right", "analytics_id": "5383592c-13c2-407a-82fe-f099617c05d9"},
"label": "Mozilla",
"pretranslated_label": None,
"custom_label": "Mozilla",
"link": {
"link_to": "custom_url",
"page": None,
Expand All @@ -190,7 +196,8 @@ def get_button_variants(full=False) -> dict[str, dict]:
"icon_position": "right",
"analytics_id": "b4adffda-872a-4f2b-b45a-63ac7cb71e91",
},
"label": "Relay new Tab",
"pretranslated_label": None,
"custom_label": "Relay new Tab",
"link": {
"link_to": "custom_url",
"page": None,
Expand All @@ -214,7 +221,8 @@ def get_button_variants(full=False) -> dict[str, dict]:
"icon_position": "right",
"analytics_id": "77d97583-3536-48ae-a72f-6a67077b9988",
},
"label": "Wikipedia",
"pretranslated_label": None,
"custom_label": "Wikipedia",
"link": {
"link_to": "custom_url",
"page": None,
Expand All @@ -238,7 +246,8 @@ def get_button_variants(full=False) -> dict[str, dict]:
"icon_position": "left",
"analytics_id": "4c411613-ef35-46c0-9eff-3a1bef76dabd",
},
"label": "Wikipedia new Tab",
"pretranslated_label": None,
"custom_label": "Wikipedia new Tab",
"link": {
"link_to": "custom_url",
"page": None,
Expand All @@ -262,7 +271,8 @@ def get_button_variants(full=False) -> dict[str, dict]:
"icon_position": "left",
"analytics_id": "d9456b7f-015d-4799-a2c8-e67a2246bf4f",
},
"label": "Log in to Mozilla Account",
"pretranslated_label": None,
"custom_label": "Log in to Mozilla Account",
},
"id": "bc17ead3-29c7-44d5-b8b8-0b0aaaee3e56",
},
Expand Down Expand Up @@ -315,7 +325,8 @@ def get_button_variants(full=False) -> dict[str, dict]:
"icon_position": "right",
"analytics_id": "fb000001-0000-0000-0000-000000000001",
},
"label": "Get Firefox Focus for Android",
"pretranslated_label": None,
"custom_label": "Get Firefox Focus for Android",
"store": "android",
},
"id": "fb000001-0000-0000-0000-000000000002",
Expand All @@ -329,7 +340,8 @@ def get_button_variants(full=False) -> dict[str, dict]:
"icon_position": "right",
"analytics_id": "fb000001-0000-0000-0000-000000000003",
},
"label": "Get Firefox Focus for iOS",
"pretranslated_label": None,
"custom_label": "Get Firefox Focus for iOS",
"store": "ios",
},
"id": "fb000001-0000-0000-0000-000000000004",
Expand All @@ -349,7 +361,8 @@ def get_button_variants(full=False) -> dict[str, dict]:
"icon_position": "left",
"analytics_id": "0fef2106-9dd4-4185-9d5d-e9c352392c15",
},
"label": "Test Index Page",
"pretranslated_label": None,
"custom_label": "Test Index Page",
"link": {
"link_to": "page",
"page": index_page.id,
Expand All @@ -373,7 +386,8 @@ def get_button_variants(full=False) -> dict[str, dict]:
"icon_position": "left",
"analytics_id": "151a5822-63b4-4621-b146-4135044f21b8",
},
"label": "Test Index in new tab",
"pretranslated_label": None,
"custom_label": "Test Index in new tab",
"link": {
"link_to": "page",
"page": index_page.id,
Expand All @@ -397,7 +411,8 @@ def get_button_variants(full=False) -> dict[str, dict]:
"icon_position": "left",
"analytics_id": "2ce75501-5dc6-44cf-8609-61ee89c914b0",
},
"label": "Open document",
"pretranslated_label": None,
"custom_label": "Open document",
"link": {
"link_to": "file",
"page": None,
Expand All @@ -421,7 +436,8 @@ def get_button_variants(full=False) -> dict[str, dict]:
"icon_position": "left",
"analytics_id": "569de137-625d-48f7-bbfb-0fe87b43da83",
},
"label": "Email",
"pretranslated_label": None,
"custom_label": "Email",
"link": {
"link_to": "email",
"page": None,
Expand All @@ -445,7 +461,8 @@ def get_button_variants(full=False) -> dict[str, dict]:
"icon_position": "left",
"analytics_id": "db29813f-1941-4e78-83ac-856943e34490",
},
"label": "Phone",
"pretranslated_label": None,
"custom_label": "Phone",
"link": {
"link_to": "phone",
"page": None,
Expand Down
12 changes: 8 additions & 4 deletions springfield/cms/fixtures/freeformpage_2026.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def get_mobile_browsers_cards():
"type": "button",
"value": {
"settings": {**link_button_settings, "analytics_id": "11111111-1111-1111-1111-111111111111"},
"label": "Learn more",
"pretranslated_label": None,
"custom_label": "Learn more",
"link": {
"link_to": "custom_url",
"page": None,
Expand Down Expand Up @@ -100,7 +101,8 @@ def get_mobile_browsers_cards():
"type": "button",
"value": {
"settings": {**link_button_settings, "analytics_id": "22222222-2222-2222-2222-222222222221"},
"label": "Learn more",
"pretranslated_label": None,
"custom_label": "Learn more",
"link": {
"link_to": "custom_url",
"page": None,
Expand Down Expand Up @@ -131,7 +133,8 @@ def get_mobile_browsers_cards():
"type": "button",
"value": {
"settings": {**link_button_settings, "analytics_id": "33333333-3333-3333-3333-333333333331"},
"label": "Learn more",
"pretranslated_label": None,
"custom_label": "Learn more",
"link": {
"link_to": "custom_url",
"page": None,
Expand Down Expand Up @@ -244,7 +247,8 @@ def get_set_as_default_button_block() -> dict:
"icon_position": "right",
"analytics_id": "sad00001-0000-0000-0000-000000000002",
},
"label": "Set Firefox as default",
"pretranslated_label": None,
"custom_label": "Set Firefox as default",
"snippet": snippet.id,
},
"id": "sad00001-0000-0000-0000-000000000003",
Expand Down
3 changes: 2 additions & 1 deletion springfield/cms/fixtures/roadmap_list_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ def get_roadmap_page_intro() -> list[dict]:
"icon_position": "right",
"analytics_id": "rm0000-0000-0000-0000-000000000002",
},
"label": "What's New",
"pretranslated_label": None,
"custom_label": "What's New",
"link": {
"link_to": "page",
"page": get_whatsnew_index_page().id,
Expand Down
11 changes: 6 additions & 5 deletions springfield/cms/fixtures/sliding_carousel_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
_SHOW_TO_ALL = {"platforms": [], "firefox": "", "auth_state": ""}


def _image(image_id, dark_mode_image_id=None):
def _image(image_id, dark_mode_image_id=None, block_id=None):
return {
"type": "image",
"value": {
Expand All @@ -21,7 +21,8 @@ def _image(image_id, dark_mode_image_id=None):
"dark_mode_mobile_image": None,
},
},
"id": None,
# Stable id required for wagtail_localize (StreamBlock children must have one).
"id": block_id,
}


Expand All @@ -45,7 +46,7 @@ def get_sliding_carousel_slides() -> list[dict]:
superheading_text="Privacy",
subheading_text="Control who can see your browsing activity.",
),
"media": [_image(img, dark)],
"media": [_image(img, dark, block_id="2026sc01-0000-0000-0000-0000000000a1")],
},
"id": "2026sc01-0000-0000-0000-000000000001",
},
Expand All @@ -57,7 +58,7 @@ def get_sliding_carousel_slides() -> list[dict]:
superheading_text="Security",
subheading_text="Enhanced Tracking Protection works out of the box.",
),
"media": [_image(dark, img)],
"media": [_image(dark, img, block_id="2026sc01-0000-0000-0000-0000000000a2")],
},
"id": "2026sc01-0000-0000-0000-000000000002",
},
Expand All @@ -69,7 +70,7 @@ def get_sliding_carousel_slides() -> list[dict]:
superheading_text="Sync",
subheading_text="Bookmarks, passwords, and tabs — always with you.",
),
"media": [_image(img)],
"media": [_image(img, block_id="2026sc01-0000-0000-0000-0000000000a3")],
},
"id": "2026sc01-0000-0000-0000-000000000003",
},
Expand Down
Loading
Loading