From 6302212a6d5e9b76f8dd5ef6cc5a28642cc07f43 Mon Sep 17 00:00:00 2001 From: Kadu Ribeiro Date: Fri, 13 Dec 2019 15:33:34 +0100 Subject: [PATCH] Display a deprecated message when Service uses plugin deployment (#1391) * 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. * minimal height form * Display a deprecated message when Service uses plugin deployment --- app/models/service.rb | 5 +++++ app/views/api/services/settings_apiap.html.slim | 1 + app/views/layouts/api/_service.html.slim | 3 +++ .../service/_deprecated_plugin_warning.html.slim | 4 ++++ test/unit/helpers/services_helper_test.rb | 3 --- test/unit/service_test.rb | 10 ++++++++++ 6 files changed, 23 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..e50d24e047 100644 --- a/app/models/service.rb +++ b/app/models/service.rb @@ -521,6 +521,11 @@ def can_use_backends? proxy.apicast_configuration_driven && !proxy.service_mesh_integration? end + # TODO: Remove this when no one use plugins + def plugin_deployment? + DeploymentOption.plugins.include?(deployment_option) + 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..69c89b8944 100644 --- a/app/views/layouts/api/_service.html.slim +++ b/app/views/layouts/api/_service.html.slim @@ -2,4 +2,7 @@ h1 = yield :sublayout_title +/ TODO: Remove this when no one use plugins += 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..025b471ef2 --- /dev/null +++ b/app/views/shared/service/_deprecated_plugin_warning.html.slim @@ -0,0 +1,4 @@ +- if @service&.plugin_deployment? + .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/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..57011bddbb 100644 --- a/test/unit/service_test.rb +++ b/test/unit/service_test.rb @@ -318,6 +318,16 @@ 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 + def test_default_service_plan service = FactoryBot.build(:simple_service) service.account.settings.service_plans_ui_visible = true