From 19e45f0a70e694df62c07e1c09a3a6e3530d1592 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 9 Dec 2019 20:03:27 +0200 Subject: [PATCH 01/28] Simplify test --- test/system/admin_area/api_users/new_test.rb | 25 ----------------- .../admin_area/registrars/api_users_test.rb | 28 +++++++++++++++++++ 2 files changed, 28 insertions(+), 25 deletions(-) delete mode 100644 test/system/admin_area/api_users/new_test.rb create mode 100644 test/system/admin_area/registrars/api_users_test.rb diff --git a/test/system/admin_area/api_users/new_test.rb b/test/system/admin_area/api_users/new_test.rb deleted file mode 100644 index d34b990c2..000000000 --- a/test/system/admin_area/api_users/new_test.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'application_system_test_case' - -class AdminAreaNewApiUserTest < ApplicationSystemTestCase - setup do - sign_in users(:admin) - end - - def test_new_api_user_creation_with_required_params - visit admin_api_users_url - click_link_or_button 'New API user' - - fill_in 'Username', with: 'newtest' - fill_in 'Password', with: 'testtest' - find('#api_user_registrar_id', visible: false).set(registrars(:bestnames).id) - - assert_difference 'ApiUser.count' do - click_link_or_button 'Save' - end - - assert_current_path admin_api_user_path(ApiUser.last) - assert_text 'Record created' - assert_text 'Username newtest' - assert_text 'Password testtest' - end -end \ No newline at end of file diff --git a/test/system/admin_area/registrars/api_users_test.rb b/test/system/admin_area/registrars/api_users_test.rb new file mode 100644 index 000000000..3be5586b8 --- /dev/null +++ b/test/system/admin_area/registrars/api_users_test.rb @@ -0,0 +1,28 @@ +require 'application_system_test_case' + +class AdminRegistrarsApiUsersSystemTest < ApplicationSystemTestCase + setup do + sign_in users(:admin) + end + + def test_creates_new_api_user_with_required_attributes + username = 'john' + registrar = registrars(:bestnames) + + visit admin_registrar_path(registrar) + click_on 'New API user' + + fill_in 'Username', with: username + fill_in 'Password', with: valid_password + click_on 'Save' + + assert_text 'Record created' + assert_text "Username #{username}" + end + + private + + def valid_password + 'testtest' + end +end From 90f4480f377dffd00ab814ab77a869124b504aac Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 9 Dec 2019 20:03:40 +0200 Subject: [PATCH 02/28] Add tests --- test/system/admin_area/api_users_test.rb | 58 ++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 test/system/admin_area/api_users_test.rb diff --git a/test/system/admin_area/api_users_test.rb b/test/system/admin_area/api_users_test.rb new file mode 100644 index 000000000..c05975e4f --- /dev/null +++ b/test/system/admin_area/api_users_test.rb @@ -0,0 +1,58 @@ +require 'application_system_test_case' + +class AdminApiUsersSystemTest < ApplicationSystemTestCase + setup do + sign_in users(:admin) + end + + def test_shows_api_user_list + visit admin_api_users_path + + api_user = users(:api_bestnames) + assert_link api_user.username, href: admin_api_user_path(api_user) + end + + def test_shows_api_user_details + api_user = users(:api_bestnames) + + visit admin_api_user_path(api_user) + + assert_text "Username #{api_user.username}" + assert_text "Password #{api_user.plain_text_password}" + assert_link api_user.registrar.name, href: admin_registrar_path(api_user.registrar) + assert_text "Role #{api_user.roles.first}" + assert_text "Active #{api_user.active}" + end + + def test_updates_api_user + api_user = users(:api_bestnames) + new_username = 'new username' + assert_not_equal new_username, api_user.name + + visit admin_api_user_path(api_user) + click_link_or_button 'Edit' + fill_in 'Username', with: new_username + click_link_or_button 'Save' + + assert_text 'Record updated' + assert_text "Username #{new_username}" + end + + def test_deletes_api_user + api_user = unassociated_api_user + + visit admin_api_user_path(api_user) + click_on 'Delete' + + assert_text 'Record deleted' + end + + private + + def unassociated_api_user + new_api_user = users(:api_bestnames).dup + new_api_user.username = "unique-#{rand(100)}" + new_api_user.save! + new_api_user + end +end From eb342cdbd42af5f028b3111b5fe1c8a5d3ab8990 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 9 Dec 2019 20:10:05 +0200 Subject: [PATCH 03/28] Do not allow adding new API users outside of registrar details view This feature is not needed. --- app/views/admin/api_users/index.haml | 2 -- config/locales/admin/api_users.en.yml | 1 - config/routes.rb | 2 +- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/app/views/admin/api_users/index.haml b/app/views/admin/api_users/index.haml index 4815607a7..2a20d4c59 100644 --- a/app/views/admin/api_users/index.haml +++ b/app/views/admin/api_users/index.haml @@ -1,5 +1,3 @@ -- content_for :actions do - = link_to(t('.new_btn'), new_admin_api_user_path, class: 'btn btn-primary') = render 'shared/title', name: t('.title') .row diff --git a/config/locales/admin/api_users.en.yml b/config/locales/admin/api_users.en.yml index 89a31f081..de4fddb08 100644 --- a/config/locales/admin/api_users.en.yml +++ b/config/locales/admin/api_users.en.yml @@ -2,7 +2,6 @@ en: admin: api_users: index: - new_btn: New API user title: API users active: Active diff --git a/config/routes.rb b/config/routes.rb index 1e9a6bfc4..29aca2855 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -270,7 +270,7 @@ Rails.application.routes.draw do end resources :admin_users - resources :api_users do + resources :api_users, except: %i[new] do resources :certificates do member do post 'sign' From f1992c03a944096b3c9f3e344ec22c41520fd023 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 9 Dec 2019 20:10:49 +0200 Subject: [PATCH 04/28] Remove unused routes --- config/routes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index 29aca2855..5b10d03b2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -259,7 +259,7 @@ Rails.application.routes.draw do end resources :registrars do - resources :api_users + resources :api_users, except: %i[create show edit update destroy] resources :white_ips end From 044bf9caadb9b491ecf82f19a264ee65b72880cf Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 9 Dec 2019 20:37:07 +0200 Subject: [PATCH 05/28] Remove unneeded content type --- app/views/admin/api_users/_form.haml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/views/admin/api_users/_form.haml b/app/views/admin/api_users/_form.haml index 12ea322aa..8cae897e0 100644 --- a/app/views/admin/api_users/_form.haml +++ b/app/views/admin/api_users/_form.haml @@ -1,5 +1,4 @@ -= form_for([:admin, @api_user], multipart: true, - html: {class: 'form-horizontal', autocomplete: 'off'}) do |f| += form_for([:admin, @api_user], html: {class: 'form-horizontal', autocomplete: 'off'}) do |f| = render 'shared/full_errors', object: @api_user .row From 3c5c0c4310d663d4512f935f2ff54513e54d5f38 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 9 Dec 2019 20:53:58 +0200 Subject: [PATCH 06/28] Pass registrar in URL instead of POST params --- .../javascripts/admin/autocomplete.js.coffee | 6 ------ app/controllers/admin/api_users_controller.rb | 11 +++++++---- app/models/api_user.rb | 5 ----- app/views/admin/api_users/_form.haml | 19 +------------------ config/routes.rb | 4 ++-- 5 files changed, 10 insertions(+), 35 deletions(-) diff --git a/app/assets/javascripts/admin/autocomplete.js.coffee b/app/assets/javascripts/admin/autocomplete.js.coffee index 84708055c..2308c1d28 100644 --- a/app/assets/javascripts/admin/autocomplete.js.coffee +++ b/app/assets/javascripts/admin/autocomplete.js.coffee @@ -47,12 +47,6 @@ class @Autocomplete selector: '.js-contact-typeahead' hiddenSelector: '.js-contact-id' - @bindAdminRegistrarSearch: -> - Autocomplete.bindTypeahead - remote: '/admin/registrars/search' - selector: '.js-registrar-typeahead' - hiddenSelector: '.js-registrar-id' - @bindClientContactSearch: -> Autocomplete.bindTypeahead remote: '/client/contacts/search' diff --git a/app/controllers/admin/api_users_controller.rb b/app/controllers/admin/api_users_controller.rb index bbf0a8a4e..0f2b9e914 100644 --- a/app/controllers/admin/api_users_controller.rb +++ b/app/controllers/admin/api_users_controller.rb @@ -2,6 +2,7 @@ module Admin class ApiUsersController < BaseController load_and_authorize_resource before_action :set_api_user, only: [:show, :edit, :update, :destroy] + before_action :find_registrar, only: %i[new create] def index @q = ApiUser.includes(:registrar).search(params[:q]) @@ -9,12 +10,11 @@ module Admin end def new - @registrar = Registrar.find_by(id: params[:registrar_id]) - @api_user = ApiUser.new(registrar: @registrar) + @api_user = ApiUser.new end def create - @api_user = ApiUser.new(api_user_params) + @api_user = @registrar.api_users.build(api_user_params) if @api_user.save flash[:notice] = I18n.t('record_created') @@ -63,8 +63,11 @@ module Admin def api_user_params params.require(:api_user).permit(:username, :plain_text_password, :active, - :registrar_id, :registrar_typeahead, :identity_code, { roles: [] }) end + + def find_registrar + @registrar = Registrar.find(params[:registrar_id]) + end end end diff --git a/app/models/api_user.rb b/app/models/api_user.rb index d08f17380..e11dbf90f 100644 --- a/app/models/api_user.rb +++ b/app/models/api_user.rb @@ -28,7 +28,6 @@ class ApiUser < User delegate :code, :name, to: :registrar, prefix: true alias_attribute :login, :username - attr_accessor :registrar_typeahead SUPER = 'super' EPP = 'epp' @@ -53,10 +52,6 @@ class ApiUser < User end end - def registrar_typeahead - @registrar_typeahead || registrar || nil - end - def to_s username end diff --git a/app/views/admin/api_users/_form.haml b/app/views/admin/api_users/_form.haml index 8cae897e0..851956e54 100644 --- a/app/views/admin/api_users/_form.haml +++ b/app/views/admin/api_users/_form.haml @@ -1,4 +1,4 @@ -= form_for([:admin, @api_user], html: {class: 'form-horizontal', autocomplete: 'off'}) do |f| += form_for([:admin, @registrar, @api_user], html: {class: 'form-horizontal', autocomplete: 'off'}) do |f| = render 'shared/full_errors', object: @api_user .row @@ -20,18 +20,6 @@ .col-md-7 = f.text_field(:identity_code, class: 'form-control') - .form-group - .form-group.has-feedback.js-typeahead-container - .col-md-4.control-label - = f.label :registrar_typeahead, t(:registrar_name), class: 'required' - .col-md-7 - = f.text_field(:registrar_typeahead, - class: 'form-control js-registrar-typeahead typeahead required', - placeholder: t(:registrar_name), autocomplete: 'off') - %span.glyphicon.glyphicon-ok.form-control-feedback.js-typeahead-ok.hidden - %span.glyphicon.glyphicon-remove.form-control-feedback.js-typeahead-remove - = f.hidden_field(:registrar_id, class: 'js-registrar-id') - .form-group .col-md-4.control-label = f.label :role, nil, class: 'required' @@ -49,8 +37,3 @@ .row .col-md-8.text-right = button_tag(t(:save), class: 'btn btn-primary') - -:javascript - window.addEventListener('load', function() { - Autocomplete.bindAdminRegistrarSearch(); - }); diff --git a/config/routes.rb b/config/routes.rb index 5b10d03b2..fb39f4307 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -259,7 +259,7 @@ Rails.application.routes.draw do end resources :registrars do - resources :api_users, except: %i[create show edit update destroy] + resources :api_users, except: %i[show edit update destroy] resources :white_ips end @@ -270,7 +270,7 @@ Rails.application.routes.draw do end resources :admin_users - resources :api_users, except: %i[new] do + resources :api_users, except: %i[new create] do resources :certificates do member do post 'sign' From c680b688e4bccf825a8e5b84bda7f9486adaf5f4 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 9 Dec 2019 21:01:36 +0200 Subject: [PATCH 07/28] Improve readability --- app/views/admin/api_users/index.haml | 8 ++++---- app/views/admin/registrars/show.html.erb | 2 +- .../show/{_users.html.erb => _api_users.html.erb} | 6 +++--- config/locales/admin/registrars.en.yml | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) rename app/views/admin/registrars/show/{_users.html.erb => _api_users.html.erb} (76%) diff --git a/app/views/admin/api_users/index.haml b/app/views/admin/api_users/index.haml index 2a20d4c59..22e1fee79 100644 --- a/app/views/admin/api_users/index.haml +++ b/app/views/admin/api_users/index.haml @@ -13,11 +13,11 @@ %th{class: 'col-xs-2'} = sort_link(@q, 'active', t('.active')) %tbody - - @api_users.each do |x| + - @api_users.each do |api_user| %tr - %td= link_to(x, [:admin, x]) - %td= link_to(x.registrar, [:admin, x.registrar]) - %td= x.active + %td= link_to api_user, [:admin, api_user] + %td= link_to api_user.registrar, [:admin, api_user.registrar] + %td= api_user.active .row .col-md-12 = paginate @api_users diff --git a/app/views/admin/registrars/show.html.erb b/app/views/admin/registrars/show.html.erb index 62e7a5df1..2da2c84ce 100644 --- a/app/views/admin/registrars/show.html.erb +++ b/app/views/admin/registrars/show.html.erb @@ -39,7 +39,7 @@
- <%= render 'admin/registrars/show/users', registrar: @registrar %> + <%= render 'admin/registrars/show/api_users', registrar: @registrar %>
diff --git a/app/views/admin/registrars/show/_users.html.erb b/app/views/admin/registrars/show/_api_users.html.erb similarity index 76% rename from app/views/admin/registrars/show/_users.html.erb rename to app/views/admin/registrars/show/_api_users.html.erb index f182e4615..2d10b1c56 100644 --- a/app/views/admin/registrars/show/_users.html.erb +++ b/app/views/admin/registrars/show/_api_users.html.erb @@ -12,10 +12,10 @@ - <% registrar.api_users.each do |user| %> + <% registrar.api_users.each do |api_user| %> - <%= link_to(user, [:admin, user]) %> - <%= user.active %> + <%= link_to api_user, admin_registrar_api_user_path(api_user.registrar, api_user) %> + <%= api_user.active %> <% end %> diff --git a/config/locales/admin/registrars.en.yml b/config/locales/admin/registrars.en.yml index b6ba75fc9..98aabbd95 100644 --- a/config/locales/admin/registrars.en.yml +++ b/config/locales/admin/registrars.en.yml @@ -25,7 +25,7 @@ en: preferences: header: Preferences - users: + api_users: header: API Users new_btn: New API user @@ -67,4 +67,4 @@ en: iban_hint: Used for e-invoices preferences: - header: Preferences \ No newline at end of file + header: Preferences From de6934625c17d1581ffe5f185ff9a42f76de962c Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 9 Dec 2019 21:34:36 +0200 Subject: [PATCH 08/28] Nest API users under registrar in admin area --- app/controllers/admin/api_users_controller.rb | 15 +++--- .../admin/certificates_controller.rb | 2 +- app/views/admin/api_users/_form.haml | 2 +- app/views/admin/api_users/edit.haml | 2 +- app/views/admin/api_users/index.haml | 2 +- app/views/admin/api_users/show.haml | 4 +- app/views/admin/certificates/show.haml | 2 +- config/routes.rb | 5 +- test/system/admin_area/api_users_test.rb | 46 +----------------- .../admin_area/registrars/api_users_test.rb | 47 +++++++++++++++++++ 10 files changed, 65 insertions(+), 62 deletions(-) diff --git a/app/controllers/admin/api_users_controller.rb b/app/controllers/admin/api_users_controller.rb index 0f2b9e914..3afc9ddf8 100644 --- a/app/controllers/admin/api_users_controller.rb +++ b/app/controllers/admin/api_users_controller.rb @@ -2,7 +2,6 @@ module Admin class ApiUsersController < BaseController load_and_authorize_resource before_action :set_api_user, only: [:show, :edit, :update, :destroy] - before_action :find_registrar, only: %i[new create] def index @q = ApiUser.includes(:registrar).search(params[:q]) @@ -10,15 +9,15 @@ module Admin end def new - @api_user = ApiUser.new + @api_user = registrar.api_users.build end def create - @api_user = @registrar.api_users.build(api_user_params) + @api_user = registrar.api_users.build(api_user_params) if @api_user.save flash[:notice] = I18n.t('record_created') - redirect_to [:admin, @api_user] + redirect_to admin_registrar_api_user_path(@api_user.registrar, @api_user) else flash.now[:alert] = I18n.t('failed_to_create_record') render 'new' @@ -38,7 +37,7 @@ module Admin if @api_user.update(api_user_params) flash[:notice] = I18n.t('record_updated') - redirect_to [:admin, @api_user] + redirect_to admin_registrar_api_user_path(@api_user.registrar, @api_user) else flash.now[:alert] = I18n.t('failed_to_update_record') render 'edit' @@ -48,7 +47,7 @@ module Admin def destroy if @api_user.destroy flash[:notice] = I18n.t('record_deleted') - redirect_to admin_api_users_path + redirect_to admin_registrar_path(@api_user.registrar) else flash.now[:alert] = I18n.t('failed_to_delete_record') render 'show' @@ -66,8 +65,8 @@ module Admin :identity_code, { roles: [] }) end - def find_registrar - @registrar = Registrar.find(params[:registrar_id]) + def registrar + Registrar.find(params[:registrar_id]) end end end diff --git a/app/controllers/admin/certificates_controller.rb b/app/controllers/admin/certificates_controller.rb index 636a69367..d338b2e9f 100644 --- a/app/controllers/admin/certificates_controller.rb +++ b/app/controllers/admin/certificates_controller.rb @@ -34,7 +34,7 @@ module Admin if @certificate.destroy flash[:notice] = I18n.t('record_deleted') - redirect_to admin_api_user_path(@api_user) + redirect_to admin_registrar_api_user_path(@api_user.registrar, @api_user) else flash.now[:alert] = I18n.t('failed_to_delete_record') render 'show' diff --git a/app/views/admin/api_users/_form.haml b/app/views/admin/api_users/_form.haml index 851956e54..23b245aea 100644 --- a/app/views/admin/api_users/_form.haml +++ b/app/views/admin/api_users/_form.haml @@ -1,4 +1,4 @@ -= form_for([:admin, @registrar, @api_user], html: {class: 'form-horizontal', autocomplete: 'off'}) do |f| += form_for([:admin, @api_user.registrar, @api_user], html: {class: 'form-horizontal', autocomplete: 'off'}) do |f| = render 'shared/full_errors', object: @api_user .row diff --git a/app/views/admin/api_users/edit.haml b/app/views/admin/api_users/edit.haml index 867d084d5..cd32618fa 100644 --- a/app/views/admin/api_users/edit.haml +++ b/app/views/admin/api_users/edit.haml @@ -1,5 +1,5 @@ - content_for :actions do - = link_to(t(:back_to_api_user), [:admin, @api_user], class: 'btn btn-default') + = link_to(t(:back_to_api_user), admin_registrar_api_user_path(@api_user.registrar, @api_user), class: 'btn btn-default') = render 'shared/title', name: "#{t(:edit)}: #{@api_user.username}" = render 'form' diff --git a/app/views/admin/api_users/index.haml b/app/views/admin/api_users/index.haml index 22e1fee79..3d5e6a320 100644 --- a/app/views/admin/api_users/index.haml +++ b/app/views/admin/api_users/index.haml @@ -15,7 +15,7 @@ %tbody - @api_users.each do |api_user| %tr - %td= link_to api_user, [:admin, api_user] + %td= link_to api_user, admin_registrar_api_user_path(api_user.registrar, api_user) %td= link_to api_user.registrar, [:admin, api_user.registrar] %td= api_user.active .row diff --git a/app/views/admin/api_users/show.haml b/app/views/admin/api_users/show.haml index 2e13445d1..998a6c078 100644 --- a/app/views/admin/api_users/show.haml +++ b/app/views/admin/api_users/show.haml @@ -1,6 +1,6 @@ - content_for :actions do - = link_to(t(:edit), edit_admin_api_user_path(@api_user), class: 'btn btn-default') - = link_to(t(:delete), admin_api_user_path(@api_user), + = link_to(t(:edit), edit_admin_registrar_api_user_path(@api_user.registrar, @api_user), class: 'btn btn-default') + = link_to(t(:delete), admin_registrar_api_user_path(@api_user.registrar, @api_user), method: :delete, data: { confirm: t(:are_you_sure) }, class: 'btn btn-danger') = render 'shared/title', name: @api_user.username diff --git a/app/views/admin/certificates/show.haml b/app/views/admin/certificates/show.haml index 821d7ec9a..30d095f65 100644 --- a/app/views/admin/certificates/show.haml +++ b/app/views/admin/certificates/show.haml @@ -20,7 +20,7 @@ .panel-body %dl.dl-horizontal %dt= t(:api_user) - %dd= link_to(@certificate.api_user, [:admin, @api_user]) + %dd= link_to(@certificate.api_user, [:admin, @api_user.registrar, @api_user]) %dt= t(:common_name) %dd= @certificate.common_name diff --git a/config/routes.rb b/config/routes.rb index fb39f4307..8cc5a5721 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -259,7 +259,7 @@ Rails.application.routes.draw do end resources :registrars do - resources :api_users, except: %i[show edit update destroy] + resources :api_users, except: %i[index] resources :white_ips end @@ -270,7 +270,8 @@ Rails.application.routes.draw do end resources :admin_users - resources :api_users, except: %i[new create] do + # /admin/api_users is mainly for manual testing + resources :api_users, only: :index do resources :certificates do member do post 'sign' diff --git a/test/system/admin_area/api_users_test.rb b/test/system/admin_area/api_users_test.rb index c05975e4f..d79434ef6 100644 --- a/test/system/admin_area/api_users_test.rb +++ b/test/system/admin_area/api_users_test.rb @@ -9,50 +9,6 @@ class AdminApiUsersSystemTest < ApplicationSystemTestCase visit admin_api_users_path api_user = users(:api_bestnames) - assert_link api_user.username, href: admin_api_user_path(api_user) - end - - def test_shows_api_user_details - api_user = users(:api_bestnames) - - visit admin_api_user_path(api_user) - - assert_text "Username #{api_user.username}" - assert_text "Password #{api_user.plain_text_password}" - assert_link api_user.registrar.name, href: admin_registrar_path(api_user.registrar) - assert_text "Role #{api_user.roles.first}" - assert_text "Active #{api_user.active}" - end - - def test_updates_api_user - api_user = users(:api_bestnames) - new_username = 'new username' - assert_not_equal new_username, api_user.name - - visit admin_api_user_path(api_user) - click_link_or_button 'Edit' - fill_in 'Username', with: new_username - click_link_or_button 'Save' - - assert_text 'Record updated' - assert_text "Username #{new_username}" - end - - def test_deletes_api_user - api_user = unassociated_api_user - - visit admin_api_user_path(api_user) - click_on 'Delete' - - assert_text 'Record deleted' - end - - private - - def unassociated_api_user - new_api_user = users(:api_bestnames).dup - new_api_user.username = "unique-#{rand(100)}" - new_api_user.save! - new_api_user + assert_link api_user.username, href: admin_registrar_api_user_path(api_user.registrar, api_user) end end diff --git a/test/system/admin_area/registrars/api_users_test.rb b/test/system/admin_area/registrars/api_users_test.rb index 3be5586b8..69288265f 100644 --- a/test/system/admin_area/registrars/api_users_test.rb +++ b/test/system/admin_area/registrars/api_users_test.rb @@ -18,10 +18,57 @@ class AdminRegistrarsApiUsersSystemTest < ApplicationSystemTestCase assert_text 'Record created' assert_text "Username #{username}" + new_api_user = ApiUser.last + assert_current_path admin_registrar_api_user_path(registrar, new_api_user) + end + + def test_shows_api_user_details + api_user = users(:api_bestnames) + + visit admin_registrar_path(api_user.registrar) + click_on api_user.username + + assert_text "Username #{api_user.username}" + assert_text "Password #{api_user.plain_text_password}" + assert_link api_user.registrar.name, href: admin_registrar_path(api_user.registrar) + assert_text "Role #{api_user.roles.first}" + assert_text "Active #{api_user.active}" + end + + def test_updates_api_user + api_user = users(:api_bestnames) + new_username = 'new username' + assert_not_equal new_username, api_user.username + + visit admin_registrar_api_user_path(api_user.registrar, api_user) + click_link_or_button 'Edit' + fill_in 'Username', with: new_username + click_link_or_button 'Save' + + assert_text 'Record updated' + assert_text "Username #{new_username}" + assert_current_path admin_registrar_api_user_path(api_user.registrar, api_user) + end + + def test_deletes_api_user + api_user = unassociated_api_user + + visit admin_registrar_api_user_path(api_user.registrar, api_user) + click_on 'Delete' + + assert_text 'Record deleted' + assert_current_path admin_registrar_path(api_user.registrar) end private + def unassociated_api_user + new_api_user = users(:api_bestnames).dup + new_api_user.username = "unique-#{rand(100)}" + new_api_user.save! + new_api_user + end + def valid_password 'testtest' end From 4d6098513865312295ae35d29ed1f7057ed7bca8 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 9 Dec 2019 21:39:08 +0200 Subject: [PATCH 09/28] Convert HAML to ERB --- app/views/admin/api_users/_form.haml | 39 -------- app/views/admin/api_users/_form.html.erb | 51 +++++++++++ app/views/admin/api_users/edit.haml | 5 - app/views/admin/api_users/edit.html.erb | 5 + app/views/admin/api_users/index.haml | 23 ----- app/views/admin/api_users/index.html.erb | 42 +++++++++ app/views/admin/api_users/new.haml | 3 - app/views/admin/api_users/new.html.erb | 2 + app/views/admin/api_users/show.haml | 61 ------------- app/views/admin/api_users/show.html.erb | 111 +++++++++++++++++++++++ 10 files changed, 211 insertions(+), 131 deletions(-) delete mode 100644 app/views/admin/api_users/_form.haml create mode 100644 app/views/admin/api_users/_form.html.erb delete mode 100644 app/views/admin/api_users/edit.haml create mode 100644 app/views/admin/api_users/edit.html.erb delete mode 100644 app/views/admin/api_users/index.haml create mode 100644 app/views/admin/api_users/index.html.erb delete mode 100644 app/views/admin/api_users/new.haml create mode 100644 app/views/admin/api_users/new.html.erb delete mode 100644 app/views/admin/api_users/show.haml create mode 100644 app/views/admin/api_users/show.html.erb diff --git a/app/views/admin/api_users/_form.haml b/app/views/admin/api_users/_form.haml deleted file mode 100644 index 23b245aea..000000000 --- a/app/views/admin/api_users/_form.haml +++ /dev/null @@ -1,39 +0,0 @@ -= form_for([:admin, @api_user.registrar, @api_user], html: {class: 'form-horizontal', autocomplete: 'off'}) do |f| - = render 'shared/full_errors', object: @api_user - - .row - .col-md-8 - .form-group - .col-md-4.control-label - = f.label :username, nil, class: 'required' - .col-md-7 - = f.text_field :username, required: true, autofocus: true, class: 'form-control' - .form-group - .col-md-4.control-label - = f.label :plain_text_password, nil, class: 'required' - .col-md-7 - = f.text_field :plain_text_password, required: true, class: 'form-control' - - .form-group - .col-md-4.control-label - = f.label :identity_code - .col-md-7 - = f.text_field(:identity_code, class: 'form-control') - - .form-group - .col-md-4.control-label - = f.label :role, nil, class: 'required' - .col-md-7 - = select_tag 'api_user[roles][]', - options_for_select(ApiUser::ROLES.map {|x| [x, x] }, @api_user.roles.try(:first)), - class: 'form-control selectize' - .checkbox - %label{for: 'api_user_active'} - = f.check_box(:active) - = t('.active') - - %hr - - .row - .col-md-8.text-right - = button_tag(t(:save), class: 'btn btn-primary') diff --git a/app/views/admin/api_users/_form.html.erb b/app/views/admin/api_users/_form.html.erb new file mode 100644 index 000000000..b97d45539 --- /dev/null +++ b/app/views/admin/api_users/_form.html.erb @@ -0,0 +1,51 @@ +<%= form_for([:admin, @api_user.registrar, @api_user], html: { class: 'form-horizontal', autocomplete: 'off' }) do |f| %> + <%= render 'shared/full_errors', object: @api_user %> +
+
+
+
+ <%= f.label :username, nil, class: 'required' %> +
+
+ <%= f.text_field :username, required: true, autofocus: true, class: 'form-control' %> +
+
+
+
+ <%= f.label :plain_text_password, nil, class: 'required' %> +
+
+ <%= f.text_field :plain_text_password, required: true, class: 'form-control' %> +
+
+
+
+ <%= f.label :identity_code %> +
+
+ <%= f.text_field(:identity_code, class: 'form-control') %> +
+
+
+
+ <%= f.label :role, nil, class: 'required' %> +
+
+ <%= select_tag 'api_user[roles][]', options_for_select(ApiUser::ROLES.map { |x| [x, x] }, @api_user.roles.try(:first)), class: 'form-control selectize' %> +
+ +
+
+
+
+
+
+
+
+ <%= button_tag(t(:save), class: 'btn btn-primary') %> +
+
+<% end %> diff --git a/app/views/admin/api_users/edit.haml b/app/views/admin/api_users/edit.haml deleted file mode 100644 index cd32618fa..000000000 --- a/app/views/admin/api_users/edit.haml +++ /dev/null @@ -1,5 +0,0 @@ -- content_for :actions do - = link_to(t(:back_to_api_user), admin_registrar_api_user_path(@api_user.registrar, @api_user), class: 'btn btn-default') -= render 'shared/title', name: "#{t(:edit)}: #{@api_user.username}" - -= render 'form' diff --git a/app/views/admin/api_users/edit.html.erb b/app/views/admin/api_users/edit.html.erb new file mode 100644 index 000000000..5fee5b941 --- /dev/null +++ b/app/views/admin/api_users/edit.html.erb @@ -0,0 +1,5 @@ +<% content_for :actions do %> + <%= link_to(t(:back_to_api_user), admin_registrar_api_user_path(@api_user.registrar, @api_user), class: 'btn btn-default') %> +<% end %> +<%= render 'shared/title', name: "#{t(:edit)}: #{@api_user.username}" %> +<%= render 'form' %> diff --git a/app/views/admin/api_users/index.haml b/app/views/admin/api_users/index.haml deleted file mode 100644 index 3d5e6a320..000000000 --- a/app/views/admin/api_users/index.haml +++ /dev/null @@ -1,23 +0,0 @@ -= render 'shared/title', name: t('.title') - -.row - .col-md-12 - .table-responsive - %table.table.table-hover.table-bordered.table-condensed - %thead - %tr - %th{class: 'col-xs-2'} - = sort_link(@q, 'username') - %th{class: 'col-xs-2'} - = sort_link(@q, 'registrar_name', t(:registrar_name)) - %th{class: 'col-xs-2'} - = sort_link(@q, 'active', t('.active')) - %tbody - - @api_users.each do |api_user| - %tr - %td= link_to api_user, admin_registrar_api_user_path(api_user.registrar, api_user) - %td= link_to api_user.registrar, [:admin, api_user.registrar] - %td= api_user.active -.row - .col-md-12 - = paginate @api_users diff --git a/app/views/admin/api_users/index.html.erb b/app/views/admin/api_users/index.html.erb new file mode 100644 index 000000000..dacd6398a --- /dev/null +++ b/app/views/admin/api_users/index.html.erb @@ -0,0 +1,42 @@ +<%= render 'shared/title', name: t('.title') %> +
+
+
+ + + + + + + + + + <% @api_users.each do |api_user| %> + + + + + + <% end %> + +
+ <%= sort_link(@q, 'username') %> + + <%= sort_link(@q, 'registrar_name', t(:registrar_name)) %> + + <%= sort_link(@q, 'active', t('.active')) %> +
+ <%= link_to api_user, admin_registrar_api_user_path(api_user.registrar, api_user) %> + + <%= link_to api_user.registrar, [:admin, api_user.registrar] %> + + <%= api_user.active %> +
+
+
+
+
+
+ <%= paginate @api_users %> +
+
diff --git a/app/views/admin/api_users/new.haml b/app/views/admin/api_users/new.haml deleted file mode 100644 index f8282f44f..000000000 --- a/app/views/admin/api_users/new.haml +++ /dev/null @@ -1,3 +0,0 @@ -= render 'shared/title', name: t('.title') - -= render 'form' diff --git a/app/views/admin/api_users/new.html.erb b/app/views/admin/api_users/new.html.erb new file mode 100644 index 000000000..f9a096937 --- /dev/null +++ b/app/views/admin/api_users/new.html.erb @@ -0,0 +1,2 @@ +<%= render 'shared/title', name: t('.title') %> +<%= render 'form' %> diff --git a/app/views/admin/api_users/show.haml b/app/views/admin/api_users/show.haml deleted file mode 100644 index 998a6c078..000000000 --- a/app/views/admin/api_users/show.haml +++ /dev/null @@ -1,61 +0,0 @@ -- content_for :actions do - = link_to(t(:edit), edit_admin_registrar_api_user_path(@api_user.registrar, @api_user), class: 'btn btn-default') - = link_to(t(:delete), admin_registrar_api_user_path(@api_user.registrar, @api_user), - method: :delete, data: { confirm: t(:are_you_sure) }, class: 'btn btn-danger') -= render 'shared/title', name: @api_user.username - -- if @api_user.errors.any? - - @api_user.errors.each do |attr, err| - = err - %br -- if @api_user.errors.any? - %hr -.row - .col-md-12 - .panel.panel-default - .panel-heading - %h3.panel-title= t(:general) - .panel-body - %dl.dl-horizontal - %dt= t(:username) - %dd= @api_user.username - - %dt= t(:password) - %dd= @api_user.plain_text_password - - %dt= t(:registrar_name) - %dd= link_to(@api_user.registrar, admin_registrar_path(@api_user.registrar)) - - %dt= t(:role) - %dd= @api_user.roles.join(', ') - - %dt= t('.active') - %dd= @api_user.active -.row - .col-md-12 - .panel.panel-default - .panel-heading.clearfix - .pull-left - = t(:certificates) - .pull-right - = link_to(t(:upload_crt), - new_admin_api_user_certificate_path(@api_user, crt: true), class: 'btn btn-primary btn-xs') - = link_to(t(:upload_csr), - new_admin_api_user_certificate_path(@api_user), class: 'btn btn-primary btn-xs') - - .table-responsive - %table.table.table-hover.table-bordered.table-condensed - %thead - %tr - %th{class: 'col-xs-10'}= t('.subject') - %th{class: 'col-xs-2'}= t(:status) - %tbody - - @api_user.certificates.each do |x| - - if x.csr - %tr - %td= link_to(x.parsed_csr.try(:subject), admin_api_user_certificate_path(@api_user, x)) - %td= x.status - - elsif x.crt - %tr - %td= link_to(x.parsed_crt.try(:subject), admin_api_user_certificate_path(@api_user, x)) - %td= x.status diff --git a/app/views/admin/api_users/show.html.erb b/app/views/admin/api_users/show.html.erb new file mode 100644 index 000000000..ace211f52 --- /dev/null +++ b/app/views/admin/api_users/show.html.erb @@ -0,0 +1,111 @@ +<% content_for :actions do %> + <%= link_to(t(:edit), edit_admin_registrar_api_user_path(@api_user.registrar, @api_user), class: 'btn btn-default') %> + <%= link_to(t(:delete), admin_registrar_api_user_path(@api_user.registrar, @api_user), method: :delete, data: { confirm: t(:are_you_sure) }, class: 'btn btn-danger') %> +<% end %> +<%= render 'shared/title', name: @api_user.username %> +<% if @api_user.errors.any? %> + <% @api_user.errors.each do |attr, err| %> + <%= err %> +
+ <% end %> +<% end %> +<% if @api_user.errors.any? %> +
+<% end %> +
+
+
+
+

+ <%= t(:general) %> +

+
+
+
+
+ <%= t(:username) %> +
+
+ <%= @api_user.username %> +
+
+ <%= t(:password) %> +
+
+ <%= @api_user.plain_text_password %> +
+
+ <%= t(:registrar_name) %> +
+
+ <%= link_to(@api_user.registrar, admin_registrar_path(@api_user.registrar)) %> +
+
+ <%= t(:role) %> +
+
+ <%= @api_user.roles.join(', ') %> +
+
+ <%= t('.active') %> +
+
+ <%= @api_user.active %> +
+
+
+
+
+
+
+
+
+
+
+ <%= t(:certificates) %> +
+
+ <%= link_to(t(:upload_crt), new_admin_api_user_certificate_path(@api_user, crt: true), class: 'btn btn-primary btn-xs') %> + <%= link_to(t(:upload_csr), new_admin_api_user_certificate_path(@api_user), class: 'btn btn-primary btn-xs') %> +
+
+
+ + + + + + + + + <% @api_user.certificates.each do |x| %> + <% if x.csr %> + + + + + <% elsif x.crt %> + + + + + <% end %> + <% end %> + +
+ <%= t('.subject') %> + + <%= t(:status) %> +
+ <%= link_to(x.parsed_csr.try(:subject), admin_api_user_certificate_path(@api_user, x)) %> + + <%= x.status %> +
+ <%= link_to(x.parsed_crt.try(:subject), admin_api_user_certificate_path(@api_user, x)) %> + + <%= x.status %> +
+
+
+
+
From a28a4ebb349ce5169decec6c46e611b92d0138d8 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 9 Dec 2019 21:56:44 +0200 Subject: [PATCH 10/28] Use standard header for registrar API users in admin area --- app/views/admin/api_users/edit.html.erb | 17 ++++++++++--- app/views/admin/api_users/index.html.erb | 4 ++- app/views/admin/api_users/new.html.erb | 11 ++++++++- app/views/admin/api_users/show.html.erb | 31 ++++++++++++++++++++---- config/locales/admin/api_users.en.yml | 9 +++++-- config/locales/en.yml | 1 - 6 files changed, 59 insertions(+), 14 deletions(-) diff --git a/app/views/admin/api_users/edit.html.erb b/app/views/admin/api_users/edit.html.erb index 5fee5b941..d065c885c 100644 --- a/app/views/admin/api_users/edit.html.erb +++ b/app/views/admin/api_users/edit.html.erb @@ -1,5 +1,14 @@ -<% content_for :actions do %> - <%= link_to(t(:back_to_api_user), admin_registrar_api_user_path(@api_user.registrar, @api_user), class: 'btn btn-default') %> -<% end %> -<%= render 'shared/title', name: "#{t(:edit)}: #{@api_user.username}" %> + + + + <%= render 'form' %> diff --git a/app/views/admin/api_users/index.html.erb b/app/views/admin/api_users/index.html.erb index dacd6398a..20c76e54f 100644 --- a/app/views/admin/api_users/index.html.erb +++ b/app/views/admin/api_users/index.html.erb @@ -1,4 +1,6 @@ -<%= render 'shared/title', name: t('.title') %> +
diff --git a/app/views/admin/api_users/new.html.erb b/app/views/admin/api_users/new.html.erb index f9a096937..b3f4580e1 100644 --- a/app/views/admin/api_users/new.html.erb +++ b/app/views/admin/api_users/new.html.erb @@ -1,2 +1,11 @@ -<%= render 'shared/title', name: t('.title') %> + + + + <%= render 'form' %> diff --git a/app/views/admin/api_users/show.html.erb b/app/views/admin/api_users/show.html.erb index ace211f52..7090d777b 100644 --- a/app/views/admin/api_users/show.html.erb +++ b/app/views/admin/api_users/show.html.erb @@ -1,8 +1,29 @@ -<% content_for :actions do %> - <%= link_to(t(:edit), edit_admin_registrar_api_user_path(@api_user.registrar, @api_user), class: 'btn btn-default') %> - <%= link_to(t(:delete), admin_registrar_api_user_path(@api_user.registrar, @api_user), method: :delete, data: { confirm: t(:are_you_sure) }, class: 'btn btn-danger') %> -<% end %> -<%= render 'shared/title', name: @api_user.username %> + + + + <% if @api_user.errors.any? %> <% @api_user.errors.each do |attr, err| %> <%= err %> diff --git a/config/locales/admin/api_users.en.yml b/config/locales/admin/api_users.en.yml index de4fddb08..245b0e4d7 100644 --- a/config/locales/admin/api_users.en.yml +++ b/config/locales/admin/api_users.en.yml @@ -2,15 +2,20 @@ en: admin: api_users: index: - title: API users + header: API users active: Active show: active: Active subject: Subject + edit_btn: Edit + delete_btn: Delete new: - title: New API user + header: New API user + + edit: + header: Edit API user form: active: Active diff --git a/config/locales/en.yml b/config/locales/en.yml index 5742398f7..a12385169 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -277,7 +277,6 @@ en: certificate_signing_req: 'Certificate signing request' csr: 'CSR' crt: 'CRT' - back_to_api_user: 'Back to API user' dnskey: 'DNS key' dnskeys: 'DNS Keys' From e010fdbc0037b3f868c708bcaacbc39390cf51b1 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 9 Dec 2019 21:58:20 +0200 Subject: [PATCH 11/28] Remove unneeded code --- app/views/admin/api_users/show.html.erb | 9 --------- 1 file changed, 9 deletions(-) diff --git a/app/views/admin/api_users/show.html.erb b/app/views/admin/api_users/show.html.erb index 7090d777b..0061263f8 100644 --- a/app/views/admin/api_users/show.html.erb +++ b/app/views/admin/api_users/show.html.erb @@ -24,15 +24,6 @@
-<% if @api_user.errors.any? %> - <% @api_user.errors.each do |attr, err| %> - <%= err %> -
- <% end %> -<% end %> -<% if @api_user.errors.any? %> -
-<% end %>
From c91c12ab304e779cec0479890884a2dccb290f4f Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 9 Dec 2019 22:01:56 +0200 Subject: [PATCH 12/28] Reformat --- app/views/admin/api_users/_form.html.erb | 8 ++ app/views/admin/api_users/index.html.erb | 47 +++++----- app/views/admin/api_users/show.html.erb | 108 +++++++++++------------ 3 files changed, 81 insertions(+), 82 deletions(-) diff --git a/app/views/admin/api_users/_form.html.erb b/app/views/admin/api_users/_form.html.erb index b97d45539..0b4eadb0f 100644 --- a/app/views/admin/api_users/_form.html.erb +++ b/app/views/admin/api_users/_form.html.erb @@ -1,5 +1,6 @@ <%= form_for([:admin, @api_user.registrar, @api_user], html: { class: 'form-horizontal', autocomplete: 'off' }) do |f| %> <%= render 'shared/full_errors', object: @api_user %> +
@@ -10,6 +11,7 @@ <%= f.text_field :username, required: true, autofocus: true, class: 'form-control' %>
+
<%= f.label :plain_text_password, nil, class: 'required' %> @@ -18,6 +20,7 @@ <%= f.text_field :plain_text_password, required: true, class: 'form-control' %>
+
<%= f.label :identity_code %> @@ -26,10 +29,12 @@ <%= f.text_field(:identity_code, class: 'form-control') %>
+
<%= f.label :role, nil, class: 'required' %>
+
<%= select_tag 'api_user[roles][]', options_for_select(ApiUser::ROLES.map { |x| [x, x] }, @api_user.roles.try(:first)), class: 'form-control selectize' %>
@@ -42,10 +47,13 @@
+
+
<%= button_tag(t(:save), class: 'btn btn-primary') %>
+ <% end %> diff --git a/app/views/admin/api_users/index.html.erb b/app/views/admin/api_users/index.html.erb index 20c76e54f..8faff2cff 100644 --- a/app/views/admin/api_users/index.html.erb +++ b/app/views/admin/api_users/index.html.erb @@ -1,42 +1,41 @@ +
- - - - - - - - <% @api_users.each do |api_user| %> - - - + + + - <% end %> + + + + <% @api_users.each do |api_user| %> + + + + + + <% end %>
- <%= sort_link(@q, 'username') %> - - <%= sort_link(@q, 'registrar_name', t(:registrar_name)) %> - - <%= sort_link(@q, 'active', t('.active')) %> -
- <%= link_to api_user, admin_registrar_api_user_path(api_user.registrar, api_user) %> - - <%= link_to api_user.registrar, [:admin, api_user.registrar] %> - - <%= api_user.active %> - + <%= sort_link(@q, 'username') %> + + <%= sort_link(@q, 'registrar_name', t(:registrar_name)) %> + + <%= sort_link(@q, 'active', t('.active')) %> +
<%= link_to api_user, + admin_registrar_api_user_path(api_user.registrar, + api_user) %><%= link_to api_user.registrar, [:admin, api_user.registrar] %><%= api_user.active %>
+
<%= paginate @api_users %> diff --git a/app/views/admin/api_users/show.html.erb b/app/views/admin/api_users/show.html.erb index 0061263f8..1c7c9941b 100644 --- a/app/views/admin/api_users/show.html.erb +++ b/app/views/admin/api_users/show.html.erb @@ -32,43 +32,29 @@ <%= t(:general) %>
+
-
- <%= t(:username) %> -
-
- <%= @api_user.username %> -
-
- <%= t(:password) %> -
-
- <%= @api_user.plain_text_password %> -
-
- <%= t(:registrar_name) %> -
-
- <%= link_to(@api_user.registrar, admin_registrar_path(@api_user.registrar)) %> -
-
- <%= t(:role) %> -
-
- <%= @api_user.roles.join(', ') %> -
-
- <%= t('.active') %> -
-
- <%= @api_user.active %> -
+
<%= t(:username) %>
+
<%= @api_user.username %>
+ +
<%= t(:password) %>
+
<%= @api_user.plain_text_password %>
+ +
<%= t(:registrar_name) %>
+
<%= link_to(@api_user.registrar, admin_registrar_path(@api_user.registrar)) %>
+ +
<%= t(:role) %>
+
<%= @api_user.roles.join(', ') %>
+ +
<%= t('.active') %>
+
<%= @api_user.active %>
+
@@ -81,40 +67,46 @@ <%= link_to(t(:upload_csr), new_admin_api_user_certificate_path(@api_user), class: 'btn btn-primary btn-xs') %>
+
- - - - + + + + + - <% @api_user.certificates.each do |x| %> - <% if x.csr %> - - - - - <% elsif x.crt %> - - - - + <% @api_user.certificates.each do |x| %> + <% if x.csr %> + + + + + <% elsif x.crt %> + + + + + <% end %> <% end %> - <% end %>
- <%= t('.subject') %> - - <%= t(:status) %> -
+ <%= t('.subject') %> + + <%= t(:status) %> +
- <%= link_to(x.parsed_csr.try(:subject), admin_api_user_certificate_path(@api_user, x)) %> - - <%= x.status %> -
- <%= link_to(x.parsed_crt.try(:subject), admin_api_user_certificate_path(@api_user, x)) %> - - <%= x.status %> -
+ <%= link_to(x.parsed_csr.try(:subject), + admin_api_user_certificate_path(@api_user, + x)) %> + + <%= x.status %> +
+ <%= link_to(x.parsed_crt.try(:subject), + admin_api_user_certificate_path(@api_user, + x)) %> + + <%= x.status %> +
From 837f3ed541dcdf1584fe458bc6b97f70ad158e36 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 9 Dec 2019 22:06:15 +0200 Subject: [PATCH 13/28] Fix invalid HTML --- app/views/admin/api_users/_form.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/api_users/_form.html.erb b/app/views/admin/api_users/_form.html.erb index 0b4eadb0f..5fe0dae75 100644 --- a/app/views/admin/api_users/_form.html.erb +++ b/app/views/admin/api_users/_form.html.erb @@ -32,7 +32,7 @@
- <%= f.label :role, nil, class: 'required' %> + <%= f.label :role, nil, for: nil, class: 'required' %>
From b850efb939050909b584ed6c6fa22471855e755e Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 9 Dec 2019 22:13:53 +0200 Subject: [PATCH 14/28] Use standard UI --- app/views/admin/api_users/_form.html.erb | 7 +++---- app/views/admin/api_users/show.html.erb | 4 ++-- config/locales/admin/api_users.en.yml | 2 ++ test/system/admin_area/registrars/api_users_test.rb | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/views/admin/api_users/_form.html.erb b/app/views/admin/api_users/_form.html.erb index 5fe0dae75..6119bc727 100644 --- a/app/views/admin/api_users/_form.html.erb +++ b/app/views/admin/api_users/_form.html.erb @@ -1,5 +1,5 @@ <%= form_for([:admin, @api_user.registrar, @api_user], html: { class: 'form-horizontal', autocomplete: 'off' }) do |f| %> - <%= render 'shared/full_errors', object: @api_user %> + <%= render 'form_errors', target: @api_user %>
@@ -48,12 +48,11 @@
-
+
- <%= button_tag(t(:save), class: 'btn btn-primary') %> + <%= button_tag t(".#{f.object.new_record? ? 'create' : 'update'}_btn"), class: 'btn btn-success' %>
- <% end %> diff --git a/app/views/admin/api_users/show.html.erb b/app/views/admin/api_users/show.html.erb index 1c7c9941b..5022bc58b 100644 --- a/app/views/admin/api_users/show.html.erb +++ b/app/views/admin/api_users/show.html.erb @@ -14,12 +14,12 @@
<%= link_to t('.edit_btn'), edit_admin_registrar_api_user_path(@api_user.registrar, @api_user), - class: 'btn btn-default' %> + class: 'btn btn-primary' %> <%= link_to t('.delete_btn'), admin_registrar_api_user_path(@api_user.registrar, @api_user), method: :delete, data: { confirm: t(:are_you_sure) }, - class: 'btn btn-danger' %> + class: 'btn btn-default' %>
diff --git a/config/locales/admin/api_users.en.yml b/config/locales/admin/api_users.en.yml index 245b0e4d7..0c8e6273c 100644 --- a/config/locales/admin/api_users.en.yml +++ b/config/locales/admin/api_users.en.yml @@ -19,3 +19,5 @@ en: form: active: Active + create_btn: Create API user + update_btn: Update API user diff --git a/test/system/admin_area/registrars/api_users_test.rb b/test/system/admin_area/registrars/api_users_test.rb index 69288265f..054261c71 100644 --- a/test/system/admin_area/registrars/api_users_test.rb +++ b/test/system/admin_area/registrars/api_users_test.rb @@ -14,7 +14,7 @@ class AdminRegistrarsApiUsersSystemTest < ApplicationSystemTestCase fill_in 'Username', with: username fill_in 'Password', with: valid_password - click_on 'Save' + click_on 'Create API user' assert_text 'Record created' assert_text "Username #{username}" @@ -43,7 +43,7 @@ class AdminRegistrarsApiUsersSystemTest < ApplicationSystemTestCase visit admin_registrar_api_user_path(api_user.registrar, api_user) click_link_or_button 'Edit' fill_in 'Username', with: new_username - click_link_or_button 'Save' + click_link_or_button 'Update API user' assert_text 'Record updated' assert_text "Username #{new_username}" From 01c877fe70c3c48cd60797fe881dc5da7ea0acfa Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 9 Dec 2019 22:16:36 +0200 Subject: [PATCH 15/28] Remove unneded code --- app/controllers/admin/api_users_controller.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/admin/api_users_controller.rb b/app/controllers/admin/api_users_controller.rb index 3afc9ddf8..1343e2f91 100644 --- a/app/controllers/admin/api_users_controller.rb +++ b/app/controllers/admin/api_users_controller.rb @@ -1,7 +1,6 @@ module Admin class ApiUsersController < BaseController load_and_authorize_resource - before_action :set_api_user, only: [:show, :edit, :update, :destroy] def index @q = ApiUser.includes(:registrar).search(params[:q]) From e5eaac291ee7d9a713baaec182028214600056f0 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 9 Dec 2019 22:23:12 +0200 Subject: [PATCH 16/28] Show validation errors in UI, otherwise fail loudly --- app/controllers/admin/api_users_controller.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/api_users_controller.rb b/app/controllers/admin/api_users_controller.rb index 1343e2f91..4b79ffdaa 100644 --- a/app/controllers/admin/api_users_controller.rb +++ b/app/controllers/admin/api_users_controller.rb @@ -14,11 +14,11 @@ module Admin def create @api_user = registrar.api_users.build(api_user_params) - if @api_user.save + if @api_user.valid? + @api_user.save! flash[:notice] = I18n.t('record_created') redirect_to admin_registrar_api_user_path(@api_user.registrar, @api_user) else - flash.now[:alert] = I18n.t('failed_to_create_record') render 'new' end end @@ -34,11 +34,13 @@ module Admin params[:api_user].delete(:plain_text_password) end - if @api_user.update(api_user_params) + @api_user.attributes = api_user_params + + if @api_user.valid? + @api_user.save! flash[:notice] = I18n.t('record_updated') redirect_to admin_registrar_api_user_path(@api_user.registrar, @api_user) else - flash.now[:alert] = I18n.t('failed_to_update_record') render 'edit' end end From 61f6a3705f52f5afd858724e757c1a74f848c282 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 9 Dec 2019 22:25:03 +0200 Subject: [PATCH 17/28] Fail Loudly --- app/controllers/admin/api_users_controller.rb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/controllers/admin/api_users_controller.rb b/app/controllers/admin/api_users_controller.rb index 4b79ffdaa..cb2c6ff52 100644 --- a/app/controllers/admin/api_users_controller.rb +++ b/app/controllers/admin/api_users_controller.rb @@ -46,13 +46,8 @@ module Admin end def destroy - if @api_user.destroy - flash[:notice] = I18n.t('record_deleted') - redirect_to admin_registrar_path(@api_user.registrar) - else - flash.now[:alert] = I18n.t('failed_to_delete_record') - render 'show' - end + @api_user.destroy! + redirect_to admin_registrar_path(@api_user.registrar), notice: t('record_deleted') end private From aa8be7d1482a9ab515990add33fc3968476f6992 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 9 Dec 2019 22:30:02 +0200 Subject: [PATCH 18/28] Improve error messages --- app/controllers/admin/api_users_controller.rb | 10 +++++----- config/locales/admin/api_users.en.yml | 15 ++++++++++++--- .../admin_area/registrars/api_users_test.rb | 6 +++--- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/app/controllers/admin/api_users_controller.rb b/app/controllers/admin/api_users_controller.rb index cb2c6ff52..0eba34739 100644 --- a/app/controllers/admin/api_users_controller.rb +++ b/app/controllers/admin/api_users_controller.rb @@ -16,8 +16,8 @@ module Admin if @api_user.valid? @api_user.save! - flash[:notice] = I18n.t('record_created') - redirect_to admin_registrar_api_user_path(@api_user.registrar, @api_user) + redirect_to admin_registrar_api_user_path(@api_user.registrar, @api_user), + notice: t('.created') else render 'new' end @@ -38,8 +38,8 @@ module Admin if @api_user.valid? @api_user.save! - flash[:notice] = I18n.t('record_updated') - redirect_to admin_registrar_api_user_path(@api_user.registrar, @api_user) + redirect_to admin_registrar_api_user_path(@api_user.registrar, @api_user), + notice: t('.updated') else render 'edit' end @@ -47,7 +47,7 @@ module Admin def destroy @api_user.destroy! - redirect_to admin_registrar_path(@api_user.registrar), notice: t('record_deleted') + redirect_to admin_registrar_path(@api_user.registrar), notice: t('.deleted') end private diff --git a/config/locales/admin/api_users.en.yml b/config/locales/admin/api_users.en.yml index 0c8e6273c..49b72a2bd 100644 --- a/config/locales/admin/api_users.en.yml +++ b/config/locales/admin/api_users.en.yml @@ -5,18 +5,27 @@ en: header: API users active: Active + new: + header: New API user + + create: + created: API user has been successfully created + show: active: Active subject: Subject edit_btn: Edit delete_btn: Delete - new: - header: New API user - edit: header: Edit API user + update: + updated: API user has been successfully updated + + destroy: + deleted: API user has been successfully deleted + form: active: Active create_btn: Create API user diff --git a/test/system/admin_area/registrars/api_users_test.rb b/test/system/admin_area/registrars/api_users_test.rb index 054261c71..5d833dde2 100644 --- a/test/system/admin_area/registrars/api_users_test.rb +++ b/test/system/admin_area/registrars/api_users_test.rb @@ -16,7 +16,7 @@ class AdminRegistrarsApiUsersSystemTest < ApplicationSystemTestCase fill_in 'Password', with: valid_password click_on 'Create API user' - assert_text 'Record created' + assert_text 'API user has been successfully created' assert_text "Username #{username}" new_api_user = ApiUser.last assert_current_path admin_registrar_api_user_path(registrar, new_api_user) @@ -45,7 +45,7 @@ class AdminRegistrarsApiUsersSystemTest < ApplicationSystemTestCase fill_in 'Username', with: new_username click_link_or_button 'Update API user' - assert_text 'Record updated' + assert_text 'API user has been successfully updated' assert_text "Username #{new_username}" assert_current_path admin_registrar_api_user_path(api_user.registrar, api_user) end @@ -56,7 +56,7 @@ class AdminRegistrarsApiUsersSystemTest < ApplicationSystemTestCase visit admin_registrar_api_user_path(api_user.registrar, api_user) click_on 'Delete' - assert_text 'Record deleted' + assert_text 'API user has been successfully deleted' assert_current_path admin_registrar_path(api_user.registrar) end From d82c44600a81b8854bfb226c74a59c9011d64533 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 9 Dec 2019 22:30:14 +0200 Subject: [PATCH 19/28] Remove unneded code --- app/controllers/admin/api_users_controller.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/controllers/admin/api_users_controller.rb b/app/controllers/admin/api_users_controller.rb index 0eba34739..f47a4b652 100644 --- a/app/controllers/admin/api_users_controller.rb +++ b/app/controllers/admin/api_users_controller.rb @@ -52,10 +52,6 @@ module Admin private - def set_api_user - @api_user = ApiUser.find(params[:id]) - end - def api_user_params params.require(:api_user).permit(:username, :plain_text_password, :active, :identity_code, { roles: [] }) From 3cea41e1193609aeab5558267fa9228f189776d2 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 9 Dec 2019 22:33:30 +0200 Subject: [PATCH 20/28] Extract partial --- app/views/admin/api_users/_api_user.html.erb | 5 +++++ app/views/admin/api_users/index.html.erb | 10 +--------- 2 files changed, 6 insertions(+), 9 deletions(-) create mode 100644 app/views/admin/api_users/_api_user.html.erb diff --git a/app/views/admin/api_users/_api_user.html.erb b/app/views/admin/api_users/_api_user.html.erb new file mode 100644 index 000000000..196cb2ebb --- /dev/null +++ b/app/views/admin/api_users/_api_user.html.erb @@ -0,0 +1,5 @@ + + <%= link_to api_user, admin_registrar_api_user_path(api_user.registrar, api_user) %> + <%= link_to api_user.registrar, [:admin, api_user.registrar] %> + <%= api_user.active %> + diff --git a/app/views/admin/api_users/index.html.erb b/app/views/admin/api_users/index.html.erb index 8faff2cff..1ca018bb1 100644 --- a/app/views/admin/api_users/index.html.erb +++ b/app/views/admin/api_users/index.html.erb @@ -21,15 +21,7 @@ - <% @api_users.each do |api_user| %> - - <%= link_to api_user, - admin_registrar_api_user_path(api_user.registrar, - api_user) %> - <%= link_to api_user.registrar, [:admin, api_user.registrar] %> - <%= api_user.active %> - - <% end %> + <%= render @api_users %>
From e780005517ef99f37ac3b46cf78b1cac40c7fa88 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 9 Dec 2019 22:35:27 +0200 Subject: [PATCH 21/28] Use named route explicitly --- app/views/admin/api_users/_api_user.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/api_users/_api_user.html.erb b/app/views/admin/api_users/_api_user.html.erb index 196cb2ebb..d8412a519 100644 --- a/app/views/admin/api_users/_api_user.html.erb +++ b/app/views/admin/api_users/_api_user.html.erb @@ -1,5 +1,5 @@ <%= link_to api_user, admin_registrar_api_user_path(api_user.registrar, api_user) %> - <%= link_to api_user.registrar, [:admin, api_user.registrar] %> + <%= link_to api_user.registrar, admin_registrar_path(api_user.registrar) %> <%= api_user.active %> From 54be3995e6686a771b260a68f17d690022780056 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 10 Dec 2019 15:21:35 +0200 Subject: [PATCH 22/28] Remove unneeded translations --- config/locales/api_users.en.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/config/locales/api_users.en.yml b/config/locales/api_users.en.yml index 757ded049..2d8538023 100644 --- a/config/locales/api_users.en.yml +++ b/config/locales/api_users.en.yml @@ -3,14 +3,3 @@ en: attributes: api_user: plain_text_password: Password - errors: - models: - api_user: - attributes: - username: - blank: 'Username is missing' - taken: 'Username already exists' - plain_text_password: - blank: 'Password is missing' - registrar: - blank: 'Registrar is missing' \ No newline at end of file From e6981e7e280ed61b62dd54813b132db8099e9aa4 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 10 Dec 2019 15:21:57 +0200 Subject: [PATCH 23/28] Remove unneeded code --- app/controllers/admin/api_users_controller.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/controllers/admin/api_users_controller.rb b/app/controllers/admin/api_users_controller.rb index f47a4b652..8876c726f 100644 --- a/app/controllers/admin/api_users_controller.rb +++ b/app/controllers/admin/api_users_controller.rb @@ -30,10 +30,6 @@ module Admin end def update - if params[:api_user][:plain_text_password].blank? - params[:api_user].delete(:plain_text_password) - end - @api_user.attributes = api_user_params if @api_user.valid? From ce8f7993c2bd50e31c37ec007a8d21cdd284a794 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 10 Dec 2019 15:54:30 +0200 Subject: [PATCH 24/28] Use default translations --- app/views/admin/api_users/_form.html.erb | 2 +- app/views/admin/api_users/index.html.erb | 4 ++-- app/views/admin/api_users/show.html.erb | 10 +++++----- config/locales/admin/api_users.en.yml | 3 --- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/app/views/admin/api_users/_form.html.erb b/app/views/admin/api_users/_form.html.erb index 6119bc727..23dd27b26 100644 --- a/app/views/admin/api_users/_form.html.erb +++ b/app/views/admin/api_users/_form.html.erb @@ -40,7 +40,7 @@
diff --git a/app/views/admin/api_users/index.html.erb b/app/views/admin/api_users/index.html.erb index 1ca018bb1..9c00f32d6 100644 --- a/app/views/admin/api_users/index.html.erb +++ b/app/views/admin/api_users/index.html.erb @@ -12,10 +12,10 @@ <%= sort_link(@q, 'username') %> - <%= sort_link(@q, 'registrar_name', t(:registrar_name)) %> + <%= sort_link(@q, 'registrar_name', Registrar.model_name.human) %> - <%= sort_link(@q, 'active', t('.active')) %> + <%= sort_link(@q, 'active', ApiUser.human_attribute_name(:active)) %> diff --git a/app/views/admin/api_users/show.html.erb b/app/views/admin/api_users/show.html.erb index 5022bc58b..3e7c5347d 100644 --- a/app/views/admin/api_users/show.html.erb +++ b/app/views/admin/api_users/show.html.erb @@ -35,19 +35,19 @@
-
<%= t(:username) %>
+
<%= ApiUser.human_attribute_name :username %>
<%= @api_user.username %>
-
<%= t(:password) %>
+
<%= ApiUser.human_attribute_name :plain_text_password %>
<%= @api_user.plain_text_password %>
-
<%= t(:registrar_name) %>
+
<%= Registrar.model_name.human %>
<%= link_to(@api_user.registrar, admin_registrar_path(@api_user.registrar)) %>
-
<%= t(:role) %>
+
<%= ApiUser.human_attribute_name :roles %>
<%= @api_user.roles.join(', ') %>
-
<%= t('.active') %>
+
<%= ApiUser.human_attribute_name :active %>
<%= @api_user.active %>
diff --git a/config/locales/admin/api_users.en.yml b/config/locales/admin/api_users.en.yml index 49b72a2bd..39c1006f6 100644 --- a/config/locales/admin/api_users.en.yml +++ b/config/locales/admin/api_users.en.yml @@ -3,7 +3,6 @@ en: api_users: index: header: API users - active: Active new: header: New API user @@ -12,7 +11,6 @@ en: created: API user has been successfully created show: - active: Active subject: Subject edit_btn: Edit delete_btn: Delete @@ -27,6 +25,5 @@ en: deleted: API user has been successfully deleted form: - active: Active create_btn: Create API user update_btn: Update API user From fe690c52f502344e7cb2ed24023fde90c8cf4bc2 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 10 Dec 2019 15:57:23 +0200 Subject: [PATCH 25/28] Extract translations --- app/views/admin/api_users/show.html.erb | 4 ++-- config/locales/admin/api_users.en.yml | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/admin/api_users/show.html.erb b/app/views/admin/api_users/show.html.erb index 3e7c5347d..bba7a698f 100644 --- a/app/views/admin/api_users/show.html.erb +++ b/app/views/admin/api_users/show.html.erb @@ -18,7 +18,7 @@ <%= link_to t('.delete_btn'), admin_registrar_api_user_path(@api_user.registrar, @api_user), method: :delete, - data: { confirm: t(:are_you_sure) }, + data: { confirm: t('.delete_btn_confirm') }, class: 'btn btn-default' %>
@@ -29,7 +29,7 @@

- <%= t(:general) %> + <%= t '.header' %>

diff --git a/config/locales/admin/api_users.en.yml b/config/locales/admin/api_users.en.yml index 39c1006f6..bd3772556 100644 --- a/config/locales/admin/api_users.en.yml +++ b/config/locales/admin/api_users.en.yml @@ -11,9 +11,11 @@ en: created: API user has been successfully created show: + header: Details subject: Subject edit_btn: Edit delete_btn: Delete + delete_btn_confirm: Are you sure you want to delete this API user? edit: header: Edit API user From 9079fc68ecfd6955184393b40409276863f1571c Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 10 Dec 2019 15:58:05 +0200 Subject: [PATCH 26/28] Correct attribute name --- app/views/admin/api_users/_form.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/api_users/_form.html.erb b/app/views/admin/api_users/_form.html.erb index 23dd27b26..ad6ee6b2b 100644 --- a/app/views/admin/api_users/_form.html.erb +++ b/app/views/admin/api_users/_form.html.erb @@ -32,7 +32,7 @@
- <%= f.label :role, nil, for: nil, class: 'required' %> + <%= f.label :roles, nil, for: nil, class: 'required' %>
From c815da3afd356c3766663a01b57df1a31c2f5cae Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 10 Dec 2019 16:11:51 +0200 Subject: [PATCH 27/28] Extract partials --- app/views/admin/api_users/show.html.erb | 82 +------------------ .../api_users/show/_certificates.html.erb | 55 +++++++++++++ .../admin/api_users/show/_details.html.erb | 26 ++++++ config/locales/admin/api_users.en.yml | 8 +- 4 files changed, 89 insertions(+), 82 deletions(-) create mode 100644 app/views/admin/api_users/show/_certificates.html.erb create mode 100644 app/views/admin/api_users/show/_details.html.erb diff --git a/app/views/admin/api_users/show.html.erb b/app/views/admin/api_users/show.html.erb index bba7a698f..05c5651ce 100644 --- a/app/views/admin/api_users/show.html.erb +++ b/app/views/admin/api_users/show.html.erb @@ -26,90 +26,12 @@
-
-
-

- <%= t '.header' %> -

-
- -
-
-
<%= ApiUser.human_attribute_name :username %>
-
<%= @api_user.username %>
- -
<%= ApiUser.human_attribute_name :plain_text_password %>
-
<%= @api_user.plain_text_password %>
- -
<%= Registrar.model_name.human %>
-
<%= link_to(@api_user.registrar, admin_registrar_path(@api_user.registrar)) %>
- -
<%= ApiUser.human_attribute_name :roles %>
-
<%= @api_user.roles.join(', ') %>
- -
<%= ApiUser.human_attribute_name :active %>
-
<%= @api_user.active %>
-
-
-
+ <%= render 'admin/api_users/show/details' %>
-
-
-
- <%= t(:certificates) %> -
-
- <%= link_to(t(:upload_crt), new_admin_api_user_certificate_path(@api_user, crt: true), class: 'btn btn-primary btn-xs') %> - <%= link_to(t(:upload_csr), new_admin_api_user_certificate_path(@api_user), class: 'btn btn-primary btn-xs') %> -
-
- -
- - - - - - - - - - <% @api_user.certificates.each do |x| %> - <% if x.csr %> - - - - - <% elsif x.crt %> - - - - - <% end %> - <% end %> - -
- <%= t('.subject') %> - - <%= t(:status) %> -
- <%= link_to(x.parsed_csr.try(:subject), - admin_api_user_certificate_path(@api_user, - x)) %> - - <%= x.status %> -
- <%= link_to(x.parsed_crt.try(:subject), - admin_api_user_certificate_path(@api_user, - x)) %> - - <%= x.status %> -
-
-
+ <%= render 'admin/api_users/show/certificates' %>
diff --git a/app/views/admin/api_users/show/_certificates.html.erb b/app/views/admin/api_users/show/_certificates.html.erb new file mode 100644 index 000000000..75a3cc2df --- /dev/null +++ b/app/views/admin/api_users/show/_certificates.html.erb @@ -0,0 +1,55 @@ +
+
+
+ <%= t(:certificates) %> +
+ +
+ <%= link_to(t(:upload_crt), new_admin_api_user_certificate_path(@api_user, crt: true), class: 'btn btn-primary btn-xs') %> + <%= link_to(t(:upload_csr), new_admin_api_user_certificate_path(@api_user), class: 'btn btn-primary btn-xs') %> +
+
+ +
+ + + + + + + + + + <% @api_user.certificates.each do |x| %> + <% if x.csr %> + + + + + <% elsif x.crt %> + + + + + <% end %> + <% end %> + +
+ <%= t('.subject') %> + + <%= t(:status) %> +
+ <%= link_to(x.parsed_csr.try(:subject), + admin_api_user_certificate_path(@api_user, + x)) %> + + <%= x.status %> +
+ <%= link_to(x.parsed_crt.try(:subject), + admin_api_user_certificate_path(@api_user, + x)) %> + + <%= x.status %> +
+
+
diff --git a/app/views/admin/api_users/show/_details.html.erb b/app/views/admin/api_users/show/_details.html.erb new file mode 100644 index 000000000..c98f23866 --- /dev/null +++ b/app/views/admin/api_users/show/_details.html.erb @@ -0,0 +1,26 @@ +
+
+

+ <%= t '.header' %> +

+
+ +
+
+
<%= ApiUser.human_attribute_name :username %>
+
<%= @api_user.username %>
+ +
<%= ApiUser.human_attribute_name :plain_text_password %>
+
<%= @api_user.plain_text_password %>
+ +
<%= Registrar.model_name.human %>
+
<%= link_to(@api_user.registrar, admin_registrar_path(@api_user.registrar)) %>
+ +
<%= ApiUser.human_attribute_name :roles %>
+
<%= @api_user.roles.join(', ') %>
+ +
<%= ApiUser.human_attribute_name :active %>
+
<%= @api_user.active %>
+
+
+
diff --git a/config/locales/admin/api_users.en.yml b/config/locales/admin/api_users.en.yml index bd3772556..9fde2db14 100644 --- a/config/locales/admin/api_users.en.yml +++ b/config/locales/admin/api_users.en.yml @@ -11,12 +11,16 @@ en: created: API user has been successfully created show: - header: Details - subject: Subject edit_btn: Edit delete_btn: Delete delete_btn_confirm: Are you sure you want to delete this API user? + details: + header: Details + + certificates: + subject: Subject + edit: header: Edit API user From f4abb0afce7b30c86973cb6c82b3b8545e0de2ef Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 10 Dec 2019 16:12:02 +0200 Subject: [PATCH 28/28] Fix translation --- config/locales/api_users.en.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/locales/api_users.en.yml b/config/locales/api_users.en.yml index 2d8538023..9d4fcb63a 100644 --- a/config/locales/api_users.en.yml +++ b/config/locales/api_users.en.yml @@ -3,3 +3,4 @@ en: attributes: api_user: plain_text_password: Password + roles: Role