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.
- checksums.yaml +4 -4
- data/README.md +13 -6
- data/app/assets/javascripts/foreman_resource_quota/locale/bn/foreman_resource_quota.js +213 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/bn_IN/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/bqi/foreman_resource_quota.js +213 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/ca/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/cs_CZ/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/de/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/de_AT/foreman_resource_quota.js +213 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/de_DE/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/el/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/en/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/en_GB/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/en_US/foreman_resource_quota.js +213 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/es/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/et_EE/foreman_resource_quota.js +213 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/fr/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/gl/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/gu/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/he_IL/foreman_resource_quota.js +213 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/hi/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/id/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/it/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/ja/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/ka/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/kn/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/ko/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/ml_IN/foreman_resource_quota.js +213 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/mr/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/nl_NL/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/or/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/pa/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/pl/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/pl_PL/foreman_resource_quota.js +213 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/pt/foreman_resource_quota.js +213 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/pt_BR/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/ro/foreman_resource_quota.js +213 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/ro_RO/foreman_resource_quota.js +213 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/ru/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/sl/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/sv_SE/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/ta/foreman_resource_quota.js +213 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/ta_IN/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/te/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/tr/foreman_resource_quota.js +213 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/vi/foreman_resource_quota.js +213 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/vi_VN/foreman_resource_quota.js +213 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/zh/foreman_resource_quota.js +213 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/zh_CN/foreman_resource_quota.js +214 -0
- data/app/assets/javascripts/foreman_resource_quota/locale/zh_TW/foreman_resource_quota.js +214 -0
- data/app/controllers/foreman_resource_quota/api/v2/resource_quotas_controller.rb +17 -10
- data/app/controllers/foreman_resource_quota/concerns/api/v2/hosts_controller_extensions.rb +20 -0
- data/app/controllers/foreman_resource_quota/concerns/api/v2/usergroups_controller_extensions.rb +19 -0
- data/app/controllers/foreman_resource_quota/concerns/api/v2/users_controller_extensions.rb +22 -0
- data/app/models/concerns/foreman_resource_quota/host_managed_extensions.rb +9 -7
- data/app/views/foreman_resource_quota/api/v2/users/resource_quota.json.rabl +1 -1
- data/app/views/foreman_resource_quota/resource_quotas/index.html.erb +1 -1
- data/config/initializers/inflections.rb +1 -0
- data/lib/foreman_resource_quota/engine.rb +8 -1
- data/lib/foreman_resource_quota/register.rb +4 -2
- data/lib/foreman_resource_quota/version.rb +1 -1
- data/lib/tasks/foreman_resource_quota_tasks.rake +3 -3
- data/locale/Makefile +19 -6
- data/locale/bn/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/bn/foreman_resource_quota.po +214 -0
- data/locale/bn_IN/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/bn_IN/foreman_resource_quota.po +219 -0
- data/locale/bqi/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/bqi/foreman_resource_quota.po +215 -0
- data/locale/ca/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/ca/foreman_resource_quota.po +218 -0
- data/locale/cs_CZ/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/cs_CZ/foreman_resource_quota.po +221 -0
- data/locale/de/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/de/foreman_resource_quota.po +223 -0
- data/locale/de_AT/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/de_AT/foreman_resource_quota.po +215 -0
- data/locale/de_DE/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/de_DE/foreman_resource_quota.po +219 -0
- data/locale/el/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/el/foreman_resource_quota.po +218 -0
- data/locale/en/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/en/foreman_resource_quota.po +207 -9
- data/locale/en_GB/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/en_GB/foreman_resource_quota.po +220 -0
- data/locale/en_US/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/en_US/foreman_resource_quota.po +215 -0
- data/locale/es/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/es/foreman_resource_quota.po +223 -0
- data/locale/et_EE/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/et_EE/foreman_resource_quota.po +215 -0
- data/locale/foreman_resource_quota.pot +322 -8
- data/locale/fr/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/fr/foreman_resource_quota.po +222 -0
- data/locale/gl/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/gl/foreman_resource_quota.po +218 -0
- data/locale/gu/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/gu/foreman_resource_quota.po +218 -0
- data/locale/he_IL/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/he_IL/foreman_resource_quota.po +216 -0
- data/locale/hi/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/hi/foreman_resource_quota.po +218 -0
- data/locale/id/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/id/foreman_resource_quota.po +218 -0
- data/locale/it/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/it/foreman_resource_quota.po +221 -0
- data/locale/ja/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/ja/foreman_resource_quota.po +219 -0
- data/locale/ka/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/ka/foreman_resource_quota.po +218 -0
- data/locale/kn/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/kn/foreman_resource_quota.po +218 -0
- data/locale/ko/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/ko/foreman_resource_quota.po +220 -0
- data/locale/ml_IN/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/ml_IN/foreman_resource_quota.po +215 -0
- data/locale/mr/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/mr/foreman_resource_quota.po +218 -0
- data/locale/nl_NL/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/nl_NL/foreman_resource_quota.po +223 -0
- data/locale/or/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/or/foreman_resource_quota.po +218 -0
- data/locale/pa/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/pa/foreman_resource_quota.po +219 -0
- data/locale/pl/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/pl/foreman_resource_quota.po +221 -0
- data/locale/pl_PL/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/pl_PL/foreman_resource_quota.po +217 -0
- data/locale/pt/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/pt/foreman_resource_quota.po +215 -0
- data/locale/pt_BR/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/pt_BR/foreman_resource_quota.po +222 -0
- data/locale/ro/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/ro/foreman_resource_quota.po +215 -0
- data/locale/ro_RO/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/ro_RO/foreman_resource_quota.po +216 -0
- data/locale/ru/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/ru/foreman_resource_quota.po +222 -0
- data/locale/sl/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/sl/foreman_resource_quota.po +219 -0
- data/locale/sv_SE/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/sv_SE/foreman_resource_quota.po +221 -0
- data/locale/ta/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/ta/foreman_resource_quota.po +214 -0
- data/locale/ta_IN/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/ta_IN/foreman_resource_quota.po +219 -0
- data/locale/te/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/te/foreman_resource_quota.po +218 -0
- data/locale/tr/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/tr/foreman_resource_quota.po +214 -0
- data/locale/vi/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/vi/foreman_resource_quota.po +214 -0
- data/locale/vi_VN/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/vi_VN/foreman_resource_quota.po +215 -0
- data/locale/zh/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/zh/foreman_resource_quota.po +214 -0
- data/locale/zh_CN/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/zh_CN/foreman_resource_quota.po +221 -0
- data/locale/zh_TW/LC_MESSAGES/foreman_resource_quota.mo +0 -0
- data/locale/zh_TW/foreman_resource_quota.po +220 -0
- data/package.json +10 -10
- data/webpack/components/ResourceQuotaEmptyState/__test__/ResourceQuotaEmptyState.test.js +35 -0
- data/webpack/components/ResourceQuotaEmptyState/__test__/__snapshots__/ResourceQuotaEmptyState.test.js.snap +81 -0
- data/webpack/components/ResourceQuotaEmptyState/index.js +20 -3
- data/webpack/components/ResourceQuotaForm/ResourceQuotaForm.scss +1 -1
- data/webpack/components/ResourceQuotaForm/ResourceQuotaFormConstants.js +6 -6
- data/webpack/components/ResourceQuotaForm/components/Properties/Properties.scss +4 -3
- data/webpack/components/ResourceQuotaForm/components/Properties/StaticDetail.js +2 -2
- data/webpack/components/ResourceQuotaForm/components/Properties/TextInputField.js +1 -1
- data/webpack/components/ResourceQuotaForm/components/Properties/index.js +77 -63
- data/webpack/components/ResourceQuotaForm/components/Resource/Resource.scss +5 -5
- data/webpack/components/ResourceQuotaForm/components/Resource/UnitInputField.js +97 -52
- data/webpack/components/ResourceQuotaForm/components/Resource/UnitInputField.scss +7 -0
- data/webpack/components/ResourceQuotaForm/components/Resource/UtilizationProgress.js +1 -1
- data/webpack/components/ResourceQuotaForm/components/Resource/UtilizationProgress.scss +4 -4
- data/webpack/components/ResourceQuotaForm/components/Resource/__test__/UnitInputField.test.js +108 -0
- data/webpack/components/ResourceQuotaForm/components/Resource/__test__/__snapshots__/UnitInputField.test.js.snap +153 -0
- data/webpack/components/ResourceQuotaForm/components/Resource/index.js +25 -18
- data/webpack/components/ResourceQuotaForm/components/Submit.js +1 -1
- data/webpack/lib/ActionableDetail.scss +1 -1
- data/webpack/lib/EditableSwitch.js +1 -1
- data/webpack/lib/EditableTextInput/EditableTextInput.js +81 -77
- data/webpack/lib/EditableTextInput/editableTextInput.scss +30 -28
- data/webpack/test_helper.js +49 -0
- 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 '
|
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: '
|
23
|
-
{ symbol: '
|
24
|
-
{ symbol: '
|
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: '
|
28
|
-
{ symbol: '
|
29
|
-
{ symbol: '
|
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 */
|
@@ -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}
|
@@ -8,9 +8,9 @@ import {
|
|
8
8
|
Card,
|
9
9
|
CardBody,
|
10
10
|
CardHeader,
|
11
|
-
CardActions,
|
12
11
|
CardTitle,
|
13
|
-
|
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
|
-
`
|
67
|
+
`Successfully fetched latest data.`,
|
68
68
|
`An error occurred fetching quota information.`
|
69
69
|
)
|
70
70
|
);
|
71
71
|
};
|
72
72
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
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
|
-
<
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
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
|
-
|
128
|
+
linkUrl={`/users?search=resource_quota="${initialName}"`}
|
129
|
+
tooltipText="Number of assigned users"
|
97
130
|
/>
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
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
|
69
|
-
const
|
70
|
-
|
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
|
-
|
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
|
-
<
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
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
|
-
<
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
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
|
|
@@ -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
|
}
|