From 2ac3c4799feba170c65881ed1d0df178a3f34f83 Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:44:34 +0000 Subject: [PATCH] Merge requests - remove action link --- app/helpers/merge_requests_helper.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/helpers/merge_requests_helper.rb b/app/helpers/merge_requests_helper.rb index 6fa50a7f8..212a115bb 100644 --- a/app/helpers/merge_requests_helper.rb +++ b/app/helpers/merge_requests_helper.rb @@ -6,6 +6,10 @@ module MergeRequestsHelper value.presence || content_tag(:span, placeholder, class: "app-!-colour-muted") end + def value_exists?(merge_request, attribute) + merge_request.send(attribute).present? || (attribute == "helpdesk_ticket" && merge_request.has_helpdesk_ticket == false) + end + def details_prompt_link(page, merge_request) govuk_link_to(merge_request_details_prompt(page), send("#{page}_merge_request_path", merge_request, referrer: "check_answers"), class: "govuk-link govuk-link--no-visited-state") end @@ -20,8 +24,8 @@ module MergeRequestsHelper messages[page] || "Enter #{lowercase_first_letter(page.humanize)}" end - def merge_request_action_text(attribute, merge_request) - merge_request.send(attribute).present? || (attribute == "helpdesk_ticket" && merge_request.has_helpdesk_ticket == false) ? "Change" : "" + def merge_request_action_text(merge_request, attribute) + value_exists?(merge_request, attribute) ? "Change" : "" end def request_details(merge_request) @@ -95,8 +99,10 @@ module MergeRequestsHelper def merge_request_action(merge_request, page, attribute = nil) attribute = page if attribute.nil? + return nil unless value_exists?(merge_request, attribute) + unless merge_request.status == "request_merged" || merge_request.status == "processing" - { text: merge_request_action_text(attribute, merge_request), href: send("#{page}_merge_request_path", merge_request, referrer: "check_answers"), visually_hidden_text: page.humanize } + { text: merge_request_action_text(merge_request, attribute), href: send("#{page}_merge_request_path", merge_request, referrer: "check_answers"), visually_hidden_text: page.humanize } end end