Move omniauth form partial to a component
This way we simplify the view a little bit and replace some slow system tests with faster component tests.
This commit is contained in:
20
app/components/devise/omniauth_form_component.html.erb
Normal file
20
app/components/devise/omniauth_form_component.html.erb
Normal file
@@ -0,0 +1,20 @@
|
||||
<div class="row">
|
||||
<div class="small-12 column">
|
||||
<div class="margin-bottom">
|
||||
<strong><%= t("omniauth.info.#{action}") %></strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% oauth_logins.each do |login| %>
|
||||
<div class="small-12 medium-6 large-4 column end">
|
||||
<%= link_to t("omniauth.#{login}.name"), send("user_#{login}_omniauth_authorize_path"),
|
||||
title: t("omniauth.#{login}.#{action}"),
|
||||
class: "button-#{login.to_s.delete_suffix("_oauth2")} button expanded",
|
||||
method: :post %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="small-12 column auth-divider">
|
||||
<span><%= t("omniauth.or_fill") %></span>
|
||||
</div>
|
||||
</div>
|
||||
22
app/components/devise/omniauth_form_component.rb
Normal file
22
app/components/devise/omniauth_form_component.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
class Devise::OmniauthFormComponent < ApplicationComponent
|
||||
attr_reader :action
|
||||
|
||||
def initialize(action)
|
||||
@action = action
|
||||
end
|
||||
|
||||
def render?
|
||||
oauth_logins.any?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def oauth_logins
|
||||
[
|
||||
(:twitter if feature?(:twitter_login)),
|
||||
(:facebook if feature?(:facebook_login)),
|
||||
(:google_oauth2 if feature?(:google_login)),
|
||||
(:wordpress_oauth2 if feature?(:wordpress_login))
|
||||
].compact
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user