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

Take part document #4218

Merged
merged 13 commits into from
Nov 5, 2024
Merged

Take part document #4218

merged 13 commits into from
Nov 5, 2024

Conversation

KludgeKML
Copy link
Contributor

@KludgeKML KludgeKML commented Sep 3, 2024

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

What

Handle Take Part documents in Frontend, in preparation for them being taken out of Government Frontend

Why

https://trello.com/c/0LYU5bSd/318-move-route-document-type-takepart-from-governmentfrontend-to-frontend

How

These documents all have a fixed prefix, so add a scoped route for them, a controller, a model and a view. Here we add the initial ContentItem model the document type models will be based on, with the minimum functionality required to get Take Part documents working.

We also port across the figure component, which is used in this document type.

We also create a couple of helpers for rendering generic content.

Screenshots?

From example page: https://www.gov.uk/government/get-involved/take-part/improve-your-social-housing

Before (running in Government Frontend)

www gov uk_government_get-involved_take-part_improve-your-social-housing (1)

After (running in Frontend)

frontend dev gov uk_government_get-involved_take-part_improve-your-social-housing (1)

@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4218 September 3, 2024 16:10 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4218 September 4, 2024 08:35 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4218 September 4, 2024 08:53 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4218 September 4, 2024 09:38 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4218 September 4, 2024 11:52 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4218 September 4, 2024 11:53 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4218 September 4, 2024 12:04 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4218 September 4, 2024 14:19 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4218 September 4, 2024 14:43 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4218 September 5, 2024 10:06 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4218 September 5, 2024 10:09 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4218 September 5, 2024 10:15 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4218 September 5, 2024 10:18 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4218 September 5, 2024 10:24 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4218 September 5, 2024 10:25 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4218 September 5, 2024 12:52 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4218 September 5, 2024 13:09 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4218 September 5, 2024 14:55 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4218 September 9, 2024 13:05 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4218 September 10, 2024 13:27 Inactive
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.

On the whole the code looks good. 🎉

However, the request tests are missing and should be added.

Also, I think every commit message should be checked to make sure that it's linking to the permalink to the file in government-frontend rather than the commit containing the latest change, as some of those contain a lot of files.

In some cases the file is being linked to, and even better, the actual lines being pulled across, but in those cases it would be better if it linked to the "code" rather than the "blame".

Once these things are fixed this PR will be good to go.

Copy link
Contributor

Choose a reason for hiding this comment

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

The content of this commit looks good, but can you update commit message to point to the actual files in government-frontend rather than the commits.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -1,6 +1,56 @@
RSpec.describe ContentItem do
let(:subject) { build(:content_item_with_data_attachments, schema_name: "fancy_page_type") }

describe "#initialize" do
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not a blocker, but I do find it odd that we're having to test initialize like this because of how much logic it contains, rather than an ordered_related_items attribute on the model or the method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've called it describe "ordered_related_items attribute"

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you link to the files in government-frontend, rather than the commits or the "blame".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines +10 to +12
def native_language_name_for(locale)
I18n.t("language_names.#{locale}", locale:)
end
Copy link
Contributor

Choose a reason for hiding this comment

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

This method is in the content item presenter. Could that file be linked to in the commit message as well.

@@ -12,3 +12,70 @@ ar:
show_all_updates: إظهار كل التحديثات
i18n:
direction: rtl
language_names:
ar: العربيَّة
Copy link
Contributor

Choose a reason for hiding this comment

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

It's great that these locale updates are in a separate commit.

Could this commit also link to the locale files rather than a commit diff. Linking to the top-level folder is probably enough. e.g. https://github.com/alphagov/government-frontend/tree/c4bea9e232e929995c4fb5539951cadae8c740c8/config/locales

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

RSpec.shared_examples "it has meta tags for images" do |schema, base_path|
before do
example_doc = GovukSchemas::RandomExample.for_schema(frontend_schema: schema) do |random|
random["details"] = random["details"].merge(
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 you can do random["details"].merge!(...) to change the original object rather than an assign.

spec/system/take_part_spec.rb Show resolved Hide resolved
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4218 November 4, 2024 10:00 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4218 November 4, 2024 10:18 Inactive
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.

It's looking great. There's only one minor CSS file fix, mentioned inline, and a commit message that needs to be edited that we've chatted about elsewhere. Otherwise it looks good. 🎉

@import "govuk_publishing_components/individual_component_support";

.app-c-figure {
@include govuk-clearfix;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if it makes a difference, however I think the @include should be below the property definitions. The same goes for @include govuk-font(16); on line 44.

I'm basing that on the changes in PR alphagov/government-frontend#3323:

This involves moving all the @ declarations to after the other statements

@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4218 November 4, 2024 13:11 Inactive
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.

Looks great! Thanks for adding such a great audit trail of the files back to government-frontend. 🥇

- In practise, it's almost always request.path, and the specific
  content items that need it to be something different are already
  overriding it, so better to configure it as default here
- Add code in ContentItem links into the desired internal format
  for the sidebar. Take part is the first document that uses
  ordered_related_links.
- Add tests

Commit audit trail:
- https://github.com/alphagov/government-frontend/blob/6523741691ddfb9551967311a3f79775e9403ecf/app/controllers/content_items_controller.rb#L151-L157
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4218 November 4, 2024 13:51 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4218 November 4, 2024 21:37 Inactive
- We also update one test that is a little too specific
  about what the wrapper class should be.
- Needed for the tests added in the next commit.
- Separate from the no-image tags test already here,
  as the shared examples for images break if run on a
  non-image-bearing document type like help pages

Commit audit trail:
- https://github.com/alphagov/government-frontend/blob/6523741691ddfb9551967311a3f79775e9403ecf/test/integration/meta_tags_test.rb
- add view and helpers
- convert test suite to RSpec on move
- note that we explicitly remove the content-bottom-margin div
  class that was immediately inside the 2/3rds column. This is
  a style used in a handful of government-frontend document
  types which (on review with frontend developers) does not
  really fix the problem it's trying to fix (insufficient bottom
  margin on some tablet-sized devices). This has been captured
  as alphagov/govuk_publishing_components#4220
  to be fixed properly in the components gem.
- We replace the call to TitleHelper in the view with a direct call,
  as it didn't add much and it's not clear whether it's worth
  copying that helper across yet.
- main element wrapper added as it's in the layout in government-
  frontend, but not in frontend.

Commit audit trail:
- https://github.com/alphagov/government-frontend/blob/6523741691ddfb9551967311a3f79775e9403ecf/app/views/content_items/take_part.html.erb
- https://github.com/alphagov/government-frontend/blob/6523741691ddfb9551967311a3f79775e9403ecf/test/integration/take_part_test.rb
- copied from government-frontend, originally this was in content_item.schema_name.take_part,
  here we put it in formats.take_part

Commit audit trail:
- https://github.com/alphagov/government-frontend/tree/6523741691ddfb9551967311a3f79775e9403ecf/config/locales
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4218 November 4, 2024 22:00 Inactive
@KludgeKML KludgeKML merged commit 8fd0d8e into main Nov 5, 2024
12 checks passed
@KludgeKML KludgeKML deleted the take-part-document branch November 5, 2024 10:54
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