From 01ca75e4393a6f172b2b58a3e5fa9957b0691b2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Hal=C3=A1sz?= Date: Tue, 30 Apr 2019 14:46:17 +0200 Subject: [PATCH] Include the regions if they're supported with OPTIONS /api/providers --- app/controllers/api/providers_controller.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/providers_controller.rb b/app/controllers/api/providers_controller.rb index a9f58a32fe..6d104a6e27 100644 --- a/app/controllers/api/providers_controller.rb +++ b/app/controllers/api/providers_controller.rb @@ -89,11 +89,16 @@ def options end supported_providers = ExtManagementSystem.supported_types_for_create.map do |klass| + if klass.supports_regions? + regions = klass.parent::Regions.all.sort_by { |r| r[:description] }.map { |r| r.slice(:name, :description) } + end + { - :title => klass.description, - :type => klass.to_s, - :kind => klass.to_s.demodulize.sub(/Manager$/, '').underscore - } + :title => klass.description, + :type => klass.to_s, + :kind => klass.to_s.demodulize.sub(/Manager$/, '').underscore, + :regions => regions + }.compact end render_options(:providers, "provider_settings" => providers_options, "supported_providers" => supported_providers)