foreman_resource_quota 0.4.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46b1ed89e58274a5cfb37c6c32544151202c8b80e921560e5617cb132f5b7188
4
- data.tar.gz: b04271957baf9f86d79281f0b5834733349fe09163d3ccdd4136d19644c396e1
3
+ metadata.gz: cf7fe8ad234e899887460b9e87041b4e2d05f6eaad6540a9567110326dc6ec7b
4
+ data.tar.gz: 100ee9af0fd01a0f7d026cafaae6ef1faf9b1e2897952bdb935ae896ed948dca
5
5
  SHA512:
6
- metadata.gz: 96e7878190f41b66998e8c2f58412e5b4b5db2bd89271b4c42760c1d5894eff7d0dcf5890d9ff9f1231cb3e972e5cc4066b26cfd90899652122a854ebcfe2d74
7
- data.tar.gz: b14c3f7584293897ad9d558ff27ed89f9f1fc24b41c3820e6aca8e961ad02016d23fce9aabd8562b9ebbdf5bb59fd17f3a466ec059370fefa189c5abbae3092c
6
+ metadata.gz: 8511f2e3460efa522ced8b3759555755fc2e4bd44613f68d74266a103a32bc54beafe75982ad58d9263264fd1c77102b44f0eb9564abdf4c972813f7ecbd4135
7
+ data.tar.gz: 5bd4034854f07d0cc7600864c84904a9295c49f4f0142880c6c5c37855d9fd3b77834dad065fdcf1ffc481a7a2dc7a40c5724e8861896352e349c72440f0c2e6
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ForemanResourceQuota
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.0'
5
5
  end
data/package.json CHANGED
@@ -28,11 +28,11 @@
28
28
  "@sheerun/mutationobserver-shim": "^0.3.3",
29
29
  "@testing-library/react": "^16.2.0",
30
30
  "@testing-library/user-event": "^14.6.1",
31
- "@theforeman/builder": ">= 12.0.1",
32
- "@theforeman/eslint-plugin-foreman": ">= 12.0.1",
33
- "@theforeman/find-foreman": ">= 12.0.1",
34
- "@theforeman/test": ">= 12.0.1",
35
- "@theforeman/vendor-dev": ">= 12.0.1",
31
+ "@theforeman/builder": ">= 15.0.0",
32
+ "@theforeman/eslint-plugin-foreman": ">= 15.0.0",
33
+ "@theforeman/find-foreman": ">= 15.0.0",
34
+ "@theforeman/test": ">= 15.0.0",
35
+ "@theforeman/vendor-dev": ">= 15.0.0",
36
36
  "babel-eslint": "^10.0.3",
37
37
  "eslint": "^6.7.2",
38
38
  "prettier": "^1.19.1",
@@ -42,6 +42,7 @@ exports[`ResourceQuotaEmptyState should render 1`] = `
42
42
  onClose={[Function]}
43
43
  ouiaId="foreman-resource-quota-create-modal"
44
44
  ouiaSafe={true}
45
+ position="default"
45
46
  showClose={true}
46
47
  title="Create resource quota"
47
48
  titleIconVariant={null}
@@ -1 +1 @@
1
- @import '~@theforeman/vendor/scss/variables';
1
+ @import 'foremanReact/common/variables';
@@ -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}
@@ -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,
@@ -70,69 +70,83 @@ const Properties = ({
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
  }
@@ -3,16 +3,24 @@ import PropTypes from 'prop-types';
3
3
  import {
4
4
  FormGroup,
5
5
  FormHelperText,
6
+ HelperText,
7
+ HelperTextItem,
6
8
  TextInput,
7
9
  InputGroup,
10
+ InputGroupItem,
8
11
  InputGroupText,
12
+ } from '@patternfly/react-core';
13
+ import { ExclamationCircleIcon } from '@patternfly/react-icons';
14
+
15
+ import {
9
16
  Dropdown,
10
17
  DropdownItem,
11
18
  DropdownToggle,
12
- } from '@patternfly/react-core';
19
+ } from '@patternfly/react-core/deprecated';
13
20
 
14
21
  import { sprintf, translate as __ } from 'foremanReact/common/I18n';
15
22
 
23
+ import './UnitInputField.scss';
16
24
  import { findLargestFittingUnit } from '../../../../helper';
17
25
 
18
26
  const UnitInputField = ({
@@ -69,11 +77,6 @@ const UnitInputField = ({
69
77
  [units]
70
78
  );
71
79
 
72
- /* warning text displayed beneath value input field (built-in is used for errors) */
73
- const helperTextWarning = (text, isHidden) => (
74
- <FormHelperText isHidden={isHidden}>{text}</FormHelperText>
75
- );
76
-
77
80
  /* applies the selected unit and checks the bounds */
78
81
  const isValid = useCallback(
79
82
  val => {
@@ -164,41 +167,81 @@ const UnitInputField = ({
164
167
  }
165
168
 
166
169
  return (
167
- <Dropdown
168
- onSelect={onUnitSelect}
169
- toggle={
170
- <DropdownToggle isDisabled={isDisabled} onToggle={onUnitToggle}>
171
- {__(`${selectedUnit.symbol}`)}
172
- </DropdownToggle>
173
- }
174
- isOpen={isUnitOpen}
175
- dropdownItems={unitDropdownItems}
176
- />
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>
177
185
  );
178
186
  };
179
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
+
180
220
  return (
181
- <FormGroup
182
- label={__('Quota Limit')}
183
- validated={validated}
184
- helperTextInvalid={errorText}
185
- helperText={helperTextWarning(errorText, validated !== 'warning')}
186
- fieldId="quota-limit-resource-quota-form-group"
187
- labelIcon={labelIcon || {}}
188
- >
189
- <InputGroup>
190
- <TextInput
191
- isDisabled={isDisabled}
192
- value={inputValue}
193
- min={minValue}
194
- max={maxValue}
195
- validated={validated}
196
- id="reg_token_life_time_input"
197
- onChange={setInputValue}
198
- />
199
- {unitView()}
200
- </InputGroup>
201
- </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>
202
245
  );
203
246
  };
204
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
  }
@@ -1,155 +1,153 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`UnitInputField should render as disabled field 1`] = `
4
- <FormGroup
5
- fieldId="quota-limit-resource-quota-form-group"
6
- helperText={
7
- <FormHelperText
8
- isHidden={true}
9
- >
10
-
11
- </FormHelperText>
12
- }
13
- helperTextInvalid=""
14
- label="Quota Limit"
15
- labelIcon={
16
- <LabelIcon
17
- text="Descriptive title."
18
- />
19
- }
20
- validated="default"
4
+ <div
5
+ className="container-unit-input-field"
21
6
  >
22
- <InputGroup>
23
- <TextInput
24
- id="reg_token_life_time_input"
25
- isDisabled={true}
26
- max={5}
27
- min={0}
28
- onChange={[Function]}
29
- validated="default"
30
- value={0}
31
- />
32
- <Dropdown
33
- dropdownItems={
34
- Array [
35
- <DropdownItem
36
- id="unit-dropdownitem-mib"
37
- >
38
- MiB
39
- </DropdownItem>,
40
- <DropdownItem
41
- id="unit-dropdownitem-gib"
42
- >
43
- GiB
44
- </DropdownItem>,
45
- ]
46
- }
47
- isOpen={false}
48
- onSelect={[Function]}
49
- toggle={
50
- <DropdownToggle
7
+ <FormGroup
8
+ fieldId="quota-limit-resource-quota-form-group"
9
+ label="Quota Limit"
10
+ labelIcon={
11
+ <LabelIcon
12
+ text="Descriptive title."
13
+ />
14
+ }
15
+ validated="default"
16
+ >
17
+ <InputGroup>
18
+ <InputGroupItem>
19
+ <TextInput
20
+ id="reg_token_life_time_input"
51
21
  isDisabled={true}
52
- onToggle={[Function]}
53
- >
54
- MiB
55
- </DropdownToggle>
56
- }
57
- />
58
- </InputGroup>
59
- </FormGroup>
22
+ max={5}
23
+ min={0}
24
+ onChange={[Function]}
25
+ validated="default"
26
+ value={0}
27
+ />
28
+ </InputGroupItem>
29
+ <InputGroupItem>
30
+ <Dropdown
31
+ dropdownItems={
32
+ Array [
33
+ <DropdownItem
34
+ id="unit-dropdownitem-mib"
35
+ >
36
+ MiB
37
+ </DropdownItem>,
38
+ <DropdownItem
39
+ id="unit-dropdownitem-gib"
40
+ >
41
+ GiB
42
+ </DropdownItem>,
43
+ ]
44
+ }
45
+ isOpen={false}
46
+ onSelect={[Function]}
47
+ toggle={
48
+ <DropdownToggle
49
+ isDisabled={true}
50
+ onToggle={[Function]}
51
+ >
52
+ MiB
53
+ </DropdownToggle>
54
+ }
55
+ />
56
+ </InputGroupItem>
57
+ </InputGroup>
58
+ </FormGroup>
59
+ </div>
60
60
  `;
61
61
 
62
62
  exports[`UnitInputField should render default 1`] = `
63
- <FormGroup
64
- fieldId="quota-limit-resource-quota-form-group"
65
- helperText={
66
- <FormHelperText
67
- isHidden={true}
68
- >
69
-
70
- </FormHelperText>
71
- }
72
- helperTextInvalid=""
73
- label="Quota Limit"
74
- labelIcon={
75
- <LabelIcon
76
- text="Descriptive title."
77
- />
78
- }
79
- validated="default"
63
+ <div
64
+ className="container-unit-input-field"
80
65
  >
81
- <InputGroup>
82
- <TextInput
83
- id="reg_token_life_time_input"
84
- isDisabled={false}
85
- max={5}
86
- min={0}
87
- onChange={[Function]}
88
- validated="default"
89
- value={0}
90
- />
91
- <Dropdown
92
- dropdownItems={
93
- Array [
94
- <DropdownItem
95
- id="unit-dropdownitem-mib"
96
- >
97
- MiB
98
- </DropdownItem>,
99
- <DropdownItem
100
- id="unit-dropdownitem-gib"
101
- >
102
- GiB
103
- </DropdownItem>,
104
- ]
105
- }
106
- isOpen={false}
107
- onSelect={[Function]}
108
- toggle={
109
- <DropdownToggle
66
+ <FormGroup
67
+ fieldId="quota-limit-resource-quota-form-group"
68
+ label="Quota Limit"
69
+ labelIcon={
70
+ <LabelIcon
71
+ text="Descriptive title."
72
+ />
73
+ }
74
+ validated="default"
75
+ >
76
+ <InputGroup>
77
+ <InputGroupItem>
78
+ <TextInput
79
+ id="reg_token_life_time_input"
110
80
  isDisabled={false}
111
- onToggle={[Function]}
112
- >
113
- MiB
114
- </DropdownToggle>
115
- }
116
- />
117
- </InputGroup>
118
- </FormGroup>
81
+ max={5}
82
+ min={0}
83
+ onChange={[Function]}
84
+ validated="default"
85
+ value={0}
86
+ />
87
+ </InputGroupItem>
88
+ <InputGroupItem>
89
+ <Dropdown
90
+ dropdownItems={
91
+ Array [
92
+ <DropdownItem
93
+ id="unit-dropdownitem-mib"
94
+ >
95
+ MiB
96
+ </DropdownItem>,
97
+ <DropdownItem
98
+ id="unit-dropdownitem-gib"
99
+ >
100
+ GiB
101
+ </DropdownItem>,
102
+ ]
103
+ }
104
+ isOpen={false}
105
+ onSelect={[Function]}
106
+ toggle={
107
+ <DropdownToggle
108
+ isDisabled={false}
109
+ onToggle={[Function]}
110
+ >
111
+ MiB
112
+ </DropdownToggle>
113
+ }
114
+ />
115
+ </InputGroupItem>
116
+ </InputGroup>
117
+ </FormGroup>
118
+ </div>
119
119
  `;
120
120
 
121
121
  exports[`UnitInputField should render without dropdown (single unit) 1`] = `
122
- <FormGroup
123
- fieldId="quota-limit-resource-quota-form-group"
124
- helperText={
125
- <FormHelperText
126
- isHidden={true}
127
- >
128
-
129
- </FormHelperText>
130
- }
131
- helperTextInvalid=""
132
- label="Quota Limit"
133
- labelIcon={
134
- <LabelIcon
135
- text="Descriptive title."
136
- />
137
- }
138
- validated="default"
122
+ <div
123
+ className="container-unit-input-field"
139
124
  >
140
- <InputGroup>
141
- <TextInput
142
- id="reg_token_life_time_input"
143
- isDisabled={false}
144
- max={5}
145
- min={0}
146
- onChange={[Function]}
147
- validated="default"
148
- value={0}
149
- />
150
- <InputGroupText>
151
- cores
152
- </InputGroupText>
153
- </InputGroup>
154
- </FormGroup>
125
+ <FormGroup
126
+ fieldId="quota-limit-resource-quota-form-group"
127
+ label="Quota Limit"
128
+ labelIcon={
129
+ <LabelIcon
130
+ text="Descriptive title."
131
+ />
132
+ }
133
+ validated="default"
134
+ >
135
+ <InputGroup>
136
+ <InputGroupItem>
137
+ <TextInput
138
+ id="reg_token_life_time_input"
139
+ isDisabled={false}
140
+ max={5}
141
+ min={0}
142
+ onChange={[Function]}
143
+ validated="default"
144
+ value={0}
145
+ />
146
+ </InputGroupItem>
147
+ <InputGroupText>
148
+ cores
149
+ </InputGroupText>
150
+ </InputGroup>
151
+ </FormGroup>
152
+ </div>
155
153
  `;
@@ -4,7 +4,6 @@ import { useDispatch } from 'react-redux';
4
4
  import {
5
5
  Button,
6
6
  Card,
7
- CardActions,
8
7
  CardExpandableContent,
9
8
  CardHeader,
10
9
  CardTitle,
@@ -132,19 +131,41 @@ const Resource = ({
132
131
  onChange,
133
132
  ]);
134
133
 
134
+ const renderApplyButton = () => {
135
+ if (isNewQuota) {
136
+ return <></>;
137
+ }
138
+ return (
139
+ <Button
140
+ isDisabled={!isUpdateApplicable}
141
+ size="sm"
142
+ isActive={isApplyLoading}
143
+ variant="primary"
144
+ onClick={onClickApply}
145
+ isLoading={isApplyLoading}
146
+ >
147
+ {__('Apply')}
148
+ </Button>
149
+ );
150
+ };
151
+
135
152
  return (
136
153
  <Card
137
154
  isExpanded={isExpanded}
138
155
  isDisabledRaised={!isEnabled}
139
156
  id={`resource-card-${cardId}`}
140
157
  >
141
- <CardHeader onExpand={onExpand} isToggleRightAligned={false}>
158
+ <CardHeader
159
+ actions={{ actions: renderApplyButton() }}
160
+ onExpand={onExpand}
161
+ isToggleRightAligned={false}
162
+ >
142
163
  <Flex>
143
164
  <FlexItem>
144
165
  <Switch
145
166
  id={`switch-${cardId}`}
146
167
  aria-label={`switch-${cardId}`}
147
- onChange={onChangeEnabled}
168
+ onChange={(_event, val) => onChangeEnabled(val)}
148
169
  isChecked={isEnabled}
149
170
  />
150
171
  </FlexItem>
@@ -152,20 +173,6 @@ const Resource = ({
152
173
  <CardTitle>{resourceTitle}</CardTitle>
153
174
  </FlexItem>
154
175
  </Flex>
155
- {!isNewQuota && (
156
- <CardActions>
157
- <Button
158
- isDisabled={!isUpdateApplicable}
159
- isSmall
160
- isActive={isApplyLoading}
161
- variant="primary"
162
- onClick={onClickApply}
163
- isLoading={isApplyLoading}
164
- >
165
- {__('Apply')}
166
- </Button>
167
- </CardActions>
168
- )}
169
176
  </CardHeader>
170
177
  <CardExpandableContent>
171
178
  <CardBody>
@@ -1,4 +1,4 @@
1
1
 
2
2
  dt {
3
- font-size: var(--pf-global--FontSize--sm);
3
+ font-size: var(--pf-v5-global--FontSize--sm);
4
4
  }
@@ -23,7 +23,7 @@ const EditableSwitch = ({
23
23
  aria-label={identifier}
24
24
  ouiaId={`switch-${identifier}`}
25
25
  isChecked={value}
26
- onChange={onSwitch}
26
+ onChange={(_event, val) => onSwitch(val)}
27
27
  disabled={disabled}
28
28
  />
29
29
  );
@@ -89,87 +89,91 @@ const EditableTextInput = ({
89
89
  onKeyUp,
90
90
  component,
91
91
  value: inputValue || '',
92
- onChange: setInputValue,
92
+ onChange: (_event, val) => setInputValue(val),
93
93
  validated: valid,
94
94
  };
95
95
 
96
- return editing ? (
97
- <Split>
98
- <SplitItem>
99
- {textArea ? (
100
- <TextArea {...inputProps} aria-label={`${attribute} text area`} />
101
- ) : (
102
- <TextInput
103
- {...inputProps}
104
- type={isPassword && !showPassword ? 'password' : 'text'}
105
- aria-label={`${attribute} text input`}
106
- ouiaId={ouiaId}
107
- />
108
- )}
109
- </SplitItem>
110
- <SplitItem>
111
- <Button
112
- ouiaId={`submit-button-${attribute}`}
113
- aria-label={`submit ${attribute}`}
114
- variant="plain"
115
- onClick={onSubmit}
116
- >
117
- <CheckIcon />
118
- </Button>
119
- </SplitItem>
120
- <SplitItem>
121
- <Button
122
- ouiaId={`clear-button-${attribute}`}
123
- aria-label={`clear ${attribute}`}
124
- variant="plain"
125
- onClick={onClear}
126
- >
127
- <TimesIcon />
128
- </Button>
129
- </SplitItem>
130
- {isPassword ? (
131
- <SplitItem>
132
- <Button
133
- ouiaId={`show-button-${attribute}`}
134
- aria-label={`show-password ${attribute}`}
135
- variant="plain"
136
- isDisabled={!inputValue?.length}
137
- onClick={toggleShowPassword}
138
- >
139
- {showPassword ? <EyeSlashIcon /> : <EyeIcon />}
140
- </Button>
141
- </SplitItem>
142
- ) : null}
143
- </Split>
144
- ) : (
145
- <Split>
146
- <SplitItem>
147
- {inputValue ? (
148
- <Text
149
- className={`text${textArea ? 'Area' : 'Input'}-value`}
150
- ouiaId={`${attribute}-text-value`}
151
- aria-label={`${attribute} text value`}
152
- component={component}
153
- >
154
- {editing ? inputValue : passwordPlaceholder || inputValue}
155
- </Text>
156
- ) : (
157
- <Text
158
- className={`text${textArea ? 'Area' : 'Input'}-placeholder`}
159
- ouiaId={`${attribute}-text-value`}
160
- aria-label={`${attribute} text value`}
161
- component={component}
162
- >
163
- {passwordPlaceholder || placeholder}
164
- </Text>
165
- )}
166
- </SplitItem>
167
- {!disabled && (
168
- <SplitItem>
169
- <PencilEditButton {...{ attribute, onEditClick }} />
170
- </SplitItem>
96
+ return (
97
+ <div className="container-editable-text-input">
98
+ {editing ? (
99
+ <Split>
100
+ <SplitItem>
101
+ {textArea ? (
102
+ <TextArea {...inputProps} aria-label={`${attribute} text area`} />
103
+ ) : (
104
+ <TextInput
105
+ {...inputProps}
106
+ type={isPassword && !showPassword ? 'password' : 'text'}
107
+ aria-label={`${attribute} text input`}
108
+ ouiaId={ouiaId}
109
+ />
110
+ )}
111
+ </SplitItem>
112
+ <SplitItem>
113
+ <Button
114
+ ouiaId={`submit-button-${attribute}`}
115
+ aria-label={`submit ${attribute}`}
116
+ variant="plain"
117
+ onClick={onSubmit}
118
+ >
119
+ <CheckIcon />
120
+ </Button>
121
+ </SplitItem>
122
+ <SplitItem>
123
+ <Button
124
+ ouiaId={`clear-button-${attribute}`}
125
+ aria-label={`clear ${attribute}`}
126
+ variant="plain"
127
+ onClick={onClear}
128
+ >
129
+ <TimesIcon />
130
+ </Button>
131
+ </SplitItem>
132
+ {isPassword ? (
133
+ <SplitItem>
134
+ <Button
135
+ ouiaId={`show-button-${attribute}`}
136
+ aria-label={`show-password ${attribute}`}
137
+ variant="plain"
138
+ isDisabled={!inputValue?.length}
139
+ onClick={toggleShowPassword}
140
+ >
141
+ {showPassword ? <EyeSlashIcon /> : <EyeIcon />}
142
+ </Button>
143
+ </SplitItem>
144
+ ) : null}
145
+ </Split>
146
+ ) : (
147
+ <Split>
148
+ <SplitItem>
149
+ {inputValue ? (
150
+ <Text
151
+ className={`text${textArea ? 'Area' : 'Input'}-value`}
152
+ ouiaId={`${attribute}-text-value`}
153
+ aria-label={`${attribute} text value`}
154
+ component={component}
155
+ >
156
+ {editing ? inputValue : passwordPlaceholder || inputValue}
157
+ </Text>
158
+ ) : (
159
+ <Text
160
+ className={`text${textArea ? 'Area' : 'Input'}-placeholder`}
161
+ ouiaId={`${attribute}-text-value`}
162
+ aria-label={`${attribute} text value`}
163
+ component={component}
164
+ >
165
+ {passwordPlaceholder || placeholder}
166
+ </Text>
167
+ )}
168
+ </SplitItem>
169
+ {!disabled && (
170
+ <SplitItem>
171
+ <PencilEditButton {...{ attribute, onEditClick }} />
172
+ </SplitItem>
173
+ )}
174
+ </Split>
171
175
  )}
172
- </Split>
176
+ </div>
173
177
  );
174
178
  };
175
179
 
@@ -1,38 +1,40 @@
1
1
  /* Credits: https://github.com/Katello/katello/blob/631d5bb83dc5d87320ee9002a6de33809a281b3e/webpack/components/EditableTextInput/editableTextInput.scss */
2
- @import '~@theforeman/vendor/scss/variables';
2
+ @import 'foremanReact/common/variables';
3
3
 
4
- .foreman-limited-text {
5
- max-width: 200px;
6
- margin: auto 0px;
7
- }
4
+ .container-editable-text-input {
5
+ .foreman-limited-text {
6
+ max-width: 200px;
7
+ margin: auto 0px;
8
+ }
8
9
 
9
- .foreman-limited-editable-text {
10
- max-width: 300px;
11
- margin: auto 0px;
12
- }
10
+ .foreman-limited-editable-text {
11
+ max-width: 300px;
12
+ margin: auto 0px;
13
+ }
13
14
 
14
- // Edit icon isn't in line with text
15
- .foreman-edit-icon {
16
- padding-top: 2px;
17
- }
15
+ // Edit icon isn't in line with text
16
+ .foreman-edit-icon {
17
+ padding-top: 2px;
18
+ }
18
19
 
19
- .textInput-placeholder, .textArea-placeholder {
20
- color: var(--pf-global--disabled-color--100);
21
- }
20
+ .textInput-placeholder, .textArea-placeholder {
21
+ color: var(--pf-v5-global--disabled-color--100);
22
+ }
22
23
 
23
- textarea.pf-c-form-control {
24
- width: 215px;
25
- }
24
+ textarea.pf-v5-c-form-control {
25
+ width: 215px;
26
+ }
26
27
 
27
- .pf-c-form-control:not(textarea) {
28
- width: 215px;
29
- }
28
+ .pf-v5-c-form-control:not(textarea) {
29
+ width: 215px;
30
+ }
30
31
 
31
- p {
32
- width: 215px;
33
- }
32
+ p {
33
+ width: 215px;
34
+ }
34
35
 
35
- p.textArea-placeholder, p.textArea-value {
36
- width: 215px;
37
- height: 50px;
36
+ p.textArea-placeholder, p.textArea-value {
37
+ width: 215px;
38
+ height: 50px;
39
+ }
38
40
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_resource_quota
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bastian Schmidt
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '10.0'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '11'
22
+ version: '12'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '10.0'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '11'
32
+ version: '12'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: theforeman-rubocop
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -276,6 +276,7 @@ files:
276
276
  - webpack/components/ResourceQuotaForm/components/QuotaState.js
277
277
  - webpack/components/ResourceQuotaForm/components/Resource/Resource.scss
278
278
  - webpack/components/ResourceQuotaForm/components/Resource/UnitInputField.js
279
+ - webpack/components/ResourceQuotaForm/components/Resource/UnitInputField.scss
279
280
  - webpack/components/ResourceQuotaForm/components/Resource/UtilizationProgress.js
280
281
  - webpack/components/ResourceQuotaForm/components/Resource/UtilizationProgress.scss
281
282
  - webpack/components/ResourceQuotaForm/components/Resource/__test__/UnitInputField.test.js