Skip to content

Remove RenderedAttachmentsHelper [WHIT-1922]#11366

Open
patrickpatrickpatrick wants to merge 3 commits intomainfrom
remove-attachments-rendering
Open

Remove RenderedAttachmentsHelper [WHIT-1922]#11366
patrickpatrickpatrick wants to merge 3 commits intomainfrom
remove-attachments-rendering

Conversation

@patrickpatrickpatrick
Copy link
Copy Markdown
Contributor

@patrickpatrickpatrick patrickpatrickpatrick commented Apr 15, 2026

What

  • Remove RenderedAttachmentsHelper
  • Remove fields referencing output of RenderedAttachmentsHelper from Publishing API payload presenters (details.documents, details.final_outcome_documents, details.public_feedback_documents) that are no longer referenced by frontend rendering applications
  • Use locale when building details.attachments, preserve previous behaviour of attachments and update tests

Why

Frontend rendering applications now render attachments themselves instead of using pre-rendered markup delivered by Whitehall. Therefore we can remove the RenderedAttachmentsHelper as well as the fields in the payload that contained the output of this helper.

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

This application is owned by the Whitehall Experience team. Please let us know in #govuk-whitehall-experience-tech when you raise any PRs.

Follow these steps if you are doing a Rails upgrade.

@patrickpatrickpatrick patrickpatrickpatrick force-pushed the remove-attachments-rendering branch from cf4e372 to 1b57496 Compare April 15, 2026 14:07
@patrickpatrickpatrick patrickpatrickpatrick changed the title Remove documents from details Remove documents from details [WHIT-1922] Apr 15, 2026
@patrickpatrickpatrick patrickpatrickpatrick marked this pull request as ready for review April 16, 2026 08:52
@patrickpatrickpatrick patrickpatrickpatrick force-pushed the remove-attachments-rendering branch from 835e82c to 0842234 Compare April 16, 2026 09:59
@patrickpatrickpatrick patrickpatrickpatrick changed the title Remove documents from details [WHIT-1922] Remove RenderedAttachmentsHelper [WHIT-1922] Apr 16, 2026
@patrickpatrickpatrick patrickpatrickpatrick force-pushed the remove-attachments-rendering branch from 0842234 to 62373cf Compare April 16, 2026 12:11
attachments = item.attachments_ready_for_publishing
# nil/"" locale should always be returned
locales_that_match = [I18n.locale.to_s, ""]
attachments.to_a.select { |attachment| locales_that_match.include?(attachment.locale.to_s) }.map(&:publishing_api_details)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit seems a bit rushed - no commit message explaining the 'why', no corresponding test to ensure we don't accidentally regress, etc. Please revisit 🙏

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to delete all this code 🚀 Would be good to amend the commit message with the 'why', so a future dev doesn't have to navigate to the PR itself to find out why.

@patrickpatrickpatrick patrickpatrickpatrick force-pushed the remove-attachments-rendering branch from 62373cf to e58edd4 Compare April 20, 2026 10:36
Currently `attachments` does not use `locale` to determine what
documents should be included in the `payload`. This has not been noticed
yet but for a document type in which attachments are `featured`
(the user does not choose where in the document they are included, they
are instead rendered as a list) all the attachments for the every locale
the document is available in will be rendered. This functionality was
present within the `documents` payload (which is subsequently being
removed) and so therefore needs to be moved here.
@patrickpatrickpatrick patrickpatrickpatrick force-pushed the remove-attachments-rendering branch from e58edd4 to 1b31d98 Compare April 20, 2026 12:59
The frontend rendering applications have moved away from using
pre-rendered mark-up in the Publishing API payload and instead
generating the attachment mark-up themselves using
`details.attachments`. This means we can remove `details.documents`
from the the Publishing API payload.
As we no longer include rendered attachments in the API payload, we no
longer use the `RenderedAttachmentsHelper` and so it can be removed from
Whitehall (along with it's associated tests).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants