Skip to content

Remove the override releated links from service pages #291

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

Merged
merged 3 commits into from
Jan 21, 2025

Conversation

andybroomfield
Copy link
Contributor

@andybroomfield andybroomfield commented Dec 20, 2024

Fix #72

What does this change?

This is a holdover from the old BHCC site, but the functionality for automated links was never implemented in Localgov Drupal.

This will remove this field for new sites, and will always render the related links if they are present regardless.

How to test

Do a fresh install, create a service page.
There should no longer be a replace automatically generated related links.
When adding a related link, this will now show on a service page all the time.
Before, if the above was not checked, then related links would not display, since the auto generation function was never implemented in LGD.

How can we measure success?

Related links now work as an editor would expect.

Have we considered potential risks?

Some councils may be using this 'feature' to hide related links and not show them, we should check that.

Images

Accessibility

n/a

@andybroomfield andybroomfield force-pushed the fix/2.x-72-remove-override-related-links branch from 5a19c5b to 91c2fee Compare December 20, 2024 16:13
Fix #72

This is a holdover from the old BHCC site, but the functionlity for
automated links was never implemented in Localgov Drupal.

This will remove this field for new sites, and will always render the
releated links if they are present regardless.
@andybroomfield andybroomfield force-pushed the fix/2.x-72-remove-override-related-links branch from 91c2fee to 480808c Compare December 20, 2024 18:15
Related links should now always show when present
@andybroomfield
Copy link
Contributor Author

@localgovdrupal/maintainers Does this need an update to remove it, or are we happy others removing it themselves? Councils might already have done?

@andybroomfield andybroomfield marked this pull request as ready for review January 7, 2025 11:46
@finnlewis finnlewis self-assigned this Jan 7, 2025
@finnlewis
Copy link
Member

finnlewis commented Jan 7, 2025

@willguv is adding this whole topics / related links to the content group / review functionality list.

In the mean time, @ekes suggests we refactor this to just do the minimum to hide this from new installs:

  1. hide the checkbox on the node form
  2. default new installs to have the default to display the links
  3. remove commented or redundant code
  4. but keep the block functionality just in case people are using it.

@finnlewis finnlewis assigned ekes and unassigned finnlewis Jan 7, 2025
@ekes
Copy link
Member

ekes commented Jan 9, 2025

@andybroomfield Let me just double-check a bit of logic here:

If we leave this method in:

if ($this->node->hasField('localgov_override_related_links') && !$this->node->get('localgov_override_related_links')->isEmpty()) {

sites that have got the field will continue to return either the links (TRUE) or an empty array (FALSE).

Maybe we rename it getShouldOverrideLinks() and comment it as legacy to be removed.

We then also change the default return value to TRUE, and remove the field for new installs. They will get the desired default behaviour of showing the links if there are any.

Then the line

$links = $this->getShouldUseManual() ? $this->buildManual() : $this->buildAutomated();
can be changed for something like

    $links = $this->getShouldOverrideLinks() ? $this->getLinks() : [];

The rest of your patch remains, remove the field for new installs, remove the redundant commented out code.

@ekes
Copy link
Member

ekes commented Jan 10, 2025

@andybroomfield sommat like that 50567a8

@andybroomfield
Copy link
Contributor Author

I think that should work @ekes, though for completeness do we need to add the methods getShouldUseManual buildManual and buildAutomated in case someone has extended the block? Marking them as deprecated. Or do we think its fine (as said, I think this feature was never really implemented.

@ekes
Copy link
Member

ekes commented Jan 13, 2025

@andybroomfield

for completeness do we need to add the methods getShouldUseManual buildManual and buildAutomated in case someone has extended the block?

They were private so that's easy, no need to keep BC. Although I'd be inclined to remove them anyway as you say they didn't work.

@finnlewis
Copy link
Member

I'm testing this now.

@finnlewis finnlewis self-assigned this Jan 15, 2025
Copy link
Member

@finnlewis finnlewis left a comment

Choose a reason for hiding this comment

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

Tested and happy.

Confirmed that

  1. on an existing install, the behaviour is unaffected. Existing related links continue to work with the (odd) toggle switch.
  2. On a fresh install, the toggle is gone and the links display if they are present and not if they are not.

Added a related issue #297 where if no link text, the link displays blank, but we can deal with that separately.

@willguv
Copy link
Member

willguv commented Jan 15, 2025

Thanks for checking this @finnlewis

Also thanks to @andybroomfield and @ekes for spotting this and fixing

@Adnan-cds
Copy link
Contributor

  • Noticed no difference to our existing site. As Finn has said above, "Existing related links continue to work"
  • Once I uncheck the Replace automatically generated links checkbox on an existing page, the related links disappear from the sidebar of the page. This happens with or without this change. So I guess this behaviour has remained unchanged as well.

@finnlewis
Copy link
Member

Note: add some release notes to explain how the original behaviour was broken and how this removes that.

@finnlewis finnlewis merged commit 4e65945 into 2.x Jan 21, 2025
8 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

Automated related links not being generated
5 participants