From 22b0d4136815d8fedea855e8e74885ce17b6792c Mon Sep 17 00:00:00 2001 From: dinsmol Date: Fri, 3 Dec 2021 15:07:57 +0300 Subject: [PATCH 1/4] Add rollback statuses --- app/controllers/admin/domains_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/controllers/admin/domains_controller.rb b/app/controllers/admin/domains_controller.rb index 8a086027b..3125fe00e 100644 --- a/app/controllers/admin/domains_controller.rb +++ b/app/controllers/admin/domains_controller.rb @@ -41,6 +41,8 @@ module Admin end def update + rollback_history = @domain.json_statuses_history['admin_store_statuses_history'] + rollback_params = ActionController::Parameters.new(statuses: @domain.statuses).permit(:statuses) dp = ignore_empty_statuses @domain.is_admin = true @domain.admin_status_update dp[:statuses] @@ -49,6 +51,8 @@ module Admin flash[:notice] = I18n.t('domain_updated') redirect_to [:admin, @domain] else + @domain.reload + @domain.admin_status_update rollback_history build_associations flash.now[:alert] = "#{I18n.t('failed_to_update_domain')} #{@domain.errors.full_messages.join(', ')}" render 'edit' From 5e331bef224d3864981e50cbb76ab94475d08902 Mon Sep 17 00:00:00 2001 From: dinsmol Date: Tue, 7 Dec 2021 09:38:42 +0300 Subject: [PATCH 2/4] Remove unused code --- app/controllers/admin/domains_controller.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/admin/domains_controller.rb b/app/controllers/admin/domains_controller.rb index 3125fe00e..c912d713a 100644 --- a/app/controllers/admin/domains_controller.rb +++ b/app/controllers/admin/domains_controller.rb @@ -42,7 +42,6 @@ module Admin def update rollback_history = @domain.json_statuses_history['admin_store_statuses_history'] - rollback_params = ActionController::Parameters.new(statuses: @domain.statuses).permit(:statuses) dp = ignore_empty_statuses @domain.is_admin = true @domain.admin_status_update dp[:statuses] From ab3b957d0747cd9a364c482970f5e02bbd55f65e Mon Sep 17 00:00:00 2001 From: dinsmol Date: Tue, 7 Dec 2021 09:54:50 +0300 Subject: [PATCH 3/4] Fix error --- app/controllers/admin/domains_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/admin/domains_controller.rb b/app/controllers/admin/domains_controller.rb index c912d713a..b5ef428dd 100644 --- a/app/controllers/admin/domains_controller.rb +++ b/app/controllers/admin/domains_controller.rb @@ -41,7 +41,7 @@ module Admin end def update - rollback_history = @domain.json_statuses_history['admin_store_statuses_history'] + rollback_history = @domain.json_statuses_history&.[]('admin_store_statuses_history') dp = ignore_empty_statuses @domain.is_admin = true @domain.admin_status_update dp[:statuses] From 7ae814fe5b1c92e3d62f4fc9eb59ef7ac8777077 Mon Sep 17 00:00:00 2001 From: dinsmol Date: Wed, 8 Dec 2021 00:17:39 +0300 Subject: [PATCH 4/4] Disable method length metrics --- app/controllers/admin/domains_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/controllers/admin/domains_controller.rb b/app/controllers/admin/domains_controller.rb index b5ef428dd..8946b006d 100644 --- a/app/controllers/admin/domains_controller.rb +++ b/app/controllers/admin/domains_controller.rb @@ -3,6 +3,7 @@ module Admin before_action :set_domain, only: %i[show edit update keep] authorize_resource + # rubocop:disable Metrics/MethodLength def index params[:q] ||= {} domains = if params[:statuses_contains] @@ -30,6 +31,7 @@ module Admin render_by_format('admin/domains/index', 'domains') end + # rubocop:enable Metrics/MethodLength def show # Validation is needed to warn users @@ -40,6 +42,7 @@ module Admin build_associations end + # rubocop:disable Metrics/MethodLength def update rollback_history = @domain.json_statuses_history&.[]('admin_store_statuses_history') dp = ignore_empty_statuses @@ -57,6 +60,7 @@ module Admin render 'edit' end end + # rubocop:enable Metrics/MethodLength def versions @domain = Domain.where(id: params[:domain_id]).includes({ versions: :item }).first