-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11617 from vpereira/sign_up_component
Create SignUp component
- Loading branch information
Showing
6 changed files
with
56 additions
and
6 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
...app/views/webui/shared/_sign_up.html.haml → ...pp/components/sign_up_component.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
class SignUpComponent < ApplicationComponent | ||
attr_accessor :submit_btn_text | ||
|
||
def initialize(submit_btn_text: 'Sign Up', create_page: false, config: CONFIG) | ||
super | ||
|
||
@config = config | ||
@submit_btn_text = sanitize(create_page ? 'Create' : submit_btn_text) | ||
end | ||
|
||
def proxy_auth_enabled? | ||
@config['proxy_auth_mode'] == :on | ||
end | ||
|
||
def proxy_auth_register_page | ||
@config['proxy_auth_register_page'] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/api/spec/components/previews/sign_up_component_preview.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class SignUpComponentPreview < ViewComponent::Preview | ||
# Preview at http://HOST:PORT/rails/view_components/sign_up_component/sign_up | ||
def sign_up | ||
render(SignUpComponent.new(config: {})) | ||
end | ||
|
||
# Preview at http://HOST:PORT/rails/view_components/sign_up_component/create | ||
def create | ||
render(SignUpComponent.new(config: {}, create_page: true)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe SignUpComponent, type: :component do | ||
context 'signing up disabled' do | ||
let(:config) { { 'proxy_auth_mode' => :on } } | ||
|
||
it do | ||
expect(render_inline(described_class.new(config: config)).to_html).to have_text('signing up is currently disabled') | ||
end | ||
|
||
context 'there is a proxy auth register page' do | ||
let(:config) { { 'proxy_auth_mode' => :on, 'proxy_auth_register_page' => 'http://foo.org' } } | ||
|
||
it do | ||
expect(render_inline(described_class.new(config: config)).to_html).to have_text('Use this link to Sign Up') | ||
end | ||
end | ||
end | ||
end |