From df10818fe0b824fe279eec18781d01f42353e9f6 Mon Sep 17 00:00:00 2001 From: Carlos Ribeiro Date: Thu, 31 Oct 2019 12:53:30 -0300 Subject: [PATCH 1/4] Display a deprecated message when Service uses plugin deployment THREESCALE-2395 Our plugin deployment option is deprecated. To avoid needing some data migration in database, this commit sets the deployment option as hosted if the current option is set to plugins and also displays a message to the user to update their configuration. --- app/models/service.rb | 12 ++++++++++++ app/views/api/services/settings_apiap.html.slim | 1 + app/views/layouts/api/_service.html.slim | 2 ++ .../service/_deprecated_plugin_warning.html.slim | 9 +++++++++ test/unit/helpers/services_helper_test.rb | 3 --- test/unit/service_test.rb | 16 ++++++++++++++++ 6 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 app/views/shared/service/_deprecated_plugin_warning.html.slim diff --git a/app/models/service.rb b/app/models/service.rb index c584e80035..66f2051f1d 100644 --- a/app/models/service.rb +++ b/app/models/service.rb @@ -521,6 +521,18 @@ def can_use_backends? proxy.apicast_configuration_driven && !proxy.service_mesh_integration? end + # TODO: Remove this when no one use plugins + def plugin_deployment? + deployment = self[:deployment_option] + DeploymentOption.plugins.include?(deployment) + end + + # TODO: Remove this when no one use plugins + def deployment_option + return 'hosted' if plugin_deployment? + super + end + private def archive_as_deleted diff --git a/app/views/api/services/settings_apiap.html.slim b/app/views/api/services/settings_apiap.html.slim index 045a9b187e..3de965b72c 100644 --- a/app/views/api/services/settings_apiap.html.slim +++ b/app/views/api/services/settings_apiap.html.slim @@ -1,4 +1,5 @@ - content_for :sublayout_title, 'Settings' + = semantic_form_for @service, :url => admin_service_path(@service) do |form| = render :partial => 'api/services/forms/integration_settings_apiap', :locals => {:form => form} = form.buttons do diff --git a/app/views/layouts/api/_service.html.slim b/app/views/layouts/api/_service.html.slim index dfca04f107..06dd583c9d 100644 --- a/app/views/layouts/api/_service.html.slim +++ b/app/views/layouts/api/_service.html.slim @@ -2,4 +2,6 @@ h1 = yield :sublayout_title += render 'shared/service/deprecated_plugin_warning' + = yield diff --git a/app/views/shared/service/_deprecated_plugin_warning.html.slim b/app/views/shared/service/_deprecated_plugin_warning.html.slim new file mode 100644 index 0000000000..75c929c246 --- /dev/null +++ b/app/views/shared/service/_deprecated_plugin_warning.html.slim @@ -0,0 +1,9 @@ +- if @service&.plugin_deployment? + = semantic_form_for @service, :url => admin_service_path(@service) do |form| + .deprecated_plugin_message + p.InfoBox--notice.InfoBox + 'Your product currently uses plugin as deployment option. We no longer support plugins. Please update your settings. + = form.input :deployment_option, + as: :hidden + = form.buttons do + = form.commit_button 'Ok' diff --git a/test/unit/helpers/services_helper_test.rb b/test/unit/helpers/services_helper_test.rb index 05cb3a3937..afbccec0ad 100644 --- a/test/unit/helpers/services_helper_test.rb +++ b/test/unit/helpers/services_helper_test.rb @@ -7,8 +7,5 @@ def test_show_mappings? @service.deployment_option = 'hosted' assert show_mappings? - - @service.deployment_option = 'plugin_java' - refute show_mappings? end end diff --git a/test/unit/service_test.rb b/test/unit/service_test.rb index 5bbfe783a8..93e8555951 100644 --- a/test/unit/service_test.rb +++ b/test/unit/service_test.rb @@ -318,6 +318,22 @@ def test_update_account_default_service assert_raise(ActiveRecord::RecordNotFound) { service.reload } end + test '#plugin_deployment? returns true when using a plugin as deployment option' do + service = FactoryBot.build(:service, deployment_option: 'plugin_ruby') + + assert service.plugin_deployment? + + service = FactoryBot.build(:service, deployment_option: 'hosted') + + refute service.plugin_deployment? + end + + test '#deployment_option should default to hosted if using plugin as deployment option' do + service = FactoryBot.build(:service, deployment_option: 'plugin_ruby') + + assert_equal 'hosted', service.deployment_option + end + def test_default_service_plan service = FactoryBot.build(:simple_service) service.account.settings.service_plans_ui_visible = true From aed69cf24b96490a325a25e7d82c7144eb7161dc Mon Sep 17 00:00:00 2001 From: Thomas Maas Date: Mon, 4 Nov 2019 21:14:43 +0100 Subject: [PATCH 2/4] minimal height form --- .../service/_deprecated_plugin_warning.html.slim | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/views/shared/service/_deprecated_plugin_warning.html.slim b/app/views/shared/service/_deprecated_plugin_warning.html.slim index 75c929c246..7c46decc11 100644 --- a/app/views/shared/service/_deprecated_plugin_warning.html.slim +++ b/app/views/shared/service/_deprecated_plugin_warning.html.slim @@ -1,9 +1,7 @@ - if @service&.plugin_deployment? - = semantic_form_for @service, :url => admin_service_path(@service) do |form| + = form_for @service, :url => admin_service_path(@service) do |form| .deprecated_plugin_message p.InfoBox--notice.InfoBox - 'Your product currently uses plugin as deployment option. We no longer support plugins. Please update your settings. - = form.input :deployment_option, - as: :hidden - = form.buttons do - = form.commit_button 'Ok' + i This Product currently uses a plugin as the deployment option. Your integration will keep on working but we no longer support plugins. + = form.hidden_field :deployment_option + = form.submit 'Ok', class: 'button next outline-button-thin outline-button-thin--positive' From ecaeb8af560ef983b620e90168c2b750ebcd80d5 Mon Sep 17 00:00:00 2001 From: Carlos Ribeiro Date: Thu, 31 Oct 2019 12:53:30 -0300 Subject: [PATCH 3/4] Display a deprecated message when Service uses plugin deployment THREESCALE-2395 Our plugin deployment option is deprecated. To avoid needing some data migration in database, this commit sets the deployment option as hosted if the current option is set to plugins and also displays a message to the user to update their configuration. --- app/views/layouts/api/_service.html.slim | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/layouts/api/_service.html.slim b/app/views/layouts/api/_service.html.slim index 06dd583c9d..69c89b8944 100644 --- a/app/views/layouts/api/_service.html.slim +++ b/app/views/layouts/api/_service.html.slim @@ -2,6 +2,7 @@ h1 = yield :sublayout_title +/ TODO: Remove this when no one use plugins = render 'shared/service/deprecated_plugin_warning' = yield From 9f6d191240d76f645d2e0b07121043d27d0f73cc Mon Sep 17 00:00:00 2001 From: Carlos Ribeiro Date: Wed, 4 Dec 2019 17:27:21 -0300 Subject: [PATCH 4/4] Only display the message instead of changing the deployment_option --- app/models/service.rb | 9 +-------- .../shared/service/_deprecated_plugin_warning.html.slim | 9 +++------ test/unit/service_test.rb | 6 ------ 3 files changed, 4 insertions(+), 20 deletions(-) diff --git a/app/models/service.rb b/app/models/service.rb index 66f2051f1d..e50d24e047 100644 --- a/app/models/service.rb +++ b/app/models/service.rb @@ -523,14 +523,7 @@ def can_use_backends? # TODO: Remove this when no one use plugins def plugin_deployment? - deployment = self[:deployment_option] - DeploymentOption.plugins.include?(deployment) - end - - # TODO: Remove this when no one use plugins - def deployment_option - return 'hosted' if plugin_deployment? - super + DeploymentOption.plugins.include?(deployment_option) end private diff --git a/app/views/shared/service/_deprecated_plugin_warning.html.slim b/app/views/shared/service/_deprecated_plugin_warning.html.slim index 7c46decc11..025b471ef2 100644 --- a/app/views/shared/service/_deprecated_plugin_warning.html.slim +++ b/app/views/shared/service/_deprecated_plugin_warning.html.slim @@ -1,7 +1,4 @@ - if @service&.plugin_deployment? - = form_for @service, :url => admin_service_path(@service) do |form| - .deprecated_plugin_message - p.InfoBox--notice.InfoBox - i This Product currently uses a plugin as the deployment option. Your integration will keep on working but we no longer support plugins. - = form.hidden_field :deployment_option - = form.submit 'Ok', class: 'button next outline-button-thin outline-button-thin--positive' + .deprecated_plugin_message + p.InfoBox--notice.InfoBox + i This Product currently uses a plugin as the deployment option. Your integration will keep on working but we no longer support plugins. diff --git a/test/unit/service_test.rb b/test/unit/service_test.rb index 93e8555951..57011bddbb 100644 --- a/test/unit/service_test.rb +++ b/test/unit/service_test.rb @@ -328,12 +328,6 @@ def test_update_account_default_service refute service.plugin_deployment? end - test '#deployment_option should default to hosted if using plugin as deployment option' do - service = FactoryBot.build(:service, deployment_option: 'plugin_ruby') - - assert_equal 'hosted', service.deployment_option - end - def test_default_service_plan service = FactoryBot.build(:simple_service) service.account.settings.service_plans_ui_visible = true