foreman_puppet 0.0.1 → 1.0.0.rc.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +61 -7
  3. data/app/controllers/concerns/foreman_puppet/environments_import.rb +1 -1
  4. data/app/controllers/concerns/foreman_puppet/extensions/api_base_controller.rb +28 -0
  5. data/app/controllers/concerns/foreman_puppet/extensions/api_template_combinations_controller.rb +1 -1
  6. data/app/controllers/concerns/foreman_puppet/extensions/hostgroups_controller_extensions.rb +1 -1
  7. data/app/controllers/concerns/foreman_puppet/extensions/hosts_controller_extensions.rb +1 -1
  8. data/app/controllers/concerns/foreman_puppet/extensions/parameters_host.rb +3 -10
  9. data/app/controllers/concerns/foreman_puppet/parameters/puppetclass_lookup_key.rb +2 -2
  10. data/app/controllers/foreman_puppet/api/v2/config_groups_controller.rb +9 -1
  11. data/app/controllers/foreman_puppet/api/v2/environments_controller.rb +5 -2
  12. data/app/controllers/foreman_puppet/api/v2/host_classes_controller.rb +9 -1
  13. data/app/controllers/foreman_puppet/api/v2/hostgroup_classes_controller.rb +9 -1
  14. data/app/controllers/foreman_puppet/api/v2/override_values_controller.rb +1 -2
  15. data/app/controllers/foreman_puppet/api/v2/{base_controller.rb → puppet_base_controller.rb} +2 -3
  16. data/app/controllers/foreman_puppet/api/v2/{lookups_common_controller.rb → puppet_lookups_common_controller.rb} +6 -2
  17. data/app/controllers/foreman_puppet/api/v2/puppetclasses_controller.rb +5 -1
  18. data/app/controllers/foreman_puppet/api/v2/smart_class_parameters_controller.rb +1 -2
  19. data/app/controllers/foreman_puppet/config_groups_controller.rb +4 -0
  20. data/app/controllers/foreman_puppet/puppet_smart_proxies_controller.rb +4 -0
  21. data/app/controllers/foreman_puppet/puppetclass_lookup_keys_controller.rb +2 -2
  22. data/app/controllers/foreman_puppet/puppetclasses_controller.rb +12 -4
  23. data/app/graphgl/concerns/foreman_puppet/mutations/hosts/create_extensions.rb +29 -0
  24. data/app/graphgl/concerns/foreman_puppet/types/host_extensions.rb +13 -0
  25. data/app/graphgl/concerns/foreman_puppet/types/hostgroup_extensions.rb +13 -0
  26. data/app/graphgl/concerns/foreman_puppet/types/interface_attributes_input_extensions.rb +9 -0
  27. data/app/graphgl/concerns/foreman_puppet/types/location_extensions.rb +14 -0
  28. data/app/graphgl/concerns/foreman_puppet/types/organization_extensions.rb +14 -0
  29. data/app/graphgl/foreman_puppet/types/environment.rb +20 -0
  30. data/app/graphgl/foreman_puppet/types/puppetclass.rb +20 -0
  31. data/app/helpers/foreman_puppet/environments_helper.rb +1 -1
  32. data/app/helpers/foreman_puppet/hosts_helper.rb +15 -0
  33. data/app/helpers/foreman_puppet/puppetclass_lookup_keys_helper.rb +2 -2
  34. data/app/helpers/foreman_puppet/puppetclasses_and_environments_helper.rb +1 -1
  35. data/app/helpers/foreman_puppet/puppetclasses_helper.rb +2 -2
  36. data/app/models/concerns/foreman_puppet/extensions/host.rb +24 -9
  37. data/app/models/concerns/foreman_puppet/extensions/host_common.rb +17 -0
  38. data/app/models/concerns/foreman_puppet/extensions/hostgroup.rb +13 -7
  39. data/app/models/concerns/foreman_puppet/extensions/operatingsystem.rb +1 -1
  40. data/app/models/concerns/foreman_puppet/extensions/provisioning_template.rb +19 -13
  41. data/app/models/concerns/foreman_puppet/extensions/report.rb +18 -0
  42. data/app/models/concerns/foreman_puppet/extensions/taxonomy.rb +1 -1
  43. data/app/models/concerns/foreman_puppet/extensions/template_combination.rb +1 -1
  44. data/app/models/concerns/foreman_puppet/extensions/user.rb +19 -12
  45. data/app/models/foreman_puppet/environment.rb +2 -0
  46. data/app/models/foreman_puppet/environment_class.rb +1 -1
  47. data/app/models/foreman_puppet/host_class.rb +1 -1
  48. data/app/models/foreman_puppet/host_puppet_facet.rb +5 -4
  49. data/app/models/foreman_puppet/hostgroup_puppet_facet.rb +1 -1
  50. data/app/models/{concerns/foreman_puppet/host_common.rb → foreman_puppet/puppet_facet_common.rb} +1 -1
  51. data/app/models/foreman_puppet/puppetclass.rb +15 -1
  52. data/app/{views/api/v2/template_combinations/base.json.erb → prepend_views/api/v2/template_combinations/base.json.rabl} +0 -0
  53. data/app/services/foreman_puppet/host_info_providers/config_groups_info.rb +2 -0
  54. data/app/services/foreman_puppet/puppet_class_importer.rb +17 -18
  55. data/app/views/foreman_puppet/common/_puppetclasses_or_envs_changed.html.erb +62 -0
  56. data/app/views/foreman_puppet/config_groups/index.html.erb +2 -2
  57. data/app/views/foreman_puppet/config_groups/welcome.html.erb +12 -11
  58. data/app/views/foreman_puppet/environments/index.html.erb +1 -1
  59. data/app/views/foreman_puppet/environments/welcome.html.erb +3 -15
  60. data/app/views/foreman_puppet/puppetclass_lookup_keys/welcome.html.erb +10 -8
  61. data/app/views/foreman_puppet/puppetclasses/_classes.html.erb +1 -1
  62. data/app/views/foreman_puppet/puppetclasses/_selected_classes.html.erb +1 -1
  63. data/app/views/foreman_puppet/puppetclasses/index.html.erb +1 -1
  64. data/app/views/hosts/_form_puppet_enc_tab.html.erb +1 -1
  65. data/app/views/hosts/select_multiple_environment.html.erb +1 -1
  66. data/app/views/smart_proxies/plugins/_puppet_ca.html.erb +44 -0
  67. data/config/initializers/api_reroute.rb +13 -0
  68. data/db/migrate/20200803113903_migrate_host_type_in_host_config_groups.foreman_puppet.rb +37 -12
  69. data/db/migrate/20201125113903_migrate_puppetclasses_to_facets.foreman_puppet.rb +13 -1
  70. data/lib/foreman_puppet.rb +3 -3
  71. data/lib/foreman_puppet/engine.rb +68 -19
  72. data/lib/foreman_puppet/register.rb +7 -2
  73. data/lib/foreman_puppet/version.rb +1 -1
  74. data/locale/Makefile +1 -1
  75. data/locale/action_names.rb +4 -4
  76. data/locale/en/LC_MESSAGES/foreman_puppet.mo +0 -0
  77. data/locale/en/foreman_puppet.edit.po +19 -3
  78. data/locale/en/foreman_puppet.po +18 -6
  79. data/locale/en/foreman_puppet.pox +0 -0
  80. data/locale/foreman_puppet.pot +19 -3
  81. data/locale/messages.mo +0 -0
  82. data/package.json +45 -0
  83. data/test/controllers/foreman_puppet/api/v2/config_groups_controller_test.rb +7 -3
  84. data/test/controllers/foreman_puppet/api/v2/environments_controller_test.rb +18 -16
  85. data/test/controllers/foreman_puppet/api/v2/hosts_controller_test.rb +3 -2
  86. data/test/controllers/foreman_puppet/api/v2/lookups_common_controller_test.rb +1 -1
  87. data/test/controllers/foreman_puppet/api/v2/provisioning_templates_controller_test.rb +32 -0
  88. data/test/controllers/foreman_puppet/api/v2/puppetclasses_controller_test.rb +3 -0
  89. data/test/controllers/foreman_puppet/api/v2/smart_class_parameters_controller_test.rb +7 -1
  90. data/test/controllers/foreman_puppet/api/v2/template_combinations_controller_test.rb +2 -2
  91. data/test/controllers/foreman_puppet/config_groups_controller_test.rb +7 -3
  92. data/test/controllers/foreman_puppet/environments_controller_test.rb +2 -2
  93. data/test/controllers/foreman_puppet/puppetclass_lookup_keys_controller_test.rb +2 -2
  94. data/test/controllers/foreman_puppet/puppetclasses_controller_test.rb +5 -6
  95. data/test/factories/foreman_puppet_factories.rb +3 -0
  96. data/test/factories/host_puppet_enhancements.rb +6 -6
  97. data/test/graphql/mutations/hosts/create_mutation_test.rb +87 -0
  98. data/test/graphql/queries/environment_query_test.rb +54 -0
  99. data/test/graphql/queries/environments_query_test.rb +43 -0
  100. data/test/{qraphql → graphql}/queries/host_puppet_query_test.rb +3 -8
  101. data/test/{qraphql → graphql}/queries/hostgroup_puppet_query_test.rb +1 -6
  102. data/test/graphql/queries/location_query_test.rb +52 -0
  103. data/test/graphql/queries/organization_query_test.rb +52 -0
  104. data/test/graphql/queries/puppetclass_query_test.rb +68 -0
  105. data/test/graphql/queries/puppetclasses_query_test.rb +43 -0
  106. data/test/integration/foreman_puppet/environment_js_test.rb +4 -1
  107. data/test/integration/foreman_puppet/host_js_test.rb +1 -1
  108. data/test/integration/foreman_puppet/puppetclass_js_test.rb +4 -0
  109. data/test/models/foreman_puppet/config_group_class_test.rb +3 -1
  110. data/test/models/foreman_puppet/environment_test.rb +2 -0
  111. data/test/models/foreman_puppet/host_puppet_facet_test.rb +34 -1
  112. data/test/models/foreman_puppet/host_test.rb +4 -3
  113. data/test/models/foreman_puppet/hostgroup_puppet_facet_test.rb +2 -3
  114. data/test/models/foreman_puppet/provisioning_template_test.rb +14 -7
  115. data/test/models/foreman_puppet/report_test.rb +21 -0
  116. data/test/models/foreman_puppet/smart_proxy_test.rb +1 -1
  117. data/test/models/foreman_puppet/user_test.rb +37 -0
  118. data/test/services/foreman_puppet/host_info_providers/config_groups_info_test.rb +35 -0
  119. data/test/services/foreman_puppet/host_info_providers/puppet_info_test.rb +159 -197
  120. data/test/unit/foreman_puppet/puppet_class_importer_test.rb +16 -2
  121. data/webpack/index.js +3 -4
  122. data/webpack/src/Components/Environments/Welcome.js +37 -0
  123. metadata +54 -14
@@ -5,7 +5,7 @@ module ForemanPuppet
5
5
 
6
6
  included do
7
7
  if ForemanPuppet.extracted_from_core?
8
- belongs_to :environment
8
+ belongs_to :environment, class_name: 'ForemanPuppet::Environment'
9
9
 
10
10
  validates :environment_id, uniqueness: { scope: %i[hostgroup_id provisioning_template_id] }
11
11
 
@@ -3,19 +3,26 @@ module ForemanPuppet
3
3
  module User
4
4
  extend ActiveSupport::Concern
5
5
 
6
- def visible_environments
7
- authorized_scope = Environment.unscoped.authorized(:view_environments)
8
- authorized_scope = authorized_scope
9
- .joins(:taxable_taxonomies)
10
- .where('taxable_taxonomies.taxonomy_id' => taxonomy_ids[:organizations] + taxonomy_ids[:locations])
11
- result = authorized_scope.distinct.pluck(:name)
12
- if User.current.admin?
13
- # Admin users can also see Environments that do not have any organization or location, even when
14
- # organizations and locations are enabled.
15
- untaxed_environments = Environment.unscoped.where.not(id: TaxableTaxonomy.where(taxable_type: 'ForemanPuppet::Environment').distinct.select(:taxable_id)).pluck(:name)
16
- result += untaxed_environments
6
+ included do
7
+ prepend PatchedMethods
8
+ end
9
+
10
+ module PatchedMethods
11
+ def visible_environments
12
+ authorized_scope = ForemanPuppet::Environment.unscoped.authorized(:view_environments)
13
+ authorized_scope = authorized_scope
14
+ .joins(:taxable_taxonomies)
15
+ .where('taxable_taxonomies.taxonomy_id' => taxonomy_ids[:organizations] + taxonomy_ids[:locations])
16
+ result = authorized_scope.distinct.pluck(:name)
17
+ if ::User.current.admin?
18
+ # Admin users can also see Environments that do not have any organization or location, even when
19
+ # organizations and locations are enabled.
20
+ untaxed_env_ids = TaxableTaxonomy.where(taxable_type: 'ForemanPuppet::Environment').distinct.select(:taxable_id)
21
+ untaxed_environments = ForemanPuppet::Environment.unscoped.where.not(id: untaxed_env_ids).pluck(:name)
22
+ result += untaxed_environments
23
+ end
24
+ result
17
25
  end
18
- result
19
26
  end
20
27
  end
21
28
  end
@@ -2,6 +2,8 @@ module ForemanPuppet
2
2
  class Environment < ApplicationRecord
3
3
  self.table_name = 'environments'
4
4
 
5
+ graphql_type 'ForemanPuppet::Types::Environment'
6
+
5
7
  audited
6
8
  extend FriendlyId
7
9
  friendly_id :name, reserved_words: []
@@ -6,7 +6,7 @@ module ForemanPuppet
6
6
  belongs_to :puppetclass, inverse_of: :environment_classes
7
7
  belongs_to :puppetclass_lookup_key, inverse_of: :environment_classes, class_name: 'ForemanPuppet::PuppetclassLookupKey'
8
8
  validates :puppetclass_lookup_key_id, uniqueness: { scope: %i[environment_id puppetclass_id] }
9
- validates :puppetclass_id, :environment_id, presence: true
9
+ validates :puppetclass, :environment, presence: true
10
10
  after_destroy :delete_orphaned_lookup_keys
11
11
 
12
12
  scope :parameters_for_class, lambda { |puppetclasses_ids, environment_id|
@@ -6,7 +6,7 @@ module ForemanPuppet
6
6
  include Authorizable
7
7
 
8
8
  validates_lengths_from_database
9
- belongs_to :puppetclass
9
+ belongs_to :puppetclass, class_name: 'ForemanPuppet::Puppetclass'
10
10
  belongs_to :host_puppet_facet
11
11
  has_one :host, through: :host_puppet_facet
12
12
 
@@ -4,9 +4,9 @@ module ForemanPuppet
4
4
  audited associated_with: :host
5
5
 
6
6
  include Facets::Base
7
- include ForemanPuppet::HostCommon
7
+ include ForemanPuppet::PuppetFacetCommon
8
8
 
9
- has_many :host_classes, dependent: :destroy
9
+ has_many :host_classes, dependent: :destroy, class_name: 'ForemanPuppet::HostClass'
10
10
  has_many :puppetclasses, through: :host_classes
11
11
 
12
12
  validates :environment_id, presence: true, unless: ->(facet) { facet.host.puppet_proxy_id.blank? }
@@ -18,10 +18,11 @@ module ForemanPuppet
18
18
  type ||= 'puppet'
19
19
  return unless type == 'puppet'
20
20
 
21
+ facet = host.puppet || host.build_puppet
21
22
  if Setting[:update_environment_from_facts]
22
- host.set_non_empty_values parser, [:environment]
23
+ facet.environment = parser.environment if parser.environment.present?
23
24
  elsif parser.environment.present?
24
- self.environment ||= parser.environment
25
+ facet.environment ||= parser.environment
25
26
  end
26
27
 
27
28
  # if proxy authentication is enabled and we have no puppet proxy set and the upload came from puppet,
@@ -61,7 +61,7 @@ module ForemanPuppet
61
61
  audited associated_with: :hostgroup
62
62
  self.table_name = 'hostgroup_puppet_facets'
63
63
 
64
- include ForemanPuppet::HostCommon
64
+ include ForemanPuppet::PuppetFacetCommon
65
65
  include Facets::HostgroupFacet
66
66
 
67
67
  has_many :hostgroup_classes, dependent: :destroy
@@ -1,7 +1,7 @@
1
1
  module ForemanPuppet
2
2
  # Common methods between host and hostgroup
3
3
  # mostly for template rendering consistency
4
- module HostCommon
4
+ module PuppetFacetCommon
5
5
  extend ActiveSupport::Concern
6
6
 
7
7
  included do
@@ -2,6 +2,8 @@ module ForemanPuppet
2
2
  class Puppetclass < ApplicationRecord
3
3
  self.table_name = 'puppetclasses'
4
4
 
5
+ graphql_type 'ForemanPuppet::Types::Puppetclass'
6
+
5
7
  audited
6
8
  include Authorizable
7
9
  include ScopedSearchExtensions
@@ -29,6 +31,7 @@ module ForemanPuppet
29
31
  has_many :config_groups, through: :config_group_classes
30
32
 
31
33
  has_many :class_params, -> { distinct }, through: :environment_classes, source: :puppetclass_lookup_key
34
+ accepts_nested_attributes_for :environment_classes
32
35
  accepts_nested_attributes_for :class_params, reject_if: ->(a) { a[:key].blank? }, allow_destroy: true
33
36
 
34
37
  validates :name, uniqueness: true, presence: true, no_whitespace: true
@@ -72,6 +75,17 @@ module ForemanPuppet
72
75
  hash
73
76
  end
74
77
 
78
+ # For Audits to be correctly taxed for Puppetclass creation
79
+ # Puppetclass gets saved before the environment class and thus taxonomy ids are empty
80
+ # We collect the ids from unsaved environment_classes for the Audits correct taxation
81
+ def location_ids
82
+ environment_classes.select(&:new_record?).flat_map { |ec| ec.environment.location_ids }.concat(super).uniq
83
+ end
84
+
85
+ def organization_ids
86
+ environment_classes.select(&:new_record?).flat_map { |ec| ec.environment.organization_ids }.concat(super).uniq
87
+ end
88
+
75
89
  # returns module name (excluding of the class name)
76
90
  # if class separator does not exists (the "::" chars), then returns the whole class name
77
91
  def module_name
@@ -106,7 +120,7 @@ module ForemanPuppet
106
120
  # We are going through two associations, so we are on our own to define modifiers
107
121
  def hostgroup_ids=(hg_ids)
108
122
  hg_ids = Array(hg_ids).reject(&:blank?)
109
- hg_to_facets_ids = Hash[HostgroupPuppetFacet.where(hostgroup_id: hg_ids).pluck(:hostgroup_id, :id)]
123
+ hg_to_facets_ids = HostgroupPuppetFacet.where(hostgroup_id: hg_ids).pluck(:hostgroup_id, :id).to_h
110
124
  missing_facet_ids = hg_ids.map(&:to_i) - hg_to_facets_ids.keys
111
125
  new_facet_ids = missing_facet_ids.map { |hg_id| HostgroupPuppetFacet.create(hostgroup_id: hg_id).id }
112
126
  self.hostgroup_puppet_facet_ids = hg_to_facets_ids.values + new_facet_ids
@@ -2,6 +2,8 @@ module ForemanPuppet
2
2
  module HostInfoProviders
3
3
  class ConfigGroupsInfo < HostInfo::Provider
4
4
  def host_info
5
+ return {} unless host.puppet
6
+
5
7
  config_groups = (host.puppet.config_groups + host.puppet.parent_config_groups).uniq.map(&:name)
6
8
  { 'parameters' => { 'foreman_config_groups' => config_groups } }
7
9
  end
@@ -162,7 +162,7 @@ module ForemanPuppet
162
162
  end
163
163
 
164
164
  def db_environments
165
- @db_environments ||= (Environment.pluck('environments.name') - ignored_environments)
165
+ @db_environments ||= (Environment.pluck(:name) - ignored_environments)
166
166
  end
167
167
 
168
168
  def actual_environments
@@ -248,15 +248,11 @@ module ForemanPuppet
248
248
  end
249
249
 
250
250
  def add_classes_to_foreman(env_name, klasses)
251
- env = find_or_create_env env_name
252
- # look for Puppet class in all scopes to make sure we do not try to create a new record
253
- # with a name that already exists and hit the uniqueness constraint on name
254
- new_classes = klasses.map { |k| find_or_create_puppetclass(name: k[0]) }
251
+ env = find_or_create_env env_name
255
252
 
256
- new_classes.each do |new_class|
257
- EnvironmentClass.find_or_create_by! puppetclass_id: new_class.id, environment_id: env.id
258
- class_params = klasses[new_class.to_s]
259
- add_new_parameter(env, new_class, class_params) if class_params.any?
253
+ klasses.each do |klass_name, klass_params|
254
+ puppetclass = find_or_create_puppetclass_for_env(klass_name, env)
255
+ add_new_parameter(env, puppetclass, klass_params) if klass_params.any?
260
256
  end
261
257
  end
262
258
 
@@ -302,7 +298,7 @@ module ForemanPuppet
302
298
  changed_params['new'].map do |param_name, value|
303
299
  param = find_or_create_puppet_class_param klass, param_name, value
304
300
  EnvironmentClass.find_or_create_by! puppetclass_id: klass.id, environment_id: env.id,
305
- puppetclass_lookup_key_id: param.id
301
+ puppetclass_lookup_key_id: param.id
306
302
  end
307
303
  end
308
304
 
@@ -317,10 +313,9 @@ module ForemanPuppet
317
313
  Host.where(environment_id: env).update_all(environment_id: nil)
318
314
  Hostgroup.where(environment_id: env).update_all(environment_id: nil)
319
315
  # rubocop:enable Rails/SkipsModelValidations
320
-
321
- # we can't guaranty that the env would be removed as it might have hosts attached to it.
322
- env.destroy if klasses.include? '_destroy_'
323
316
  end
317
+ # we can't guaranty that the env would be removed as it might have hosts attached to it.
318
+ env.destroy if klasses.include? '_destroy_'
324
319
  # remove all klasses that have no environment now
325
320
  classes.not_in_any_environment.destroy_all
326
321
  end
@@ -331,8 +326,8 @@ module ForemanPuppet
331
326
 
332
327
  def find_or_create_env(env)
333
328
  user_visible_environment(env) || Environment.create!(name: env,
334
- organizations: User.current.my_organizations,
335
- locations: User.current.my_locations)
329
+ organizations: User.current.my_organizations,
330
+ locations: User.current.my_locations)
336
331
  end
337
332
 
338
333
  def user_visible_environment(env)
@@ -343,11 +338,15 @@ module ForemanPuppet
343
338
  def find_or_create_puppet_class_param(klass, param_name, value)
344
339
  klass.class_params.where(key: param_name).first ||
345
340
  PuppetclassLookupKey.create!(key: param_name, default_value: value,
346
- key_type: Foreman::ImporterPuppetclass.suggest_key_type(value))
341
+ key_type: Foreman::ImporterPuppetclass.suggest_key_type(value))
347
342
  end
348
343
 
349
- def find_or_create_puppetclass(name:)
350
- puppetclass = Puppetclass.unscoped.find_or_create_by!(name: name)
344
+ def find_or_create_puppetclass_for_env(klass_name, env)
345
+ # look for Puppet class in all scopes to make sure we do not try to create a new record
346
+ # with a name that already exists and hit the uniqueness constraint on name
347
+ puppetclass = Puppetclass.find_or_initialize_by(name: klass_name)
348
+ puppetclass.environment_classes.find_or_initialize_by(environment_id: env.id)
349
+ puppetclass.save
351
350
  raise Foreman::Exception.new('Failed to create Puppetclass: %s', puppetclass.errors.full_messages.to_sentence) unless puppetclass.errors.empty?
352
351
  puppetclass
353
352
  end
@@ -0,0 +1,62 @@
1
+ <% title _("Changed environments") %>
2
+ <%= form_tag controller.send("obsolete_and_new_#{controller_name}_path") do %>
3
+ <h4><%= _("Select the changes you want to apply to Foreman") %></h4>
4
+ <h6>
5
+ <%= _("Toggle") %>:
6
+ <%= link_to_function(icon_text("check", _("New")),
7
+ "toggleCheckboxesBySelector('.env_select_boxes_new')",
8
+ :title => _("Check/Uncheck new")) %> |
9
+ <%= link_to_function(icon_text("check", _("Updated")),
10
+ "toggleCheckboxesBySelector('.env_select_boxes_updated')",
11
+ :title => _("Check/Uncheck updated")) %> |
12
+ <%= link_to_function(icon_text("check", _("Obsolete")),
13
+ "toggleCheckboxesBySelector('.env_select_boxes_obsolete')",
14
+ :title => _("Check/Uncheck obsolete")) %>
15
+ </h6>
16
+ <table class="<%= table_css_classes %>">
17
+ <thead>
18
+ <tr>
19
+ <th class="ca">
20
+ <%= link_to_function(icon_text("check"),
21
+ "toggleCheckboxesBySelector('.env_select_boxes')",
22
+ :title => _("Check/Uncheck all")) %>
23
+ </th>
24
+ <th><%= _("Environment") %></th>
25
+ <th><%= _("Operation") %></th>
26
+ <th><%= _("Puppet Modules") %></th>
27
+ </tr>
28
+ </thead>
29
+ <tbody>
30
+ <% for kind in ["new", "obsolete", "updated", "ignored"] %>
31
+ <% unless (envs = @changed[kind]).empty? %>
32
+ <% for env in envs.keys.sort %>
33
+ <tr>
34
+ <% unless kind == 'ignored' %>
35
+ <td>
36
+ <%= check_box_tag "changed[#{kind}][#{env}]", @changed[kind][env].to_json, false, :class => "env_select_boxes env_select_boxes_#{kind} env_select_boxes_env_#{env}" %>
37
+ </td>
38
+ <td>
39
+ <%= link_to_function("#{env}", "toggleCheckboxesBySelector('.env_select_boxes_env_#{env}')", :title => _("Check/Uncheck all %s changes") % env) %>
40
+ </td>
41
+ <% else %>
42
+ <td>&nbsp;</td>
43
+ <td><%= env %></td>
44
+ <% end %>
45
+ <td>
46
+ <%= {"new" => _("Add:"), "obsolete" => _("Remove:"), "updated" => _("Update:"), "ignored" => _("Ignored:")}[kind] %>
47
+ </td>
48
+ <td>
49
+ <% pcs = @changed[kind][env] %>
50
+ <%= class_update_text pcs, env %>
51
+ </td>
52
+ </tr>
53
+ <% end %>
54
+ <% end %>
55
+ <% end %>
56
+ </tbody>
57
+ </table>
58
+ <div>
59
+ <%= link_to _("Cancel"), controller.send("#{controller_name}_path"), :class => "btn btn-default" %>
60
+ <%= submit_tag _("Update"), :class => "btn btn-primary" %>
61
+ </div>
62
+ <% end %>
@@ -17,12 +17,12 @@
17
17
  <tbody>
18
18
  <% @config_groups.each do |config_group| %>
19
19
  <tr>
20
- <td class="ellipsis"><%= link_to_if_authorized config_group.name, hash_for_edit_config_group_path(config_group).merge(:auth_object => config_group, :authorizer => authorizer) %></td>
20
+ <td class="ellipsis"><%= link_to_if_authorized config_group.name, hash_for_edit_config_group_path(config_group).merge(engine: foreman_puppet, :auth_object => config_group, :authorizer => authorizer) %></td>
21
21
  <td><%= link_to config_group.puppetclasses.size, puppetclasses_path(:search => %Q{config_group = "#{config_group}"}) %></td>
22
22
  <td><%= link_to config_group.hosts_count, main_app.hosts_path(:search => %Q{config_group = "#{config_group}"}) %></td>
23
23
  <td><%= link_to config_group.hostgroups_count, main_app.hostgroups_path(:search => %Q{config_group = "#{config_group}"}) %></td>
24
24
  <td><%= action_buttons(
25
- display_delete_if_authorized(hash_for_config_group_path(config_group).merge(:auth_object => config_group, :authorizer => authorizer), :data => { :confirm => _('Delete %s?') % config_group.name }))%>
25
+ display_delete_if_authorized(hash_for_config_group_path(config_group).merge(engine: foreman_puppet, :auth_object => config_group, :authorizer => authorizer), :data => { :confirm => _('Delete %s?') % config_group.name }))%>
26
26
  </td>
27
27
  </tr>
28
28
  <% end %>
@@ -1,12 +1,13 @@
1
1
  <% title _("Config Groups") %>
2
- <div class="blank-slate-pf">
3
- <div class="blank-slate-pf-icon">
4
- <%= icon_text("object-group", "", kind: "fa") %>
5
- </div>
6
- <h1><%= _('Config Groups') %></h1>
7
- <p><%= _("A config group provides a one-step method of associating many Puppet classes to either a host or host group. Typically this would be used to add a particular application profile or stack in one step.") %></p>
8
- <p><%= link_to _('Learn more about this in the documentation.'), documentation_url("using-config-groups")%></p>
9
- <div class="blank-slate-pf-main-action">
10
- <%= new_link(_("Create Config Group"), { engine: foreman_puppet }, { class: 'btn-lg' }) %>
11
- </div>
12
- </div>
2
+
3
+ <%= webpacked_plugins_js_for :foreman_puppet %>
4
+ <% description = _("A config group provides a one-step method of associating many Puppet classes to either a host or host group. Typically this would be used to add a particular application profile or stack in one step.")%>
5
+ <% action = { :title => _("Create Config Group"), :url => new_config_group_path } if authorized_for(:action => :new)%>
6
+ <%= react_component('EmptyState', {
7
+ :icon => 'object-group',
8
+ :iconType => 'fa',
9
+ :header => _('Config Groups'),
10
+ :description => description,
11
+ :documentation => { :url => documentation_url("using-config-groups") },
12
+ :action => action
13
+ }) %>
@@ -20,7 +20,7 @@
20
20
  <td>
21
21
  <%= action_buttons(
22
22
  link_to(_('Classes'), puppetclasses_path(search: "environment = #{environment}")),
23
- import_proxy_links(hash_for_import_environments_environments_path(env: environment)),
23
+ import_proxy_links(hash_for_import_environments_environments_path(env: environment).merge(engine: foreman_puppet)),
24
24
  display_delete_if_authorized(hash_for_environment_path(environment).merge(engine: foreman_puppet, auth_object: environment, authorizer: authorizer),
25
25
  data: { confirm: "Delete #{environment.name}?" })
26
26
  ) %>
@@ -1,16 +1,4 @@
1
1
  <% content_for(:title, _("Puppet environments")) %>
2
- <div class="blank-slate-pf">
3
- <div class="blank-slate-pf-icon">
4
- <%= icon_text("th", '', kind: "fa") %>
5
- </div>
6
- <h1><%= _('Environments') %></h1>
7
- <p><%= _("If you are planning to use Foreman as an external node classifier you should provide information about one or more environments. This information is commonly imported from a pre-existing Puppet configuration by the use of the %{link_start}Puppet classes and environment importer%{link_end}.").html_safe % { link_start: tag(:a, href: documentation_url("4.2.2Classes"), rel: 'external'), link_end: '</a>'.html_safe } %>
8
- </p>
9
- <p><%= link_to(_('Learn more about this in the documentation.'), documentation_url("4.2.1Environments")) %></p>
10
- <div class="blank-slate-pf-main-action">
11
- <%= new_link(_('Create Puppet Environment'), { engine: foreman_puppet }, { class: "btn-lg" }) %>
12
- </div>
13
- <div class="blank-slate-pf-secondary-action">
14
- <%= import_proxy_select(hash_for_import_environments_environments_path) %>
15
- </div>
16
- </div>
2
+
3
+ <%= webpacked_plugins_js_for :foreman_puppet %>
4
+ <%= react_component('WelcomeEnv', {canCreate: authorized_for(action: :new)}) %>
@@ -1,9 +1,11 @@
1
1
  <% title _("Smart Class Parameters") %>
2
- <div class="blank-slate-pf">
3
- <div class="blank-slate-pf-icon">
4
- <%= icon_text("info-circle", "", :kind => "fa") %>
5
- </div>
6
- <h1><%= _('Smart Class Parameters') %></h1>
7
- <p><%= _("Parameterized class support permits detecting, importing, and supplying parameters directly to classes which support it, via the ENC and depending on a set of rules (Smart Matchers).") %></p>
8
- <p><%= link_to _('Learn more about this in the documentation.'), documentation_url("4.2.5ParameterizedClasses")%></p>
9
- </div>
2
+
3
+ <%= webpacked_plugins_js_for :foreman_puppet %>
4
+ <% description = _("Parameterized class support permits detecting, importing, and supplying parameters directly to classes which support it, via the ENC and depending on a set of rules (Smart Matchers).")%>
5
+ <%= react_component('EmptyState', {
6
+ :icon => 'info-circle',
7
+ :iconType => 'fa',
8
+ :header => _('Smart Class Parameters'),
9
+ :description => description,
10
+ :documentation => { :url => documentation_url("4.2.5ParameterizedClasses") },
11
+ }) %>
@@ -1,4 +1,4 @@
1
- <% Puppetclass.classes2hash(puppetclasses).sort.in_groups(2,nil) do |group| %>
1
+ <% ForemanPuppet::Puppetclass.classes2hash(puppetclasses).sort.in_groups(2,nil) do |group| %>
2
2
  <div class="col-md-6 classes">
3
3
  <% group.each do |list| %>
4
4
  <% next if list.nil? %>
@@ -1,4 +1,4 @@
1
- <%= content_tag :li, id: "selected_puppet_class_#{klass.id}", class: [dom_class(klass, 'selected'), cycle('even', 'odd'), ('unavailable' unless klass.environments.include?(@environment))] do %>
1
+ <%= content_tag :li, id: "selected_puppetclass_#{klass.id}", class: [dom_class(klass, 'selected'), cycle('even', 'odd'), ('unavailable' unless klass.environments.include?(@environment))] do %>
2
2
  <%= link_to_remove_puppetclass(klass, obj) %>
3
3
  <%= hidden_field_tag "#{resource_type}[puppetclass_ids][]", klass.id %>
4
4
  <% end %>
@@ -1,6 +1,6 @@
1
1
  <% title _("Puppet Classes") %>
2
2
 
3
- <% title_actions import_proxy_select(hash_for_import_environments_puppetclasses_path),
3
+ <% title_actions import_proxy_select(hash_for_import_environments_puppetclasses_path.merge(engine: foreman_puppet)),
4
4
  documentation_button('4.2.2Classes') %>
5
5
 
6
6
  <table class="<%= table_css_classes 'table-fixed' %>">
@@ -7,7 +7,7 @@
7
7
  <span id="puppet_klasses_reload_url" data-url="<%= foreman_puppet.environment_selected_hostgroups_path %>"></span>
8
8
  <% end %>
9
9
  <% if @environment.present? || obj.environment.present? %>
10
- <% if accessible_resource_records(:config_group).exists? %>
10
+ <% if accessible_resource_records('ForemanPuppet::ConfigGroup').exists? %>
11
11
  <%= render 'foreman_puppet/config_groups/config_groups_selection', obj: obj, resource_type: resource_type %>
12
12
  <% end %>
13
13