Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Corporate information pages from government-frontend #4608

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

deborahchua
Copy link
Contributor

@deborahchua deborahchua commented Jan 22, 2025

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

What

We want to handle the rendering of corporate_information_page documents from government-frontend to frontend.

Why

Trello card

How

By moving the routes and necessary code to get the pages rendering in Frontend.

Page examples

https://[HEROKU-APP-ID].herokuapp.com/government/organisations/forensic-science-regulator/about
https://[HEROKU-APP-ID].herokuapp.com/government/organisations/forensic-science-regulator/about/accessible-documents-policy
https://[HEROKU-APP-ID].herokuapp.com/government/organisations/forensic-science-regulator/about/personal-information-charter
https://[HEROKU-APP-ID].herokuapp.com/government/organisations/department-for-education/about/modern-slavery-statement
https://[HEROKU-APP-ID].herokuapp.com/government/organisations/department-for-education/about/equality-and-diversity (includes a table)
https://[HEROKU-APP-ID].herokuapp.com/government/organisations/companies-house/about (has Welsh translation)

Screenshots

government-frontend (before) frontend (after)
Screenshot 2025-01-22 at 11 38 56 Screenshot 2025-01-22 at 11 39 11
Screenshot 2025-01-22 at 11 43 36 Screenshot 2025-01-22 at 11 43 44
Screenshot 2025-01-22 at 11 45 42 Screenshot 2025-01-22 at 11 45 52
Screenshot 2025-01-22 at 14 47 07 Screenshot 2025-01-22 at 14 46 32
Screenshot 2025-02-06 at 13 31 14 Screenshot 2025-02-06 at 13 31 05

@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4608 January 22, 2025 11:58 Inactive
@deborahchua deborahchua force-pushed the move-corporate-information-pages-from-government-frontend branch from dc0c87f to 2a2ae59 Compare January 22, 2025 12:17
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4608 January 22, 2025 12:17 Inactive
@deborahchua deborahchua force-pushed the move-corporate-information-pages-from-government-frontend branch from 2a2ae59 to a326913 Compare January 22, 2025 13:46
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4608 January 22, 2025 13:46 Inactive
@deborahchua deborahchua force-pushed the move-corporate-information-pages-from-government-frontend branch from a326913 to ccbfc08 Compare January 22, 2025 13:58
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4608 January 22, 2025 13:59 Inactive
@deborahchua deborahchua force-pushed the move-corporate-information-pages-from-government-frontend branch from ccbfc08 to 27b3b32 Compare January 22, 2025 14:43
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4608 January 22, 2025 14:43 Inactive
@deborahchua deborahchua force-pushed the move-corporate-information-pages-from-government-frontend branch from 27b3b32 to c68d580 Compare January 23, 2025 11:40
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4608 January 23, 2025 11:40 Inactive
@deborahchua deborahchua force-pushed the move-corporate-information-pages-from-government-frontend branch 12 times, most recently from 12527c8 to 3e7ddfd Compare February 4, 2025 10:34
@deborahchua deborahchua marked this pull request as ready for review February 4, 2025 10:40

it "yields the block without contents data" do
render_component({}) { block }
expect(rendered).to include(block)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

@deborahchua deborahchua force-pushed the move-corporate-information-pages-from-government-frontend branch from fd4484d to 8f719f0 Compare February 12, 2025 10:22
Copy link
Contributor

@leenagupte leenagupte left a comment

Choose a reason for hiding this comment

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

We've already chatted about modelling Organisations in person, but as promised I've reviewed the ContentsList concern.
It's very confusing! So I can understand why you've kept most of the code as it was in government-frontend.

Part of me wonders whether it's worth trying to deconstruct the ContentsList a bit in to it's model and presentational parts.

For example, the decision to show_contents_list? is quite presentational, not something the model cares about. Could the model return a structured object of headers? The code in the ContentsList is confusing because as I understand it, much of it won't be reached unless contents_items is overwritten.

I'm in two minds about whether it's worth the effort to simplify it now, or leave it for a firebreak. I think perhaps if the system tests are thorough, then the refactoring could be left for "later".

@@ -63,10 +63,6 @@ def meta_section
)&.downcase
end

def contributors
Copy link
Contributor

Choose a reason for hiding this comment

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

Why has this been removed? I'm hoping it's in error!

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps it's being moved to the presenter? Ideally the contributors method would pluck out the title and base_path for each, so that they can be styled as link in the view.

@@ -104,39 +104,6 @@
end
end

describe "#contributors" do
Copy link
Contributor

Choose a reason for hiding this comment

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

The removal of the test makes me think that you intended to remove contributors, but I don't understand why. Is it being replaced with something else?

(content_store_hash.dig("links", "organisations") || []).map do |organisation|
{ "title" => organisation["title"], "base_path" => organisation["base_path"], "content_id" => organisation["content_id"] }
end
content_store_hash.dig("links", "organisations") || []
Copy link
Contributor

@leenagupte leenagupte Feb 14, 2025

Choose a reason for hiding this comment

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

I'm wondering if there needs to be an Organisation class and then each organisation here could be modelled. I think that would make adding a logo in the later commit easier, and conceptually it would make more sense.

@@ -0,0 +1,182 @@
RSpec.shared_examples "it can have a contents list" do |document_type, example_name|
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for adding these tests ⭐


describe "#contents_items" do
it "includes the corporate information heading in the contents list if corporate informations groups are present" do
expect(corporate_information_page.content_store_response["details"]["corporate_information_groups"].present?).to be(true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be checking for the presence of corporate_information_page.corporate_information_groups instead?

@deborahchua deborahchua removed the request for review from georges1996 February 17, 2025 10:22
@deborahchua deborahchua force-pushed the move-corporate-information-pages-from-government-frontend branch 3 times, most recently from 7bcf360 to c30d8e6 Compare February 18, 2025 16:12
@deborahchua deborahchua marked this pull request as draft February 20, 2025 10:14
@deborahchua deborahchua force-pushed the move-corporate-information-pages-from-government-frontend branch from c30d8e6 to ff63a5d Compare March 3, 2025 13:54
The view has been directly copied over from government-frontend.
It will be updated to match the new data structure in a later
commit.

Commit audit trail:
- https://github.com/alphagov/government-frontend/blob/90cf5386b165b3a342689744feece7c83449b153/app/views/content_items/corporate_information_page.html.erb > app/views/corporate_information_page/show.html.erb
This keeps it consistent with the approach in other document types,
which call the metadata component directly. It does not include the
description tag which needs to be added manually for now.

It has also been updated to use `extra_headers`, which ensures that
the open graph meta tags are added to the page source correctly.
@deborahchua deborahchua force-pushed the move-corporate-information-pages-from-government-frontend branch 3 times, most recently from 3b22c75 to 32b4394 Compare March 6, 2025 14:43
This was originally added #4673
to accomodate including the `base_path` as the `url` for the
`organisation_logo` publishing component which is not always required
for a logo.

However, we can transform the data required for the component in the
view by passing a hash similar to https://github.com/alphagov/government-frontend/blob/baef09ffcce08cc557a7c01e952824ee803d70f9/app/presenters/content_item/organisation_branding.rb#L8-L13
, so having this additional model is not necessary, and we can
directly access the `base_path` from the `content_item`.

The view will be updated in a separate commit.
The organisation_branding presenter is not used by any of the other
document types, so it seems more appropriate to move these methods
into the model.

The `default_organisation` method is no longer private as it will
be used in the view as part of the page title.

Audit trail;
- app/models/corporate_information_page.rb > https://github.com/alphagov/government-frontend/blob/main/app/presenters/content_item/organisation_branding.rb
- spec/models/corporate_information_page_spec.rb > https://github.com/alphagov/government-frontend/blob/90cf5386b165b3a342689744feece7c83449b153/test/presenters/content_item/organisation_branding_test.rb
These are displayed in the "Corporate information" section at the
bottom of the page if those pages are available.

Ran rake "consolidation:copy_translation[corporate_information_page, formats.corporate_information_page]"

Audit trail:
https://github.com/alphagov/government-frontend/tree/e7b9db33536f487991ba907502080e0625a066cc/config/locales
Ran rake "consolidation:copy_translation[content_item.schema_name.corporate_information_page, formats.corporate_information_page]"
This is also included in numerous document types.

In government-frontend, a lot of complexity was introduced in
alphagov/government-frontend#719 to deal
with content that has only two H2 headings and criteria on their
following content lengths to determine whether or not the contents
lists were shown. This has caused a lot of confusion since, and
some recent changes were made so that there is no longer a minimum
number of headings required to show the contents list.

As long as there are H2 headings with IDs present, the contents list
will be shown. There are some document types (including corporate
information pages) where some additional headings are required which
will be handled in the document type model itself.

Audit trail:
- app/models/concerns/contents_list.rb > https://github.com/alphagov/government-frontend/blob/90cf5386b165b3a342689744feece7c83449b153/app/presenters/content_item/contents_list.rb
- spec/support/concerns/contents_list.rb > https://github.com/alphagov/government-frontend/blob/90cf5386b165b3a342689744feece7c83449b153/test/presenters/content_item/contents_list_test.rb
It is possible to have extra H2 headings in the contents list
to anchor to other sections that are included at the bottom
of the page. Overriding the `contents_items` method allows
us to include the "Corporate information" heading if there
are `corporate_information_groups` available in the `details`
hash.

As the corporate information groups methods now live in the
CorporateInformationPagePresenter it means the methods
`extra_headings` use is no longer accessible within the model.

Audit trail:
- https://github.com/alphagov/government-frontend/blob/90cf5386b165b3a342689744feece7c83449b153/app/presenters/corporate_information_page_presenter.rb#L21-L31
- https://github.com/alphagov/government-frontend/blob/90cf5386b165b3a342689744feece7c83449b153/app/presenters/content_item/corporate_information_groups.rb#L50-L57
- include title
- all occurences of `@content_item` has been updated to `content_item`
- use new Withdrawable methods introduced in 4b1d2d4

Add title to view
@deborahchua deborahchua force-pushed the move-corporate-information-pages-from-government-frontend branch from 32b4394 to 575c734 Compare March 6, 2025 14:49
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.

4 participants