orc-shared 5.7.0-dev.9 → 5.8.0-dev.2
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.
- package/dist/actions/requestsApi.js +743 -140
- package/dist/actions/scopes.js +25 -1
- package/dist/buildStore.js +2 -0
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.js +7 -3
- package/dist/components/MaterialUI/Inputs/CheckboxGroup.js +10 -4
- package/dist/components/MaterialUI/Inputs/CheckboxGroupProps.js +3 -1
- package/dist/components/MaterialUI/Inputs/InputBase.js +6 -1
- package/dist/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +15 -8
- package/dist/components/Provision.js +2 -1
- package/dist/components/ScopeExtendedConfigurationLoader.js +83 -0
- package/dist/constants.js +11 -2
- package/dist/content/icons/orckestra-icon.svg +11 -5
- package/dist/reducers/scopesExtendedConfiguration.js +68 -0
- package/dist/selectors/metadata.js +11 -1
- package/dist/selectors/scopeExtendedConfiguration.js +56 -0
- package/dist/utils/propertyBagHelper.js +3 -0
- package/package.json +1 -1
- package/src/actions/requestsApi.js +511 -89
- package/src/actions/scopes.js +25 -1
- package/src/actions/scopes.test.js +34 -0
- package/src/buildStore.js +2 -0
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.js +9 -3
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.test.js +29 -0
- package/src/components/MaterialUI/Inputs/CheckboxGroup.js +5 -4
- package/src/components/MaterialUI/Inputs/CheckboxGroup.test.js +22 -0
- package/src/components/MaterialUI/Inputs/CheckboxGroupProps.js +2 -0
- package/src/components/MaterialUI/Inputs/CheckboxGroupProps.test.js +2 -2
- package/src/components/MaterialUI/Inputs/InputBase.js +8 -5
- package/src/components/MaterialUI/Inputs/InputBase.test.js +160 -110
- package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +13 -6
- package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.test.js +57 -0
- package/src/components/Provision.js +2 -0
- package/src/components/Provision.test.js +7 -0
- package/src/components/ScopeExtendedConfigurationLoader.js +22 -0
- package/src/components/ScopeExtendedConfigurationLoader.test.js +71 -0
- package/src/constants.js +8 -0
- package/src/content/icons/orckestra-icon.svg +11 -5
- package/src/reducers/scopesExtendedConfiguration.js +16 -0
- package/src/reducers/scopesExtendedConfiguration.test.js +31 -0
- package/src/selectors/metadata.js +9 -0
- package/src/selectors/metadata.test.js +90 -0
- package/src/selectors/scopeExtendedConfiguration.js +9 -0
- package/src/selectors/scopeExtendedConfiguration.test.js +45 -0
- package/src/utils/propertyBagHelper.js +3 -0
- package/src/utils/propertyBagHelper.test.js +7 -0
package/src/actions/scopes.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { makeActionTypes } from "./makeApiAction";
|
|
2
2
|
import makeOrcApiAction from "./makeOrcApiAction";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
getApplicationModules,
|
|
5
|
+
getUserScopeRequest,
|
|
6
|
+
getUserScopeTreeRequest,
|
|
7
|
+
getScopeExtendedConfigurationRequest,
|
|
8
|
+
} from "./requestsApi";
|
|
4
9
|
import { overtureModule } from "../constants";
|
|
5
10
|
|
|
6
11
|
export const validateOvertureApplication = () => {
|
|
@@ -60,3 +65,22 @@ export const applicationScopeHasChanged = (previousScope, newScope, moduleName)
|
|
|
60
65
|
},
|
|
61
66
|
};
|
|
62
67
|
};
|
|
68
|
+
|
|
69
|
+
export const GET_SCOPE_EXTENDED_CONFIGURATION = "GET_SCOPE_EXTENDED_CONFIGURATION";
|
|
70
|
+
|
|
71
|
+
export const [
|
|
72
|
+
GET_SCOPE_EXTENDED_CONFIGURATION_REQUEST,
|
|
73
|
+
GET_SCOPE_EXTENDED_CONFIGURATION_SUCCESS,
|
|
74
|
+
GET_SCOPE_EXTENDED_CONFIGURATION_FAILURE,
|
|
75
|
+
] = makeActionTypes(GET_SCOPE_EXTENDED_CONFIGURATION);
|
|
76
|
+
|
|
77
|
+
export const getScopeExtendedConfiguration = scope =>
|
|
78
|
+
makeOrcApiAction(
|
|
79
|
+
GET_SCOPE_EXTENDED_CONFIGURATION,
|
|
80
|
+
getScopeExtendedConfigurationRequest.buildUrl(scope),
|
|
81
|
+
getScopeExtendedConfigurationRequest.verb,
|
|
82
|
+
{
|
|
83
|
+
bailout: false,
|
|
84
|
+
meta: { scope },
|
|
85
|
+
},
|
|
86
|
+
);
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
GET_APPLICATION_MODULES_REQUEST,
|
|
13
13
|
GET_APPLICATION_MODULES_SUCCESS,
|
|
14
14
|
GET_APPLICATION_MODULES_FAILURE,
|
|
15
|
+
getScopeExtendedConfiguration,
|
|
15
16
|
} from "./scopes";
|
|
16
17
|
|
|
17
18
|
jest.mock("../utils/buildUrl", () => {
|
|
@@ -150,3 +151,36 @@ describe("applicationScopeHasChanged", () => {
|
|
|
150
151
|
});
|
|
151
152
|
});
|
|
152
153
|
});
|
|
154
|
+
|
|
155
|
+
describe("getScopeExtendedConfiguration", () => {
|
|
156
|
+
it("creates a RSAA to fetch a scope extended configuration", () => {
|
|
157
|
+
expect(getScopeExtendedConfiguration, "when called with", ["zeScope"], "to exhaustively satisfy", {
|
|
158
|
+
[RSAA]: {
|
|
159
|
+
types: [
|
|
160
|
+
{
|
|
161
|
+
type: "GET_SCOPE_EXTENDED_CONFIGURATION_REQUEST",
|
|
162
|
+
meta: { scope: "zeScope" },
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
type: "GET_SCOPE_EXTENDED_CONFIGURATION_SUCCESS",
|
|
166
|
+
meta: { scope: "zeScope" },
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
type: "GET_SCOPE_EXTENDED_CONFIGURATION_FAILURE",
|
|
170
|
+
meta: { scope: "zeScope" },
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
endpoint: 'URL: scopes/zeScope/extendedConfiguration ""',
|
|
174
|
+
method: "GET",
|
|
175
|
+
body: undefined,
|
|
176
|
+
credentials: "include",
|
|
177
|
+
bailout: false,
|
|
178
|
+
headers: {
|
|
179
|
+
Accept: "application/json; charset=utf-8",
|
|
180
|
+
"Content-Type": "application/json",
|
|
181
|
+
},
|
|
182
|
+
options: { redirect: "follow" },
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
});
|
package/src/buildStore.js
CHANGED
|
@@ -11,6 +11,7 @@ import localeFactory, { cultureByDefault } from "./reducers/localeFactory";
|
|
|
11
11
|
import navigationReducer from "./reducers/navigation";
|
|
12
12
|
import requestReducer from "./reducers/request";
|
|
13
13
|
import scopesReducer from "./reducers/scopes";
|
|
14
|
+
import scopesExtendedConfigurationReducer from "./reducers/scopesExtendedConfiguration";
|
|
14
15
|
import settingsReducer from "./reducers/settings";
|
|
15
16
|
import toastReducer from "./reducers/toasts";
|
|
16
17
|
import viewReducer from "./reducers/view";
|
|
@@ -59,6 +60,7 @@ const buildStore = (reducers, devOptions = {}) => {
|
|
|
59
60
|
router: connectRouter(history),
|
|
60
61
|
requests: requestReducer,
|
|
61
62
|
scopes: scopesReducer,
|
|
63
|
+
scopesExtendedConfiguration: scopesExtendedConfigurationReducer,
|
|
62
64
|
settings: settingsReducer,
|
|
63
65
|
toasts: toastReducer,
|
|
64
66
|
versionInfo: versionInfoReducer,
|
|
@@ -77,7 +77,7 @@ const InformationItemChildren = ({
|
|
|
77
77
|
return <MultipleLinesText textProps={multipleLinesTextProps} children={value} tooltipClasses={tooltipClasses} />;
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
const InformationItemHeader = ({ classes, label, headerIcon }) => {
|
|
80
|
+
const InformationItemHeader = ({ classes, label, headerIcon, headerIconClassName }) => {
|
|
81
81
|
const formattedLabel = typeof label === "object" ? <FormattedMessage {...label} /> : label;
|
|
82
82
|
const headerText = (formattedLabel && <Typography className={classes.title} children={formattedLabel} />) ?? null;
|
|
83
83
|
|
|
@@ -85,7 +85,7 @@ const InformationItemHeader = ({ classes, label, headerIcon }) => {
|
|
|
85
85
|
return (
|
|
86
86
|
<div className={classes.headerRoot}>
|
|
87
87
|
<div className={classes.headerTextContainer}>{headerText}</div>
|
|
88
|
-
<div className={classes.headerIconContainer}>{headerIcon}</div>
|
|
88
|
+
<div className={classNames(classes.headerIconContainer, headerIconClassName)}>{headerIcon}</div>
|
|
89
89
|
</div>
|
|
90
90
|
);
|
|
91
91
|
}
|
|
@@ -99,6 +99,7 @@ const InformationItem = ({
|
|
|
99
99
|
required,
|
|
100
100
|
error,
|
|
101
101
|
headerIcon = undefined,
|
|
102
|
+
headerIconClassName = undefined,
|
|
102
103
|
showNotAvailable = false,
|
|
103
104
|
marginTop = 0,
|
|
104
105
|
isMaxLineCountEnabled,
|
|
@@ -109,7 +110,12 @@ const InformationItem = ({
|
|
|
109
110
|
|
|
110
111
|
return (
|
|
111
112
|
<div className={classes.container}>
|
|
112
|
-
<InformationItemHeader
|
|
113
|
+
<InformationItemHeader
|
|
114
|
+
classes={classes}
|
|
115
|
+
label={label}
|
|
116
|
+
headerIcon={headerIcon}
|
|
117
|
+
headerIconClassName={headerIconClassName}
|
|
118
|
+
/>
|
|
113
119
|
<InformationItemChildren
|
|
114
120
|
classes={classes}
|
|
115
121
|
children={children}
|
|
@@ -315,4 +315,33 @@ describe("Information Item", () => {
|
|
|
315
315
|
|
|
316
316
|
expect(component, "when mounted", "to satisfy", expected);
|
|
317
317
|
});
|
|
318
|
+
|
|
319
|
+
it("Renders Information Item properly with a header icon and custom header icon class", () => {
|
|
320
|
+
const label = "label";
|
|
321
|
+
const value = "value";
|
|
322
|
+
|
|
323
|
+
const component = (
|
|
324
|
+
<IntlProvider locale="en-US">
|
|
325
|
+
<InformationItem label={label} headerIcon={<span>the header icon</span>} headerIconClassName="CustomClass">
|
|
326
|
+
{value}
|
|
327
|
+
</InformationItem>
|
|
328
|
+
</IntlProvider>
|
|
329
|
+
);
|
|
330
|
+
|
|
331
|
+
const expected = (
|
|
332
|
+
<div>
|
|
333
|
+
<div>
|
|
334
|
+
<div>
|
|
335
|
+
<Typography children={label} />
|
|
336
|
+
</div>
|
|
337
|
+
<div className={"CustomClass"}>
|
|
338
|
+
<span>the header icon</span>
|
|
339
|
+
</div>
|
|
340
|
+
</div>
|
|
341
|
+
<MultipleLinesText>{value}</MultipleLinesText>
|
|
342
|
+
</div>
|
|
343
|
+
);
|
|
344
|
+
|
|
345
|
+
expect(component, "when mounted", "to satisfy", expected);
|
|
346
|
+
});
|
|
318
347
|
});
|
|
@@ -12,7 +12,7 @@ const useStyles = makeStyles(theme => ({
|
|
|
12
12
|
},
|
|
13
13
|
checkBoxContainer: {
|
|
14
14
|
display: "flex",
|
|
15
|
-
flexDirection: "row",
|
|
15
|
+
flexDirection: props => (props.row ? "row" : "column"),
|
|
16
16
|
flexWrap: "wrap",
|
|
17
17
|
"& .MuiFormControlLabel-root": {
|
|
18
18
|
[theme.breakpoints.up("xs")]: {},
|
|
@@ -35,8 +35,6 @@ const useStyles = makeStyles(theme => ({
|
|
|
35
35
|
}));
|
|
36
36
|
|
|
37
37
|
const CheckboxGroup = ({ checkboxGroupProps }) => {
|
|
38
|
-
const classes = useStyles();
|
|
39
|
-
|
|
40
38
|
if (isCheckboxGroupProps(checkboxGroupProps) === false) {
|
|
41
39
|
throw new TypeError("checkboxGroupProps property is not of type CheckboxGroupProps");
|
|
42
40
|
}
|
|
@@ -48,6 +46,9 @@ const CheckboxGroup = ({ checkboxGroupProps }) => {
|
|
|
48
46
|
const readOnly = checkboxGroupProps?.get(CheckboxGroupProps.propNames.readOnly) || false;
|
|
49
47
|
const disabled = checkboxGroupProps?.get(CheckboxGroupProps.propNames.disabled) || false;
|
|
50
48
|
const options = checkboxGroupProps?.get(CheckboxGroupProps.propNames.options) ?? [];
|
|
49
|
+
const row = checkboxGroupProps.get(CheckboxGroupProps.propNames.row) ?? true;
|
|
50
|
+
|
|
51
|
+
const classes = useStyles({ row });
|
|
51
52
|
|
|
52
53
|
const handleGroupUpdate = (checked, value, newValue) => {
|
|
53
54
|
const values = value ? value.split("|") : [];
|
|
@@ -64,7 +65,7 @@ const CheckboxGroup = ({ checkboxGroupProps }) => {
|
|
|
64
65
|
|
|
65
66
|
const checkBoxGroup = (
|
|
66
67
|
<div className={classes.container}>
|
|
67
|
-
<div className={classes.checkBoxContainer}>
|
|
68
|
+
<div className={classes.checkBoxContainer} data-qa="checkboxgroup-container">
|
|
68
69
|
{options.map((option, index) => {
|
|
69
70
|
const checkboxProps = new CheckboxProps();
|
|
70
71
|
checkboxProps.set(CheckboxProps.propNames.update, checked => handleGroupUpdate(checked, value, option.value));
|
|
@@ -85,6 +85,28 @@ describe("CheckboxGroup Component", () => {
|
|
|
85
85
|
expect(component, "when mounted", "to satisfy", expected);
|
|
86
86
|
});
|
|
87
87
|
|
|
88
|
+
it("Renders CheckboxGroup component without errors and vertical orientation", () => {
|
|
89
|
+
const props = new CheckboxGroupProps();
|
|
90
|
+
const options = [
|
|
91
|
+
{ value: "option1", sortOrder: 1 },
|
|
92
|
+
{ value: "option2", sortOrder: 2 },
|
|
93
|
+
{ value: "option3", sortOrder: 3 },
|
|
94
|
+
{ value: "option3_special", sortOrder: 4 },
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
props.set(CheckboxGroupProps.propNames.update, update);
|
|
98
|
+
props.set(CheckboxGroupProps.propNames.value, "option1|option3_special");
|
|
99
|
+
props.set(CheckboxGroupProps.propNames.options, options);
|
|
100
|
+
props.set(CheckboxGroupProps.propNames.row, false);
|
|
101
|
+
const component = <CheckboxGroup checkboxGroupProps={props} />;
|
|
102
|
+
|
|
103
|
+
const mountedComponent = mount(component);
|
|
104
|
+
const container = mountedComponent.find("[data-qa='checkboxgroup-container']");
|
|
105
|
+
|
|
106
|
+
const styles = getComputedStyle(container.getDOMNode());
|
|
107
|
+
expect(styles.flexDirection, "to be", "column");
|
|
108
|
+
});
|
|
109
|
+
|
|
88
110
|
it("Renders CheckboxGroup component without errors when options are not specified", () => {
|
|
89
111
|
const props = new CheckboxGroupProps();
|
|
90
112
|
|
|
@@ -9,6 +9,7 @@ class CheckboxGroupProps extends ComponentProps {
|
|
|
9
9
|
readOnly: "readOnly",
|
|
10
10
|
disabled: "disabled",
|
|
11
11
|
error: "error",
|
|
12
|
+
row: "row",
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
constructor() {
|
|
@@ -20,6 +21,7 @@ class CheckboxGroupProps extends ComponentProps {
|
|
|
20
21
|
this.componentProps.set(this.constructor.propNames.disabled, null);
|
|
21
22
|
this.componentProps.set(this.constructor.propNames.options, null);
|
|
22
23
|
this.componentProps.set(this.constructor.propNames.error, null);
|
|
24
|
+
this.componentProps.set(this.constructor.propNames.row, null);
|
|
23
25
|
|
|
24
26
|
this._isCheckboxGroupProps = true;
|
|
25
27
|
}
|
|
@@ -2,13 +2,13 @@ import CheckboxGroupProps, { isCheckboxGroupProps } from "./CheckboxGroupProps";
|
|
|
2
2
|
|
|
3
3
|
describe("CheckboxGroup Props", () => {
|
|
4
4
|
it("Contains necessary props keys", () => {
|
|
5
|
-
const propNames = ["update", "value", "label", "readOnly", "disabled", "options", "error"];
|
|
5
|
+
const propNames = ["update", "value", "label", "readOnly", "disabled", "options", "error", "row"];
|
|
6
6
|
|
|
7
7
|
expect(CheckboxGroupProps.propNames, "to have keys", propNames);
|
|
8
8
|
});
|
|
9
9
|
|
|
10
10
|
it("Puts keys in component props map", () => {
|
|
11
|
-
const propNames = ["update", "value", "label", "readOnly", "disabled", "options", "error"];
|
|
11
|
+
const propNames = ["update", "value", "label", "readOnly", "disabled", "options", "error", "row"];
|
|
12
12
|
|
|
13
13
|
const checkboxProps = new CheckboxGroupProps();
|
|
14
14
|
|
|
@@ -146,12 +146,15 @@ const InputBase = ({ inputProps }) => {
|
|
|
146
146
|
inputAttributes.min = -2147483648;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
+
const decimalScale = numericInputProps?.decimalScale ?? 0;
|
|
150
|
+
|
|
151
|
+
const lengthForMin = Math.trunc(inputAttributes.min).toString().length;
|
|
152
|
+
const lengthForMax = Math.trunc(inputAttributes.max).toString().length;
|
|
153
|
+
|
|
154
|
+
inputAttributes.maxLength = Math.max(lengthForMin, lengthForMax) + (decimalScale > 0 ? decimalScale + 1 : 0);
|
|
155
|
+
|
|
149
156
|
inputAttributes.isAllowed = val => {
|
|
150
|
-
return
|
|
151
|
-
val.value === "" ||
|
|
152
|
-
val.value === "-" ||
|
|
153
|
-
(val.floatValue >= inputAttributes.min && val.floatValue <= inputAttributes.max)
|
|
154
|
-
);
|
|
157
|
+
return val.value === "" || val.value === "-" || val.value !== null;
|
|
155
158
|
};
|
|
156
159
|
}
|
|
157
160
|
|
|
@@ -436,6 +436,166 @@ describe("AdvancedNumericInput", () => {
|
|
|
436
436
|
expect(advInput.props().decimalScale, "to be", 2);
|
|
437
437
|
});
|
|
438
438
|
|
|
439
|
+
it("Renders InputBase component as advanced numeric input without min max", () => {
|
|
440
|
+
const inputProps = new InputBaseProps();
|
|
441
|
+
const aLabel = "aLabel";
|
|
442
|
+
const aValue = "value";
|
|
443
|
+
|
|
444
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
445
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
446
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
447
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
448
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 2 });
|
|
449
|
+
|
|
450
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
451
|
+
|
|
452
|
+
const mountedComponent = mount(component);
|
|
453
|
+
|
|
454
|
+
const advInput = mountedComponent.find("AdvancedNumericInput");
|
|
455
|
+
expect(advInput.props().decimalScale, "to be", 2);
|
|
456
|
+
expect(advInput.props().min, "to be", -2147483648);
|
|
457
|
+
expect(advInput.props().max, "to be", 2147483647);
|
|
458
|
+
expect(advInput.props().maxLength, "to be", 14);
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
it("Renders InputBase component as advanced numeric input without min", () => {
|
|
462
|
+
const inputProps = new InputBaseProps();
|
|
463
|
+
const aLabel = "aLabel";
|
|
464
|
+
const aValue = "value";
|
|
465
|
+
|
|
466
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
467
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
468
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
469
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
470
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
471
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { max: 122 });
|
|
472
|
+
|
|
473
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
474
|
+
|
|
475
|
+
const mountedComponent = mount(component);
|
|
476
|
+
|
|
477
|
+
const advInput = mountedComponent.find("AdvancedNumericInput");
|
|
478
|
+
expect(advInput.props().decimalScale, "to be", 0);
|
|
479
|
+
expect(advInput.props().min, "to be", -2147483648);
|
|
480
|
+
expect(advInput.props().max, "to be", 122);
|
|
481
|
+
expect(advInput.props().maxLength, "to be", 11);
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
it("Renders InputBase component as advanced numeric input without max", () => {
|
|
485
|
+
const inputProps = new InputBaseProps();
|
|
486
|
+
const aLabel = "aLabel";
|
|
487
|
+
const aValue = "value";
|
|
488
|
+
|
|
489
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
490
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
491
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
492
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
493
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 2 });
|
|
494
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -9.9 });
|
|
495
|
+
|
|
496
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
497
|
+
|
|
498
|
+
const mountedComponent = mount(component);
|
|
499
|
+
|
|
500
|
+
const advInput = mountedComponent.find("AdvancedNumericInput");
|
|
501
|
+
expect(advInput.props().decimalScale, "to be", 2);
|
|
502
|
+
expect(advInput.props().min, "to be", -9.9);
|
|
503
|
+
expect(advInput.props().max, "to be", 2147483647);
|
|
504
|
+
expect(advInput.props().maxLength, "to be", 13);
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
it("Renders InputBase component as advanced numeric input with negative min positive max", () => {
|
|
508
|
+
const inputProps = new InputBaseProps();
|
|
509
|
+
const aLabel = "aLabel";
|
|
510
|
+
const aValue = "value";
|
|
511
|
+
|
|
512
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
513
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
514
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
515
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
516
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 1 });
|
|
517
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -999.9, max: 9.8 });
|
|
518
|
+
|
|
519
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
520
|
+
|
|
521
|
+
const mountedComponent = mount(component);
|
|
522
|
+
|
|
523
|
+
const advInput = mountedComponent.find("AdvancedNumericInput");
|
|
524
|
+
expect(advInput.props().decimalScale, "to be", 1);
|
|
525
|
+
expect(advInput.props().min, "to be", -999.9);
|
|
526
|
+
expect(advInput.props().max, "to be", 9.8);
|
|
527
|
+
expect(advInput.props().maxLength, "to be", 6);
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
it("Renders InputBase component as advanced numeric input with negative min large positive max", () => {
|
|
531
|
+
const inputProps = new InputBaseProps();
|
|
532
|
+
const aLabel = "aLabel";
|
|
533
|
+
const aValue = "value";
|
|
534
|
+
|
|
535
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
536
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
537
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
538
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
539
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 1 });
|
|
540
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -9.9, max: 99999.8 });
|
|
541
|
+
|
|
542
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
543
|
+
|
|
544
|
+
const mountedComponent = mount(component);
|
|
545
|
+
|
|
546
|
+
const advInput = mountedComponent.find("AdvancedNumericInput");
|
|
547
|
+
expect(advInput.props().decimalScale, "to be", 1);
|
|
548
|
+
expect(advInput.props().min, "to be", -9.9);
|
|
549
|
+
expect(advInput.props().max, "to be", 99999.8);
|
|
550
|
+
expect(advInput.props().maxLength, "to be", 7);
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
it("Renders InputBase component as advanced numeric input with negative min negative max", () => {
|
|
554
|
+
const inputProps = new InputBaseProps();
|
|
555
|
+
const aLabel = "aLabel";
|
|
556
|
+
const aValue = "value";
|
|
557
|
+
|
|
558
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
559
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
560
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
561
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
562
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 3 });
|
|
563
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -99.9, max: -9.8 });
|
|
564
|
+
|
|
565
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
566
|
+
|
|
567
|
+
const mountedComponent = mount(component);
|
|
568
|
+
|
|
569
|
+
const advInput = mountedComponent.find("AdvancedNumericInput");
|
|
570
|
+
expect(advInput.props().decimalScale, "to be", 3);
|
|
571
|
+
expect(advInput.props().min, "to be", -99.9);
|
|
572
|
+
expect(advInput.props().max, "to be", -9.8);
|
|
573
|
+
expect(advInput.props().maxLength, "to be", 7);
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
it("Renders InputBase component as advanced numeric input with positive min positive max", () => {
|
|
577
|
+
const inputProps = new InputBaseProps();
|
|
578
|
+
const aLabel = "aLabel";
|
|
579
|
+
const aValue = "value";
|
|
580
|
+
|
|
581
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
582
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
583
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
584
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
585
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 5 });
|
|
586
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: 9.9, max: 99.8 });
|
|
587
|
+
|
|
588
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
589
|
+
|
|
590
|
+
const mountedComponent = mount(component);
|
|
591
|
+
|
|
592
|
+
const advInput = mountedComponent.find("AdvancedNumericInput");
|
|
593
|
+
expect(advInput.props().decimalScale, "to be", 5);
|
|
594
|
+
expect(advInput.props().min, "to be", 9.9);
|
|
595
|
+
expect(advInput.props().max, "to be", 99.8);
|
|
596
|
+
expect(advInput.props().maxLength, "to be", 8);
|
|
597
|
+
});
|
|
598
|
+
|
|
439
599
|
it("Change advanced numeric input value", () => {
|
|
440
600
|
const inputProps = new InputBaseProps();
|
|
441
601
|
const aLabel = "aLabel";
|
|
@@ -686,116 +846,6 @@ describe("AdvancedNumericInput", () => {
|
|
|
686
846
|
// no idea what to assert here, this test is mostly for code coverage
|
|
687
847
|
});
|
|
688
848
|
|
|
689
|
-
it("Change advanced numeric input value with min value out of default bounds", () => {
|
|
690
|
-
const inputProps = new InputBaseProps();
|
|
691
|
-
const aLabel = "aLabel";
|
|
692
|
-
const aValue = "12.2";
|
|
693
|
-
const metadata = {
|
|
694
|
-
test: "value",
|
|
695
|
-
};
|
|
696
|
-
|
|
697
|
-
inputProps.set(InputBaseProps.propNames.update, update);
|
|
698
|
-
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
699
|
-
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
700
|
-
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
701
|
-
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 2 });
|
|
702
|
-
inputProps.set(InputBaseProps.propNames.metadata, metadata);
|
|
703
|
-
|
|
704
|
-
const component = <InputBase inputProps={inputProps} />;
|
|
705
|
-
const mountedComponent = mount(component);
|
|
706
|
-
const input = mountedComponent.find("input");
|
|
707
|
-
input.simulate("change", { target: { value: "-3147483648", focus: noop } });
|
|
708
|
-
|
|
709
|
-
expect(update, "not to have calls satisfying", [{ args: ["-3147483648", metadata] }]);
|
|
710
|
-
|
|
711
|
-
input.simulate("change", { target: { value: "-111", focus: noop } });
|
|
712
|
-
expect(update, "to have calls satisfying", [{ args: ["-111", metadata] }]);
|
|
713
|
-
});
|
|
714
|
-
|
|
715
|
-
it("Change advanced numeric input value with min value out of specified bounds", () => {
|
|
716
|
-
const inputProps = new InputBaseProps();
|
|
717
|
-
const aLabel = "aLabel";
|
|
718
|
-
const aValue = "12.2";
|
|
719
|
-
const metadata = {
|
|
720
|
-
test: "value",
|
|
721
|
-
};
|
|
722
|
-
|
|
723
|
-
inputProps.set(InputBaseProps.propNames.update, update);
|
|
724
|
-
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
725
|
-
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
726
|
-
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
727
|
-
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 2 });
|
|
728
|
-
inputProps.set(InputBaseProps.propNames.metadata, metadata);
|
|
729
|
-
inputProps.set(InputBaseProps.propNames.inputAttributes, {
|
|
730
|
-
min: -100,
|
|
731
|
-
});
|
|
732
|
-
|
|
733
|
-
const component = <InputBase inputProps={inputProps} />;
|
|
734
|
-
const mountedComponent = mount(component);
|
|
735
|
-
const input = mountedComponent.find("input");
|
|
736
|
-
input.simulate("change", { target: { value: "-2000", focus: noop } });
|
|
737
|
-
|
|
738
|
-
expect(update, "not to have calls satisfying", [{ args: ["-2000", metadata] }]);
|
|
739
|
-
|
|
740
|
-
input.simulate("change", { target: { value: "-11", focus: noop } });
|
|
741
|
-
expect(update, "to have calls satisfying", [{ args: ["-11", metadata] }]);
|
|
742
|
-
});
|
|
743
|
-
|
|
744
|
-
it("Change advanced numeric input value with max value out of default bounds", () => {
|
|
745
|
-
const inputProps = new InputBaseProps();
|
|
746
|
-
const aLabel = "aLabel";
|
|
747
|
-
const aValue = "12.2";
|
|
748
|
-
const metadata = {
|
|
749
|
-
test: "value",
|
|
750
|
-
};
|
|
751
|
-
|
|
752
|
-
inputProps.set(InputBaseProps.propNames.update, update);
|
|
753
|
-
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
754
|
-
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
755
|
-
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
756
|
-
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 2 });
|
|
757
|
-
inputProps.set(InputBaseProps.propNames.metadata, metadata);
|
|
758
|
-
|
|
759
|
-
const component = <InputBase inputProps={inputProps} />;
|
|
760
|
-
const mountedComponent = mount(component);
|
|
761
|
-
const input = mountedComponent.find("input");
|
|
762
|
-
input.simulate("change", { target: { value: "3147483648", focus: noop } });
|
|
763
|
-
|
|
764
|
-
expect(update, "not to have calls satisfying", [{ args: ["3147483648", metadata] }]);
|
|
765
|
-
|
|
766
|
-
input.simulate("change", { target: { value: "111", focus: noop } });
|
|
767
|
-
expect(update, "to have calls satisfying", [{ args: ["111", metadata] }]);
|
|
768
|
-
});
|
|
769
|
-
|
|
770
|
-
it("Change advanced numeric input value with max value out of specified bounds", () => {
|
|
771
|
-
const inputProps = new InputBaseProps();
|
|
772
|
-
const aLabel = "aLabel";
|
|
773
|
-
const aValue = "12.2";
|
|
774
|
-
const metadata = {
|
|
775
|
-
test: "value",
|
|
776
|
-
};
|
|
777
|
-
|
|
778
|
-
inputProps.set(InputBaseProps.propNames.update, update);
|
|
779
|
-
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
780
|
-
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
781
|
-
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
782
|
-
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 2 });
|
|
783
|
-
inputProps.set(InputBaseProps.propNames.metadata, metadata);
|
|
784
|
-
inputProps.set(InputBaseProps.propNames.inputAttributes, {
|
|
785
|
-
max: 100,
|
|
786
|
-
});
|
|
787
|
-
|
|
788
|
-
const component = <InputBase inputProps={inputProps} />;
|
|
789
|
-
const mountedComponent = mount(component);
|
|
790
|
-
const input = mountedComponent.find("input");
|
|
791
|
-
input.simulate("change", { target: { value: "2000", focus: noop } });
|
|
792
|
-
|
|
793
|
-
expect(update, "not to have calls satisfying", [{ args: ["2000", metadata] }]);
|
|
794
|
-
|
|
795
|
-
input.simulate("change", { target: { value: "11", focus: noop } });
|
|
796
|
-
expect(update, "to have calls satisfying", [{ args: ["11", metadata] }]);
|
|
797
|
-
});
|
|
798
|
-
|
|
799
849
|
it("Change advanced numeric input value: dash is allowed", () => {
|
|
800
850
|
const inputProps = new InputBaseProps();
|
|
801
851
|
const aLabel = "aLabel";
|
|
@@ -153,6 +153,7 @@ const SearchControl = ({
|
|
|
153
153
|
disabled,
|
|
154
154
|
focusAndSelectSearchFieldOnLoad = true,
|
|
155
155
|
focusSearchOnSearchOptionChange = false,
|
|
156
|
+
trimSearchvalue = true,
|
|
156
157
|
}) => {
|
|
157
158
|
searchOptions = !searchOptions?.length ? null : searchOptions;
|
|
158
159
|
searchOption = getSearchOptionValue(searchOptions, searchOption);
|
|
@@ -161,9 +162,15 @@ const SearchControl = ({
|
|
|
161
162
|
|
|
162
163
|
const inputRef = useRef();
|
|
163
164
|
|
|
164
|
-
const
|
|
165
|
+
const onSearchInternal = (newSearchOption, value) => {
|
|
166
|
+
const searchValue = trimSearchvalue ? value?.trim() : value;
|
|
167
|
+
|
|
168
|
+
onSearch(newSearchOption, searchValue);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const update = newSearchOption => {
|
|
165
172
|
if (focusSearchOnSearchOptionChange && inputRef.current) {
|
|
166
|
-
|
|
173
|
+
onSearchInternal(newSearchOption, "");
|
|
167
174
|
setTimeout(() => {
|
|
168
175
|
/* istanbul ignore next */
|
|
169
176
|
if (inputRef.current) {
|
|
@@ -173,7 +180,7 @@ const SearchControl = ({
|
|
|
173
180
|
}
|
|
174
181
|
}, 0);
|
|
175
182
|
} else {
|
|
176
|
-
|
|
183
|
+
onSearchInternal(newSearchOption, inputRef.current?.value);
|
|
177
184
|
}
|
|
178
185
|
};
|
|
179
186
|
|
|
@@ -208,7 +215,7 @@ const SearchControl = ({
|
|
|
208
215
|
|
|
209
216
|
const onSubmit = event => {
|
|
210
217
|
// using form submit instead of a keydown (with key=enter) to allow the 'enter key' event to be canceled elsewhere to avoid the submit event
|
|
211
|
-
|
|
218
|
+
onSearchInternal(searchOption, inputRef.current?.value);
|
|
212
219
|
event.preventDefault();
|
|
213
220
|
};
|
|
214
221
|
|
|
@@ -231,7 +238,7 @@ const SearchControl = ({
|
|
|
231
238
|
disabled={disabled}
|
|
232
239
|
onClick={() => {
|
|
233
240
|
inputRef.current.value = null;
|
|
234
|
-
|
|
241
|
+
onSearchInternal(searchOption);
|
|
235
242
|
inputRef.current.focus();
|
|
236
243
|
}}
|
|
237
244
|
className={classes.clearButton}
|
|
@@ -252,7 +259,7 @@ const SearchControl = ({
|
|
|
252
259
|
disabled={disabled}
|
|
253
260
|
classes={{ root: classes.searchButton }}
|
|
254
261
|
onClick={() => {
|
|
255
|
-
|
|
262
|
+
onSearchInternal(searchOption, inputRef.current.value);
|
|
256
263
|
}}
|
|
257
264
|
>
|
|
258
265
|
<Icon id="search" />
|