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

AO3-6765 Improve Skin Preview Message #4934

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

BoldestDungeon
Copy link
Contributor

@BoldestDungeon BoldestDungeon commented Sep 28, 2024

Issue

https://otwarchive.atlassian.net/browse/AO3-6765

Purpose

  • Adds the skin ID to the preview tip (rather than making the user copy-paste it themselves)
  • Wraps the "Return" button in a paragraph tag so that it is not a bulleted list item
  • Adjusts wording in message

Testing Instructions

Updated preview message following the changes in the ticket should look like this:
image

References

Are there other relevant issues/pull requests/mailing list discussions?

Credit

David Bilsky/Ironskink (He/Him)

@BoldestDungeon BoldestDungeon force-pushed the AO3-6765__improveSkinPreviewMessage branch 2 times, most recently from d501414 to b83403c Compare September 28, 2024 19:40
* Adds the skin ID to the preview tip (rather than making the user copy-paste it themselves)
* Wraps the "Return" button in a paragraph tag so that it is not a bulleted list item
* Adjusts wording in message
@BoldestDungeon BoldestDungeon force-pushed the AO3-6765__improveSkinPreviewMessage branch from b83403c to 43bd263 Compare September 28, 2024 20:03
flash[:notice] << "<a href='#{skin_path(@skin)}' class='action' role='button'>".html_safe + ts("Return To Skin To Use") + "</a>".html_safe
flash[:notice] << ts("Go back or follow any link to remove the skin.")
flash[:notice] << (ts("Tip: You can preview any archive page you want by adding '?site_skin=%{skin_id}' to the end of the URL.", skin_id: @skin.id) +
"<p><a href='#{skin_path(@skin)}' class='action'>".html_safe + ts("Return to Skin to Use") + "</a></p>".html_safe)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apparently the linter had a field day with this file when I saved it - the three lines above are the only three deliberately edited in this file, the rest was the auto-linting, sorry.

When I follow "Return To Skin To Use"
And I should see "Go back or follow any link to remove the skin"
And I should see "Tip: You can preview any archive page you want by adding '?site_skin="
And I should see "' to the end of the URL."
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'm not familiar enough with Ruby test suites to have been able to figure out how to put the actual test-skin ID into this string, so split it up into the before and after parts. If there's a better way to do that I would love to learn :)

Copy link
Member

Choose a reason for hiding this comment

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

I think this is fine; if we wanted to check the actual ID, we would need to add a custom step to https://github.com/otwcode/otwarchive/blob/master/features/step_definitions/skin_steps.rb (which IMO is overkill here)

@brianjaustin brianjaustin changed the title AO3-6765: Improve Skin Preview Message AO3-6765 Improve Skin Preview Message Oct 1, 2024
if current_user && current_user.is_a?(User)
@preference = current_user.preference
end
@preference = current_user.preference if current_user && current_user.is_a?(User)
Copy link
Member

Choose a reason for hiding this comment

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

One better over Rubocop, we don't need to check nil at all here because nil.is_a?(User) will return false. So, this can be simplified down to

Suggested change
@preference = current_user.preference if current_user && current_user.is_a?(User)
@preference = current_user.preference if current_user.is_a?(User)

if @user != current_user
flash[:error] = "You can only browse your own skins and approved public skins."
redirect_to skins_path and return
end
if is_work_skin
@skins = @user.work_skins.sort_by_recent
@title = ts('My Work Skins')
@title = ts("My Work Skins")
Copy link
Member

Choose a reason for hiding this comment

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

Since we're cleaning up the auto-fixable Rubocop issues in this file already, could you update these uses of ts to us the Rails translation helper instead?

Comment on lines +118 to +119
flash[:notice] << (ts("Tip: You can preview any archive page you want by adding '?site_skin=%{skin_id}' to the end of the URL.", skin_id: @skin.id) +
"<p><a href='#{skin_path(@skin)}' class='action'>".html_safe + ts("Return to Skin to Use") + "</a></p>".html_safe)
Copy link
Member

@brianjaustin brianjaustin Oct 15, 2024

Choose a reason for hiding this comment

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

Same thing about the translation helper, but also noting that this does not follow our current internationalisation standards. Generally, we'd now prefer something like

Suggested change
flash[:notice] << (ts("Tip: You can preview any archive page you want by adding '?site_skin=%{skin_id}' to the end of the URL.", skin_id: @skin.id) +
"<p><a href='#{skin_path(@skin)}' class='action'>".html_safe + ts("Return to Skin to Use") + "</a></p>".html_safe)
flash[:notice] << t(".preview_tip_html",
skin_id: @skin.id,
return_to_skin_link: tag.p(link_to(t(".return_to_skin"), skin_path(@skin))))

with the corresponding keys in https://github.com/otwcode/otwarchive/blob/master/config/locales/controllers/en.yml. (I haven't run the above through a linter, so some tweaks will probably be needed for it to work perfectly.)

Additionally, make sure to swap out the single quotes around 'site_skin?=%{skin_id}' to be double quotes "site_skin?=%{skin_id}" (this should require less escaping when things are moved into the YAML file, so I'd recommend doing that move first).

When I follow "Return To Skin To Use"
And I should see "Go back or follow any link to remove the skin"
And I should see "Tip: You can preview any archive page you want by adding '?site_skin="
And I should see "' to the end of the URL."
Copy link
Member

Choose a reason for hiding this comment

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

I think this is fine; if we wanted to check the actual ID, we would need to add a custom step to https://github.com/otwcode/otwarchive/blob/master/features/step_definitions/skin_steps.rb (which IMO is overkill here)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants