mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 02:35:57 +02:00
Merge pull request #1202 from internetee/improve-registrar-area-account-view
Improve registrar area account view
This commit is contained in:
commit
7b7a87348b
18 changed files with 137 additions and 56 deletions
24
app/controllers/registrar/account_controller.rb
Normal file
24
app/controllers/registrar/account_controller.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
class Registrar
|
||||
class AccountController < BaseController
|
||||
skip_authorization_check
|
||||
|
||||
def show; end
|
||||
|
||||
def edit
|
||||
@registrar = current_registrar_user.registrar
|
||||
end
|
||||
|
||||
def update
|
||||
@registrar = current_registrar_user.registrar
|
||||
@registrar.update!(registrar_params)
|
||||
|
||||
redirect_to registrar_account_path, notice: t('.saved')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def registrar_params
|
||||
params.require(:registrar).permit(:billing_email)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,17 +0,0 @@
|
|||
class Registrar
|
||||
class ProfileController < BaseController
|
||||
skip_authorization_check
|
||||
|
||||
helper_method :linked_users
|
||||
|
||||
def show
|
||||
@user = current_registrar_user
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def linked_users
|
||||
current_registrar_user.linked_users
|
||||
end
|
||||
end
|
||||
end
|
|
@ -182,7 +182,7 @@ class Registrar
|
|||
if can?(:show, :poll)
|
||||
registrar_root_path
|
||||
else
|
||||
registrar_profile_path
|
||||
registrar_account_path
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<%= link_to can?(:show, :poll) ? registrar_root_path : registrar_profile_path,
|
||||
<%= link_to can?(:show, :poll) ? registrar_root_path : registrar_account_path,
|
||||
class: 'navbar-brand' do %>
|
||||
<%= t(:registrar_head_title) %>
|
||||
<% if unstable_env.present? %>
|
||||
|
|
16
app/views/registrar/account/_details.html.erb
Normal file
16
app/views/registrar/account/_details.html.erb
Normal file
|
@ -0,0 +1,16 @@
|
|||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<%= t '.header' %>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<dl class="dl-horizontal">
|
||||
<dt><%= Registrar.human_attribute_name :billing_email %></dt>
|
||||
<dd><%= registrar.billing_email %></dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<div class="panel-footer text-right">
|
||||
<%= link_to t('.edit_btn'), edit_registrar_account_path, class: 'btn btn-default btn-sm' %>
|
||||
</div>
|
||||
</div>
|
21
app/views/registrar/account/_form.html.erb
Normal file
21
app/views/registrar/account/_form.html.erb
Normal file
|
@ -0,0 +1,21 @@
|
|||
<%= form_for @registrar, url: registrar_account_path, method: :patch, html: { class: 'form-horizontal' } do |f| %>
|
||||
<%= render 'form_errors', target: @registrar %>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2 control-label">
|
||||
<%= f.label :billing_email %>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-4">
|
||||
<%= f.email_field :billing_email, autofocus: true, class: 'form-control' %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-6 text-right">
|
||||
<%= f.submit t('.submit_btn'), class: 'btn btn-success' %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
10
app/views/registrar/account/edit.html.erb
Normal file
10
app/views/registrar/account/edit.html.erb
Normal file
|
@ -0,0 +1,10 @@
|
|||
<ol class="breadcrumb">
|
||||
<li><%= link_to t('registrar.account.show.header'), registrar_account_path %></li>
|
||||
<li><%= t '.header' %></li>
|
||||
</ol>
|
||||
|
||||
<div class="page-header">
|
||||
<h1><%= t '.header' %></h1>
|
||||
</div>
|
||||
|
||||
<%= render 'form' %>
|
15
app/views/registrar/account/show.html.erb
Normal file
15
app/views/registrar/account/show.html.erb
Normal file
|
@ -0,0 +1,15 @@
|
|||
<div class="page-header">
|
||||
<h1><%= t '.header' %></h1>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-5">
|
||||
<%= render 'details', registrar: current_registrar_user.registrar %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-5">
|
||||
<%= render 'linked_users', linked_users: current_registrar_user.linked_users %>
|
||||
</div>
|
||||
</div>
|
|
@ -1,5 +1,4 @@
|
|||
<% current_user_presenter = UserPresenter.new(user: current_registrar_user, view: self) %>
|
||||
<%= link_to current_user_presenter.login_with_role, registrar_profile_path, id: 'registrar-profile-btn',
|
||||
class: 'navbar-link' %>
|
||||
<%= link_to current_user_presenter.login_with_role, registrar_account_path, class: 'navbar-link' %>
|
||||
<span class="text-muted">|</span>
|
||||
<%= link_to t('.sign_out'), destroy_registrar_user_session_path, method: :delete, class: 'navbar-link' %>
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
<div class="page-header">
|
||||
<h1><%= t '.header' %></h1>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<%= render 'linked_users', linked_users: linked_users %>
|
||||
</div>
|
||||
</div>
|
22
config/locales/registrar/account.en.yml
Normal file
22
config/locales/registrar/account.en.yml
Normal file
|
@ -0,0 +1,22 @@
|
|||
en:
|
||||
registrar:
|
||||
account:
|
||||
show:
|
||||
header: Your account
|
||||
|
||||
edit:
|
||||
header: Edit your account
|
||||
|
||||
form:
|
||||
submit_btn: Save changes
|
||||
|
||||
update:
|
||||
saved: Your account has been updated
|
||||
|
||||
details:
|
||||
header: Details
|
||||
edit_btn: Edit
|
||||
|
||||
linked_users:
|
||||
header: Linked users
|
||||
switch_btn: Switch
|
|
@ -1,9 +0,0 @@
|
|||
en:
|
||||
registrar:
|
||||
profile:
|
||||
show:
|
||||
header: My profile
|
||||
|
||||
linked_users:
|
||||
header: Linked users
|
||||
switch_btn: Switch
|
|
@ -66,7 +66,7 @@ Rails.application.routes.draw do
|
|||
resources :account_activities
|
||||
|
||||
put 'current_user/switch/:new_user_id', to: 'current_user#switch', as: :switch_current_user
|
||||
resource :profile, controller: :profile, only: :show
|
||||
resource :account, controller: :account, only: %i[show edit update]
|
||||
|
||||
resources :domains do
|
||||
collection do
|
||||
|
|
|
@ -10,7 +10,7 @@ RSpec.feature 'Registrar area linked users', settings: false do
|
|||
end
|
||||
|
||||
scenario 'switches current user to a linked one' do
|
||||
visit registrar_profile_path
|
||||
visit registrar_account_path
|
||||
click_link_or_button 'switch-current-user-2-btn'
|
||||
expect(page).to have_text('You are now signed in as a user "new-user-name"')
|
||||
end
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.feature 'Registrar area profile', settings: false do
|
||||
background do
|
||||
sign_in_to_registrar_area(user: create(:api_user_with_unlimited_balance))
|
||||
end
|
||||
|
||||
scenario 'shows profile' do
|
||||
visit registrar_root_path
|
||||
click_on 'registrar-profile-btn'
|
||||
expect(page).to have_text(t('registrar.profile.show.header'))
|
||||
end
|
||||
end
|
22
test/system/registrar_area/account_test.rb
Normal file
22
test/system/registrar_area/account_test.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrarAccountTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
@registrar = registrars(:bestnames)
|
||||
sign_in users(:api_bestnames)
|
||||
end
|
||||
|
||||
def test_updates_account
|
||||
new_billing_email = 'new@registrar.test'
|
||||
assert_not_equal new_billing_email, @registrar.billing_email
|
||||
|
||||
visit registrar_account_path
|
||||
click_on 'Edit'
|
||||
|
||||
fill_in 'Billing email', with: new_billing_email
|
||||
click_on 'Save changes'
|
||||
|
||||
assert_text 'Your account has been updated'
|
||||
assert_text new_billing_email
|
||||
end
|
||||
end
|
|
@ -17,10 +17,10 @@ class RegistrarAreaPasswordSignInTest < ApplicationSystemTestCase
|
|||
assert_current_path registrar_root_path
|
||||
end
|
||||
|
||||
def test_after_successful_sign_in_billing_user_sees_profile
|
||||
def test_after_successful_sign_in_billing_user_sees_account
|
||||
@user.update!(roles: [ApiUser::BILLING])
|
||||
login_with_correct_credentials
|
||||
assert_current_path registrar_profile_path
|
||||
assert_current_path registrar_account_path
|
||||
end
|
||||
|
||||
def test_wrong_password
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue