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

UI to add a taxonomy topic email override to document collections #7950

Merged
merged 9 commits into from
Nov 28, 2023

Conversation

BeckaL
Copy link
Contributor

@BeckaL BeckaL commented Jul 14, 2023

Contains work done by @BeckaL and @hannako

What

Add a new tab to the document collection edit view, to all publishers (with a special signon permission), to set a taxonomy_topic_email_override field on their document collection.

Screenshot 2023-08-04 at 21 57 30 Screenshot 2023-08-04 at 22 00 32

Example content item created from using this UI on integration to publish a collection:

content_item

Why

We (Homepage and Navigation Team) are retiring specialist topic pages i.e. we are redirecting all specialist topics to other pieces of content on GOV.UK and then removing support for specialist topics from the code base. One dept would like their specialist topics redirected to document collections, but they want the email signup button on those document collection pages to behave differently:

  • Normal document_collection pages have a single page notification button that allows the user to subscribe to notifications on that document, and the collection of documents belonging to that document.
  • Document collections that have a taxonomy_topic_email_override field will have a email signup link instead, that allows the user to subscribe to notifications on that taxonomy topic instead. A much broader subscription that meets the needs of their users better.

How

  • If a user with email_override_editor permissions is editing a draft document collection, there will be an additional tab visible
  • Selecting Emails about this page sets an taxonomy_topic_email_override value of nil, which on the frontend will result in the page getting a standard single page notification button
  • Selecting Emails about this topic, and choosing a taxonomy topic, will store the content id of the taxon on the model, and when formatted for publishing API, the field will be added to the content _item's links.

Related PR's upon which this work depends:

Future work

Once this feature has been used by the department to publish their collection pages, we will:

  • Remove the form to set the override.
  • Users will only be able to see the summary page

Trello

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

Follow these steps if you are doing a Rails upgrade.

@hannako hannako force-pushed the email-signup-override-for-doc-collections branch 7 times, most recently from b9826df to 74ff206 Compare August 3, 2023 12:07
@hannako hannako force-pushed the email-signup-override-for-doc-collections branch 15 times, most recently from 64a1a4d to 4444b2b Compare August 4, 2023 21:51
@hannako hannako changed the title Email signup override for doc collections UI to add a taxonomy topic email override to document collections Aug 4, 2023
@hannako hannako force-pushed the email-signup-override-for-doc-collections branch from 4444b2b to cba2303 Compare August 4, 2023 22:07
@hannako hannako force-pushed the email-signup-override-for-doc-collections branch 3 times, most recently from bce5500 to 9610fbb Compare August 29, 2023 10:20
@hannako hannako force-pushed the email-signup-override-for-doc-collections branch from 9610fbb to 001d361 Compare August 29, 2023 16:36
@hannako hannako force-pushed the email-signup-override-for-doc-collections branch 10 times, most recently from 1839e3d to 5c87bcd Compare November 15, 2023 23:30
@hannako hannako marked this pull request as ready for review November 15, 2023 23:38
Copy link
Contributor

@ryanb-gds ryanb-gds left a comment

Choose a reason for hiding this comment

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

The more I look at this code the more I wonder if there should be a model to represent the TopicTaxonomyEmailOverride, backed by its own database table. I feel the logic is complex enough to justify it, even though the model would only have a few attributes. At the moment all of that logic is distributed across the controller, a presenter and some helpers, which makes it harder to reason about than it would be if it were all in one location. Also, it feels like we're arm-wrestling Rails a bit to make it do validation via flash messages, which to me is a good indication that we're missing a model. What do you think?

app/helpers/errors_helper.rb Show resolved Hide resolved
features/support/publishing_api.rb Outdated Show resolved Hide resolved
app/presenters/topic_list_select_presenter.rb Show resolved Hide resolved
@ryanb-gds ryanb-gds self-requested a review November 27, 2023 11:43
Copy link
Contributor

@ryanb-gds ryanb-gds left a comment

Choose a reason for hiding this comment

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

Having learned that this is intended to be a temporary measure whilst we migrate some specialist topics to document collections, happy for this to be merged

BeckaL and others added 8 commits November 28, 2023 10:06
This will only display when the user has the relevant permission.
- This commit contains a placeholder implementation of the taxonomy topic select,
using hardcoded values. It will be replaced in a subsequent commit.
When setting an email override field, a user must select a topic, and check
a confirmation box. If they do both of those things, they will be redirected
to the document collection edit page.

It will only be possible to set and email override on a draft document
collection. This restriction will be added in subsequent commit.
Attempting to set an email override field on a document that has already
been published will raise a validation error. Update the controller to handle
this exception. This error is not shown to the user as a flash, because in the next
commit, we make it impossible to access the document collection email subscription
edit forms for published document collections.
When a document collection is published, we will not allow the email
override field to be edited. Users clicking the email notifications tab
for a published document collection will see a summary, instead of the form.
If editing a draft document collection that already has a taxonomy_topic_email value
assigned, select the relevant radio button and topic from the drop down when the page
loads.

If a user doesn't sumbit all the required values, and presses save they are redirected back,
and shown an error. We should still retain their previous selections if any were made.
@hannako hannako force-pushed the email-signup-override-for-doc-collections branch from 5c87bcd to b5a0a78 Compare November 28, 2023 10:24
- the select-with-search component already exists in this application, and
supports grouped items i.e. multiple things in a single row of the select.
@hannako hannako force-pushed the email-signup-override-for-doc-collections branch from b5a0a78 to 88a6f9c Compare November 28, 2023 10:54
@hannako hannako merged commit 547df11 into main Nov 28, 2023
14 checks passed
@hannako hannako deleted the email-signup-override-for-doc-collections branch November 28, 2023 11:50
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.

3 participants