Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Button
class ButtonComponent < ViewComponent::Base
attr_accessor :label, :destination, :method, :additional_classes

def initialize(label:, destination:, method: :get, additional_classes: nil, disabled: false)
def initialize(label:, destination:, method: :post, additional_classes: nil, disabled: false)
super
@label = label
@destination = destination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</div>
<div class="flex-align-self-center">
<% if @button_params %>
<%= button_to @button_params[:name], @button_params[:path], method: @button_params[:method], class: 'usa-button' %>
<%= link_to @button_params[:name], @button_params[:path], class: 'usa-button' %>
<% end %>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@
</ul>
</p>
<%= render Core::Button::ButtonComponent.new(label: 'Verify information',
destination: confirm_organization_invitation_path(@organization, @invitation),
method: :post) %>
destination: confirm_organization_invitation_path(@organization, @invitation)) %>
<% end %>
<% if @invitation.credential_delegate? %>
<p>Your identity has been verified. You can now accept your invite</p>
<%= render Core::Button::ButtonComponent.new(label: 'Accept invite',
destination: register_organization_invitation_path(@organization, @invitation),
method: :post) %>
destination: register_organization_invitation_path(@organization, @invitation)) %>
<% end %>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
<p><%=raw t(key=@text, org_name: @org_name) %></p>
<% 'have to put statement here, as do not have route helper in ViewComponent'
if @reason == :fail_to_proof %>
<%= render Core::Button::ButtonComponent.new(label: 'Go to DPC Portal',
destination: root_url,
method: :get) %>
<%= link_to 'Go to DPC Portal', root_url, class: 'usa-button margin-bottom-3' %>
<% end %>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
<% end %>
</ul>
</p>
<%= button_to login_organization_invitation_url(@invitation.provider_organization, @invitation), class: 'usa-button margin-bottom-1 margin-top-2', data: { turbo: false } do %>
Verify my identity
<% end %>
<%= button_to 'Verify my identity', login_organization_invitation_url(@invitation.provider_organization, @invitation), class: 'usa-button margin-bottom-1 margin-top-2', data: { turbo: false } %>
<div><%= link_to 'How to verify your identity', 'https://login.gov/help/verify-your-identity/how-to-verify-your-identity/', target: :_blank %> <%= link_to 'Login.gov FAQ', 'https://www.login.gov/help/', target: :_blank, class: 'margin-left-2' %></div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<div>
<p>Your role as Authorized Official and your organization's Medicare enrollment have been verified.</p>
<%= render Core::Button::ButtonComponent.new(label: "Submit registration",
destination: register_organization_invitation_path(@organization, @invitation),
method: :post) %>
destination: register_organization_invitation_path(@organization, @invitation)) %>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,8 @@
<% end %>
</ul>
</p>
<%= render Core::Button::ButtonComponent.new(label: 'Begin registration',
destination: accept_organization_invitation_path(@organization, @invitation),
additional_classes: ['start-component-button'],
method: :get) if @invitation.authorized_official? %>
<%= render Core::Button::ButtonComponent.new(label: 'Get Started',
destination: confirm_cd_organization_invitation_path(@organization, @invitation),
additional_classes: ['start-component-button'],
method: :get) if @invitation.credential_delegate? %>
<%= link_to 'Begin registration', accept_organization_invitation_path(@organization, @invitation), class: 'usa-button start-component-button' if @invitation.authorized_official? %>
<%= link_to 'Get Started', confirm_cd_organization_invitation_path(@organization, @invitation), class: 'usa-button start-component-button' if @invitation.credential_delegate? %>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,5 @@
<% end %>
</ul>
<% end %>
<%= render Core::Button::ButtonComponent.new(label: 'Go to DPC Portal',
destination: root_url,
method: :get) %>
<%= link_to 'Go to DPC Portal', root_url, class: 'usa-button margin-right-0' %>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div id="credentials">
<%= render(Core::Card::BasicComponent.new(text_content: '<h2>Client tokens</h2>',
button_params: { name: 'Generate token', path: new_organization_client_token_path(@organization.path_id), method: :get} )) do %>
button_params: { name: 'Generate token', path: new_organization_client_token_path(@organization.path_id)} )) do %>
<div>
<p>Client tokens monitor who's accessing the API with your organization credentials.</p>
<% if @organization.client_tokens.present? %>
Expand All @@ -16,7 +16,7 @@
</div>
<% end %>
<%= render(Core::Card::BasicComponent.new(text_content: '<h2>Public keys</h2>',
button_params: { name: 'Add key', path: new_organization_public_key_path(@organization.path_id), method: :get} )) do %>
button_params: { name: 'Add key', path: new_organization_public_key_path(@organization.path_id) } )) do %>
<div>
<p>Public keys verify that client token requests come from an authorized application.</p>
<% if @organization.public_keys.present? %>
Expand All @@ -33,7 +33,7 @@
<% end %>

<%= render(Core::Card::BasicComponent.new(text_content: '<h2>Public IP addresses</h2>',
button_params: { name: 'Add IP', path: new_organization_ip_address_path(@organization.path_id), method: :get} )) do %>
button_params: { name: 'Add IP', path: new_organization_ip_address_path(@organization.path_id)} )) do %>
<div>
<p>Provide a maximum of 8 public IP addresses associated with systems that will access claims data.</p>
<% if @organization.public_ips.present? %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div class="margin-top-5">
<div class="display-flex flex-row flex-start" style="gap:20px;">
<div class="flex-align-self-center">
<%= render Core::Button::ButtonComponent.new(label: 'Assign CD now', destination: new_organization_credential_delegate_invitation_path(@organization))%>
<%= link_to 'Assign CD now', new_organization_credential_delegate_invitation_path(@organization), class: 'usa-button margin-right-0' %>
</div>
<div class="flex-align-self-center">
<%= link_to 'Assign CD later', root_path %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
<p>
You don't need an invite to sign up for the DPC Sandbox. This publicly available resource gives you access to test data.
</p>
<form class="button_to sandbox_url" method="get" action="https://sandbox.dpc.cms.gov/">
<button class="usa-button--outline usa-button" type="submit">Sign up to use test data</button>
</form>
<div>
<a href="https://sandbox.dpc.cms.gov/" class="usa-button--outline usa-button">Sign up to use test data</a>
</div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,13 @@
when :ao_expired %>
<%= render Core::Button::ButtonComponent.new(label: "Request new link",
disabled: @invitation&.renewed?,
destination: renew_organization_invitation_path(@invitation.provider_organization, @invitation),
method: :post) %>
destination: renew_organization_invitation_path(@invitation.provider_organization, @invitation)) %>
<% when :ao_accepted %>
<%= button_to new_user_session_path, class: 'usa-button', method: :get, data: { turbo: false } do %>
<%= link_to new_user_session_path, class: 'usa-button', data: { turbo: false } do %>
Sign in with <span class="login-button__logo">Login.gov</span>
<% end %>
<% when :cd_accepted %>
<%= render Core::Button::ButtonComponent.new(label: "Go to DPC home",
destination: root_path,
method: :get) %>
<%= link_to 'Go to DPC home', root_url, class: 'usa-button margin-right-0' %>
<% when :pii_mismatch %>
<%= render Core::Button::ButtonComponent.new(label: "Sign out of Login.gov",
destination: login_dot_gov_logout_path(invitation_id: @invitation.id),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
let(:component) { described_class.new(label: 'label', destination: 'destination') }
let(:expected_html) do
<<~HTML
<form class="button_to" method="get" action="destination"><button class="usa-button" type="submit">label</button></form>
<form class="button_to" method="post" action="destination"><button class="usa-button" type="submit">label</button></form>
HTML
end

Expand All @@ -30,7 +30,7 @@
end
let(:expected_html) do
<<~HTML
<form class="button_to" method="get" action="destination"><button class="usa-button--outline usa-button" type="submit">label</button></form>
<form class="button_to" method="post" action="destination"><button class="usa-button--outline usa-button" type="submit">label</button></form>
HTML
end
it { is_expected.to match_html_fragment(expected_html) }
Expand All @@ -42,7 +42,7 @@
end
let(:expected_html) do
<<~HTML
<form class="button_to" method="get" action="destination"><button class="usa-button" disabled="disabled" type="submit">label</button></form>
<form class="button_to" method="post" action="destination"><button class="usa-button" disabled="disabled" type="submit">label</button></form>
HTML
end
it { is_expected.to match_html_fragment(expected_html) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

context 'when has button' do
let(:component) do
described_class.new(text_content: '<h1>Yo</h1>', button_params: { name: 'Doit', path: '/there', method: :post })
described_class.new(text_content: '<h1>Yo</h1>', button_params: { name: 'Doit', path: '/there' })
end
let(:expected_html) do
<<~HTML
Expand All @@ -45,9 +45,7 @@
<h1>Yo</h1>
</div>
<div class="flex-align-self-center">
<form class="button_to" method="post" action="/there">
<button class="usa-button" type="submit">Doit</button>
</form>#{' '}
<a href="/there" class="usa-button">Doit</a>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<h2>Invites</h2>
</div>
<div class="flex-align-self-center">
<form class="button_to" method="get" action="/organizations/#{org.path_id}/credential_delegate_invitations/new"><button class="usa-button" type="submit">Invite CD</button></form>
<a href="/organizations/#{org.path_id}/credential_delegate_invitations/new" class="usa-button">Invite CD</a>
</div>
</div>
<p>You can invite users to be Credential Delegates.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@
let(:reason) { 'fail_to_proof' }
it 'should have url to login' do
url = 'http://test.host/'
expect(page.find('form')[:action]).to eq url
expect(page.find('form')[:method]).to eq 'get'
expect(page.find('a.usa-button')[:href]).to eq url
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@

it 'should go to accept page' do
expected = "/organizations/#{invitation.provider_organization.id}/invitations/#{invitation.id}/accept"
form = page.find('form')
expect(form[:action]).to eq expected
link = page.find('a.usa-button')
expect(link[:href]).to eq expected
end

it 'should include organization name and NPI' do
Expand Down Expand Up @@ -63,8 +63,8 @@

it 'should go to confirm_cd page' do
expected = "/organizations/#{invitation.provider_organization.id}/invitations/#{invitation.id}/confirm_cd"
form = page.find('form')
expect(form[:action]).to eq expected
link = page.find('a.usa-button')
expect(link[:href]).to eq expected
end

it 'should include organization name' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,19 @@
let(:org) { ComponentSupport::MockOrg.new(0) }
it 'Should have Generate token button' do
button = <<~BUTTON
<form class="button_to" method="get" action="/organizations/#{org.path_id}/client_tokens/new">
<button class="usa-button" type="submit">Generate token</button>
</form>
<a class="usa-button" href="/organizations/#{org.path_id}/client_tokens/new">Generate token</a>
BUTTON
is_expected.to include(normalize_space(button))
end
it 'Should have Create key button' do
button = <<~BUTTON
<form class="button_to" method="get" action="/organizations/#{org.path_id}/public_keys/new">
<button class="usa-button" type="submit">Add key</button>
</form>
<a class="usa-button" href="/organizations/#{org.path_id}/public_keys/new">Add key</a>
BUTTON
is_expected.to include(normalize_space(button))
end
it 'Should have Add IP button' do
button = <<~BUTTON
<form class="button_to" method="get" action="/organizations/#{org.path_id}/ip_addresses/new">
<button class="usa-button" type="submit">Add IP</button>
</form>
<a class="usa-button" href="/organizations/#{org.path_id}/ip_addresses/new">Add IP</a>
BUTTON
is_expected.to include(normalize_space(button))
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
<div class="margin-top-5">
<div class="display-flex flex-row flex-start" style="gap:20px;">
<div class="flex-align-self-center">
<form class="button_to" method="get" action="/organizations/#{org.id}/credential_delegate_invitations/new"><button class="usa-button" type="submit">Assign CD now</button></form>

<a href="/organizations/#{org.id}/credential_delegate_invitations/new" class="usa-button margin-right-0">Assign CD now</a>
</div>
<div class="flex-align-self-center">
<a href="/">Assign CD later</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@
expect(page.find('form', match: :first)[:method]).to eq 'post'
end

it 'test data button should post to sandbox url' do
expect(page.find('form.sandbox_url')[:action]).to eq sandbox_url
expect(page.find('form.sandbox_url')[:method]).to eq 'get'
it 'test data button should link to sandbox url' do
expect(page.find('a.usa-button--outline.usa-button')[:href]).to eq sandbox_url
end

it 'should have two columns' do
Expand Down
Loading