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

Replace button_link_to with either button_to or link_to #2601

Merged
merged 3 commits into from
Feb 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions backend/app/helpers/spree/admin/navigation_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,19 @@ def button(text, icon_name = nil, button_type = 'submit', options = {})
end

def button_link_to(text, url, html_options = {})
Spree::Deprecation.warn "Passing button_link_to is deprecated. Use either link_to or button_to instead.", caller
html_options = { class: '' }.merge(html_options)
if html_options[:method] &&
html_options[:method].to_s.downcase != 'get' &&
!html_options[:remote]
form_tag(url, method: html_options.delete(:method)) do
if html_options.delete(:icon)
Spree::Deprecation.warn "Passing :icon to button_link_to is deprecated and has no effect.", caller
end
html_options.delete(:icon)
button_tag(text, html_options)
end
else
html_options[:class] += ' button'

if html_options[:icon]
Spree::Deprecation.warn "Using :icon option is deprecated. Icons could not be visible in future versions.", caller
html_options[:class] += " fa fa-#{html_options[:icon]}"
end
link_to(text, url, html_options)
Expand Down
6 changes: 3 additions & 3 deletions backend/app/helpers/spree/admin/orders_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ def event_links
links = []
@order_events.sort.each do |event|
next unless @order.send("can_#{event}?")
links << button_link_to(t(event, scope: 'spree'), [event, :admin, @order],
method: :put,
data: { confirm: t('spree.order_sure_want_to', event: t(event, scope: 'spree')) })
links << button_to(t(event, scope: 'spree'), [event, :admin, @order],
method: :put,
data: { confirm: t('spree.order_sure_want_to', event: t(event, scope: 'spree')) })
end
safe_join(links, '&nbsp;'.html_safe)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<% content_for :page_actions do %>
<ul class="actions inline-menu">
<li>
<%= button_link_to t('spree.new_adjustment_reason'), new_object_url, { id: 'admin_new_named_type' } %>
<%= link_to t('spree.new_adjustment_reason'), new_object_url, id: 'admin_new_named_type', class: 'btn btn-primary' %>
</li>
</ul>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/adjustments/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<% content_for :page_actions do %>
<% if can? :create, Spree::Adjustment %>
<li>
<%= button_link_to t('spree.new_adjustment'), new_admin_order_adjustment_url(@order) %>
<%= link_to t('spree.new_adjustment'), new_admin_order_adjustment_url(@order), class: 'btn btn-primary' %>
</li>
<% end %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/adjustments/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<div class="filter-actions actions" data-hook="buttons">
<%= button_tag t('spree.continue'), class: 'btn btn-primary' %>
<%= button_link_to t('spree.actions.cancel'), admin_order_adjustments_url(@order) %>
<%= link_to t('spree.actions.cancel'), admin_order_adjustments_url(@order), class: 'btn btn-primary' %>
</div>
</fieldset>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<% content_for :page_actions do %>
<% if can? :create, Spree::CustomerReturn %>
<li>
<%= button_link_to t('spree.new_customer_return'), spree.new_admin_order_customer_return_path(@order) %>
<%= link_to t('spree.new_customer_return'), spree.new_admin_order_customer_return_path(@order), class: 'btn btn-primary' %>
</li>
<% end %>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

<div class="form-buttons filter-actions actions" data-hook="buttons">
<%= button_tag t('spree.actions.create'), class: 'btn btn-primary' %>
<%= button_link_to t('spree.actions.cancel'), admin_order_customer_returns_url(@order) %>
<%= link_to t('spree.actions.cancel'), admin_order_customer_returns_url(@order), class: 'btn btn-primary' %>
</div>
</fieldset>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/images/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


<% content_for :page_actions do %>
<li><%= button_link_to t('spree.back_to_images_list'), admin_product_images_url(@product) %></li>
<li><%= link_to t('spree.back_to_images_list'), admin_product_images_url(@product), class: 'btn btn-primary' %></li>
<% end %>

<%= form_for [:admin, @product, @image], html: { multipart: true } do |f| %>
Expand Down
4 changes: 2 additions & 2 deletions backend/app/views/spree/admin/log_entries/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<% admin_breadcrumb(plural_resource_name(Spree::LogEntry)) %>

<% content_for :page_actions do %>
<li><%= button_link_to t('spree.logs'), spree.admin_order_payment_log_entries_url(@order, @payment) %></li>
<li><%= button_link_to t('spree.back_to_payment'), spree.admin_order_payment_url(@order, @payment) %></li>
<li><%= link_to t('spree.logs'), spree.admin_order_payment_log_entries_url(@order, @payment), class: 'btn btn-primary' %></li>
<li><%= link_to t('spree.back_to_payment'), spree.admin_order_payment_url(@order, @payment), class: 'btn btn-primary' %></li>
<% end %>

<table class='index' id='listing_log_entries'>
Expand Down
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/option_types/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<% content_for :page_actions do %>
<% if can?(:create, Spree::OptionType) %>
<li id="new_ot_link">
<%= button_link_to t('spree.new_option_type'), new_admin_option_type_url, { remote: true, id: 'new_option_type_link' } %>
<%= link_to t('spree.new_option_type'), new_admin_option_type_url, remote: true, id: 'new_option_type_link', class: 'btn btn-primary' %>
</li>
<% end %>
<% end %>
Expand Down
4 changes: 2 additions & 2 deletions backend/app/views/spree/admin/orders/cart.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<% content_for :page_actions do %>
<% if can?(:fire, @order) %>
<li><%= event_links %></li>
<li><%= event_links %></li>
<% end %>
<% if can?(:resend, @order) && @order.completed? %>
<li><%= button_link_to t('spree.resend'), resend_admin_order_url(@order), method: :post %></li>
<li><%= button_to t('spree.resend'), resend_admin_order_url(@order), method: :post %></li>
<% end %>
<% end %>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


<% content_for :page_actions do %>
<li><%= button_link_to t('spree.back_to_orders_list'), admin_orders_path %></li>
<li><%= link_to t('spree.back_to_orders_list'), admin_orders_path, class: 'btn btn-primary' %></li>
<% end %>


Expand Down
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/orders/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<li><%= event_links %></li>
<% end %>
<% if can?(:resend, @order) && @order.completed? %>
<li><%= button_link_to t('spree.resend'), resend_admin_order_url(@order), method: :post %></li>
<li><%= button_to t('spree.resend'), resend_admin_order_url(@order), method: :post, class: 'btn btn-primary' %></li>
<% end %>
<% end %>

Expand Down
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/orders/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<% content_for :page_actions do %>
<li>
<%= button_link_to t('spree.new_order'), new_admin_order_url, id: 'admin_new_order' %>
<%= link_to t('spree.new_order'), new_admin_order_url, id: 'admin_new_order', class: 'btn btn-primary' %>
</li>
<% end if can? :create, Spree::Order %>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<% content_for :page_actions do %>
<% if can?(:create, Spree::PaymentMethod) %>
<li>
<%= button_link_to t('spree.new_payment_method'), new_object_url, id: 'admin_new_payment_methods_link' %>
<%= link_to t('spree.new_payment_method'), new_object_url, id: 'admin_new_payment_methods_link', class: 'btn btn-primary' %>
</li>
<% end %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/payments/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<% content_for :page_actions do %>
<% if @order.outstanding_balance? %>
<li id="new_payment_section">
<%= button_link_to t('spree.new_payment'), new_admin_order_payment_url(@order) %>
<%= link_to t('spree.new_payment'), new_admin_order_payment_url(@order), class: 'btn btn-primary' %>
</li>
<% end %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/payments/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


<% content_for :page_actions do %>
<li><%= button_link_to t('spree.logs'), spree.admin_order_payment_log_entries_url(@order, @payment) %></li>
<li><%= link_to t('spree.logs'), spree.admin_order_payment_log_entries_url(@order, @payment), class: 'btn btn-primary' %></li>
<% end %>

<%= render partial: "spree/admin/payments/source_views/#{@payment.payment_method.partial_name}", locals: { payment: @payment.source.is_a?(Spree::Payment) ? @payment.source : @payment } %>
Expand Down
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/prices/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<% content_for :page_actions do %>
<li id="new_price_link">
<%= button_link_to t(".new_price"), new_object_url %>
<%= link_to t(".new_price"), new_object_url, class: 'btn btn-primary' %>
</li>
<% end if can?(:create, Spree::Product) %>

Expand Down
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/products/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<% content_for :page_actions do %>
<% if can?(:create, Spree::Product) %>
<li id="new_product_link">
<%= button_link_to t('spree.new_product'), new_object_url, { id: 'admin_new_product' } %>
<%= link_to t('spree.new_product'), new_object_url, id: 'admin_new_product', class: 'btn btn-primary' %>
</li>
<% end %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/products/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<% content_for :page_actions do %>
<li>
<%= button_link_to t('spree.new_product'), new_object_url %>
<%= link_to t('spree.new_product'), new_object_url, class: 'btn btn-primary' %>
</li>
<% end if can?(:create, Spree::Product) %>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<% content_for :page_actions do %>
<% if can?(:create, Spree::PromotionCategory) %>
<li>
<%= button_link_to t('spree.new_promotion_category'), spree.new_admin_promotion_category_path %>
<%= link_to t('spree.new_promotion_category'), spree.new_admin_promotion_category_path, class: 'btn btn-primary' %>
</li>
<% end %>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<% content_for :page_actions do %>
<li>
<% if can?(:create, Spree::PromotionCodeBatch) %>
<%= button_link_to t('spree.new_promotion_code_batch'), new_object_url %>
<%= link_to t('spree.new_promotion_code_batch'), new_object_url, class: 'btn btn-primary' %>
<% end %>
</li>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<% content_for :page_actions do %>
<li>
<%= button_link_to t('spree.download_promotion_code_list'), admin_promotion_promotion_codes_path(promotion_id: @promotion.id, format: :csv) %>
<%= link_to t('spree.download_promotion_code_list'), admin_promotion_promotion_codes_path(promotion_id: @promotion.id, format: :csv), class: 'btn btn-primary' %>
</li>
<% end %>

Expand Down
4 changes: 2 additions & 2 deletions backend/app/views/spree/admin/promotions/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<% content_for :page_actions do %>
<li>
<% if can?(:display, Spree::PromotionCode) %>
<%= button_link_to t('spree.download_promotion_code_list'), admin_promotion_promotion_codes_path(promotion_id: @promotion.id, format: :csv) %>
<%= link_to t('spree.download_promotion_code_list'), admin_promotion_promotion_codes_path(promotion_id: @promotion.id, format: :csv), class: 'btn btn-primary' %>
<% end %>

<% if can?(:display, Spree::PromotionCodeBatch) %>
<%= button_link_to plural_resource_name(Spree::PromotionCodeBatch), admin_promotion_promotion_code_batches_path(promotion_id: @promotion.id) %>
<%= link_to plural_resource_name(Spree::PromotionCodeBatch), admin_promotion_promotion_code_batches_path(promotion_id: @promotion.id), class: 'btn btn-primary' %>
<% end %>
</li>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/promotions/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<% content_for :page_actions do %>
<% if can? :create, Spree::Promotion %>
<li>
<%= button_link_to t('spree.new_promotion'), spree.new_admin_promotion_path %>
<%= link_to t('spree.new_promotion'), spree.new_admin_promotion_path, class: 'btn btn-primary' %>
</li>
<% end %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/properties/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<% content_for :page_actions do %>
<% if can?(:create, Spree::Property) %>
<li id="new_property_link">
<%= button_link_to t('spree.new_property'), new_admin_property_url, { remote: true, id: 'new_property_link' } %>
<%= link_to t('spree.new_property'), new_admin_property_url, remote: true, id: 'new_property_link', class: 'btn btn-primary' %>
</li>
<% end %>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ul class="actions inline-menu">
<% if can?(:create, Spree::RefundReason) %>
<li>
<%= button_link_to t('spree.new_refund_reason'), new_object_url, { id: 'admin_new_named_type' } %>
<%= link_to t('spree.new_refund_reason'), new_object_url, id: 'admin_new_named_type', class: 'btn btn-primary' %>
</li>
<% end %>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/refunds/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

<div class="form-buttons filter-actions actions" data-hook="buttons">
<%= button_tag t('spree.actions.save'), class: 'btn btn-primary' %>
<%= button_link_to t('spree.actions.cancel'), admin_order_payments_url(@refund.payment.order) %>
<%= link_to t('spree.actions.cancel'), admin_order_payments_url(@refund.payment.order), class: 'btn btn-primary' %>
</div>
</fieldset>
<% end %>
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/refunds/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

<div class="form-buttons filter-actions actions" data-hook="buttons">
<%= button_tag Spree::Refund.model_name.human, class: 'btn btn-primary' %>
<%= button_link_to t('spree.actions.cancel'), admin_order_payments_url(@refund.payment.order) %>
<%= link_to t('spree.actions.cancel'), admin_order_payments_url(@refund.payment.order), class: 'btn btn-primary' %>
</div>
</fieldset>
<% end %>
4 changes: 2 additions & 2 deletions backend/app/views/spree/admin/reimbursements/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


<% content_for :page_actions do %>
<li><%= button_link_to t('spree.back_to_customer_return'), url_for([:edit, :admin, @order, @reimbursement.customer_return]) %></li>
<li><%= link_to t('spree.back_to_customer_return'), url_for([:edit, :admin, @order, @reimbursement.customer_return]), class: 'btn btn-primary' %></li>
<% end %>

<%= render partial: 'spree/shared/error_messages', locals: { target: @reimbursement } %>
Expand Down Expand Up @@ -100,7 +100,7 @@
<%= button_to [:perform, :admin, @order, @reimbursement], { class: 'button', method: 'post' } do %>
<%= t('spree.reimburse') %>
<% end %>
<%= button_link_to t('spree.actions.cancel'), url_for([:admin, @order, @reimbursement.customer_return]) %>
<%= link_to t('spree.actions.cancel'), url_for([:admin, @order, @reimbursement.customer_return]), class: 'btn btn-primary' %>
<% end %>
</div>
</fieldset>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<% admin_breadcrumb(plural_resource_name(Spree::Reimbursement)) %>

<% content_for :page_actions do %>
<li><%= button_link_to t('spree.back_to_customer_return_list'), spree.admin_order_customer_returns_url(@order) %></li>
<li><%= link_to t('spree.back_to_customer_return_list'), spree.admin_order_customer_returns_url(@order), class: 'btn btn-primary' %></li>
<% end %>

<%= render partial: 'spree/shared/error_messages', locals: { target: @customer_return } %>
Expand Down
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/reimbursements/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


<% content_for :page_actions do %>
<li><%= button_link_to t('spree.back_to_customer_return'), url_for([:edit, :admin, @order, @reimbursement.customer_return]) %></li>
<li><%= link_to t('spree.back_to_customer_return'), url_for([:edit, :admin, @order, @reimbursement.customer_return]), class: 'btn btn-primary' %></li>
<% end %>

<%= render partial: 'spree/shared/error_messages', locals: { target: @reimbursement } %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<% content_for :page_actions do %>
<% if @return_authorization.can_cancel? %>
<li>
<%= button_link_to t('spree.actions.cancel'), fire_admin_order_return_authorization_url(@order, @return_authorization, e: 'cancel'), method: :put, data: { confirm: t('spree.are_you_sure') } %>
<%= button_to t('spree.actions.cancel'), fire_admin_order_return_authorization_url(@order, @return_authorization, e: 'cancel'), method: :put, data: { confirm: t('spree.are_you_sure') } %>
</li>
<% end %>
<% end %>
Expand All @@ -28,7 +28,7 @@

<div class="form-buttons filter-actions actions" data-hook="buttons">
<%= button_tag t('spree.actions.update'), class: 'btn btn-primary' %>
<%= button_link_to t('spree.actions.cancel'), admin_order_return_authorizations_url(@order) %>
<%= link_to t('spree.actions.cancel'), admin_order_return_authorizations_url(@order), class: 'btn btn-primary' %>
</div>
</fieldset>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<% if @order.shipments.any? &:shipped? %>
<li>
<% if can? :create, Spree::ReturnAuthorization %>
<%= button_link_to t('spree.new_return_authorization'), new_admin_order_return_authorization_url(@order) %>
<%= link_to t('spree.new_return_authorization'), new_admin_order_return_authorization_url(@order), class: 'btn btn-primary' %>
<% end %>
</li>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<div class="form-buttons filter-actions actions" data-hook="buttons">
<%= button_tag t('spree.actions.create'), class: 'btn btn-primary' %>
<%= button_link_to t('spree.actions.cancel'), admin_order_return_authorizations_url(@order) %>
<%= link_to t('spree.actions.cancel'), admin_order_return_authorizations_url(@order), class: 'btn btn-primary' %>
</div>
</fieldset>
<% end %>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="form-buttons filter-actions actions" data-hook="buttons">
<%= button_tag t('spree.actions.update'), class: 'btn btn-primary' %>
<%= button_link_to t('spree.actions.cancel'), collection_url %>
<%= link_to t('spree.actions.cancel'), collection_url, class: 'btn btn-primary' %>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ul class="actions inline-menu">
<% if can?(:create, Spree::ReturnReason) %>
<li>
<%= button_link_to new_button_text, new_object_url, { id: 'admin_new_named_type' } %>
<%= link_to new_button_text, new_object_url, id: 'admin_new_named_type', class: 'btn btn-primary' %>
</li>
<% end %>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<% content_for :page_actions do %>
<% if can?(:create, Spree::ShippingCategory) %>
<li>
<%= button_link_to t('spree.new_shipping_category'), new_object_url %>
<%= link_to t('spree.new_shipping_category'), new_object_url, class: 'btn btn-primary' %>
</li>
<% end %>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<% content_for :page_actions do %>
<% if can?(:create, Spree::ShippingMethod) %>
<li>
<%= button_link_to t('spree.new_shipping_method'), new_object_url, id: 'admin_new_shipping_method_link' %>
<%= link_to t('spree.new_shipping_method'), new_object_url, id: 'admin_new_shipping_method_link', class: 'btn btn-primary' %>
</li>
<% end %>
<% end %>
Expand Down
Loading