From 8a2d29da8497cf0c9a8e8a96bb7d1c980ccdb3dd Mon Sep 17 00:00:00 2001 From: Niels Mokkenstorm Date: Mon, 10 Aug 2026 10:44:08 +0000 Subject: [PATCH] refactor: unify amend copy in shared record_detail helpers --- web/test/record_amend_test.gleam | 12 ++++-------- web/src/crate_web/view.gleam | 7 +------ web/src/crate_web/pages/record.gleam | 14 +------------- web/src/crate_web/pages/record_amend.gleam | 15 ++------------- web/src/crate_web/ui/record_detail.gleam | 23 ++++++----------------- 5 file(s) changed, 14 insertion(s)(+), 57 deletion(s)(-) diff --git a/web/test/record_amend_test.gleam b/web/test/record_amend_test.gleam --- a/web/test/record_amend_test.gleam +++ b/web/test/record_amend_test.gleam @@ -130,13 +130,9 @@ assert effect == empty_effect() } -pub fn record_amend_page_titles_itself_by_the_entrys_provenance_test() { - [ - #(dict.new(), "AMEND PRESSING"), - #(dict.from_list([#("e1", "bob.test")]), "SUGGEST A FIX"), - ] - |> list.each(fn(row) { - let #(via_handles, expected_title) = row +pub fn record_amend_page_titles_itself_amend_regardless_of_provenance_test() { + [dict.new(), dict.from_list([#("e1", "bob.test")])] + |> list.each(fn(via_handles) { let seeded = set_crate( Model(..logged_in(), route: RecordAmend("e1"), via_handles:), @@ -144,7 +140,7 @@ ShelfLoaded(Own, [an_entry()]), ) let html = view.view(seeded) |> element.to_string - assert string.contains(html, expected_title) + assert string.contains(html, "AMEND") }) } diff --git a/web/src/crate_web/view.gleam b/web/src/crate_web/view.gleam --- a/web/src/crate_web/view.gleam +++ b/web/src/crate_web/view.gleam @@ -28,7 +28,6 @@ import crate_web/route import crate_web/ui/app_bar as bar import crate_web/ui/nav -import crate_web/ui/record_detail as rd import crate_web/ui/states import gleam/option.{type Option, None, Some} import lustre/attribute as attr @@ -157,7 +156,7 @@ } RecordAmend(entry_id) -> sub_page_to( - amend_title(model, entry_id), + "AMEND", route.to_path(Record(entry_id)), element.none(), record_amend.view(model), @@ -194,10 +193,6 @@ ), body, ]) -} - -fn amend_title(model: Model, entry_id: String) -> String { - rd.amend_action_label(model.via_handles, entry_id, "AMEND PRESSING") } fn edit_proposal_page(model: Model, id: String) -> Element(Msg) { diff --git a/web/src/crate_web/pages/record.gleam b/web/src/crate_web/pages/record.gleam --- a/web/src/crate_web/pages/record.gleam +++ b/web/src/crate_web/pages/record.gleam @@ -48,7 +48,7 @@ html.div([attr.class("actions-block")], [ actions(entry.entry_id, model.editing, model.confirm_remove), remove_hint(model.confirm_remove), - amend_footnote(), + rd.actions_footnote(), ]), share_block(model, entry.entry_id), edit_panel(entry, model.editing, model.busy), @@ -318,18 +318,6 @@ ) False -> element.none() } -} - -/// Locally worded rather than `ui/record_detail.actions_footnote` (still on -/// the retired "a fix mints your own version" copy): publishing an amendment -/// saves your own copy of the pressing's catalog fields, it never edits the -/// shared one other crates read from. -fn amend_footnote() -> Element(Msg) { - html.p([attr.class("actions-footnote")], [ - text( - "Publishing an amendment saves your own copy of this pressing's details. It never changes anyone else's.", - ), - ]) } fn edit_panel(entry: Entry, editing: Bool, busy: Bool) -> Element(Msg) { diff --git a/web/src/crate_web/pages/record_amend.gleam b/web/src/crate_web/pages/record_amend.gleam --- a/web/src/crate_web/pages/record_amend.gleam +++ b/web/src/crate_web/pages/record_amend.gleam @@ -14,6 +14,7 @@ } import crate_web/ui/controls as ctl import crate_web/ui/forms as frm +import crate_web/ui/record_detail as rd import crate_web/ui/states import gleam/option.{type Option, None, Some} import lustre/attribute as attr @@ -48,7 +49,7 @@ attr.disabled(model.amend_activity != AmendIdle), attr.class("btn--block"), ]), - amend_footnote(), + rd.actions_footnote(), ]) } @@ -96,17 +97,5 @@ attr.value(value), event.on_input(AmendField(field, _)), ]), - ]) -} - -/// Locally worded rather than `ui/record_detail.amend_footnote` (still on -/// the retired "a fix mints your own version" copy): publishing an amendment -/// saves your own copy of the pressing's catalog fields, it never edits the -/// shared one other crates read from. -fn amend_footnote() -> Element(Msg) { - html.p([attr.class("actions-footnote")], [ - text( - "Publishing an amendment saves your own copy of this pressing's details. It never changes anyone else's.", - ), ]) } diff --git a/web/src/crate_web/ui/record_detail.gleam b/web/src/crate_web/ui/record_detail.gleam --- a/web/src/crate_web/ui/record_detail.gleam +++ b/web/src/crate_web/ui/record_detail.gleam @@ -2,7 +2,6 @@ //// layer-section bands (the pressing vs. your record), provenance lines, //// and the shared record-grade vocabulary. -import gleam/dict import gleam/int import gleam/list import gleam/string @@ -81,10 +80,14 @@ } /// The aside under the record page's actions (and again near the amend -/// screen's publish button): what AMEND/SUGGEST A FIX actually does. +/// screen's publish button): what AMEND actually does. It writes to the +/// visitor's own copy of the pressing, never to the shared catalog entry +/// other crates read from. pub fn actions_footnote() -> Element(msg) { html.p([attr.class("actions-footnote")], [ - text("a fix mints your own version of this pressing; nothing merges"), + text( + "Publishing an amendment saves your own copy of this pressing's details. It never changes anyone else's.", + ), ]) } @@ -93,20 +96,6 @@ html.p([attr.class("notes__label")], [text("NOTES")]), html.p([attr.class("notes__text")], [text(body)]), ]) -} - -/// A foreign (adopted) pressing gets the shared "suggest a fix" copy; a -/// self-minted one gets `own_label`, whichever wording the caller's screen -/// uses for its own amend action. -pub fn amend_action_label( - via_handles: dict.Dict(String, String), - entry_id: String, - own_label: String, -) -> String { - case dict.get(via_handles, entry_id) { - Ok(_) -> "SUGGEST A FIX" - Error(Nil) -> own_label - } } pub const grades = ["M", "NM", "VG+", "VG", "G+", "G", "F", "P"] -- tangled.sh