killbill-kpm-ui 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aab4bda0f66ef5ab1e2b09e8cbb807078ca61397
4
- data.tar.gz: deb4fe2e09be47ad243911dad3263471e10a6ff9
3
+ metadata.gz: 2d36d5716f6a5803657904f97c6f2874f266af1e
4
+ data.tar.gz: 5d0eefbbfe86ed48efd6eeec07575a47de3ddad7
5
5
  SHA512:
6
- metadata.gz: 776f46c5e5dbdb8a28f454e4c44777212902f5045db6784f9cc501163096383611b22e2779deb0ec9b8d887869a3f197211fc7bfd5fe745a2b8ce2ff118b74d2
7
- data.tar.gz: 5111ac8e69101091610ce5fb2dd9e3b2903dd04c7b1f03354d227501d762740a36510579c0fe4e7d9eaf7275ae356a9cc72e12910de38546d7fb9cdca347f265
6
+ metadata.gz: 8164906e17512ba0fb89b4447ae929da383f276a361d1922854853871707f6332cdfd6cb4f7344d7dc67c96238efe2bec947ce961df9a43d3baec09121940b23
7
+ data.tar.gz: fbf349a46acf0eccf9386830bdc45f36df1058953875a4e271aaf4a2b27b4bfd329627d107c4b69f8d4f434fa6ccad80133aa9b137188e59d3dac04d2e9cf877
@@ -4,16 +4,45 @@ module KPM
4
4
  class PluginsController < EngineController
5
5
 
6
6
  def index
7
- begin
8
- plugins = ::Killbill::KPM::KPMClient.get_available_plugins(true, options_for_klient)
9
- rescue => e
10
- # No connectivity, GitHub down, ...
11
- Rails.logger.warn("Unable to get latest plugins, trying built-in directory: #{e.inspect}")
12
- plugins = ::Killbill::KPM::KPMClient.get_available_plugins(false, options_for_klient)
7
+ nodes_by_kb_version, @kb_version = killbill_version
8
+ @warning_message = ''
9
+ plugins = []
10
+ if nodes_by_kb_version.size > 1
11
+ @warning_message = different_versions_warning_message(nodes_by_kb_version)
12
+ else
13
+ begin
14
+ plugins = ::Killbill::KPM::KPMClient.get_available_plugins(true, options_for_klient)
15
+ rescue => e
16
+ # No connectivity, GitHub down, ...
17
+ Rails.logger.warn("Unable to get latest plugins, trying built-in directory: #{e.inspect}")
18
+ plugins = ::Killbill::KPM::KPMClient.get_available_plugins(false, options_for_klient)
19
+ end
20
+ plugins.select! { |plugin_key, info| info['versions'].keys.include?(@kb_version) }
13
21
  end
14
-
15
22
  @plugins = Hash[plugins.sort]
16
23
  end
17
24
 
25
+ private
26
+
27
+ def different_versions_warning_message(nodes_by_kb_version)
28
+ message = '<b>Warning!</b> Unable to find plugins to install, different versions of Kill Bill were found:<ul>'
29
+ nodes_by_kb_version.each do |version, node_name|
30
+ message = "#{message} <li><b>#{version}:</b> #{node_name}</li>"
31
+ end
32
+ "#{message}</ul>"
33
+ end
34
+
35
+ def killbill_version
36
+ nodes_info = ::KillBillClient::Model::NodesInfo.nodes_info(options_for_klient)
37
+ return nil if nodes_info.blank?
38
+
39
+ first_node_version = nodes_info.first.kb_version
40
+ nodes_by_kb_version = {}
41
+ nodes_info.each do |node|
42
+ nodes_by_kb_version[node.kb_version] = "#{(nodes_by_kb_version[node.kb_version] || '')} #{node.node_name}"
43
+ end
44
+ [nodes_by_kb_version, first_node_version.scan(/(\d+\.\d+)(\.\d)?/).flatten[0]]
45
+ end
46
+
18
47
  end
19
48
  end
@@ -1,41 +1,45 @@
1
- <table id="plugins-table" class="table table-condensed table-striped mobile-data">
2
- <thead>
3
- <tr>
4
- <th>Name</th>
5
- <th>Type</th>
6
- <th>Versions</th>
7
- <th>Required configuration</th>
8
- <th></th>
9
- </tr>
10
- </thead>
11
- <tbody>
12
- <% plugins.each do |name, details| %>
13
- <tr>
14
- <td><%= name %></td>
15
- <td><%= details['type'] %></td>
16
- <td>
17
- <% unless details['versions'].nil? %>
18
- <ul>
19
- <% details['versions'].each do |kb_version, plugin_version| %>
20
- <li><%= kb_version %>: <%= plugin_version %></li>
1
+ <% if @warning_message.blank? %>
2
+ <table id="plugins-table" class="table table-condensed table-striped mobile-data">
3
+ <thead>
4
+ <tr>
5
+ <th>Name</th>
6
+ <th>Type</th>
7
+ <th>Version</th>
8
+ <th>Required configuration</th>
9
+ <th></th>
10
+ </tr>
11
+ </thead>
12
+ <tbody>
13
+ <% plugins.each do |name, details| %>
14
+ <tr>
15
+ <td><%= name %></td>
16
+ <td><%= details['type'] %></td>
17
+ <td>
18
+ <% unless details['versions'].nil? %>
19
+ <% details['versions'].each do |kb_version, plugin_version| %>
20
+ <% if kb_version.eql?(@kb_version) %>
21
+ &ensp;<%= plugin_version %>
21
22
  <% end %>
22
- </ul>
23
- <% end %>
24
- </td>
25
- <td>
26
- <% unless (details['require'] || []).empty? %>
27
- <ul>
28
- <% details['require'].each do |property| %>
29
- <li><%= property %></li>
30
- <% end %>
31
- </ul>
32
- <% end %>
33
- </td>
34
- <td><%= link_to '<i class="fa fa-cloud-download"></i>'.html_safe, plugin_install_path(:plugin_key => name), :method => :post, :title => 'Install' %></td>
35
- </tr>
36
- <% end %>
37
- </tbody>
38
- </table>
23
+ <% end %>
24
+ <% end %>
25
+ </td>
26
+ <td>
27
+ <% unless (details['require'] || []).empty? %>
28
+ <ul>
29
+ <% details['require'].each do |property| %>
30
+ <li><%= property %></li>
31
+ <% end %>
32
+ </ul>
33
+ <% end %>
34
+ </td>
35
+ <td><%= link_to '<i class="fa fa-cloud-download"></i>'.html_safe, plugin_install_path(:plugin_key => name), :method => :post, :title => 'Install' %></td>
36
+ </tr>
37
+ <% end %>
38
+ </tbody>
39
+ </table>
40
+ <% else %>
41
+ <div class="alert alert-warning" role="alert"><%= @warning_message.html_safe %></div>
42
+ <% end %>
39
43
 
40
44
  <%= javascript_tag do %>
41
45
  $(document).ready(function() {
data/lib/kpm/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module KPM
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: killbill-kpm-ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kill Bill core team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-30 00:00:00.000000000 Z
11
+ date: 2018-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails