Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display a deprecated message when Service uses plugin deployment #1391

Merged
merged 4 commits into from
Dec 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/models/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions app/views/api/services/settings_apiap.html.slim
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions app/views/layouts/api/_service.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
h1
= yield :sublayout_title

/ TODO: Remove this when no one use plugins
= render 'shared/service/deprecated_plugin_warning'

= yield
4 changes: 4 additions & 0 deletions app/views/shared/service/_deprecated_plugin_warning.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- if @service&.plugin_deployment?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not get why the nil check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were some controllers Api::MetricsController that used this layout but didn't loaded the service in the variable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This smells then :)

.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.
3 changes: 0 additions & 3 deletions test/unit/helpers/services_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions test/unit/service_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down