@truedat/dq 4.44.4 → 4.45.1
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/CHANGELOG.md +11 -0
- package/package.json +24 -17
- package/src/components/NewRuleImplementation.js +6 -29
- package/src/components/RemediationForm.js +20 -47
- package/src/components/RemediationPlan.js +1 -1
- package/src/components/RuleFilters.js +1 -5
- package/src/components/RuleForm.js +20 -59
- package/src/components/RuleImplementationFilters.js +1 -5
- package/src/components/__tests__/ExecutionForm.spec.js +14 -12
- package/src/components/__tests__/NewRuleImplementation.spec.js +27 -15
- package/src/components/__tests__/RemediationForm.spec.js +11 -46
- package/src/components/__tests__/RemediationPlan.spec.js +49 -73
- package/src/components/__tests__/RuleForm.spec.js +22 -52
- package/src/components/__tests__/RuleProperties.spec.js +39 -27
- package/src/components/__tests__/__snapshots__/ExecutionForm.spec.js.snap +75 -5
- package/src/components/__tests__/__snapshots__/NewRuleImplementation.spec.js.snap +202 -2
- package/src/components/__tests__/__snapshots__/RemediationForm.spec.js.snap +77 -3
- package/src/components/__tests__/__snapshots__/RemediationPlan.spec.js.snap +40 -1
- package/src/components/__tests__/__snapshots__/RuleForm.spec.js.snap +156 -6
- package/src/components/__tests__/__snapshots__/RuleImplementationsSearch.spec.js.snap +1 -1
- package/src/components/__tests__/__snapshots__/RuleProperties.spec.js.snap +68 -56
- package/src/components/__tests__/__snapshots__/RuleSearch.spec.js.snap +1 -1
- package/src/components/ruleImplementationForm/InformationForm.js +14 -33
- package/src/components/ruleImplementationForm/RuleImplementationForm.js +7 -11
- package/src/components/ruleImplementationForm/RuleImplementationRawForm.js +20 -39
- package/src/components/ruleImplementationForm/__tests__/RuleImplementationForm.spec.js +11 -7
- package/src/components/ruleImplementationForm/__tests__/RuleImplementationRawForm.spec.js +175 -156
- package/src/components/ruleImplementationForm/__tests__/__snapshots__/RuleImplementationForm.spec.js.snap +75 -0
- package/src/components/ruleImplementationForm/__tests__/__snapshots__/RuleImplementationRawForm.spec.js.snap +412 -165
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [4.44.5] 2022-05-20
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- [TD-4230] Refactored components to use `SelectableDynamicForm`:
|
|
8
|
+
- `NewRuleImplementation`
|
|
9
|
+
- `RemediationForm`
|
|
10
|
+
- `RuleForm`
|
|
11
|
+
- `InformationForm`
|
|
12
|
+
- `RuleImplementationRawForm`
|
|
13
|
+
|
|
3
14
|
## [4.44.3] 2022-05-11
|
|
4
15
|
|
|
5
16
|
### Added
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/dq",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.45.1",
|
|
4
4
|
"description": "Truedat Web Data Quality Module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"jsnext:main": "src/index.js",
|
|
@@ -22,17 +22,20 @@
|
|
|
22
22
|
"eslint:fix": "eslint --fix src/**"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@babel/cli": "^7.
|
|
26
|
-
"@babel/core": "^7.
|
|
27
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
28
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.
|
|
29
|
-
"@babel/plugin-proposal-optional-chaining": "^7.
|
|
25
|
+
"@babel/cli": "^7.17.10",
|
|
26
|
+
"@babel/core": "^7.18.0",
|
|
27
|
+
"@babel/plugin-proposal-class-properties": "^7.17.12",
|
|
28
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.18.0",
|
|
29
|
+
"@babel/plugin-proposal-optional-chaining": "^7.17.12",
|
|
30
30
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
31
|
-
"@babel/plugin-transform-modules-commonjs": "^7.
|
|
32
|
-
"@babel/preset-env": "^7.
|
|
33
|
-
"@babel/preset-react": "^7.
|
|
34
|
-
"@
|
|
35
|
-
"
|
|
31
|
+
"@babel/plugin-transform-modules-commonjs": "^7.18.0",
|
|
32
|
+
"@babel/preset-env": "^7.18.0",
|
|
33
|
+
"@babel/preset-react": "^7.17.12",
|
|
34
|
+
"@testing-library/jest-dom": "^5.16.4",
|
|
35
|
+
"@testing-library/react": "^12.0.0",
|
|
36
|
+
"@testing-library/user-event": "^13.2.1",
|
|
37
|
+
"@truedat/test": "4.45.1",
|
|
38
|
+
"babel-jest": "^28.1.0",
|
|
36
39
|
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
37
40
|
"babel-plugin-lodash": "^3.3.4",
|
|
38
41
|
"babel-plugin-react-intl": "^5.1.18",
|
|
@@ -41,7 +44,8 @@
|
|
|
41
44
|
"enzyme-adapter-react-16": "^1.15.6",
|
|
42
45
|
"enzyme-to-json": "^3.6.2",
|
|
43
46
|
"identity-obj-proxy": "^3.0.0",
|
|
44
|
-
"jest": "^
|
|
47
|
+
"jest": "^28.1.0",
|
|
48
|
+
"jest-environment-jsdom": "^28.1.0",
|
|
45
49
|
"react": "^16.14.0",
|
|
46
50
|
"react-dom": "^16.14.0",
|
|
47
51
|
"redux-saga-test-plan": "^4.0.4",
|
|
@@ -49,6 +53,8 @@
|
|
|
49
53
|
"semantic-ui-react": "^2.0.3"
|
|
50
54
|
},
|
|
51
55
|
"jest": {
|
|
56
|
+
"maxWorkers": "50%",
|
|
57
|
+
"testTimeout": 10000,
|
|
52
58
|
"moduleDirectories": [
|
|
53
59
|
"<rootDir>/src",
|
|
54
60
|
"../../node_modules"
|
|
@@ -81,15 +87,16 @@
|
|
|
81
87
|
]
|
|
82
88
|
},
|
|
83
89
|
"dependencies": {
|
|
84
|
-
"@apollo/client": "^3.4
|
|
85
|
-
"@truedat/core": "4.
|
|
86
|
-
"@truedat/df": "4.
|
|
90
|
+
"@apollo/client": "^3.6.4",
|
|
91
|
+
"@truedat/core": "4.45.1",
|
|
92
|
+
"@truedat/df": "4.45.1",
|
|
87
93
|
"axios": "^0.19.2",
|
|
88
94
|
"graphql": "^15.5.3",
|
|
89
95
|
"path-to-regexp": "^1.7.0",
|
|
90
|
-
"prop-types": "^15.
|
|
96
|
+
"prop-types": "^15.8.1",
|
|
91
97
|
"rc-slider": "^8.6.1",
|
|
92
98
|
"react-intl": "^5.20.10",
|
|
99
|
+
"react-moment": "^1.1.2",
|
|
93
100
|
"react-redux": "^7.2.4",
|
|
94
101
|
"react-router-dom": "^5.2.0",
|
|
95
102
|
"redux": "^4.1.1",
|
|
@@ -103,5 +110,5 @@
|
|
|
103
110
|
"react-dom": ">= 16.8.6 < 17",
|
|
104
111
|
"semantic-ui-react": ">= 0.88.2 < 2.1"
|
|
105
112
|
},
|
|
106
|
-
"gitHead": "
|
|
113
|
+
"gitHead": "c13f37ee357bf4a5e8c8c99eb6bd0c798f468c49"
|
|
107
114
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
-
import React, { useState
|
|
2
|
+
import React, { useState } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { connect } from "react-redux";
|
|
5
5
|
import { Divider, Header, Grid } from "semantic-ui-react";
|
|
@@ -7,7 +7,6 @@ import { FormattedMessage } from "react-intl";
|
|
|
7
7
|
import { gql, useQuery } from "@apollo/client";
|
|
8
8
|
import { Loading } from "@truedat/core/components";
|
|
9
9
|
import { getFieldType } from "@truedat/core/services/fieldType";
|
|
10
|
-
import { applyTemplate } from "@truedat/df/utils";
|
|
11
10
|
import {
|
|
12
11
|
createRuleImplementation,
|
|
13
12
|
updateRuleImplementation,
|
|
@@ -251,7 +250,6 @@ export const NewRuleImplementation = ({
|
|
|
251
250
|
withDefaultAlias
|
|
252
251
|
)(ruleImplementationProps);
|
|
253
252
|
|
|
254
|
-
const [template, setTemplate] = useState(null);
|
|
255
253
|
const [ruleImplementation, setRuleImplementation] = useState(
|
|
256
254
|
edition
|
|
257
255
|
? {
|
|
@@ -411,7 +409,7 @@ export const NewRuleImplementation = ({
|
|
|
411
409
|
};
|
|
412
410
|
|
|
413
411
|
const onChange = (prop, value) =>
|
|
414
|
-
setRuleImplementation({ ...
|
|
412
|
+
setRuleImplementation((prevValue) => ({ ...prevValue, [prop]: value }));
|
|
415
413
|
|
|
416
414
|
const addPopulation = () => {
|
|
417
415
|
const populations = _.concat(
|
|
@@ -452,28 +450,11 @@ export const NewRuleImplementation = ({
|
|
|
452
450
|
const setImplementationRawContent = (rawContent) =>
|
|
453
451
|
setRuleImplementation({ ...ruleImplementation, rawContent });
|
|
454
452
|
|
|
455
|
-
useEffect(() => {
|
|
456
|
-
if (template) {
|
|
457
|
-
onChange(
|
|
458
|
-
"dfContent",
|
|
459
|
-
applyTemplate(template)(ruleImplementation.dfContent)
|
|
460
|
-
);
|
|
461
|
-
}
|
|
462
|
-
/* eslint-disable react-hooks/exhaustive-deps */
|
|
463
|
-
}, [template]);
|
|
464
|
-
|
|
465
453
|
const doSubmit = () => {
|
|
466
454
|
const populations = _.reject(_.isEmpty)(ruleImplementation.populations);
|
|
467
455
|
const validations = _.reject(_.isEmpty)(ruleImplementation.validations);
|
|
468
456
|
const segments = _.reject(_.isEmpty)(ruleImplementation.segments);
|
|
469
457
|
|
|
470
|
-
const dfContent = _.flow(
|
|
471
|
-
_.prop("dfContent"),
|
|
472
|
-
applyTemplate(template)
|
|
473
|
-
)(ruleImplementation);
|
|
474
|
-
|
|
475
|
-
const df_name = template?.name || ruleImplementation?.dfName || null;
|
|
476
|
-
|
|
477
458
|
const raw_content = _.prop("rawContent")(ruleImplementation);
|
|
478
459
|
const source_id = _.prop("source_id")(raw_content);
|
|
479
460
|
const source = _.find({ id: source_id })(sources);
|
|
@@ -484,8 +465,8 @@ export const NewRuleImplementation = ({
|
|
|
484
465
|
executable: ruleImplementation.executable,
|
|
485
466
|
implementation_key: ruleImplementation.implementationKey,
|
|
486
467
|
implementation_type: ruleImplementation.implementationType,
|
|
487
|
-
df_name,
|
|
488
|
-
df_content: dfContent,
|
|
468
|
+
df_name: ruleImplementation?.dfName,
|
|
469
|
+
df_content: ruleImplementation?.dfContent,
|
|
489
470
|
rule_id: rule ? rule.id : ruleImplementation.rule_id,
|
|
490
471
|
raw_content: { ...raw_content, source },
|
|
491
472
|
result_type: ruleImplementation.result_type,
|
|
@@ -501,8 +482,8 @@ export const NewRuleImplementation = ({
|
|
|
501
482
|
segments,
|
|
502
483
|
implementation_key: ruleImplementation.implementationKey,
|
|
503
484
|
implementation_type: ruleImplementation.implementationType,
|
|
504
|
-
df_name,
|
|
505
|
-
df_content: dfContent,
|
|
485
|
+
df_name: ruleImplementation?.dfName,
|
|
486
|
+
df_content: ruleImplementation?.dfContent,
|
|
506
487
|
rule_id: rule ? rule.id : ruleImplementation.rule_id,
|
|
507
488
|
result_type: ruleImplementation.result_type,
|
|
508
489
|
minimum: ruleImplementation.minimum,
|
|
@@ -554,8 +535,6 @@ export const NewRuleImplementation = ({
|
|
|
554
535
|
onSubmit={doSubmit}
|
|
555
536
|
sources={sources}
|
|
556
537
|
sourcesLoading={sourcesLoading}
|
|
557
|
-
template={template}
|
|
558
|
-
setTemplate={setTemplate}
|
|
559
538
|
/>
|
|
560
539
|
) : (
|
|
561
540
|
<RuleImplementationForm
|
|
@@ -569,9 +548,7 @@ export const NewRuleImplementation = ({
|
|
|
569
548
|
setPopulations={setPopulations}
|
|
570
549
|
setSegments={setSegments}
|
|
571
550
|
setStructures={setDataset}
|
|
572
|
-
setTemplate={setTemplate}
|
|
573
551
|
setValidations={setValidations}
|
|
574
|
-
template={template}
|
|
575
552
|
/>
|
|
576
553
|
)}
|
|
577
554
|
</Grid.Row>
|
|
@@ -1,53 +1,37 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { useState } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { useIntl } from "react-intl";
|
|
5
|
-
import { applyTemplate, validateContent } from "@truedat/df/utils";
|
|
6
5
|
import { connect } from "react-redux";
|
|
7
6
|
import { useParams } from "react-router-dom";
|
|
8
7
|
import { Button, Form } from "semantic-ui-react";
|
|
9
|
-
import { TemplateSelector } from "@truedat/core/components";
|
|
10
8
|
import { createRemediation, updateRemediation } from "../routines";
|
|
11
9
|
|
|
12
|
-
const
|
|
13
|
-
import("@truedat/df/components/
|
|
10
|
+
const SelectableDynamicForm = React.lazy(() =>
|
|
11
|
+
import("@truedat/df/components/SelectableDynamicForm")
|
|
14
12
|
);
|
|
15
13
|
|
|
16
14
|
export const RemediationForm = ({
|
|
17
15
|
createRemediation,
|
|
18
16
|
updateRemediation,
|
|
19
17
|
remediation,
|
|
18
|
+
ruleImplementation,
|
|
20
19
|
onSave,
|
|
21
20
|
latestResultId,
|
|
22
21
|
}) => {
|
|
23
22
|
const { formatMessage } = useIntl();
|
|
24
|
-
const [
|
|
25
|
-
const [
|
|
23
|
+
const [dfName, setDfName] = useState(remediation?.df_name);
|
|
24
|
+
const [isValid, setIsValid] = useState();
|
|
25
|
+
const [content, setContent] = useState(remediation?.df_content || {});
|
|
26
26
|
const {
|
|
27
27
|
id,
|
|
28
28
|
implementation_id: implementationId,
|
|
29
29
|
rule_result_id: ruleResultId,
|
|
30
30
|
} = useParams();
|
|
31
31
|
|
|
32
|
-
const
|
|
33
|
-
const isValid = _.has("name")(template) && isValidContent(content);
|
|
34
|
-
|
|
35
|
-
const handleTemplatesLoaded = ({ templates }) => {
|
|
36
|
-
const name = remediation?.df_name;
|
|
37
|
-
const template = name
|
|
38
|
-
? _.find(_.propEq("name", name))(templates)
|
|
39
|
-
: _.size(templates) == 1
|
|
40
|
-
? templates[0]
|
|
41
|
-
: null;
|
|
42
|
-
setTemplate(template);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const handleTemplateSelected = (e, { template }) => {
|
|
46
|
-
setTemplate(template);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const handleContentChange = (content) => {
|
|
32
|
+
const handleChange = ({ valid, content }) => {
|
|
50
33
|
setContent(content);
|
|
34
|
+
setIsValid(_.isEmpty(valid));
|
|
51
35
|
};
|
|
52
36
|
|
|
53
37
|
const handleSubmit = () => {
|
|
@@ -58,8 +42,8 @@ export const RemediationForm = ({
|
|
|
58
42
|
actionFunction({
|
|
59
43
|
remediation: {
|
|
60
44
|
...remediation,
|
|
61
|
-
df_name:
|
|
62
|
-
df_content:
|
|
45
|
+
df_name: dfName,
|
|
46
|
+
df_content: content,
|
|
63
47
|
},
|
|
64
48
|
id,
|
|
65
49
|
implementation_id: implementationId,
|
|
@@ -68,30 +52,18 @@ export const RemediationForm = ({
|
|
|
68
52
|
onSave();
|
|
69
53
|
};
|
|
70
54
|
|
|
71
|
-
|
|
72
|
-
const content =
|
|
73
|
-
template && remediation?.df_content
|
|
74
|
-
? applyTemplate(template)(remediation.df_content)
|
|
75
|
-
: null;
|
|
76
|
-
setContent(content);
|
|
77
|
-
}, [remediation, template]);
|
|
78
|
-
|
|
55
|
+
const domainId = ruleImplementation?.domain_id;
|
|
79
56
|
return (
|
|
80
57
|
<Form aria-label="remediation-form">
|
|
81
|
-
<
|
|
58
|
+
<SelectableDynamicForm
|
|
82
59
|
scope="remediation"
|
|
83
|
-
|
|
84
|
-
onChange={handleTemplateSelected}
|
|
85
|
-
onLoad={handleTemplatesLoaded}
|
|
60
|
+
domainIds={_.isNil(domainId) ? null : [domainId]}
|
|
86
61
|
required
|
|
62
|
+
content={content}
|
|
63
|
+
name={dfName}
|
|
64
|
+
onChange={handleChange}
|
|
65
|
+
onNameChange={setDfName}
|
|
87
66
|
/>
|
|
88
|
-
{template ? (
|
|
89
|
-
<DynamicForm
|
|
90
|
-
template={template}
|
|
91
|
-
onChange={handleContentChange}
|
|
92
|
-
content={content || {}}
|
|
93
|
-
/>
|
|
94
|
-
) : null}
|
|
95
67
|
<Button
|
|
96
68
|
primary
|
|
97
69
|
disabled={!isValid}
|
|
@@ -109,10 +81,11 @@ RemediationForm.propTypes = {
|
|
|
109
81
|
latestResultId: PropTypes.number,
|
|
110
82
|
onSave: PropTypes.func,
|
|
111
83
|
remediation: PropTypes.object,
|
|
84
|
+
ruleImplementation: PropTypes.object,
|
|
112
85
|
updateRemediation: PropTypes.func,
|
|
113
86
|
};
|
|
114
87
|
|
|
115
|
-
export default connect(
|
|
88
|
+
export default connect(_.pick("ruleImplementation"), {
|
|
116
89
|
createRemediation,
|
|
117
90
|
updateRemediation,
|
|
118
91
|
})(RemediationForm);
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import React from "react";
|
|
2
1
|
import { connect } from "react-redux";
|
|
3
2
|
import { bindActionCreators } from "redux";
|
|
3
|
+
import { AvailableFilters } from "@truedat/core/components";
|
|
4
4
|
import { addRuleFilter, resetRuleFilters } from "../routines";
|
|
5
5
|
import { getRuleAvailableFilters } from "../selectors";
|
|
6
6
|
|
|
7
|
-
const AvailableFilters = React.lazy(() =>
|
|
8
|
-
import("@truedat/core/components/AvailableFilters")
|
|
9
|
-
);
|
|
10
|
-
|
|
11
7
|
const mapStateToProps = (state) => ({
|
|
12
8
|
filters: getRuleAvailableFilters(state),
|
|
13
9
|
disabled: state.ruleFiltersLoading,
|
|
@@ -16,9 +16,7 @@ import {
|
|
|
16
16
|
Popup,
|
|
17
17
|
Icon,
|
|
18
18
|
} from "semantic-ui-react";
|
|
19
|
-
import { HistoryBackButton
|
|
20
|
-
import { applyTemplate } from "@truedat/df/utils";
|
|
21
|
-
import { selectDomain } from "@truedat/df/routines";
|
|
19
|
+
import { HistoryBackButton } from "@truedat/core/components";
|
|
22
20
|
import { getDomainSelectorOptions } from "@truedat/bg/selectors";
|
|
23
21
|
|
|
24
22
|
const DomainDropdownSelector = React.lazy(() =>
|
|
@@ -33,8 +31,8 @@ const ConceptSelector = React.lazy(() =>
|
|
|
33
31
|
import("@truedat/bg/concepts/relations/components/ConceptSelector")
|
|
34
32
|
);
|
|
35
33
|
|
|
36
|
-
const
|
|
37
|
-
import("@truedat/df/components/
|
|
34
|
+
const SelectableDynamicForm = React.lazy(() =>
|
|
35
|
+
import("@truedat/df/components/SelectableDynamicForm")
|
|
38
36
|
);
|
|
39
37
|
|
|
40
38
|
export const FieldLabelWrapping = ({
|
|
@@ -96,10 +94,9 @@ export class RuleForm extends React.Component {
|
|
|
96
94
|
};
|
|
97
95
|
|
|
98
96
|
componentDidMount() {
|
|
99
|
-
const { rule, concept
|
|
97
|
+
const { rule, concept } = this.props;
|
|
100
98
|
const description = rule ? _.propOr({}, "description")(rule) : {};
|
|
101
99
|
if (rule) {
|
|
102
|
-
!_.isNil(rule.domain_id) && selectDomain({ id: rule.domain_id });
|
|
103
100
|
this.setState({
|
|
104
101
|
...rule,
|
|
105
102
|
concept: {
|
|
@@ -108,7 +105,6 @@ export class RuleForm extends React.Component {
|
|
|
108
105
|
},
|
|
109
106
|
});
|
|
110
107
|
} else if (!_.isEmpty(concept)) {
|
|
111
|
-
!_.isNil(concept.domain.id) && selectDomain({ id: concept.domain.id });
|
|
112
108
|
this.setState({ concept });
|
|
113
109
|
}
|
|
114
110
|
|
|
@@ -119,32 +115,8 @@ export class RuleForm extends React.Component {
|
|
|
119
115
|
this.setState({ ...rule });
|
|
120
116
|
};
|
|
121
117
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
this.setState({
|
|
125
|
-
template,
|
|
126
|
-
df_name: template?.name || null,
|
|
127
|
-
df_content: template
|
|
128
|
-
? applyTemplate(template)(df_content, domain_id)
|
|
129
|
-
: null,
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
handleTemplatesLoaded = ({ templates }) => {
|
|
134
|
-
const name = this.props.rule?.df_name;
|
|
135
|
-
const template = name
|
|
136
|
-
? _.find(_.propEq("name", name))(templates)
|
|
137
|
-
: _.size(templates) == 1
|
|
138
|
-
? templates[0]
|
|
139
|
-
: null;
|
|
140
|
-
this.setState({ template, templatesLoading: false });
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
handleTemplateSelected = (e, { template }) => {
|
|
144
|
-
this.setState({ template });
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
handleContentChange = (df_content) => this.setState({ df_content });
|
|
118
|
+
handleContentChange = ({ valid, content: df_content }) =>
|
|
119
|
+
this.setState({ df_content, valid });
|
|
148
120
|
|
|
149
121
|
messagesInformed = (messages) => _.some(_.negate(_.isNil))(messages);
|
|
150
122
|
|
|
@@ -180,14 +152,10 @@ export class RuleForm extends React.Component {
|
|
|
180
152
|
e.preventDefault();
|
|
181
153
|
if (this.messagesInformed(this.generateValidationMessages())) return;
|
|
182
154
|
const { onSubmit, match } = this.props;
|
|
183
|
-
|
|
184
|
-
const { template, concept, templatesLoading, ...rule } = this.state;
|
|
185
|
-
const df_content = template
|
|
186
|
-
? applyTemplate(template)(rule?.df_content, rule?.domain_id)
|
|
187
|
-
: null;
|
|
155
|
+
const { concept, ...rule } = this.state;
|
|
188
156
|
|
|
189
157
|
onSubmit({
|
|
190
|
-
rule
|
|
158
|
+
rule,
|
|
191
159
|
ids: match.params,
|
|
192
160
|
});
|
|
193
161
|
};
|
|
@@ -202,8 +170,7 @@ export class RuleForm extends React.Component {
|
|
|
202
170
|
|
|
203
171
|
handleDomainSelected = (e, { value }) => {
|
|
204
172
|
const domain_id = value;
|
|
205
|
-
const {
|
|
206
|
-
!_.isString(domain_id) && selectDomain({ id: domain_id });
|
|
173
|
+
const { editMode } = this.props;
|
|
207
174
|
|
|
208
175
|
this.setState(
|
|
209
176
|
editMode
|
|
@@ -241,7 +208,7 @@ export class RuleForm extends React.Component {
|
|
|
241
208
|
isSubmitting,
|
|
242
209
|
intl: { formatMessage },
|
|
243
210
|
} = this.props;
|
|
244
|
-
const { template, ...rule } = this.state;
|
|
211
|
+
const { template, valid, ...rule } = this.state;
|
|
245
212
|
const { domain_id } = rule;
|
|
246
213
|
const { concept, domainOptions } = this.props;
|
|
247
214
|
const messages = this.generateValidationMessages();
|
|
@@ -348,20 +315,17 @@ export class RuleForm extends React.Component {
|
|
|
348
315
|
</Accordion>
|
|
349
316
|
</Segment>
|
|
350
317
|
)}
|
|
351
|
-
|
|
318
|
+
|
|
319
|
+
<SelectableDynamicForm
|
|
352
320
|
scope="dq"
|
|
353
|
-
|
|
354
|
-
onChange={this.handleTemplateSelected}
|
|
355
|
-
onLoad={this.handleTemplatesLoaded}
|
|
321
|
+
domainIds={_.isNil(domain_id) ? null : [domain_id]}
|
|
356
322
|
required
|
|
323
|
+
content={rule.df_content}
|
|
324
|
+
name={rule.df_name}
|
|
325
|
+
onChange={this.handleContentChange}
|
|
326
|
+
onNameChange={(df_name) => this.setState({ df_name })}
|
|
357
327
|
/>
|
|
358
|
-
|
|
359
|
-
<DynamicForm
|
|
360
|
-
onChange={this.handleContentChange}
|
|
361
|
-
content={rule.df_content}
|
|
362
|
-
template={template}
|
|
363
|
-
/>
|
|
364
|
-
) : null}
|
|
328
|
+
|
|
365
329
|
<div className="actions">
|
|
366
330
|
<HistoryBackButton
|
|
367
331
|
content={formatMessage({ id: "actions.cancel" })}
|
|
@@ -371,7 +335,7 @@ export class RuleForm extends React.Component {
|
|
|
371
335
|
type="submit"
|
|
372
336
|
primary
|
|
373
337
|
loading={isSubmitting}
|
|
374
|
-
disabled={this.messagesInformed(messages)}
|
|
338
|
+
disabled={this.messagesInformed(messages) || !_.isEmpty(valid)}
|
|
375
339
|
content={formatMessage({ id: "actions.save" })}
|
|
376
340
|
/>
|
|
377
341
|
</div>
|
|
@@ -397,7 +361,6 @@ RuleForm.propTypes = {
|
|
|
397
361
|
match: PropTypes.object,
|
|
398
362
|
onSubmit: PropTypes.func.isRequired,
|
|
399
363
|
rule: PropTypes.object,
|
|
400
|
-
selectDomain: PropTypes.func,
|
|
401
364
|
};
|
|
402
365
|
|
|
403
366
|
const mapStateToProps = (state) => ({
|
|
@@ -406,10 +369,8 @@ const mapStateToProps = (state) => ({
|
|
|
406
369
|
domainOptions: _.pathOr(null, "conceptRulesActions.domain_ids")(state),
|
|
407
370
|
});
|
|
408
371
|
|
|
409
|
-
const mapDispatchToProps = { selectDomain };
|
|
410
|
-
|
|
411
372
|
export default compose(
|
|
412
373
|
withRouter,
|
|
413
374
|
injectIntl,
|
|
414
|
-
connect(mapStateToProps
|
|
375
|
+
connect(mapStateToProps)
|
|
415
376
|
)(RuleForm);
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import React from "react";
|
|
2
1
|
import { connect } from "react-redux";
|
|
3
2
|
import { bindActionCreators } from "redux";
|
|
3
|
+
import { AvailableFilters } from "@truedat/core/components";
|
|
4
4
|
import {
|
|
5
5
|
addImplementationFilter,
|
|
6
6
|
resetImplementationFilters,
|
|
7
7
|
} from "../routines";
|
|
8
8
|
import { getRuleImplementationAvailableFilters } from "../selectors";
|
|
9
9
|
|
|
10
|
-
const AvailableFilters = React.lazy(() =>
|
|
11
|
-
import("@truedat/core/components/AvailableFilters")
|
|
12
|
-
);
|
|
13
|
-
|
|
14
10
|
const mapStateToProps = (state) => ({
|
|
15
11
|
filters: getRuleImplementationAvailableFilters(state),
|
|
16
12
|
disabled: state.ruleFiltersLoading,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { waitFor } from "@testing-library/react";
|
|
2
3
|
import { render } from "@truedat/test/render";
|
|
4
|
+
import { multipleTemplatesMock } from "@truedat/test/mocks";
|
|
3
5
|
import { ExecutionForm } from "../ExecutionForm";
|
|
4
6
|
|
|
5
7
|
describe("<ExecutionForm />", () => {
|
|
@@ -12,20 +14,20 @@ describe("<ExecutionForm />", () => {
|
|
|
12
14
|
selectTemplate,
|
|
13
15
|
};
|
|
14
16
|
const renderOpts = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"actions.cancel": "cancel",
|
|
18
|
-
"actions.create": "create",
|
|
19
|
-
"implementation.actions.execution.confirmation.content": "content",
|
|
20
|
-
"implementations.actions.execution.confirmation.content": "content",
|
|
21
|
-
"implementations.actions.execution.confirmation.header": "header",
|
|
22
|
-
"implementations.actions.execution.confirmation.legend": "legend",
|
|
23
|
-
},
|
|
24
|
-
},
|
|
17
|
+
mocks: [multipleTemplatesMock({ scope: "qe" })],
|
|
18
|
+
fallback: "lazy",
|
|
25
19
|
};
|
|
26
20
|
|
|
27
|
-
it("matches the latest snapshot", () => {
|
|
28
|
-
const { container } = render(
|
|
21
|
+
it("matches the latest snapshot", async () => {
|
|
22
|
+
const { container, queryByText } = render(
|
|
23
|
+
<ExecutionForm {...props} />,
|
|
24
|
+
renderOpts
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
await waitFor(() =>
|
|
28
|
+
expect(queryByText(/loading/i)).not.toBeInTheDocument()
|
|
29
|
+
);
|
|
30
|
+
await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument());
|
|
29
31
|
expect(container).toMatchSnapshot();
|
|
30
32
|
});
|
|
31
33
|
});
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { waitFor } from "@testing-library/react";
|
|
2
3
|
import { render } from "@truedat/test/render";
|
|
4
|
+
import { multipleTemplatesMock } from "@truedat/test/mocks";
|
|
3
5
|
import { NewRuleImplementation } from "../NewRuleImplementation";
|
|
4
6
|
import { newRuleImplementationProps } from "../__test_samples__/NewRuleImplementationProps";
|
|
5
7
|
|
|
6
|
-
const renderOpts = {
|
|
7
|
-
state: { ruleImplementationCreating: false },
|
|
8
|
-
};
|
|
9
|
-
|
|
10
8
|
describe("<NewRuleImplementation />", () => {
|
|
11
9
|
const createRuleImplementation = jest.fn();
|
|
12
10
|
const updateRuleImplementation = jest.fn();
|
|
@@ -18,29 +16,43 @@ describe("<NewRuleImplementation />", () => {
|
|
|
18
16
|
updateRuleImplementation,
|
|
19
17
|
sources,
|
|
20
18
|
};
|
|
19
|
+
const renderOpts = {
|
|
20
|
+
mocks: [
|
|
21
|
+
multipleTemplatesMock({
|
|
22
|
+
scope: "ri",
|
|
23
|
+
domainIds: null,
|
|
24
|
+
}),
|
|
25
|
+
],
|
|
26
|
+
state: { ruleImplementationCreating: false },
|
|
27
|
+
fallback: "lazy",
|
|
28
|
+
};
|
|
21
29
|
|
|
22
|
-
it("matches the latest snapshot", () => {
|
|
23
|
-
const { container } = render(
|
|
24
|
-
<
|
|
25
|
-
<NewRuleImplementation {...props} />
|
|
26
|
-
</Suspense>,
|
|
30
|
+
it("matches the latest snapshot", async () => {
|
|
31
|
+
const { container, queryByText } = render(
|
|
32
|
+
<NewRuleImplementation {...props} />,
|
|
27
33
|
renderOpts
|
|
28
34
|
);
|
|
35
|
+
await waitFor(() =>
|
|
36
|
+
expect(queryByText(/loading/i)).not.toBeInTheDocument()
|
|
37
|
+
);
|
|
38
|
+
await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument());
|
|
29
39
|
expect(container).toMatchSnapshot();
|
|
30
40
|
});
|
|
31
41
|
|
|
32
|
-
it("calculate aliases when not informed", () => {
|
|
42
|
+
it("calculate aliases when not informed", async () => {
|
|
33
43
|
const applyTemplate = jest.fn();
|
|
34
44
|
const props = {
|
|
35
45
|
...newRuleImplementationProps,
|
|
36
46
|
applyTemplate: applyTemplate,
|
|
37
47
|
};
|
|
38
|
-
const { container } = render(
|
|
39
|
-
<
|
|
40
|
-
<NewRuleImplementation {...props} />
|
|
41
|
-
</Suspense>,
|
|
48
|
+
const { container, queryByText } = render(
|
|
49
|
+
<NewRuleImplementation {...props} />,
|
|
42
50
|
renderOpts
|
|
43
51
|
);
|
|
52
|
+
await waitFor(() =>
|
|
53
|
+
expect(queryByText(/loading/i)).not.toBeInTheDocument()
|
|
54
|
+
);
|
|
55
|
+
await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument());
|
|
44
56
|
expect(container).toMatchSnapshot();
|
|
45
57
|
});
|
|
46
58
|
});
|