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

Update backend New Image link for consistency #3786

Merged
merged 1 commit into from
Oct 6, 2020

Conversation

brchristian
Copy link
Contributor

@brchristian brchristian commented Oct 4, 2020

This makes the New Image link consistent with visual style of other backend views.

Other Views:

Screen Shot 2020-10-03 at 5 31 58 PM

Screen Shot 2020-10-03 at 5 32 07 PM

Current Behavior:

Screen Shot 2020-10-03 at 5 31 40 PM

New Behavior:

Screen Shot 2020-10-03 at 5 33 07 PM

Checklist:

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have updated Guides and README accordingly to this change (if needed)
  • I have added tests to cover this change (if needed)
  • I have attached screenshots to this PR for visual changes (if needed)

Copy link
Member

@aldesantis aldesantis left a comment

Choose a reason for hiding this comment

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

Thanks @brchristian!

@aldesantis aldesantis requested a review from a team October 4, 2020 07:53
@@ -5,7 +5,9 @@

<% content_for :page_actions do %>
<% if can?(:create, Spree::Image) %>
<li><%= link_to_with_icon('plus', t('spree.new_image'), new_admin_product_image_url(@product), id: 'new_image_link', class: 'btn btn-primary') %></li>
<li id="new_image_link">
<%= link_to t('spree.new_image'), new_admin_product_image_url(@product), id: 'new_image_link', class: 'btn btn-primary' %>
Copy link
Member

Choose a reason for hiding this comment

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

Looks like you've applied the new_image_link ID to both the li and the a elements. Since IDs should be unique and it's conceivable that someone could be using deface overrides to target this, I think it's best to leave the ID on the a and not also add it to the li.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jarednorman Good catch!

Looking around at other backend views, it seems like in https://github.com/solidusio/solidus/blob/master/backend/app/views/spree/admin/prices/index.html.erb#L5-L7 and https://github.com/solidusio/solidus/blob/master/backend/app/views/spree/admin/variants/index.html.erb#L7-L13, the convention is to put the ID on the li element. I’d suggest that we do the same here for consistency with those other views.

I’ve force-pushed the latest; LMK what you think.

Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

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

Thanks @brchristian !

@kennyadsl kennyadsl requested a review from jarednorman October 5, 2020 09:44
@brchristian
Copy link
Contributor Author

Ahh, actually there is more to the story here, because there are both specs and JS that expect the ID to live on the a element:

$('#new_image_link').click(function(event) {

For now, I have reversed my earlier decision and have force-pushed a version that puts the ID on the a and not the li. This is inconsistent with admin/prices.index and admin/variants/index, which use the li:

<li id="new_price_link">
<%= link_to t(".new_price"), new_object_url, class: 'btn btn-primary' %>
</li>

<li id="new_var_link" data-hook>
<%= link_to(
t('spree.new_variant'),
new_admin_product_variant_url(@product),
class: 'btn btn-primary'
) %>
</li>

...so my OCD is triggered, but on the other hand, putting the ID on the a element: (1) doesn't change from the current behavior, which already has the ID on the a element, and (2) doesn't require changing the specs or JS.

Probably a more principled solution would be to move the "new_image_link" ID to the li for consistency with other backend views, but to then come up with some other unique ID to put on the a element and have that ID in the spec and JS. However I'm not exactly sure what that other ID should be, because "new image link" is such an obvious name. :)

Make consistent with visual style of other backend views
@aldesantis aldesantis merged commit cb03dd8 into solidusio:master Oct 6, 2020
@aldesantis
Copy link
Member

Thanks @brchristian! This triggered my OCD too... I guess another solution would be to update both the JS and the spec to just take the link that is contained in the li element (#new_image_link > a), but it's definitely not a priority. 🙂

@brchristian brchristian deleted the patch-4 branch October 6, 2020 16:17
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