foreman_resource_quota 0.3.1 → 0.5.0

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.
Files changed (185) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -6
  3. data/app/assets/javascripts/foreman_resource_quota/locale/bn/foreman_resource_quota.js +213 -0
  4. data/app/assets/javascripts/foreman_resource_quota/locale/bn_IN/foreman_resource_quota.js +214 -0
  5. data/app/assets/javascripts/foreman_resource_quota/locale/bqi/foreman_resource_quota.js +213 -0
  6. data/app/assets/javascripts/foreman_resource_quota/locale/ca/foreman_resource_quota.js +214 -0
  7. data/app/assets/javascripts/foreman_resource_quota/locale/cs_CZ/foreman_resource_quota.js +214 -0
  8. data/app/assets/javascripts/foreman_resource_quota/locale/de/foreman_resource_quota.js +214 -0
  9. data/app/assets/javascripts/foreman_resource_quota/locale/de_AT/foreman_resource_quota.js +213 -0
  10. data/app/assets/javascripts/foreman_resource_quota/locale/de_DE/foreman_resource_quota.js +214 -0
  11. data/app/assets/javascripts/foreman_resource_quota/locale/el/foreman_resource_quota.js +214 -0
  12. data/app/assets/javascripts/foreman_resource_quota/locale/en/foreman_resource_quota.js +214 -0
  13. data/app/assets/javascripts/foreman_resource_quota/locale/en_GB/foreman_resource_quota.js +214 -0
  14. data/app/assets/javascripts/foreman_resource_quota/locale/en_US/foreman_resource_quota.js +213 -0
  15. data/app/assets/javascripts/foreman_resource_quota/locale/es/foreman_resource_quota.js +214 -0
  16. data/app/assets/javascripts/foreman_resource_quota/locale/et_EE/foreman_resource_quota.js +213 -0
  17. data/app/assets/javascripts/foreman_resource_quota/locale/fr/foreman_resource_quota.js +214 -0
  18. data/app/assets/javascripts/foreman_resource_quota/locale/gl/foreman_resource_quota.js +214 -0
  19. data/app/assets/javascripts/foreman_resource_quota/locale/gu/foreman_resource_quota.js +214 -0
  20. data/app/assets/javascripts/foreman_resource_quota/locale/he_IL/foreman_resource_quota.js +213 -0
  21. data/app/assets/javascripts/foreman_resource_quota/locale/hi/foreman_resource_quota.js +214 -0
  22. data/app/assets/javascripts/foreman_resource_quota/locale/id/foreman_resource_quota.js +214 -0
  23. data/app/assets/javascripts/foreman_resource_quota/locale/it/foreman_resource_quota.js +214 -0
  24. data/app/assets/javascripts/foreman_resource_quota/locale/ja/foreman_resource_quota.js +214 -0
  25. data/app/assets/javascripts/foreman_resource_quota/locale/ka/foreman_resource_quota.js +214 -0
  26. data/app/assets/javascripts/foreman_resource_quota/locale/kn/foreman_resource_quota.js +214 -0
  27. data/app/assets/javascripts/foreman_resource_quota/locale/ko/foreman_resource_quota.js +214 -0
  28. data/app/assets/javascripts/foreman_resource_quota/locale/ml_IN/foreman_resource_quota.js +213 -0
  29. data/app/assets/javascripts/foreman_resource_quota/locale/mr/foreman_resource_quota.js +214 -0
  30. data/app/assets/javascripts/foreman_resource_quota/locale/nl_NL/foreman_resource_quota.js +214 -0
  31. data/app/assets/javascripts/foreman_resource_quota/locale/or/foreman_resource_quota.js +214 -0
  32. data/app/assets/javascripts/foreman_resource_quota/locale/pa/foreman_resource_quota.js +214 -0
  33. data/app/assets/javascripts/foreman_resource_quota/locale/pl/foreman_resource_quota.js +214 -0
  34. data/app/assets/javascripts/foreman_resource_quota/locale/pl_PL/foreman_resource_quota.js +213 -0
  35. data/app/assets/javascripts/foreman_resource_quota/locale/pt/foreman_resource_quota.js +213 -0
  36. data/app/assets/javascripts/foreman_resource_quota/locale/pt_BR/foreman_resource_quota.js +214 -0
  37. data/app/assets/javascripts/foreman_resource_quota/locale/ro/foreman_resource_quota.js +213 -0
  38. data/app/assets/javascripts/foreman_resource_quota/locale/ro_RO/foreman_resource_quota.js +213 -0
  39. data/app/assets/javascripts/foreman_resource_quota/locale/ru/foreman_resource_quota.js +214 -0
  40. data/app/assets/javascripts/foreman_resource_quota/locale/sl/foreman_resource_quota.js +214 -0
  41. data/app/assets/javascripts/foreman_resource_quota/locale/sv_SE/foreman_resource_quota.js +214 -0
  42. data/app/assets/javascripts/foreman_resource_quota/locale/ta/foreman_resource_quota.js +213 -0
  43. data/app/assets/javascripts/foreman_resource_quota/locale/ta_IN/foreman_resource_quota.js +214 -0
  44. data/app/assets/javascripts/foreman_resource_quota/locale/te/foreman_resource_quota.js +214 -0
  45. data/app/assets/javascripts/foreman_resource_quota/locale/tr/foreman_resource_quota.js +213 -0
  46. data/app/assets/javascripts/foreman_resource_quota/locale/vi/foreman_resource_quota.js +213 -0
  47. data/app/assets/javascripts/foreman_resource_quota/locale/vi_VN/foreman_resource_quota.js +213 -0
  48. data/app/assets/javascripts/foreman_resource_quota/locale/zh/foreman_resource_quota.js +213 -0
  49. data/app/assets/javascripts/foreman_resource_quota/locale/zh_CN/foreman_resource_quota.js +214 -0
  50. data/app/assets/javascripts/foreman_resource_quota/locale/zh_TW/foreman_resource_quota.js +214 -0
  51. data/app/controllers/foreman_resource_quota/api/v2/resource_quotas_controller.rb +17 -10
  52. data/app/controllers/foreman_resource_quota/concerns/api/v2/hosts_controller_extensions.rb +20 -0
  53. data/app/controllers/foreman_resource_quota/concerns/api/v2/usergroups_controller_extensions.rb +19 -0
  54. data/app/controllers/foreman_resource_quota/concerns/api/v2/users_controller_extensions.rb +22 -0
  55. data/app/models/concerns/foreman_resource_quota/host_managed_extensions.rb +9 -7
  56. data/app/views/foreman_resource_quota/api/v2/users/resource_quota.json.rabl +1 -1
  57. data/app/views/foreman_resource_quota/resource_quotas/index.html.erb +1 -1
  58. data/config/initializers/inflections.rb +1 -0
  59. data/lib/foreman_resource_quota/engine.rb +8 -1
  60. data/lib/foreman_resource_quota/register.rb +4 -2
  61. data/lib/foreman_resource_quota/version.rb +1 -1
  62. data/lib/tasks/foreman_resource_quota_tasks.rake +3 -3
  63. data/locale/Makefile +19 -6
  64. data/locale/bn/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  65. data/locale/bn/foreman_resource_quota.po +214 -0
  66. data/locale/bn_IN/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  67. data/locale/bn_IN/foreman_resource_quota.po +219 -0
  68. data/locale/bqi/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  69. data/locale/bqi/foreman_resource_quota.po +215 -0
  70. data/locale/ca/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  71. data/locale/ca/foreman_resource_quota.po +218 -0
  72. data/locale/cs_CZ/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  73. data/locale/cs_CZ/foreman_resource_quota.po +221 -0
  74. data/locale/de/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  75. data/locale/de/foreman_resource_quota.po +223 -0
  76. data/locale/de_AT/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  77. data/locale/de_AT/foreman_resource_quota.po +215 -0
  78. data/locale/de_DE/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  79. data/locale/de_DE/foreman_resource_quota.po +219 -0
  80. data/locale/el/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  81. data/locale/el/foreman_resource_quota.po +218 -0
  82. data/locale/en/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  83. data/locale/en/foreman_resource_quota.po +207 -9
  84. data/locale/en_GB/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  85. data/locale/en_GB/foreman_resource_quota.po +220 -0
  86. data/locale/en_US/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  87. data/locale/en_US/foreman_resource_quota.po +215 -0
  88. data/locale/es/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  89. data/locale/es/foreman_resource_quota.po +223 -0
  90. data/locale/et_EE/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  91. data/locale/et_EE/foreman_resource_quota.po +215 -0
  92. data/locale/foreman_resource_quota.pot +322 -8
  93. data/locale/fr/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  94. data/locale/fr/foreman_resource_quota.po +222 -0
  95. data/locale/gl/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  96. data/locale/gl/foreman_resource_quota.po +218 -0
  97. data/locale/gu/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  98. data/locale/gu/foreman_resource_quota.po +218 -0
  99. data/locale/he_IL/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  100. data/locale/he_IL/foreman_resource_quota.po +216 -0
  101. data/locale/hi/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  102. data/locale/hi/foreman_resource_quota.po +218 -0
  103. data/locale/id/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  104. data/locale/id/foreman_resource_quota.po +218 -0
  105. data/locale/it/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  106. data/locale/it/foreman_resource_quota.po +221 -0
  107. data/locale/ja/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  108. data/locale/ja/foreman_resource_quota.po +219 -0
  109. data/locale/ka/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  110. data/locale/ka/foreman_resource_quota.po +218 -0
  111. data/locale/kn/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  112. data/locale/kn/foreman_resource_quota.po +218 -0
  113. data/locale/ko/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  114. data/locale/ko/foreman_resource_quota.po +220 -0
  115. data/locale/ml_IN/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  116. data/locale/ml_IN/foreman_resource_quota.po +215 -0
  117. data/locale/mr/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  118. data/locale/mr/foreman_resource_quota.po +218 -0
  119. data/locale/nl_NL/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  120. data/locale/nl_NL/foreman_resource_quota.po +223 -0
  121. data/locale/or/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  122. data/locale/or/foreman_resource_quota.po +218 -0
  123. data/locale/pa/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  124. data/locale/pa/foreman_resource_quota.po +219 -0
  125. data/locale/pl/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  126. data/locale/pl/foreman_resource_quota.po +221 -0
  127. data/locale/pl_PL/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  128. data/locale/pl_PL/foreman_resource_quota.po +217 -0
  129. data/locale/pt/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  130. data/locale/pt/foreman_resource_quota.po +215 -0
  131. data/locale/pt_BR/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  132. data/locale/pt_BR/foreman_resource_quota.po +222 -0
  133. data/locale/ro/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  134. data/locale/ro/foreman_resource_quota.po +215 -0
  135. data/locale/ro_RO/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  136. data/locale/ro_RO/foreman_resource_quota.po +216 -0
  137. data/locale/ru/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  138. data/locale/ru/foreman_resource_quota.po +222 -0
  139. data/locale/sl/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  140. data/locale/sl/foreman_resource_quota.po +219 -0
  141. data/locale/sv_SE/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  142. data/locale/sv_SE/foreman_resource_quota.po +221 -0
  143. data/locale/ta/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  144. data/locale/ta/foreman_resource_quota.po +214 -0
  145. data/locale/ta_IN/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  146. data/locale/ta_IN/foreman_resource_quota.po +219 -0
  147. data/locale/te/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  148. data/locale/te/foreman_resource_quota.po +218 -0
  149. data/locale/tr/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  150. data/locale/tr/foreman_resource_quota.po +214 -0
  151. data/locale/vi/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  152. data/locale/vi/foreman_resource_quota.po +214 -0
  153. data/locale/vi_VN/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  154. data/locale/vi_VN/foreman_resource_quota.po +215 -0
  155. data/locale/zh/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  156. data/locale/zh/foreman_resource_quota.po +214 -0
  157. data/locale/zh_CN/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  158. data/locale/zh_CN/foreman_resource_quota.po +221 -0
  159. data/locale/zh_TW/LC_MESSAGES/foreman_resource_quota.mo +0 -0
  160. data/locale/zh_TW/foreman_resource_quota.po +220 -0
  161. data/package.json +10 -10
  162. data/webpack/components/ResourceQuotaEmptyState/__test__/ResourceQuotaEmptyState.test.js +35 -0
  163. data/webpack/components/ResourceQuotaEmptyState/__test__/__snapshots__/ResourceQuotaEmptyState.test.js.snap +81 -0
  164. data/webpack/components/ResourceQuotaEmptyState/index.js +20 -3
  165. data/webpack/components/ResourceQuotaForm/ResourceQuotaForm.scss +1 -1
  166. data/webpack/components/ResourceQuotaForm/ResourceQuotaFormConstants.js +6 -6
  167. data/webpack/components/ResourceQuotaForm/components/Properties/Properties.scss +4 -3
  168. data/webpack/components/ResourceQuotaForm/components/Properties/StaticDetail.js +2 -2
  169. data/webpack/components/ResourceQuotaForm/components/Properties/TextInputField.js +1 -1
  170. data/webpack/components/ResourceQuotaForm/components/Properties/index.js +77 -63
  171. data/webpack/components/ResourceQuotaForm/components/Resource/Resource.scss +5 -5
  172. data/webpack/components/ResourceQuotaForm/components/Resource/UnitInputField.js +97 -52
  173. data/webpack/components/ResourceQuotaForm/components/Resource/UnitInputField.scss +7 -0
  174. data/webpack/components/ResourceQuotaForm/components/Resource/UtilizationProgress.js +1 -1
  175. data/webpack/components/ResourceQuotaForm/components/Resource/UtilizationProgress.scss +4 -4
  176. data/webpack/components/ResourceQuotaForm/components/Resource/__test__/UnitInputField.test.js +108 -0
  177. data/webpack/components/ResourceQuotaForm/components/Resource/__test__/__snapshots__/UnitInputField.test.js.snap +153 -0
  178. data/webpack/components/ResourceQuotaForm/components/Resource/index.js +25 -18
  179. data/webpack/components/ResourceQuotaForm/components/Submit.js +1 -1
  180. data/webpack/lib/ActionableDetail.scss +1 -1
  181. data/webpack/lib/EditableSwitch.js +1 -1
  182. data/webpack/lib/EditableTextInput/EditableTextInput.js +81 -77
  183. data/webpack/lib/EditableTextInput/editableTextInput.scss +30 -28
  184. data/webpack/test_helper.js +49 -0
  185. metadata +161 -9
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import '@testing-library/jest-dom';
3
+
4
+ import { mount, testComponentSnapshotsWithFixtures } from '@theforeman/test';
5
+ // Notice: (not) importing Modal affects the snapshot test since it fills
6
+ // the components data dynamically in snapshots as soon as it can find the component.
7
+ import { Modal } from '@patternfly/react-core';
8
+
9
+ import { withMockedProvider, withRedux } from '../../../test_helper';
10
+ import ResourceQuotaForm from '../../ResourceQuotaForm';
11
+ import ResourceQuotaEmptyState from '../index';
12
+
13
+ const TestComponent = withRedux(withMockedProvider(ResourceQuotaEmptyState));
14
+
15
+ describe('ResourceQuotaEmptyState', () => {
16
+ testComponentSnapshotsWithFixtures(ResourceQuotaEmptyState, {
17
+ 'should render': {}, // component has no props
18
+ });
19
+
20
+ test('opens the modal on clicking "Create resource quota" button', () => {
21
+ const wrapper = mount(<TestComponent />);
22
+
23
+ expect(wrapper.find(Modal).prop('isOpen')).toBe(false); // check we provide the correct input to Modal
24
+ expect(wrapper.find(ResourceQuotaForm).exists()).toBe(false);
25
+
26
+ wrapper
27
+ .find('button')
28
+ .filterWhere(button => button.text() === 'Create resource quota')
29
+ .simulate('click');
30
+ wrapper.update();
31
+
32
+ expect(wrapper.find(Modal).prop('isOpen')).toBe(true);
33
+ expect(wrapper.find(ResourceQuotaForm).exists()).toBe(true);
34
+ });
35
+ });
@@ -0,0 +1,81 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`ResourceQuotaEmptyState should render 1`] = `
4
+ <div>
5
+ <EmptyStatePattern
6
+ action={
7
+ <Button
8
+ id="foreman-resource-quota-welcome-create-modal-button"
9
+ onClick={[Function]}
10
+ variant="primary"
11
+ >
12
+ Create resource quota
13
+ </Button>
14
+ }
15
+ description={
16
+ <span>
17
+ Resource Quotas help admins to manage resources including CPUs, memory, and disk space among users or user groups.
18
+ <br />
19
+ Define a Resource Quota here and apply it to users to guarantee a fair share of your resources.
20
+ <br />
21
+ </span>
22
+ }
23
+ documentation={
24
+ Object {
25
+ "url": "/links/docs/Administering_Project?chapter=limiting-host-resources",
26
+ }
27
+ }
28
+ header="Resource Quotas"
29
+ icon="pficon pficon-cluster"
30
+ iconType="pf"
31
+ secondaryActions={Array []}
32
+ />
33
+ <Modal
34
+ actions={Array []}
35
+ appendTo={<body />}
36
+ aria-describedby=""
37
+ aria-label=""
38
+ aria-labelledby=""
39
+ className=""
40
+ hasNoBodyWrapper={false}
41
+ isOpen={false}
42
+ onClose={[Function]}
43
+ ouiaId="foreman-resource-quota-create-modal"
44
+ ouiaSafe={true}
45
+ position="default"
46
+ showClose={true}
47
+ title="Create resource quota"
48
+ titleIconVariant={null}
49
+ titleLabel=""
50
+ variant="small"
51
+ >
52
+ <ResourceQuotaForm
53
+ initialProperties={
54
+ Object {
55
+ "cpu_cores": null,
56
+ "description": "",
57
+ "disk_gb": null,
58
+ "memory_mb": null,
59
+ "name": "",
60
+ }
61
+ }
62
+ initialStatus={
63
+ Object {
64
+ "missing_hosts": null,
65
+ "number_of_hosts": null,
66
+ "number_of_usergroups": null,
67
+ "number_of_users": null,
68
+ "utilization": Object {
69
+ "cpu_cores": null,
70
+ "disk_gb": null,
71
+ "memory_mb": null,
72
+ },
73
+ }
74
+ }
75
+ isNewQuota={true}
76
+ onSubmit={[Function]}
77
+ quotaChangesCallback={null}
78
+ />
79
+ </Modal>
80
+ </div>
81
+ `;
@@ -2,6 +2,7 @@ import React, { useState } from 'react';
2
2
  import { Button, Modal, ModalVariant } from '@patternfly/react-core';
3
3
 
4
4
  import { translate as __ } from 'foremanReact/common/I18n';
5
+ import { getDocsURL } from 'foremanReact/common/helpers';
5
6
  import EmptyStatePattern from 'foremanReact/components/common/EmptyState/EmptyStatePattern';
6
7
 
7
8
  import ResourceQuotaForm from '../ResourceQuotaForm';
@@ -28,16 +29,32 @@ const ResourceQuotaEmptyState = () => {
28
29
  {__('Create resource quota')}
29
30
  </Button>
30
31
  );
32
+
33
+ const description = (
34
+ <span>
35
+ {__(
36
+ 'Resource Quotas help admins to manage resources including CPUs, memory, and disk space among users or user groups.'
37
+ )}
38
+ <br />
39
+ {__(
40
+ 'Define a Resource Quota here and apply it to users to guarantee a fair share of your resources.'
41
+ )}
42
+ <br />
43
+ </span>
44
+ );
45
+ const documentation = {
46
+ url: getDocsURL('Administering_Project', 'limiting-host-resources'),
47
+ };
48
+
31
49
  return (
32
50
  <div>
33
51
  <EmptyStatePattern
34
52
  icon="pficon pficon-cluster"
35
53
  iconType="pf"
36
54
  header={__('Resource Quotas')}
37
- description={__(
38
- 'Resource Quotas help admins to manage hardware resources (like CPUs, RAM, and disk space) among users or usergroups. \n\rDefine a Resource Quota here and apply it to users in order to guarantee a free share of your resources.'
39
- )}
55
+ description={description}
40
56
  action={ActionButton}
57
+ documentation={documentation}
41
58
  />
42
59
  <Modal
43
60
  ouiaId={MODAL_ID_CREATE_RESOURCE_QUOTA}
@@ -1 +1 @@
1
- @import '~@theforeman/vendor/scss/variables';
1
+ @import 'foremanReact/common/variables';
@@ -19,14 +19,14 @@ export const RESOURCE_NAME_DISK = 'Disk space';
19
19
  /* Resource units (order the units with increasing factor!) */
20
20
  export const RESOURCE_UNIT_CPU = [{ symbol: 'cores', factor: 1 }];
21
21
  export const RESOURCE_UNIT_MEMORY = [
22
- { symbol: 'MB', factor: 1 },
23
- { symbol: 'GB', factor: 1024 },
24
- { symbol: 'TB', factor: 1024 * 1024 },
22
+ { symbol: 'MiB', factor: 1 },
23
+ { symbol: 'GiB', factor: 1024 },
24
+ { symbol: 'TiB', factor: 1024 * 1024 },
25
25
  ];
26
26
  export const RESOURCE_UNIT_DISK = [
27
- { symbol: 'GB', factor: 1 },
28
- { symbol: 'TB', factor: 1024 },
29
- { symbol: 'PB', factor: 1024 * 1024 },
27
+ { symbol: 'GiB', factor: 1 },
28
+ { symbol: 'TiB', factor: 1024 },
29
+ { symbol: 'PiB', factor: 1024 * 1024 },
30
30
  ];
31
31
 
32
32
  /* Resource value bounds */
@@ -1,9 +1,10 @@
1
- @import '~@theforeman/vendor/scss/variables';
1
+ @import 'foremanReact/common/variables';
2
2
 
3
- .pf-c-card__body {
3
+
4
+ .pf-v5-c-card__body {
4
5
  padding-top: 1rem;
5
6
  }
6
7
 
7
- .pf-c-content dl {
8
+ .pf-v5-c-content dl {
8
9
  margin-bottom: 0px;
9
10
  }
@@ -34,7 +34,7 @@ const StaticDetail = ({
34
34
  {isTextArea ? (
35
35
  <TextArea
36
36
  id={id}
37
- onChange={onChange}
37
+ onChange={(_event, val) => onChange(val)}
38
38
  value={value}
39
39
  validated={validated}
40
40
  isRequired={isRequired}
@@ -42,7 +42,7 @@ const StaticDetail = ({
42
42
  ) : (
43
43
  <TextInput
44
44
  id={id}
45
- onChange={onChange}
45
+ onChange={(_event, val) => onChange(val)}
46
46
  value={value}
47
47
  validated={validated}
48
48
  isRequired={isRequired}
@@ -40,7 +40,7 @@ const TextInputField = ({
40
40
  dispatchAPICallbackToast(
41
41
  success,
42
42
  response,
43
- `Sucessfully applied ${label}.`,
43
+ `Successfully applied ${label}.`,
44
44
  `An error occurred appyling ${label}.`
45
45
  )
46
46
  );
@@ -8,9 +8,9 @@ import {
8
8
  Card,
9
9
  CardBody,
10
10
  CardHeader,
11
- CardActions,
12
11
  CardTitle,
13
- Level,
12
+ Flex,
13
+ FlexItem,
14
14
  LabelGroup,
15
15
  Button,
16
16
  Tooltip,
@@ -64,75 +64,89 @@ const Properties = ({
64
64
  dispatchAPICallbackToast(
65
65
  success,
66
66
  response,
67
- `Sucessfully fetched latest data.`,
67
+ `Successfully fetched latest data.`,
68
68
  `An error occurred fetching quota information.`
69
69
  )
70
70
  );
71
71
  };
72
72
 
73
- return (
74
- <Card>
75
- <CardHeader>
76
- {!isNewQuota && (
77
- <CardActions>
78
- <Button
79
- isLoading={isFetchLoading}
80
- icon={<SyncAltIcon />}
81
- isSmall
82
- onClick={onClickFetch}
83
- ref={tooltipRefFetchButton}
73
+ const renderSyncButton = () => {
74
+ if (isNewQuota) {
75
+ return <></>;
76
+ }
77
+ return (
78
+ <Tooltip
79
+ content={
80
+ <div>
81
+ <b> {__('Fetch quota utilization')} </b>
82
+ <div>
83
+ {__(
84
+ 'This can take some time since the resources of every host, assigned to this quota, must be requested.'
85
+ )}
86
+ </div>
87
+ </div>
88
+ }
89
+ reference={tooltipRefFetchButton}
90
+ >
91
+ <Button
92
+ isLoading={isFetchLoading}
93
+ icon={<SyncAltIcon />}
94
+ size="sm"
95
+ onClick={onClickFetch}
96
+ ref={tooltipRefFetchButton}
97
+ />
98
+ </Tooltip>
99
+ );
100
+ };
101
+
102
+ const renderHeaderTitle = () => {
103
+ if (isNewQuota) {
104
+ return <CardTitle>{__('Properties')}</CardTitle>;
105
+ }
106
+ return (
107
+ <Flex>
108
+ <FlexItem>
109
+ <CardTitle>{__('Properties')}</CardTitle>
110
+ </FlexItem>
111
+ <FlexItem>
112
+ <LabelGroup isCompact>
113
+ <StatusPropertiesLabel
114
+ color="blue"
115
+ iconChild={<ClusterIcon />}
116
+ statusContent={
117
+ statusProperties[RESOURCE_IDENTIFIER_STATUS_NUM_HOSTS]
118
+ }
119
+ linkUrl={`/hosts?search=resource_quota="${initialName}"`}
120
+ tooltipText="Number of assigned hosts"
84
121
  />
85
- <Tooltip
86
- content={
87
- <div>
88
- <b> {__('Fetch quota utilization')} </b>
89
- <div>
90
- {__(
91
- 'This can take some time since the resources of every host, assigned to this quota, must be requested.'
92
- )}
93
- </div>
94
- </div>
122
+ <StatusPropertiesLabel
123
+ color="blue"
124
+ iconChild={<UserIcon />}
125
+ statusContent={
126
+ statusProperties[RESOURCE_IDENTIFIER_STATUS_NUM_USERS]
95
127
  }
96
- reference={tooltipRefFetchButton}
128
+ linkUrl={`/users?search=resource_quota="${initialName}"`}
129
+ tooltipText="Number of assigned users"
97
130
  />
98
- </CardActions>
99
- )}
100
- {isNewQuota ? (
101
- <CardTitle>{__('Properties')}</CardTitle>
102
- ) : (
103
- <Level hasGutter>
104
- <CardTitle>{__('Properties')}</CardTitle>
105
- <LabelGroup isCompact>
106
- <StatusPropertiesLabel
107
- color="blue"
108
- iconChild={<ClusterIcon />}
109
- statusContent={
110
- statusProperties[RESOURCE_IDENTIFIER_STATUS_NUM_HOSTS]
111
- }
112
- linkUrl={`/hosts?search=resource_quota="${initialName}"`}
113
- tooltipText="Number of assigned hosts"
114
- />
115
- <StatusPropertiesLabel
116
- color="blue"
117
- iconChild={<UserIcon />}
118
- statusContent={
119
- statusProperties[RESOURCE_IDENTIFIER_STATUS_NUM_USERS]
120
- }
121
- linkUrl={`/users?search=resource_quota="${initialName}"`}
122
- tooltipText="Number of assigned users"
123
- />
124
- <StatusPropertiesLabel
125
- color="blue"
126
- iconChild={<UsersIcon />}
127
- statusContent={
128
- statusProperties[RESOURCE_IDENTIFIER_STATUS_NUM_USERGROUPS]
129
- }
130
- linkUrl={`/usergroups?search=resource_quota="${initialName}"`}
131
- tooltipText="Number of assigned usergroups"
132
- />
133
- </LabelGroup>
134
- </Level>
135
- )}
131
+ <StatusPropertiesLabel
132
+ color="blue"
133
+ iconChild={<UsersIcon />}
134
+ statusContent={
135
+ statusProperties[RESOURCE_IDENTIFIER_STATUS_NUM_USERGROUPS]
136
+ }
137
+ linkUrl={`/usergroups?search=resource_quota="${initialName}"`}
138
+ tooltipText="Number of assigned usergroups"
139
+ />
140
+ </LabelGroup>
141
+ </FlexItem>
142
+ </Flex>
143
+ );
144
+ };
145
+
146
+ return (
147
+ <Card>
148
+ <CardHeader actions={{ actions: renderSyncButton() }}>
149
+ {renderHeaderTitle()}
136
150
  </CardHeader>
137
151
  <CardBody>
138
152
  <TextContent>
@@ -1,13 +1,13 @@
1
1
  //@import '~@theforeman/vendor/scss/variables';
2
2
 
3
- .pf-c-card__body:first-child {
3
+ .pf-v5-c-card__body:first-child {
4
4
  padding-top: 1rem;
5
5
  }
6
6
 
7
- .pf-c-form__label {
8
- font-size: var(--pf-global--FontSize--sm);
7
+ .pf-v5-c-form__label {
8
+ font-size: var(--pf-v5-global--FontSize--sm);
9
9
  }
10
10
 
11
- .pf-c-form__group-label-help {
12
- font-size: var(--pf-global--FontSize--sm);
11
+ .pf-v5-c-form__group-label-help {
12
+ font-size: var(--pf-v5-global--FontSize--sm);
13
13
  }
@@ -2,16 +2,25 @@ import React, { useState, useEffect, useCallback } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import {
4
4
  FormGroup,
5
+ FormHelperText,
6
+ HelperText,
7
+ HelperTextItem,
5
8
  TextInput,
6
9
  InputGroup,
10
+ InputGroupItem,
7
11
  InputGroupText,
12
+ } from '@patternfly/react-core';
13
+ import { ExclamationCircleIcon } from '@patternfly/react-icons';
14
+
15
+ import {
8
16
  Dropdown,
9
17
  DropdownItem,
10
18
  DropdownToggle,
11
- } from '@patternfly/react-core';
19
+ } from '@patternfly/react-core/deprecated';
12
20
 
13
21
  import { sprintf, translate as __ } from 'foremanReact/common/I18n';
14
22
 
23
+ import './UnitInputField.scss';
15
24
  import { findLargestFittingUnit } from '../../../../helper';
16
25
 
17
26
  const UnitInputField = ({
@@ -60,14 +69,11 @@ const UnitInputField = ({
60
69
  }, [minValue, maxValue, selectedUnit]);
61
70
 
62
71
  /* text for float errors */
63
- const errorTextNatural = useCallback(
64
- () => __('Value must be a natural number.'),
65
- []
66
- );
72
+ const errorTextNatural = useCallback(() => __('Value must be a number.'), []);
67
73
 
68
- /* text for float errors */
69
- const errorTextFloating = useCallback(
70
- () => __(`No floating point for smallest unit (${units[0].symbol}).`),
74
+ /* text for float inputs (rounding) */
75
+ const warningTextRounded = useCallback(
76
+ roundedValue => __(`Rounding to: ${roundedValue} (${units[0].symbol}).`),
71
77
  [units]
72
78
  );
73
79
 
@@ -83,20 +89,9 @@ const UnitInputField = ({
83
89
  setErrorText(errorTextBounds());
84
90
  return false;
85
91
  }
86
- if (baseValue !== Math.floor(baseValue)) {
87
- setErrorText(errorTextFloating());
88
- return false;
89
- }
90
92
  return true;
91
93
  },
92
- [
93
- minValue,
94
- maxValue,
95
- valueToBaseUnit,
96
- errorTextNatural,
97
- errorTextBounds,
98
- errorTextFloating,
99
- ]
94
+ [minValue, maxValue, valueToBaseUnit, errorTextNatural, errorTextBounds]
100
95
  );
101
96
 
102
97
  /* applies the selected unit and returns the base-unit value */
@@ -116,9 +111,17 @@ const UnitInputField = ({
116
111
  setValidated('default');
117
112
  } else if (isValid(inputValue)) {
118
113
  const baseValue = valueToBaseUnit(inputValue);
119
- onChange(baseValue);
114
+ let validatedValue = baseValue;
115
+ if (baseValue !== Math.floor(baseValue)) {
116
+ validatedValue = Math.floor(baseValue);
117
+ setErrorText(warningTextRounded(validatedValue));
118
+ setValidated('warning');
119
+ } else {
120
+ // Keep baseValue as validatedValue
121
+ setValidated('default');
122
+ }
123
+ onChange(validatedValue);
120
124
  handleInputValidation(true);
121
- setValidated('default');
122
125
  } else {
123
126
  handleInputValidation(false);
124
127
  setValidated('error');
@@ -131,6 +134,7 @@ const UnitInputField = ({
131
134
  onChange,
132
135
  isValid,
133
136
  valueToBaseUnit,
137
+ warningTextRounded,
134
138
  ]);
135
139
 
136
140
  /* set the selected unit */
@@ -163,40 +167,81 @@ const UnitInputField = ({
163
167
  }
164
168
 
165
169
  return (
166
- <Dropdown
167
- onSelect={onUnitSelect}
168
- toggle={
169
- <DropdownToggle isDisabled={isDisabled} onToggle={onUnitToggle}>
170
- {__(`${selectedUnit.symbol}`)}
171
- </DropdownToggle>
172
- }
173
- isOpen={isUnitOpen}
174
- dropdownItems={unitDropdownItems}
175
- />
170
+ <InputGroupItem>
171
+ <Dropdown
172
+ onSelect={onUnitSelect}
173
+ toggle={
174
+ <DropdownToggle
175
+ isDisabled={isDisabled}
176
+ onToggle={(_event, _val) => onUnitToggle()}
177
+ >
178
+ {__(`${selectedUnit.symbol}`)}
179
+ </DropdownToggle>
180
+ }
181
+ isOpen={isUnitOpen}
182
+ dropdownItems={unitDropdownItems}
183
+ />
184
+ </InputGroupItem>
176
185
  );
177
186
  };
178
187
 
188
+ const renderFormHelperText = () => {
189
+ if (validated === 'error') {
190
+ return (
191
+ <FormHelperText>
192
+ <HelperText>
193
+ <HelperTextItem
194
+ icon={<ExclamationCircleIcon />}
195
+ variant={validated}
196
+ >
197
+ {errorText}
198
+ </HelperTextItem>
199
+ </HelperText>
200
+ </FormHelperText>
201
+ );
202
+ }
203
+ if (validated === 'warning') {
204
+ return (
205
+ <FormHelperText>
206
+ <HelperText>
207
+ <HelperTextItem
208
+ icon={<ExclamationCircleIcon />}
209
+ variant={validated}
210
+ >
211
+ {errorText}
212
+ </HelperTextItem>
213
+ </HelperText>
214
+ </FormHelperText>
215
+ );
216
+ }
217
+ return <></>;
218
+ };
219
+
179
220
  return (
180
- <FormGroup
181
- label={__('Quota Limit')}
182
- validated={validated}
183
- helperTextInvalid={errorText}
184
- fieldId="quota-limit-resource-quota-form-group"
185
- labelIcon={labelIcon || {}}
186
- >
187
- <InputGroup>
188
- <TextInput
189
- isDisabled={isDisabled}
190
- value={inputValue}
191
- min={minValue}
192
- max={maxValue}
193
- validated={validated}
194
- id="reg_token_life_time_input"
195
- onChange={setInputValue}
196
- />
197
- {unitView()}
198
- </InputGroup>
199
- </FormGroup>
221
+ <div className="container-unit-input-field">
222
+ <FormGroup
223
+ label={__('Quota Limit')}
224
+ validated={validated}
225
+ fieldId="quota-limit-resource-quota-form-group"
226
+ labelIcon={labelIcon || {}}
227
+ >
228
+ <InputGroup>
229
+ <InputGroupItem>
230
+ <TextInput
231
+ isDisabled={isDisabled}
232
+ value={inputValue}
233
+ min={minValue}
234
+ max={maxValue}
235
+ validated={validated}
236
+ id="reg_token_life_time_input"
237
+ onChange={(_event, val) => setInputValue(val)}
238
+ />
239
+ </InputGroupItem>
240
+ {unitView()}
241
+ </InputGroup>
242
+ {renderFormHelperText()}
243
+ </FormGroup>
244
+ </div>
200
245
  );
201
246
  };
202
247
 
@@ -0,0 +1,7 @@
1
+ @import 'foremanReact/common/variables';
2
+
3
+ .container-unit-input-field {
4
+ .pf-v5-c-input-group__text {
5
+ word-break: keep-all;
6
+ }
7
+ }
@@ -7,7 +7,7 @@ import {
7
7
  ProgressMeasureLocation,
8
8
  Tooltip,
9
9
  } from '@patternfly/react-core';
10
- import SyncAltIcon from '@patternfly/react-icons';
10
+ import { SyncAltIcon } from '@patternfly/react-icons';
11
11
 
12
12
  import { translate as __ } from 'foremanReact/common/I18n';
13
13
 
@@ -1,10 +1,10 @@
1
1
  .progress-disabled {
2
2
  background-color: transparent;
3
- .pf-c-progress .pf-c-progress__bar::before {
4
- background-color: var(--pf-global--disabled-color--100);
3
+ .pf-v5-c-progress .pf-v5-c-progress__bar::before {
4
+ background-color: var(--pf-v5-global--disabled-color--100);
5
5
  }
6
6
  }
7
7
 
8
- .progress-disabled .pf-c-progress.pf-m-inside .pf-c-progress__indicator {
9
- background-color: var(--pf-global--palette--black-500);
8
+ .progress-disabled .pf-v5-c-progress.pf-v5-m-inside .pf-v5-c-progress__indicator {
9
+ background-color: var(--pf-v5-global--palette--black-500);
10
10
  }