@truedat/dq 7.2.2 → 7.2.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/dq",
3
- "version": "7.2.2",
3
+ "version": "7.2.3",
4
4
  "description": "Truedat Web Data Quality Module",
5
5
  "sideEffects": false,
6
6
  "jsnext:main": "src/index.js",
@@ -34,7 +34,7 @@
34
34
  "@testing-library/jest-dom": "^5.16.5",
35
35
  "@testing-library/react": "^12.0.0",
36
36
  "@testing-library/user-event": "^13.2.1",
37
- "@truedat/test": "7.2.2",
37
+ "@truedat/test": "7.2.3",
38
38
  "babel-jest": "^28.1.0",
39
39
  "babel-plugin-dynamic-import-node": "^2.3.3",
40
40
  "babel-plugin-lodash": "^3.3.4",
@@ -92,8 +92,8 @@
92
92
  },
93
93
  "dependencies": {
94
94
  "@apollo/client": "^3.7.1",
95
- "@truedat/core": "7.2.2",
96
- "@truedat/df": "7.2.2",
95
+ "@truedat/core": "7.2.3",
96
+ "@truedat/df": "7.2.3",
97
97
  "decode-uri-component": "^0.2.2",
98
98
  "graphql": "^15.5.3",
99
99
  "moment": "^2.29.4",
@@ -118,5 +118,5 @@
118
118
  "react-dom": ">= 16.8.6 < 17",
119
119
  "semantic-ui-react": ">= 2.0.3 < 2.2"
120
120
  },
121
- "gitHead": "9033c57eccb9e6785c0a0c5aa6078c34788d6e7d"
121
+ "gitHead": "1f8b6f4d6fbd6e278493c35885e540c14f9c551b"
122
122
  }
@@ -4,69 +4,28 @@ import PropTypes from "prop-types";
4
4
  import { connect } from "react-redux";
5
5
  import { useIntl } from "react-intl";
6
6
  import { Table } from "semantic-ui-react";
7
- import { DateTime } from "@truedat/core/components";
8
7
  import { columnDecorator } from "@truedat/core/services";
8
+ import { getExecutionGroupColumns } from "../selectors";
9
9
  import ExecutionGroupMessage from "./ExecutionGroupMessage";
10
- import RuleResultDecorator from "./RuleResultDecorator";
11
- import RuleImplementationResultsLink from "./RuleImplementationResultsLink";
12
- import RuleEventDecorator from "./RuleEventDecorator";
13
10
  import ExecutionGroupContent from "./ExecutionGroupContent";
14
11
  import ExecutionGroupBreadcrumbs from "./ExecutionGroupBreadcrumbs";
15
12
 
16
- const COLUMNS = [
17
- {
18
- name: "ruleImplementations.props.status",
19
- fieldDecorator: RuleEventDecorator,
20
- fieldSelector: _.pick(["_embedded.quality_events"]),
21
- },
22
- {
23
- name: "ruleImplementations.props.implementation_key",
24
- fieldSelector: "_embedded.implementation",
25
- fieldDecorator: RuleImplementationResultsLink,
26
- },
27
- {
28
- name: "rule.props.name",
29
- fieldSelector: "_embedded.rule.name",
30
- },
31
- {
32
- name: "ruleResult.props.date",
33
- fieldDecorator: DateTime,
34
- textAlign: "center",
35
- fieldSelector: ({ _embedded }) => ({ value: _embedded?.result?.date }),
36
- },
37
- {
38
- name: "ruleResult.props.records",
39
- textAlign: "right",
40
- fieldSelector: "_embedded.result.records",
41
- },
42
- {
43
- name: "ruleResult.props.errors",
44
- textAlign: "right",
45
- fieldSelector: "_embedded.result.errors",
46
- },
47
- {
48
- name: "ruleResult.props.quality",
49
- fieldSelector: ({ _embedded }) => ({
50
- ruleResult: _embedded?.result,
51
- ruleImplementation: _embedded?.implementation,
52
- }),
53
- fieldDecorator: RuleResultDecorator,
54
- },
55
- ];
56
-
57
- export const ExecutionRow = ({ execution }) => (
58
- <Table.Row>
59
- {COLUMNS.map(({ textAlign, ...column }, i) => (
60
- <Table.Cell
61
- key={i}
62
- content={columnDecorator(column)(execution)}
63
- textAlign={textAlign}
64
- />
65
- ))}
66
- </Table.Row>
67
- );
13
+ export const ExecutionRow = ({ execution, columns }) => {
14
+ return (
15
+ <Table.Row>
16
+ {columns.map(({ textAlign, ...column }, i) => (
17
+ <Table.Cell
18
+ key={i}
19
+ content={columnDecorator(column)(execution)}
20
+ textAlign={textAlign}
21
+ />
22
+ ))}
23
+ </Table.Row>
24
+ );
25
+ };
68
26
 
69
27
  ExecutionRow.propTypes = {
28
+ columns: PropTypes.array,
70
29
  execution: PropTypes.object,
71
30
  };
72
31
 
@@ -74,7 +33,7 @@ const isCompleted = _.flow(_.prop("_embedded.status"), (s) =>
74
33
  _.includes(s)(["SUCCEEDED", "FAILED"])
75
34
  );
76
35
 
77
- export const ExecutionGroup = ({ executionGroup }) => {
36
+ export const ExecutionGroup = ({ executionGroup, columns }) => {
78
37
  const { formatMessage } = useIntl();
79
38
  const executions = _.sortBy("_embedded.implementation.implementation_key")(
80
39
  executionGroup?._embedded?.executions
@@ -96,7 +55,7 @@ export const ExecutionGroup = ({ executionGroup }) => {
96
55
  <Table>
97
56
  <Table.Header>
98
57
  <Table.Row>
99
- {COLUMNS.map(({ name: id, textAlign }, i) => (
58
+ {columns.map(({ name: id, textAlign }, i) => (
100
59
  <Table.HeaderCell
101
60
  key={i}
102
61
  content={formatMessage({ id })}
@@ -107,7 +66,7 @@ export const ExecutionGroup = ({ executionGroup }) => {
107
66
  </Table.Header>
108
67
  <Table.Body>
109
68
  {executions?.map((execution, i) => (
110
- <ExecutionRow key={i} execution={execution} />
69
+ <ExecutionRow key={i} execution={execution} columns={columns} />
111
70
  ))}
112
71
  </Table.Body>
113
72
  </Table>
@@ -116,9 +75,15 @@ export const ExecutionGroup = ({ executionGroup }) => {
116
75
  };
117
76
 
118
77
  ExecutionGroup.propTypes = {
78
+ columns: PropTypes.array,
119
79
  executionGroup: PropTypes.object,
120
80
  };
121
81
 
122
- export const mapStateToProps = ({ executionGroup }) => ({ executionGroup });
82
+ export const mapStateToProps = (state) => {
83
+ return {
84
+ columns: getExecutionGroupColumns(state),
85
+ executionGroup: state.executionGroup,
86
+ };
87
+ };
123
88
 
124
89
  export default connect(mapStateToProps)(ExecutionGroup);
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  import { render } from "@truedat/test/render";
3
3
  import ExecutionGroup from "../ExecutionGroup";
4
+ import { defaultExecutionGroupColumns } from "../../selectors";
4
5
 
5
6
  const rule = {
6
7
  id: 1,
@@ -13,6 +14,12 @@ const implementation = {
13
14
  result_type: "percentage",
14
15
  minimum: 10,
15
16
  goal: 20,
17
+ df_content: {
18
+ df_field: "implementation_df_value",
19
+ },
20
+ dynamic_content: {
21
+ df_field: { value: "implementation_df_value", origin: "user" },
22
+ },
16
23
  };
17
24
  const result = {
18
25
  id: 1,
@@ -48,4 +55,28 @@ describe("<ExecutionGroup />", () => {
48
55
  const { container } = render(<ExecutionGroup />, renderOpts);
49
56
  expect(container).toMatchSnapshot();
50
57
  });
58
+
59
+ it("defines custom columns", () => {
60
+ const executionGroupColumns = [
61
+ {
62
+ name: "implementation.df_field",
63
+ fieldSelector:
64
+ "_embedded.implementation.dynamic_content.df_field.value",
65
+ },
66
+ ...defaultExecutionGroupColumns,
67
+ ];
68
+ const customColumnsState = {
69
+ executionGroupColumns,
70
+ ...state,
71
+ };
72
+
73
+ const { queryByText } = render(<ExecutionGroup />, {
74
+ state: customColumnsState,
75
+ });
76
+ expect(queryByText(/Identifier/)).toBeInTheDocument();
77
+ expect(queryByText(/foo/)).toBeInTheDocument();
78
+
79
+ expect(queryByText(/implementation.df_field/)).toBeInTheDocument();
80
+ expect(queryByText(/implementation_df_value/)).toBeInTheDocument();
81
+ });
51
82
  });
@@ -54,11 +54,6 @@ exports[`<ExecutionGroup /> matches the latest snapshot 1`] = `
54
54
  >
55
55
  Identifier
56
56
  </th>
57
- <th
58
- class=""
59
- >
60
- Name
61
- </th>
62
57
  <th
63
58
  class="center aligned"
64
59
  >
@@ -104,11 +99,6 @@ exports[`<ExecutionGroup /> matches the latest snapshot 1`] = `
104
99
  foo
105
100
  </a>
106
101
  </td>
107
- <td
108
- class=""
109
- >
110
- rule_name
111
- </td>
112
102
  <td
113
103
  class="center aligned"
114
104
  >
@@ -0,0 +1,17 @@
1
+ import { getExecutionGroupColumns, defaultExecutionGroupColumns } from "..";
2
+
3
+ describe("selectors: getExecutionGroupColumns", () => {
4
+ it("should return custom ruleColumns when present", () => {
5
+ const executionGroupColumns = [{ name: "test" }];
6
+ const res = getExecutionGroupColumns({
7
+ executionGroupColumns,
8
+ });
9
+ expect(res).toHaveLength(1);
10
+ expect(res).toEqual(executionGroupColumns);
11
+ });
12
+
13
+ it("should return default defaultRuleImplementationColumns when no customized", () => {
14
+ const res = getExecutionGroupColumns({});
15
+ expect(res).toHaveLength(defaultExecutionGroupColumns.length);
16
+ });
17
+ });
@@ -0,0 +1,50 @@
1
+ import _ from "lodash/fp";
2
+ import { createSelector } from "reselect";
3
+ import DateTime from "@truedat/core/components/DateTime";
4
+ import RuleEventDecorator from "../components/RuleEventDecorator";
5
+ import RuleImplementationResultsLink from "../components/RuleImplementationResultsLink";
6
+ import RuleResultDecorator from "../components/RuleResultDecorator";
7
+
8
+ export const defaultExecutionGroupColumns = [
9
+ {
10
+ name: "ruleImplementations.props.status",
11
+ fieldDecorator: RuleEventDecorator,
12
+ fieldSelector: _.pick(["_embedded.quality_events"]),
13
+ },
14
+ {
15
+ name: "ruleImplementations.props.implementation_key",
16
+ fieldSelector: "_embedded.implementation",
17
+ fieldDecorator: RuleImplementationResultsLink,
18
+ },
19
+ {
20
+ name: "ruleResult.props.date",
21
+ fieldDecorator: DateTime,
22
+ textAlign: "center",
23
+ fieldSelector: ({ _embedded }) => ({ value: _embedded?.result?.date }),
24
+ },
25
+ {
26
+ name: "ruleResult.props.records",
27
+ textAlign: "right",
28
+ fieldSelector: "_embedded.result.records",
29
+ },
30
+ {
31
+ name: "ruleResult.props.errors",
32
+ textAlign: "right",
33
+ fieldSelector: "_embedded.result.errors",
34
+ },
35
+ {
36
+ name: "ruleResult.props.quality",
37
+ fieldSelector: ({ _embedded }) => ({
38
+ ruleResult: _embedded?.result,
39
+ ruleImplementation: _embedded?.implementation,
40
+ }),
41
+ fieldDecorator: RuleResultDecorator,
42
+ },
43
+ ];
44
+
45
+ const getColumns = (state) => state.executionGroupColumns;
46
+
47
+ export const getExecutionGroupColumns = createSelector(
48
+ [getColumns],
49
+ _.defaultTo(defaultExecutionGroupColumns)
50
+ );
@@ -31,6 +31,10 @@ export {
31
31
  getRuleImplementationColumns,
32
32
  defaultImplementationColumns,
33
33
  } from "./getRuleImplementationColumns";
34
+ export {
35
+ getExecutionGroupColumns,
36
+ defaultExecutionGroupColumns,
37
+ } from "./getExecutionGroupColumns";
34
38
  export { getPreviousRuleImplementationQuery } from "./getPreviousRuleImplementationQuery";
35
39
  export { getRuleImplementationAvailableFilters } from "./getRuleImplementationAvailableFilters";
36
40
  export { getRuleImplementationFilterTypes } from "./getRuleImplementationFilterTypes";