foreman_resource_quota 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (25) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/foreman_resource_quota/api/v2/resource_quotas_controller.rb +9 -1
  3. data/app/helpers/foreman_resource_quota/resource_quota_helper.rb +2 -6
  4. data/app/models/concerns/foreman_resource_quota/host_managed_extensions.rb +2 -0
  5. data/app/models/concerns/foreman_resource_quota/user_extensions.rb +2 -2
  6. data/app/models/concerns/foreman_resource_quota/usergroup_extensions.rb +2 -2
  7. data/app/models/foreman_resource_quota/resource_quota.rb +88 -19
  8. data/app/models/foreman_resource_quota/resource_quota_missing_host.rb +10 -0
  9. data/app/models/foreman_resource_quota/resource_quota_user.rb +2 -2
  10. data/app/models/foreman_resource_quota/resource_quota_usergroup.rb +2 -2
  11. data/app/views/foreman_resource_quota/api/v2/resource_quotas/base.json.rabl +1 -1
  12. data/app/views/foreman_resource_quota/api/v2/resource_quotas/missing_hosts.json.rabl +7 -0
  13. data/config/routes.rb +1 -0
  14. data/db/migrate/20230306120001_create_resource_quotas.rb +13 -0
  15. data/lib/foreman_resource_quota/exceptions.rb +1 -0
  16. data/lib/foreman_resource_quota/register.rb +3 -2
  17. data/lib/foreman_resource_quota/version.rb +1 -1
  18. data/package.json +2 -2
  19. data/webpack/api_helper.js +1 -3
  20. data/webpack/api_helper.test.js +6 -6
  21. data/webpack/components/ResourceQuotaForm/components/Properties/TextInputField.js +8 -7
  22. data/webpack/components/ResourceQuotaForm/components/Properties/index.js +8 -7
  23. data/webpack/components/ResourceQuotaForm/components/Resource/index.js +8 -7
  24. data/webpack/components/ResourceQuotaForm/components/Submit.js +8 -7
  25. metadata +5 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b1393110224628f53323632dab3c83f5e03ba7c3cbfbde18da47adfec25c9b1
4
- data.tar.gz: e057c71794fab2329b7e4a99522bedeedc885240b60572483b1b305b7668ee6f
3
+ metadata.gz: 9ed49765e7cc2e0b0c0059798b8b7055e695d31d7f5c01fad2345f560d6e7c17
4
+ data.tar.gz: 4b45e90aaea503b7b36f33939e60006a352718d81c7e40ccf0a2c21268556e25
5
5
  SHA512:
6
- metadata.gz: af380777f0749dfe60d0a557f3c05fc86977416f572a2e18c8fb79fbd8c754ac0854dfe13a289541f1459efe0f0d8b109d91d40638f0d75fafbbe0c546ec4373
7
- data.tar.gz: bc9e7210d1e7e26355625b0bb1c3cb388f9f36095cb0efc4964161c88cff10a4005675039efb91f81551da9f032f9d6ccedb71a71ea64eed9b854f3f5d5c1a7b
6
+ metadata.gz: 5c937a1edd93a174d873c60ef741f96950d1360e0f4886cd6e72ac472ca52839cb1e692d2f2b2148087dda1af60a68e25c87d865b195363dba418caa520c4721
7
+ data.tar.gz: 35c8bac94244083c54ba64620341b87e4801b1a190fd40b29c6e350b836e79e1dde15760ce995ed86c2d44db4e53a51497c8c0179a308868d9d34ecf5380c983
@@ -14,7 +14,7 @@ module ForemanResourceQuota
14
14
  end
15
15
 
16
16
  before_action :find_resource, only: %i[show update destroy]
17
- before_action :custom_find_resource, only: %i[utilization hosts users usergroups]
17
+ before_action :custom_find_resource, only: %i[utilization missing_hosts hosts users usergroups]
18
18
 
19
19
  api :GET, '/resource_quotas', N_('List all resource quotas')
20
20
  param_group :search_and_pagination, ::Api::V2::BaseController
@@ -35,6 +35,14 @@ module ForemanResourceQuota
35
35
  process_response @resource_quota
36
36
  end
37
37
 
38
+ api :GET, '/resource_quotas/:id/missing_hosts',
39
+ N_('Show resources could not be determined when calculating utilization')
40
+ param :id, :identifier, required: true
41
+ def missing_hosts
42
+ @resource_quota.determine_utilization
43
+ process_response @resource_quota
44
+ end
45
+
38
46
  api :GET, '/resource_quotas/:id/hosts', N_('Show hosts of a resource quota')
39
47
  param :id, :identifier, required: true
40
48
  def hosts
@@ -74,12 +74,8 @@ module ForemanResourceQuota
74
74
  # { <host name>: [<list of to be determined resources>] }
75
75
  # for example:
76
76
  # {
77
- # "host_a": {
78
- # [ :cpu_cores, :disk_gb ]
79
- # },
80
- # "host_b": {
81
- # [ :cpu_cores, :disk_gb ]
82
- # },
77
+ # "host_a": [ :cpu_cores, :disk_gb ],
78
+ # "host_b": [ :cpu_cores, :disk_gb ],
83
79
  # Parameters:
84
80
  # - hosts: Array of host objects.
85
81
  # - resources: Array of resources (as symbol, e.g. [:cpu_cores, :disk_gb]).
@@ -10,6 +10,8 @@ module ForemanResourceQuota
10
10
  validate :check_resource_quota_capacity
11
11
 
12
12
  belongs_to :resource_quota, class_name: '::ForemanResourceQuota::ResourceQuota'
13
+ has_one :resource_quota_missing_resources, class_name: '::ForemanResourceQuota::ResourceQuotaMissingHost',
14
+ inverse_of: :missing_host, foreign_key: :missing_host_id, dependent: :destroy
13
15
  scoped_search relation: :resource_quota, on: :name, complete_value: true, rename: :resource_quota
14
16
  end
15
17
 
@@ -4,9 +4,9 @@ module ForemanResourceQuota
4
4
  module UserExtensions
5
5
  extend ActiveSupport::Concern
6
6
  included do
7
- has_many :resource_quota_users, class_name: 'ForemanResourceQuota::ResourceQuotaUser', dependent: :destroy,
7
+ has_many :resource_quotas_users, class_name: 'ForemanResourceQuota::ResourceQuotaUser', dependent: :destroy,
8
8
  inverse_of: :user
9
- has_many :resource_quotas, class_name: 'ForemanResourceQuota::ResourceQuota', through: :resource_quota_users
9
+ has_many :resource_quotas, class_name: 'ForemanResourceQuota::ResourceQuota', through: :resource_quotas_users
10
10
  attribute :resource_quota_is_optional, :boolean, default: false
11
11
 
12
12
  scoped_search relation: :resource_quotas, on: :name, complete_value: true, rename: :resource_quota
@@ -4,9 +4,9 @@ module ForemanResourceQuota
4
4
  module UsergroupExtensions
5
5
  extend ActiveSupport::Concern
6
6
  included do
7
- has_many :resource_quota_usergroups, class_name: 'ForemanResourceQuota::ResourceQuotaUsergroup',
7
+ has_many :resource_quotas_usergroups, class_name: 'ForemanResourceQuota::ResourceQuotaUsergroup',
8
8
  dependent: :destroy, inverse_of: :usergroup
9
- has_many :resource_quotas, class_name: 'ForemanResourceQuota::ResourceQuota', through: :resource_quota_usergroups
9
+ has_many :resource_quotas, class_name: 'ForemanResourceQuota::ResourceQuota', through: :resource_quotas_usergroups
10
10
 
11
11
  scoped_search relation: :resource_quotas, on: :name, complete_value: true, rename: :resource_quota
12
12
  end
@@ -3,6 +3,7 @@
3
3
  module ForemanResourceQuota
4
4
  class ResourceQuota < ApplicationRecord
5
5
  include ResourceQuotaHelper
6
+ include Exceptions
6
7
  include Authorizable
7
8
  include Parameterizable::ByIdName
8
9
  extend FriendlyId
@@ -11,21 +12,20 @@ module ForemanResourceQuota
11
12
 
12
13
  self.table_name = 'resource_quotas'
13
14
 
14
- has_many :resource_quota_users, class_name: 'ResourceQuotaUser', inverse_of: :resource_quota, dependent: :destroy
15
- has_many :users, class_name: '::User', through: :resource_quota_users
16
- has_many :resource_quota_usergroups, class_name: 'ResourceQuotaUsergroup', inverse_of: :resource_quota,
15
+ has_many :resource_quotas_users, class_name: 'ResourceQuotaUser', inverse_of: :resource_quota, dependent: :destroy
16
+ has_many :resource_quotas_usergroups, class_name: 'ResourceQuotaUsergroup', inverse_of: :resource_quota,
17
+ dependent: :destroy
18
+ has_many :resource_quotas_missing_hosts, class_name: 'ResourceQuotaMissingHost', inverse_of: :resource_quota,
17
19
  dependent: :destroy
18
- has_many :usergroups, class_name: '::Usergroup', through: :resource_quota_usergroups
19
20
  has_many :hosts, class_name: '::Host::Managed', dependent: :nullify
21
+ has_many :users, class_name: '::User', through: :resource_quotas_users
22
+ has_many :usergroups, class_name: '::Usergroup', through: :resource_quotas_usergroups
20
23
 
21
24
  validates :name, presence: true, uniqueness: true
22
25
 
23
26
  scoped_search on: :name, complete_value: true
24
27
  scoped_search on: :id, complete_enabled: false, only_explicit: true, validator: ScopedSearch::Validators::INTEGER
25
28
 
26
- attribute :utilization, :jsonb, default: {}
27
- attribute :missing_hosts, :jsonb, default: {}
28
-
29
29
  def number_of_hosts
30
30
  hosts.size
31
31
  end
@@ -38,13 +38,68 @@ module ForemanResourceQuota
38
38
  usergroups.size
39
39
  end
40
40
 
41
+ def number_of_missing_hosts
42
+ missing_hosts.size
43
+ end
44
+
45
+ # Returns a Hash with host name as key and a list of missing resources as value
46
+ # { <host name>: [<list of missing resources>] }
47
+ # for example:
48
+ # {
49
+ # "host_a": [ :cpu_cores, :disk_gb ],
50
+ # "host_b": [ :memory_mb ],
51
+ # }
52
+ def missing_hosts
53
+ # Initialize default value as an empty array
54
+ missing_hosts_list = Hash.new { |hash, key| hash[key] = [] }
55
+ resource_quotas_missing_hosts.each do |missing_host_rel|
56
+ host_name = missing_host_rel.missing_host.name
57
+ missing_hosts_list[host_name] << :cpu_cores if missing_host_rel.no_cpu_cores
58
+ missing_hosts_list[host_name] << :memory_mb if missing_host_rel.no_memory_mb
59
+ missing_hosts_list[host_name] << :disk_gb if missing_host_rel.no_disk_gb
60
+ end
61
+ missing_hosts_list
62
+ end
63
+
64
+ # Set the hosts that are listed in resource_quotas_missing_hosts
65
+ # Parameters:
66
+ # - val: Hash of host names and list of missing resources
67
+ # { <host name>: [<list of missing resources>] }
68
+ # for example:
69
+ # {
70
+ # "host_a": [ :cpu_cores, :disk_gb ],
71
+ # "host_b": [ :memory_mb ],
72
+ # }
73
+ def missing_hosts=(val)
74
+ # Delete all entries and write new ones
75
+ resource_quotas_missing_hosts.delete_all
76
+ val.each do |host_name, missing_resources|
77
+ add_missing_host(host_name, missing_resources)
78
+ end
79
+ end
80
+
81
+ def utilization
82
+ {
83
+ cpu_cores: utilization_cpu_cores,
84
+ memory_mb: utilization_memory_mb,
85
+ disk_gb: utilization_disk_gb,
86
+ }
87
+ end
88
+
89
+ def utilization=(val)
90
+ update_single_utilization(:cpu_cores, val)
91
+ update_single_utilization(:memory_mb, val)
92
+ update_single_utilization(:disk_gb, val)
93
+ end
94
+
41
95
  def determine_utilization(additional_hosts = [])
42
96
  quota_hosts = (hosts | (additional_hosts))
43
- self.utilization, self.missing_hosts = call_utilization_helper(quota_hosts)
44
-
45
- print_warning(missing_hosts, quota_hosts) unless missing_hosts.empty?
97
+ quota_utilization, missing_hosts_resources = call_utilization_helper(quota_hosts)
98
+ update(utilization: quota_utilization)
99
+ update(missing_hosts: missing_hosts_resources)
100
+ Rails.logger.warn create_hosts_resources_warning(missing_hosts_resources) unless missing_hosts.empty?
46
101
  rescue StandardError => e
47
- print_error(e) # print error log here and forward error
102
+ Rails.logger.error("An error occured while determining resources for quota '#{name}': #{e}")
48
103
  raise e
49
104
  end
50
105
 
@@ -67,17 +122,31 @@ module ForemanResourceQuota
67
122
  utilization_from_resource_origins(active_resources, quota_hosts)
68
123
  end
69
124
 
70
- def print_warning(missing_hosts, hosts)
71
- warn_text = "Could not determines resources for #{missing_hosts.size} hosts:"
72
- missing_hosts.each do |host_id, missing_resources|
73
- missing_host = hosts.find { |obj| obj.id == host_id }
74
- warn_text << " '#{missing_host.name}': '#{missing_resources}'\n" unless missing_host.nil?
125
+ def create_hosts_resources_warning(missing_hosts_resources)
126
+ warn_text = +"Could not determines resources for #{missing_hosts_resources.size} hosts:"
127
+ missing_hosts_resources.each do |host_name, missing_resources|
128
+ warn_text << " '#{host_name}': '#{missing_resources}'\n" unless missing_resources.empty?
75
129
  end
76
- Rails.logger.warn warn_text
77
130
  end
78
131
 
79
- def print_error(err)
80
- Rails.logger.error("An error occured while determining resources for quota '#{name}': #{err}")
132
+ def update_single_utilization(attribute, val)
133
+ return unless val.key?(attribute.to_sym) || val.key?(attribute.to_s)
134
+ update("utilization_#{attribute}": val[attribute.to_sym] || val[attribute.to_s])
135
+ end
136
+
137
+ def add_missing_host(host_name, missing_resources)
138
+ return if missing_resources.empty?
139
+
140
+ host = Host::Managed.find_by(name: host_name)
141
+ raise HostNotFoundException if host.nil?
142
+
143
+ resource_quotas_missing_hosts << ResourceQuotaMissingHost.new(
144
+ missing_host: host,
145
+ resource_quota: self,
146
+ no_cpu_cores: missing_resources.include?(:cpu_cores),
147
+ no_memory_mb: missing_resources.include?(:memory_mb),
148
+ no_disk_gb: missing_resources.include?(:disk_gb)
149
+ )
81
150
  end
82
151
  end
83
152
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ForemanResourceQuota
4
+ class ResourceQuotaMissingHost < ApplicationRecord
5
+ self.table_name = 'resource_quotas_missing_hosts'
6
+
7
+ belongs_to :resource_quota, inverse_of: :resource_quotas_missing_hosts
8
+ belongs_to :missing_host, class_name: '::Host::Managed', inverse_of: :resource_quota_missing_resources
9
+ end
10
+ end
@@ -4,7 +4,7 @@ module ForemanResourceQuota
4
4
  class ResourceQuotaUser < ApplicationRecord
5
5
  self.table_name = 'resource_quotas_users'
6
6
 
7
- belongs_to :resource_quota, inverse_of: :resource_quota_users
8
- belongs_to :user, class_name: '::User', inverse_of: :resource_quota_users
7
+ belongs_to :resource_quota, inverse_of: :resource_quotas_users
8
+ belongs_to :user, class_name: '::User', inverse_of: :resource_quotas_users
9
9
  end
10
10
  end
@@ -4,7 +4,7 @@ module ForemanResourceQuota
4
4
  class ResourceQuotaUsergroup < ApplicationRecord
5
5
  self.table_name = 'resource_quotas_usergroups'
6
6
 
7
- belongs_to :resource_quota, inverse_of: :resource_quota_usergroups
8
- belongs_to :usergroup, class_name: '::Usergroup', inverse_of: :resource_quota_usergroups
7
+ belongs_to :resource_quota, inverse_of: :resource_quotas_usergroups
8
+ belongs_to :usergroup, class_name: '::Usergroup', inverse_of: :resource_quotas_usergroups
9
9
  end
10
10
  end
@@ -3,4 +3,4 @@
3
3
  object @resource_quota
4
4
 
5
5
  attributes :name, :id, :description, :cpu_cores, :memory_mb, :disk_gb, :number_of_hosts, :number_of_users,
6
- :number_of_usergroups
6
+ :number_of_usergroups, :number_of_missing_hosts, :utilization
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ object @resource_quota
4
+
5
+ extends 'api/v2/resource_quotas/main'
6
+
7
+ attributes :missing_hosts
data/config/routes.rb CHANGED
@@ -31,6 +31,7 @@ Rails.application.routes.draw do
31
31
  end
32
32
  constraints(id: %r{[^/]+}) do
33
33
  get 'utilization'
34
+ get 'missing_hosts'
34
35
  get 'hosts'
35
36
  get 'users'
36
37
  get 'usergroups'
@@ -9,6 +9,9 @@ class CreateResourceQuotas < ActiveRecord::Migration[6.1]
9
9
  t.integer :cpu_cores, default: nil
10
10
  t.integer :memory_mb, default: nil
11
11
  t.integer :disk_gb, default: nil
12
+ t.integer :utilization_cpu_cores, default: nil
13
+ t.integer :utilization_memory_mb, default: nil
14
+ t.integer :utilization_disk_gb, default: nil
12
15
 
13
16
  t.timestamps
14
17
  end
@@ -24,6 +27,16 @@ class CreateResourceQuotas < ActiveRecord::Migration[6.1]
24
27
  t.belongs_to :user
25
28
  t.timestamps
26
29
  end
30
+
31
+ create_table :resource_quotas_missing_hosts do |t|
32
+ t.references :resource_quota, null: false, foreign_key: { to_table: :resource_quotas }
33
+ t.references :missing_host, null: false, unique: true, foreign_key: { to_table: :hosts }
34
+ t.boolean :no_cpu_cores, default: false
35
+ t.boolean :no_memory_mb, default: false
36
+ t.boolean :no_disk_gb, default: false
37
+ t.timestamps
38
+ end
39
+
27
40
  add_reference :hosts, :resource_quota, foreign_key: { to_table: :resource_quotas }
28
41
  add_column :users, :resource_quota_is_optional, :boolean, default: false
29
42
  end
@@ -7,5 +7,6 @@ module ForemanResourceQuota
7
7
  class ResourceLimitException < ResourceQuotaException; end
8
8
  class HostResourcesException < ResourceQuotaException; end
9
9
  class ResourceQuotaUtilizationException < ResourceQuotaException; end
10
+ class HostNotFoundException < ResourceQuotaException; end
10
11
  end
11
12
  end
@@ -11,9 +11,10 @@ Foreman::Plugin.register :foreman_resource_quota do
11
11
  security_block :foreman_resource_quota do
12
12
  permission 'view_foreman_resource_quota/resource_quotas',
13
13
  { 'foreman_resource_quota/resource_quotas': %i[index welcome auto_complete_search],
14
- 'foreman_resource_quota/api/v2/resource_quotas': %i[index show utilization hosts users usergroups
14
+ 'foreman_resource_quota/api/v2/resource_quotas': %i[index show utilization missing_hosts hosts users usergroups
15
15
  auto_complete_search],
16
- 'foreman_resource_quota/api/v2/resource_quotas/:resource_quota_id/': %i[utilization hosts users usergroups] },
16
+ 'foreman_resource_quota/api/v2/resource_quotas/:resource_quota_id/': %i[utilization missing_hosts hosts users
17
+ usergroups] },
17
18
  resource_type: 'ForemanResourceQuota::ResourceQuota'
18
19
  permission 'create_foreman_resource_quota/resource_quotas',
19
20
  { 'foreman_resource_quota/resource_quotas': %i[new create],
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ForemanResourceQuota
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
data/package.json CHANGED
@@ -28,7 +28,7 @@
28
28
  "@babel/core": "^7.24.3",
29
29
  "@sheerun/mutationobserver-shim": "^0.3.3",
30
30
  "@testing-library/react": "^10.4.9",
31
- "@theforeman/builder": "^10.1.3",
31
+ "@theforeman/builder": "^12.0.1",
32
32
  "@theforeman/eslint-plugin-foreman": "13.0.0",
33
33
  "@theforeman/find-foreman": "^13.0.0",
34
34
  "@theforeman/stories": "^12.2.3",
@@ -38,7 +38,7 @@
38
38
  "eslint": "^6.7.2",
39
39
  "prettier": "^1.19.1",
40
40
  "react-redux-test-utils": "^0.2.0",
41
- "stylelint": "^16.3.1",
41
+ "stylelint": "^16.4.0",
42
42
  "stylelint-config-standard": "^36.0.0"
43
43
  }
44
44
  }
@@ -68,19 +68,17 @@ const apiUpdateResourceQuota = (
68
68
 
69
69
  /**
70
70
  * Handles the callback response from an asynchronous operation, displaying a toast message accordingly.
71
- * @param {function} dispatcher - The dispatcher function to dispatch actions.
72
71
  * @param {boolean} isSuccess - Indicates whether the operation was successful or not.
73
72
  * @param {object} response - The response object returned from the operation.
74
73
  * @param {string} successMessage - The success message to display in case of success.
75
74
  * @param {string} errorMessage - The error message to display in case of failure.
76
75
  */
77
76
  const dispatchAPICallbackToast = (
78
- dispatch,
79
77
  isSuccess,
80
78
  response,
81
79
  successMessage,
82
80
  errorMessage
83
- ) => {
81
+ ) => dispatch => {
84
82
  if (isSuccess) {
85
83
  dispatch(
86
84
  addToast({
@@ -21,13 +21,13 @@ describe('dispatchAPICallbackToast', () => {
21
21
  const successMessage = 'Success message';
22
22
  const errorMessage = 'Error message';
23
23
 
24
- dispatchAPICallbackToast(
25
- dispatch,
24
+ const dispatcher = dispatchAPICallbackToast(
26
25
  isSuccess,
27
26
  response,
28
27
  successMessage,
29
28
  errorMessage
30
29
  );
30
+ dispatcher(dispatch);
31
31
 
32
32
  expect(dispatch).toHaveBeenCalledTimes(1);
33
33
  expect(dispatch).toHaveBeenCalledWith({
@@ -50,13 +50,13 @@ describe('dispatchAPICallbackToast', () => {
50
50
  const successMessage = 'Success message';
51
51
  const errorMessage = 'Error message';
52
52
 
53
- dispatchAPICallbackToast(
54
- dispatch,
53
+ const dispatcher = dispatchAPICallbackToast(
55
54
  isSuccess,
56
55
  response,
57
56
  successMessage,
58
57
  errorMessage
59
58
  );
59
+ dispatcher(dispatch);
60
60
 
61
61
  expect(dispatch).toHaveBeenCalledTimes(1);
62
62
  expect(dispatch).toHaveBeenCalledWith({
@@ -79,13 +79,13 @@ describe('dispatchAPICallbackToast', () => {
79
79
  const successMessage = 'Success message';
80
80
  const errorMessage = 'Error message';
81
81
 
82
- dispatchAPICallbackToast(
83
- dispatch,
82
+ const dispatcher = dispatchAPICallbackToast(
84
83
  isSuccess,
85
84
  response,
86
85
  successMessage,
87
86
  errorMessage
88
87
  );
88
+ dispatcher(dispatch);
89
89
 
90
90
  expect(dispatch).toHaveBeenCalledTimes(1);
91
91
  expect(dispatch).toHaveBeenCalledWith({
@@ -6,7 +6,7 @@ import { translate as __ } from 'foremanReact/common/I18n';
6
6
 
7
7
  import ActionableDetail from '../../../../lib/ActionableDetail';
8
8
  import StaticDetail from './StaticDetail';
9
- import dispatchAPICallbackToast from '../../../../api_helper';
9
+ import { dispatchAPICallbackToast } from '../../../../api_helper';
10
10
 
11
11
  const TextInputField = ({
12
12
  initialValue,
@@ -36,12 +36,13 @@ const TextInputField = ({
36
36
 
37
37
  const callback = (success, response) => {
38
38
  setIsLoading(false);
39
- dispatchAPICallbackToast(
40
- dispatch,
41
- success,
42
- response,
43
- `Sucessfully applied ${label}.`,
44
- `An error occurred appyling ${label}.`
39
+ dispatch(
40
+ dispatchAPICallbackToast(
41
+ success,
42
+ response,
43
+ `Sucessfully applied ${label}.`,
44
+ `An error occurred appyling ${label}.`
45
+ )
45
46
  );
46
47
  };
47
48
 
@@ -22,7 +22,7 @@ import ClusterIcon from '@patternfly/react-icons/dist/esm/icons/cluster-icon';
22
22
  import SyncAltIcon from '@patternfly/react-icons/dist/esm/icons/sync-alt-icon';
23
23
 
24
24
  import { translate as __ } from 'foremanReact/common/I18n';
25
- import dispatchAPICallbackToast from '../../../../api_helper';
25
+ import { dispatchAPICallbackToast } from '../../../../api_helper';
26
26
 
27
27
  import './Properties.scss';
28
28
  import StatusPropertiesLabel from './StatusPropertiesLabel';
@@ -58,12 +58,13 @@ const Properties = ({
58
58
 
59
59
  const callbackFetch = (success, response) => {
60
60
  setIsFetchLoading(false);
61
- dispatchAPICallbackToast(
62
- dispatch,
63
- success,
64
- response,
65
- `Sucessfully fetched latest data.`,
66
- `An error occurred fetching quota information.`
61
+ dispatch(
62
+ dispatchAPICallbackToast(
63
+ success,
64
+ response,
65
+ `Sucessfully fetched latest data.`,
66
+ `An error occurred fetching quota information.`
67
+ )
67
68
  );
68
69
  };
69
70
 
@@ -25,7 +25,7 @@ import UnitInputField from './UnitInputField';
25
25
  import UtilizationProgress from './UtilizationProgress';
26
26
 
27
27
  import { resourceAttributesByIdentifier } from '../../ResourceQuotaFormConstants';
28
- import dispatchAPICallbackToast from '../../../../api_helper';
28
+ import { dispatchAPICallbackToast } from '../../../../api_helper';
29
29
 
30
30
  // TODO: Visualize maximum resource (tooltip?)
31
31
  // TODO: Add error message if given quota limit exceeds present quota utilization (consumed resources)
@@ -70,12 +70,13 @@ const Resource = ({
70
70
  setInputValue(response.data[resourceIdentifier]);
71
71
  setIsEnabled(response.data[resourceIdentifier] !== null);
72
72
  }
73
- dispatchAPICallbackToast(
74
- dispatch,
75
- success,
76
- response,
77
- `Sucessfully applied ${resourceTitle}.`,
78
- `An error occurred appyling ${resourceTitle}.`
73
+ dispatch(
74
+ dispatchAPICallbackToast(
75
+ success,
76
+ response,
77
+ `Sucessfully applied ${resourceTitle}.`,
78
+ `An error occurred appyling ${resourceTitle}.`
79
+ )
79
80
  );
80
81
  };
81
82
 
@@ -5,7 +5,7 @@ import { Button, Flex, FlexItem } from '@patternfly/react-core';
5
5
 
6
6
  import { translate as __ } from 'foremanReact/common/I18n';
7
7
 
8
- import dispatchAPICallbackToast from '../../../api_helper';
8
+ import { dispatchAPICallbackToast } from '../../../api_helper';
9
9
 
10
10
  import {
11
11
  RESOURCE_IDENTIFIER_ID,
@@ -27,12 +27,13 @@ const Submit = ({ isValid, onCreate, onSubmit }) => {
27
27
 
28
28
  const onCreateCallback = (success, response) => {
29
29
  setIsSubmitLoading(false);
30
- dispatchAPICallbackToast(
31
- dispatch,
32
- success,
33
- response,
34
- `Sucessfully created new Resource Quota`,
35
- `An error occurred while creating new Resource Quota.`
30
+ dispatch(
31
+ dispatchAPICallbackToast(
32
+ success,
33
+ response,
34
+ `Sucessfully created new Resource Quota`,
35
+ `An error occurred while creating new Resource Quota.`
36
+ )
36
37
  );
37
38
  if (onSubmit) onSubmit(success);
38
39
  };
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_resource_quota
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bastian Schmidt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-17 00:00:00.000000000 Z
11
+ date: 2024-04-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Foreman Plug-in to manage resource usage among users.
14
14
  email:
@@ -30,6 +30,7 @@ files:
30
30
  - app/models/concerns/foreman_resource_quota/user_extensions.rb
31
31
  - app/models/concerns/foreman_resource_quota/usergroup_extensions.rb
32
32
  - app/models/foreman_resource_quota/resource_quota.rb
33
+ - app/models/foreman_resource_quota/resource_quota_missing_host.rb
33
34
  - app/models/foreman_resource_quota/resource_quota_user.rb
34
35
  - app/models/foreman_resource_quota/resource_quota_usergroup.rb
35
36
  - app/services/foreman_resource_quota/resource_origin.rb
@@ -43,6 +44,7 @@ files:
43
44
  - app/views/foreman_resource_quota/api/v2/resource_quotas/hosts.json.rabl
44
45
  - app/views/foreman_resource_quota/api/v2/resource_quotas/index.json.rabl
45
46
  - app/views/foreman_resource_quota/api/v2/resource_quotas/main.json.rabl
47
+ - app/views/foreman_resource_quota/api/v2/resource_quotas/missing_hosts.json.rabl
46
48
  - app/views/foreman_resource_quota/api/v2/resource_quotas/show.json.rabl
47
49
  - app/views/foreman_resource_quota/api/v2/resource_quotas/update.json.rabl
48
50
  - app/views/foreman_resource_quota/api/v2/resource_quotas/usergroups.json.rabl
@@ -127,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
129
  - !ruby/object:Gem::Version
128
130
  version: '0'
129
131
  requirements: []
130
- rubygems_version: 3.3.26
132
+ rubygems_version: 3.3.27
131
133
  signing_key:
132
134
  specification_version: 4
133
135
  summary: Foreman Plug-in for resource quota