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

Unpublish edition edit #2374

Merged
merged 11 commits into from
Oct 18, 2024
Merged

Unpublish edition edit #2374

merged 11 commits into from
Oct 18, 2024

Conversation

syed-ali-tw
Copy link
Contributor

@syed-ali-tw syed-ali-tw commented Oct 14, 2024

Trello

Add unpublish functionality for new design system edit page to allow unpublishing of published edition.

When edition is draft, does not shows unpublish tab

no unpublish for draft

When edition is published, shows unpublish tab

unpublish published edition

Confirm unpublish

confirm unpublish page

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

Follow these steps if you are doing a Rails upgrade.

syed-ali-tw and others added 5 commits October 16, 2024 22:10
- Published and draft tests separated for TabbedNavHelperTest
- Unpublish tab removed from editions_controller_test - awaiting investigation
- Add div class to fix layout to bottom tab section
- Correct linting/rubocop errors
@syed-ali-tw syed-ali-tw force-pushed the unpublish-edition-edit branch 5 times, most recently from 94d17de to f58c6cd Compare October 16, 2024 22:57
<% end %>
<% end %>

<%= render "govuk_publishing_components/components/inset_text", {
Copy link
Contributor

Choose a reason for hiding this comment

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

This component needs to be inside a govuk-grid-row wrapper otherwise it is wider than other content. Moving into the one below should be OK.

<%= form_for @edition, url: process_unpublish_edition_path(@edition), method: :post do %>
<%= hidden_field_tag :redirect_url, params[:redirect_url] %>
<p class="govuk-body govuk-!-margin-bottom-7">Are you sure you want to unpublish this document?</p>
<div class="govuk-button-group govuk-!-margin-bottom-6">
Copy link
Contributor

Choose a reason for hiding this comment

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

We wouldn't need govuk-!-margin-bottom-6 here to be consistent with the main "Unpublish" page.

@davidtrussler
Copy link
Contributor

Just added a couple of small comments regarding the UI but otherwise this looks good to me.
I would prefer someone with more Rails knowledge to look at it as well before approving for best practice etc. though it seems fine to me as well.

def process_unpublish
artefact = @resource.artefact

success = params["redirect_url"].strip.empty? ? UnpublishService.call(artefact, current_user) : UnpublishService.call(artefact, current_user, redirect_url)
Copy link
Contributor

Choose a reason for hiding this comment

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

For readability - maybe worth cleaning it up a little, setting success to a method defined outside of process_unpublish method.

end
rescue StandardError
@resource.errors.add(:unpublish, downstream_error_message)
render "secondary_nav_tabs/confirm_unpublish"
Copy link
Contributor

Choose a reason for hiding this comment

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

We could avoid duplication of those two lines

@resource.errors.add(:unpublish, downstream_error_message)
 render "secondary_nav_tabs/confirm_unpublish"

by extracting them into separate method


should "redirect to edition_path when user does not have govuk-editor permission" do
user = FactoryBot.create(:user, :welsh_editor, name: "Stub User")
login_as(user)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we move it to the setup,

  def login_as_welsh_editor
    user = FactoryBot.create(:user, :welsh_editor, name: "Stub User")
    login_as(user)
  end

to avoid repetitions below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that would mean we will have to create govuk-editor user for other test, so I am not sure if that would reduce repitations

Copy link
Contributor

@davidtrussler davidtrussler left a comment

Choose a reason for hiding this comment

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

LGTM 👍

<% end %>
<% end %>

<div class="govuk-grid-row">
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this row is nested inside another. Probably for this view we can put everything in a single row.

@syed-ali-tw syed-ali-tw merged commit 25fcb87 into main Oct 18, 2024
12 checks passed
@syed-ali-tw syed-ali-tw deleted the unpublish-edition-edit branch October 18, 2024 15:00
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