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

Use breadcrumbs based on organisation, if no parent linked #4270

Conversation

unoduetre
Copy link
Contributor

@unoduetre unoduetre commented Sep 26, 2024

What

The Content Types Discovery team's audit uncovered that corporate_information pages lack a breadcrumb that connects back to the organisation.

Currently corporate information pages without the linked parent use taxon based breadcrumbs. An example would be the following page: https://www.gov.uk/government/organisations/government-actuarys-department/about

This PR fixes that, and if there is no parent linked, it uses the first linked organisation to generate breadcrumbs.

The logic is the following:

  1. if parent is linked to, use it to generate breadcrumbs;
  2. otherwise, if organisations are linked to, use the first one to generate breadcrumbs;
  3. otherwise, if taxons are linked to, use them to generate breadcrumbs;
  4. otherwise use the default breadcrumbs linking to homepage.

Why

So that users can navigate back to the organisation to which this corporate information relates.

Trello ticket

Testing

https://government-frontend-pr-3347.herokuapp.com/government/organisations/government-actuarys-department/about
https://government-frontend-pr-3347.herokuapp.com/government/organisations/department-for-business-energy-and-industrial-strategy/about/personal-information-charter
https://government-frontend-pr-3347.herokuapp.com/government/organisations/standards-and-testing-agency/about
https://government-frontend-pr-3347.herokuapp.com/government/organisations/hm-courts-and-tribunals-service/about

Visual Changes

Before

Screenshot 2024-09-26 at 15-48-50 About us - Government Actuary's Department - GOV UK

After

Screenshot 2024-09-26 at 15-49-17 About us - Government Actuary's Department - GOV UK

@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4270 September 26, 2024 14:50 Inactive
@unoduetre unoduetre changed the title Use breadcrumbs based on organisation if no parent linked Use breadcrumbs based on organisation, if no parent linked Sep 26, 2024
@unoduetre unoduetre force-pushed the 2832-fix-corporate-information-pages-should-have-a-parent-of-an-org-page-l branch from 6aa30f8 to 3cd9e50 Compare September 26, 2024 14:53
@unoduetre unoduetre force-pushed the 2832-fix-corporate-information-pages-should-have-a-parent-of-an-org-page-l branch from 3cd9e50 to 16bbf0e Compare September 26, 2024 14:57
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4270 September 26, 2024 14:57 Inactive
@unoduetre unoduetre marked this pull request as ready for review September 26, 2024 15:42
@unoduetre unoduetre force-pushed the 2832-fix-corporate-information-pages-should-have-a-parent-of-an-org-page-l branch from 16bbf0e to 3abaf50 Compare September 27, 2024 08:19
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4270 September 27, 2024 08:19 Inactive
@unoduetre unoduetre force-pushed the 2832-fix-corporate-information-pages-should-have-a-parent-of-an-org-page-l branch from 3abaf50 to 69a27bc Compare September 27, 2024 08:49
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4270 September 27, 2024 08:49 Inactive
@unoduetre unoduetre force-pushed the 2832-fix-corporate-information-pages-should-have-a-parent-of-an-org-page-l branch from 69a27bc to 4dd674a Compare September 27, 2024 08:51
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4270 September 27, 2024 08:51 Inactive
@unoduetre unoduetre force-pushed the 2832-fix-corporate-information-pages-should-have-a-parent-of-an-org-page-l branch from 4dd674a to 7ecba90 Compare September 27, 2024 09:07
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4270 September 27, 2024 09:08 Inactive
@unoduetre unoduetre force-pushed the 2832-fix-corporate-information-pages-should-have-a-parent-of-an-org-page-l branch from 7ecba90 to bfc68be Compare September 27, 2024 09:47
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4270 September 27, 2024 09:47 Inactive
@unoduetre unoduetre force-pushed the 2832-fix-corporate-information-pages-should-have-a-parent-of-an-org-page-l branch from bfc68be to f3a86f0 Compare September 27, 2024 10:07
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4270 September 27, 2024 10:08 Inactive
@unoduetre unoduetre force-pushed the 2832-fix-corporate-information-pages-should-have-a-parent-of-an-org-page-l branch from f3a86f0 to cc89f22 Compare September 27, 2024 12:51
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4270 September 27, 2024 12:51 Inactive
Copy link
Contributor

@MartinJJones MartinJJones left a comment

Choose a reason for hiding this comment

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

I've had a quick look and have one thought on the updated breadcrumbs, using the page below as an example:

www.gov.uk/government/organisations/government-actuarys-department/about

The breadcrumbs are updated from Home > Government to Home > Government Actuary's Department which definitely feels like a nice a improvement.

It does appear that this page also has a grandparent, "Departments, agencies and public bodies", I think we should check with a content designer if this should also be included in the breadcrumbs as well, for example:

Home > Departments, agencies and public bodies > Government Actuary's Department

@unoduetre
Copy link
Contributor Author

unoduetre commented Sep 27, 2024

I've had a quick look and have one thought on the updated breadcrumbs, using the page below as an example:

www.gov.uk/government/organisations/government-actuarys-department/about

The breadcrumbs are updated from Home > Government to Home > Government Actuary's Department which definitely feels like a nice a improvement.

It does appear that this page also has a grandparent, "Departments, agencies and public bodies", I think we should check with a content designer if this should also be included in the breadcrumbs as well, for example:

Home > Departments, agencies and public bodies > Government Actuary's Department

Unfortunately, I can't find the information about the higher levels in the content item, so getting this information would require either adding things to the content item (probably with the publishing team's help) or doing a separate call to the api to retrieve that, which seems like an overkill. If we want/can modify the content item in the first place, we can add a parent link instead. This would resolve the issue, as the logic prioritises parent links. Also some examples of corporate information pages in publishing-api have parent links, so there shouldn't be a problem with adding it. So maybe we can ask the publishing team to add the parent link and in the meantime we can use this solution?

@unoduetre
Copy link
Contributor Author

unoduetre commented Sep 27, 2024

Or maybe we could use something like Home > Organisations > Government Actuary's Department
as in the Government Actuary's Department's page the breadcrumbs are Home > Organisations?

@unoduetre unoduetre force-pushed the 2832-fix-corporate-information-pages-should-have-a-parent-of-an-org-page-l branch from cc89f22 to 2768e72 Compare October 15, 2024 09:48
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4270 October 15, 2024 09:48 Inactive
@unoduetre unoduetre force-pushed the 2832-fix-corporate-information-pages-should-have-a-parent-of-an-org-page-l branch from 2768e72 to cd7167a Compare October 15, 2024 14:37
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4270 October 15, 2024 14:38 Inactive
@unoduetre
Copy link
Contributor Author

Or maybe we could use something like Home > Organisations > Government Actuary's Department as in the Government Actuary's Department's page the breadcrumbs are Home > Organisations?

This change has now been applied.

Copy link
Contributor

@MartinJJones MartinJJones left a comment

Choose a reason for hiding this comment

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

Looks good to me from a frontend perspective

@hannako please can you help review the backend changes

@unoduetre unoduetre force-pushed the 2832-fix-corporate-information-pages-should-have-a-parent-of-an-org-page-l branch from cd7167a to bc57a30 Compare October 23, 2024 13:32
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4270 October 23, 2024 13:32 Inactive
@unoduetre unoduetre force-pushed the 2832-fix-corporate-information-pages-should-have-a-parent-of-an-org-page-l branch from bc57a30 to 0128619 Compare October 24, 2024 11:09
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4270 October 24, 2024 11:10 Inactive
@unoduetre unoduetre force-pushed the 2832-fix-corporate-information-pages-should-have-a-parent-of-an-org-page-l branch from 0128619 to 0c31317 Compare October 28, 2024 16:44
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4270 October 28, 2024 16:44 Inactive
@unoduetre unoduetre force-pushed the 2832-fix-corporate-information-pages-should-have-a-parent-of-an-org-page-l branch from 0c31317 to ea3d65d Compare October 31, 2024 11:30
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4270 October 31, 2024 11:30 Inactive
Copy link
Contributor

@hannako hannako left a comment

Choose a reason for hiding this comment

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

Thanks for adding all these tests Matt 🏅

I've requested a few tiny refactors. But my main question is on what valid corporate information pages look like

@@ -72,6 +76,10 @@ def content_has_curated_related_items?
content_item.dig("links", "ordered_related_items").present? && content_item.dig("links", "parent").present?
end

def content_has_related_organisations?
ContentItem.new(content_item).related_organisations.present?
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor:

I think we should follow the existing pattern in this file of just reading from the links. This method is just a boolean ie we don't need to do anything with the data. So unless I'm missing something, instantiating a new object feels unnecessary.

content_item.dig("links", "organisations").present?

Copy link
Contributor Author

@unoduetre unoduetre Nov 21, 2024

Choose a reason for hiding this comment

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

This must match line 26 of lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_organisations.rb
So if this is to be changed, the other line needs to be changed as well.
It wouldn't be good, if we duplicated the code, as this wouldn't ensure the code (the list of methods) is always matching. Duplicating would easily lead to errors when it's changed in one place but not the other.

This solution calls the same, already existing method #related_organisations in ContentItem, which is a wrapper for raw content item data.
(Also this method contains additional logic which ensures the organisation we are interested in is always of the document type "organisation".
I know currently all organisations in links -> organisations are of "organisation" document type, so the additional logic is redundant right now.)

If we still wanted to change that, we'd need to create a method somewhere which would be called by both `lib/govuk_publishing_components/presenters/contextual_navigation.rb and lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_organisations.rb which would ensure that exactly the same list of organisations is used in both cases.

@unoduetre unoduetre force-pushed the 2832-fix-corporate-information-pages-should-have-a-parent-of-an-org-page-l branch from ea3d65d to 6ec19a8 Compare November 21, 2024 14:06
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4270 November 21, 2024 14:06 Inactive
@unoduetre unoduetre force-pushed the 2832-fix-corporate-information-pages-should-have-a-parent-of-an-org-page-l branch from 6ec19a8 to 26b24a1 Compare November 21, 2024 14:15
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4270 November 21, 2024 14:15 Inactive
@unoduetre unoduetre force-pushed the 2832-fix-corporate-information-pages-should-have-a-parent-of-an-org-page-l branch from 26b24a1 to 6ea9d7d Compare November 21, 2024 15:05
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4270 November 21, 2024 15:06 Inactive
@unoduetre unoduetre force-pushed the 2832-fix-corporate-information-pages-should-have-a-parent-of-an-org-page-l branch from 6ea9d7d to e6f74a7 Compare November 21, 2024 15:56
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4270 November 21, 2024 15:56 Inactive
Copy link
Contributor

@hannako hannako left a comment

Choose a reason for hiding this comment

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

Thanks for addressing the notes, and for adding all the tests ⭐

Use breadcrumbs based on ancestors, if the document has a linked parent.
Otherwise use breadcrumbs based on the first normal
(non-world) organisation the page is linked to.
If there are no linked organisations use taxon based breadcrumbs,
or if taxons are also not linked to,
the default breadcrumbs pointing to the homepage.
@unoduetre unoduetre force-pushed the 2832-fix-corporate-information-pages-should-have-a-parent-of-an-org-page-l branch from e6f74a7 to 20cb813 Compare November 22, 2024 11:44
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4270 November 22, 2024 11:44 Inactive
@unoduetre unoduetre merged commit a140afd into main Nov 22, 2024
12 checks passed
@unoduetre unoduetre deleted the 2832-fix-corporate-information-pages-should-have-a-parent-of-an-org-page-l branch November 22, 2024 11:47
unoduetre added a commit that referenced this pull request Nov 22, 2024
* Extend chart component options ([PR #4424](#4424))
* Use the first organisation to generate breadcrumbs, if no parent linked ([PR #4270](#4270))
@unoduetre unoduetre mentioned this pull request Nov 22, 2024
unoduetre added a commit that referenced this pull request Nov 22, 2024
* Extend chart component options ([PR #4424](#4424))
* Use the first organisation to generate breadcrumbs, if no parent linked ([PR #4270](#4270))
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