diff --git a/app/api/repp/domain_contacts_v1.rb b/app/api/repp/domain_contacts_v1.rb index 2d2cc4dbb..5a38897d4 100644 --- a/app/api/repp/domain_contacts_v1.rb +++ b/app/api/repp/domain_contacts_v1.rb @@ -22,7 +22,8 @@ module Repp if predecessor == successor error!({ error: { type: 'invalid_request_error', - message: 'Successor contact must be different from predecessor' } }, + message: 'New contact ID must be different from current' \ + ' contact ID' } }, :bad_request) end diff --git a/app/assets/javascripts/popover.js b/app/assets/javascripts/popover.js new file mode 100644 index 000000000..2f8ed57b5 --- /dev/null +++ b/app/assets/javascripts/popover.js @@ -0,0 +1,9 @@ +(function() { + function initPopover() { + $(function () { + $('[data-toggle="popover"]').popover(); + }) + } + + initPopover(); +})(); diff --git a/app/assets/javascripts/registrar-manifest.coffee b/app/assets/javascripts/registrar-manifest.coffee index 5c4a58df6..b5eb13a99 100644 --- a/app/assets/javascripts/registrar-manifest.coffee +++ b/app/assets/javascripts/registrar-manifest.coffee @@ -7,6 +7,7 @@ #= require select2 #= require datepicker #= require spell_check +#= require popover #= require shared/general #= require registrar/autocomplete #= require registrar/application diff --git a/app/controllers/registrar/domain_transfers_controller.rb b/app/controllers/registrar/domain_transfers_controller.rb index 65127155e..7c0925f03 100644 --- a/app/controllers/registrar/domain_transfers_controller.rb +++ b/app/controllers/registrar/domain_transfers_controller.rb @@ -1,5 +1,5 @@ class Registrar - class DomainTransfersController < DeppController + class DomainTransfersController < BulkChangeController before_action do authorize! :transfer, Depp::Domain end @@ -58,7 +58,7 @@ class Registrar redirect_to registrar_domains_url else @api_errors = parsed_response[:errors] - render :new + render file: 'registrar/bulk_change/new', locals: { active_tab: :bulk_transfer } end else params[:request] = true # EPP domain:transfer "op" attribute diff --git a/app/views/registrar/bulk_change/_bulk_transfer_form.html.erb b/app/views/registrar/bulk_change/_bulk_transfer_form.html.erb new file mode 100644 index 000000000..3450cd4e9 --- /dev/null +++ b/app/views/registrar/bulk_change/_bulk_transfer_form.html.erb @@ -0,0 +1,35 @@ +<%= form_tag registrar_domain_transfers_path, multipart: true, class: 'form-horizontal' do %> + <%= render 'registrar/domain_transfers/form/api_errors' %> + +
+
+ <%= label_tag :batch_file %> +
+
+ <%= file_field_tag :batch_file, required: true %> + <%= t '.file_field_hint' %> +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ <%= t '.help' %> +
+
+
+
+<% end %> diff --git a/app/views/registrar/bulk_change/_nameserver_form.html.erb b/app/views/registrar/bulk_change/_nameserver_form.html.erb index 1b1900314..2a6e8f689 100644 --- a/app/views/registrar/bulk_change/_nameserver_form.html.erb +++ b/app/views/registrar/bulk_change/_nameserver_form.html.erb @@ -6,7 +6,7 @@ <%= label_tag :old_hostname %> -
+
<%= text_field_tag :old_hostname, params[:old_hostname], required: true, class: 'form-control' %>
@@ -17,7 +17,7 @@ <%= label_tag :new_hostname %>
-
+
<%= text_field_tag :new_hostname, params[:new_hostname], required: true, class: 'form-control' %>
@@ -28,7 +28,7 @@ <%= label_tag :ipv4 %>
-
+
<%= text_area_tag :ipv4, params[:ipv4], class: 'form-control' %>
@@ -38,17 +38,31 @@ <%= label_tag :ipv6 %> -
+
<%= text_area_tag :ipv6, params[:ipv6], class: 'form-control' %> <%= t '.ip_hint' %>
-
+
+ +
+
+ +
+
+ <%= t '.help' %> +
+
+
+
<% end %> diff --git a/app/views/registrar/bulk_change/_tech_contact_form.html.erb b/app/views/registrar/bulk_change/_tech_contact_form.html.erb index 24e7ff27f..f64c738fe 100644 --- a/app/views/registrar/bulk_change/_tech_contact_form.html.erb +++ b/app/views/registrar/bulk_change/_tech_contact_form.html.erb @@ -7,10 +7,10 @@
- <%= label_tag :predecessor %> + <%= label_tag :predecessor, t('.predecessor') %>
-
+
<%= text_field_tag :predecessor, params[:predecessor], list: :contacts, required: true, @@ -21,10 +21,10 @@
- <%= label_tag :successor %> + <%= label_tag :successor, t('.successor') %>
-
+
<%= text_field_tag :successor, params[:successor], list: :contacts, required: true, @@ -33,12 +33,25 @@
-
+
+ +
+
+ +
+
+ <%= t '.help' %> +
+
+
+
<% end %> diff --git a/app/views/registrar/bulk_change/new.html.erb b/app/views/registrar/bulk_change/new.html.erb index 77cc2d20a..da85899ff 100644 --- a/app/views/registrar/bulk_change/new.html.erb +++ b/app/views/registrar/bulk_change/new.html.erb @@ -6,8 +6,7 @@

<%= t '.header' %>

-
-
+
@@ -27,6 +30,8 @@
<%= render 'nameserver_form' %>
+ +
+ <%= render 'bulk_transfer_form' %> +
-
-
diff --git a/app/views/registrar/domain_transfers/form/_single.html.erb b/app/views/registrar/domain_transfers/_form.html.erb similarity index 92% rename from app/views/registrar/domain_transfers/form/_single.html.erb rename to app/views/registrar/domain_transfers/_form.html.erb index 8a9488580..52dcca468 100644 --- a/app/views/registrar/domain_transfers/form/_single.html.erb +++ b/app/views/registrar/domain_transfers/_form.html.erb @@ -1,4 +1,6 @@ <%= form_tag registrar_domain_transfers_path, multipart: true, class: 'form-horizontal' do %> + <%= render 'registrar/domain_transfers/form/api_errors' %> +
<%= label_tag :domain_name, nil, class: 'required' %> @@ -30,7 +32,7 @@
diff --git a/app/views/registrar/domain_transfers/form/_batch.html.erb b/app/views/registrar/domain_transfers/form/_batch.html.erb deleted file mode 100644 index 6effa8a86..000000000 --- a/app/views/registrar/domain_transfers/form/_batch.html.erb +++ /dev/null @@ -1,19 +0,0 @@ -<%= form_tag registrar_domain_transfers_path, multipart: true, class: 'form-horizontal' do %> -
-
- <%= label_tag :batch_file %> -
-
- <%= file_field_tag :batch_file, required: true %> - <%= t '.batch_file_help' %> -
-
- -
-
- -
-
-<% end %> diff --git a/app/views/registrar/domain_transfers/new.html.erb b/app/views/registrar/domain_transfers/new.html.erb index 8ba658023..52dd3f900 100644 --- a/app/views/registrar/domain_transfers/new.html.erb +++ b/app/views/registrar/domain_transfers/new.html.erb @@ -6,24 +6,6 @@
- - -
-
- <%= render 'registrar/domain_transfers/form/single' %> -
- -
- <%= render 'registrar/domain_transfers/form/batch' %> -
-
+ <%= render 'form' %>
diff --git a/config/locales/registrar/bulk_change.en.yml b/config/locales/registrar/bulk_change.en.yml index 033d63e74..0bbd222bd 100644 --- a/config/locales/registrar/bulk_change.en.yml +++ b/config/locales/registrar/bulk_change.en.yml @@ -5,10 +5,27 @@ en: header: Bulk change technical_contact: Technical contact nameserver: Nameserver + bulk_transfer: Bulk transfer tech_contact_form: + predecessor: Current contact ID + successor: New contact ID submit_btn: Replace technical contacts + help_btn: Toggle help + help: >- + Replace technical contact specified in "current contact ID" with the one in "new + contact ID" on any domain registered under this registrar nameserver_form: ip_hint: One IP per line replace_btn: Replace nameserver + help_btn: Toggle help + help: >- + Replace nameserver specified in the "old hostname" with the one in "new hostname" with + optional IPv4 and IPv6 addresses on any domain registered under this registrar + + bulk_transfer_form: + file_field_hint: CSV file with domain list provided by another registrar + submit_btn: Transfer + help_btn: Toggle help + help: Transfer domains in the csv file with correct transfer code to this registrar diff --git a/config/locales/registrar/domain_transfers.en.yml b/config/locales/registrar/domain_transfers.en.yml index d162110ce..c146a5fd1 100644 --- a/config/locales/registrar/domain_transfers.en.yml +++ b/config/locales/registrar/domain_transfers.en.yml @@ -3,17 +3,10 @@ en: domain_transfers: new: header: Domain transfer - single: One by one - batch: Batch create: header: Domain transfer transferred: "%{count} domains have been successfully transferred" form: - single: - transfer_btn: Transfer - - batch: - batch_file_help: CSV file with domain list provided by another registrar - transfer_btn: Transfer batch + submit_btn: Transfer diff --git a/test/integration/api/domain_contacts_test.rb b/test/integration/api/domain_contacts_test.rb index c069bc23d..b9d405219 100644 --- a/test/integration/api/domain_contacts_test.rb +++ b/test/integration/api/domain_contacts_test.rb @@ -91,7 +91,7 @@ class APIDomainContactsTest < ActionDispatch::IntegrationTest { 'HTTP_AUTHORIZATION' => http_auth_key } assert_response :bad_request assert_equal ({ error: { type: 'invalid_request_error', - message: 'Successor contact must be different from predecessor' } }), + message: 'New contact ID must be different from current contact ID' } }), JSON.parse(response.body, symbolize_names: true) end diff --git a/test/integration/registrar/domain_transfers_test.rb b/test/integration/registrar/bulk_change/bulk_transfer_test.rb similarity index 81% rename from test/integration/registrar/domain_transfers_test.rb rename to test/integration/registrar/bulk_change/bulk_transfer_test.rb index 59202c624..5bfe7cc68 100644 --- a/test/integration/registrar/domain_transfers_test.rb +++ b/test/integration/registrar/bulk_change/bulk_transfer_test.rb @@ -1,11 +1,11 @@ require 'test_helper' -class RegistrarDomainTransfersTest < ActionDispatch::IntegrationTest +class RegistrarAreaBulkTransferTest < ActionDispatch::IntegrationTest setup do login_as users(:api_goodnames) end - def test_batch_transfer_succeeds + def test_transfer_multiple_domains_in_bulk request_body = { data: { domainTransfers: [{ domainName: 'shop.test', transferCode: '65078d5' }] } } headers = { 'Content-type' => 'application/json' } request_stub = stub_request(:post, /domain_transfers/).with(body: request_body, @@ -16,28 +16,26 @@ class RegistrarDomainTransfersTest < ActionDispatch::IntegrationTest }] }.to_json, status: 200) visit registrar_domains_url - click_link 'Transfer' - - click_on 'Batch' + click_link 'Bulk change' + click_link 'Bulk transfer' attach_file 'Batch file', Rails.root.join('test', 'fixtures', 'files', 'valid_domains_for_transfer.csv').to_s - click_button 'Transfer batch' + click_button 'Transfer' assert_requested request_stub assert_current_path registrar_domains_path assert_text '1 domains have been successfully transferred' end - def test_batch_transfer_fails_gracefully + def test_fail_gracefully body = { errors: [{ title: 'epic fail' }] }.to_json headers = { 'Content-type' => 'application/json' } stub_request(:post, /domain_transfers/).to_return(status: 400, body: body, headers: headers) visit registrar_domains_url - click_link 'Transfer' - - click_on 'Batch' + click_link 'Bulk change' + click_link 'Bulk transfer' attach_file 'Batch file', Rails.root.join('test', 'fixtures', 'files', 'valid_domains_for_transfer.csv').to_s - click_button 'Transfer batch' + click_button 'Transfer' assert_text 'epic fail' end diff --git a/test/integration/registrar/bulk_change/tech_contact_test.rb b/test/integration/registrar/bulk_change/tech_contact_test.rb index f45880c7b..2999a8853 100644 --- a/test/integration/registrar/bulk_change/tech_contact_test.rb +++ b/test/integration/registrar/bulk_change/tech_contact_test.rb @@ -16,8 +16,8 @@ class RegistrarAreaTechContactBulkChangeTest < ActionDispatch::IntegrationTest visit registrar_domains_url click_link 'Bulk change' - fill_in 'Predecessor', with: 'william-001' - fill_in 'Successor', with: 'john-001' + fill_in 'Current contact ID', with: 'william-001' + fill_in 'New contact ID', with: 'john-001' click_on 'Replace technical contacts' assert_requested request_stub @@ -36,12 +36,12 @@ class RegistrarAreaTechContactBulkChangeTest < ActionDispatch::IntegrationTest visit registrar_domains_url click_link 'Bulk change' - fill_in 'Predecessor', with: 'william-001' - fill_in 'Successor', with: 'john-001' + fill_in 'Current contact ID', with: 'william-001' + fill_in 'New contact ID', with: 'john-001' click_on 'Replace technical contacts' assert_text 'epic fail' - assert_field 'Predecessor', with: 'william-001' - assert_field 'Successor', with: 'john-001' + assert_field 'Current contact ID', with: 'william-001' + assert_field 'New contact ID', with: 'john-001' end end