@truedat/qx 7.6.0 → 7.6.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/package.json +3 -3
- package/src/components/index.js +2 -1
- package/src/components/qualityControls/QualityControlEditor.js +2 -0
- package/src/components/qualityControls/QualityControlRoutes.js +13 -4
- package/src/components/qualityControls/QualityControlScores.js +141 -91
- package/src/components/qualityControls/ScoreCriteriaView.js +2 -2
- package/src/components/qualityControls/__tests__/NewQualityControl.spec.js +12 -4
- package/src/components/qualityControls/__tests__/QualityBadge.spec.js +3 -3
- package/src/components/qualityControls/__tests__/QualityControlEditor.spec.js +42 -14
- package/src/components/qualityControls/__tests__/QualityControlRoutes.spec.js +128 -0
- package/src/components/qualityControls/__tests__/QualityControlScores.spec.js +154 -48
- package/src/components/qualityControls/__tests__/__snapshots__/QualityControlRoutes.spec.js.snap +27 -0
- package/src/components/qualityControls/__tests__/__snapshots__/QualityControlScores.spec.js.snap +71 -0
- package/src/components/qualityControls/qualityByControlMode.js +6 -6
- package/src/components/qualityControls/scoreCriterias/Count.js +2 -2
- package/src/components/qualityControls/scoreCriterias/ErrorCount.js +2 -2
- package/src/components/qualityControls/scoreCriterias/__tests__/ErrorCount.spec.js +7 -7
- package/src/components/qualityControls/scoreCriterias/__tests__/__snapshots__/ErrorCount.spec.js.snap +3 -0
- package/src/components/scores/ScoreContext.js +64 -2
- package/src/components/scores/ScoreDetails.js +13 -2
- package/src/components/scores/ScoreGroupsTable.js +55 -50
- package/src/components/scores/ScorePagination.js +28 -0
- package/src/components/scores/__tests__/ScoreContext.spec.js +64 -0
- package/src/components/scores/__tests__/ScorePagination.spec.js +66 -0
- package/src/components/scores/__tests__/__snapshots__/ScoreDetails.spec.js.snap +13 -0
- package/src/components/scores/__tests__/__snapshots__/ScorePagination.spec.js.snap +220 -0
- package/src/components/scores/index.js +4 -2
- package/src/components/selectors/__tests__/__snapshots__/getMyScoreGroupsColumns.spec.js.snap +54 -0
- package/src/components/selectors/__tests__/__snapshots__/getQualityControlScoresColumns.spec.js.snap +34 -0
- package/src/components/selectors/__tests__/getMyScoreGroupsColumns.spec.js +59 -0
- package/src/components/selectors/__tests__/getQualityControlScoresColumns.spec.js +43 -0
- package/src/components/selectors/getMyScoreGroupsColumns.js +50 -0
- package/src/components/{qualityControls/qualityControlScoresColumns.js → selectors/getQualityControlScoresColumns.js} +19 -4
- package/src/components/selectors/index.js +2 -0
- package/src/hooks/useScores.js +6 -3
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import { defaultMyScoreGroupsColumns } from "../getMyScoreGroupsColumns";
|
|
4
|
+
import { getMyScoreGroupsColumns } from "../getMyScoreGroupsColumns";
|
|
5
|
+
import { scoreGroupData } from "@truedat/qx/components/scores/__tests__/__fixtures__/scoreHelper";
|
|
6
|
+
|
|
7
|
+
describe("selectors: getMyScoreGroupsColumns", () => {
|
|
8
|
+
it("should return default columns when no state is provided", () => {
|
|
9
|
+
const state = {
|
|
10
|
+
scores: [scoreGroupData({ status_summary: { PENDING: 1, QUEUED: 2 } })],
|
|
11
|
+
};
|
|
12
|
+
const columns = getMyScoreGroupsColumns({ ...state });
|
|
13
|
+
expect(_.map("name")(columns)).toEqual(
|
|
14
|
+
_.map("name")(defaultMyScoreGroupsColumns)
|
|
15
|
+
);
|
|
16
|
+
expect(columns).toMatchSnapshot();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("should render score group link", async () => {
|
|
20
|
+
const scoreGroup = scoreGroupData();
|
|
21
|
+
const state = { scores: [scoreGroup] };
|
|
22
|
+
const columns = getMyScoreGroupsColumns({ ...state });
|
|
23
|
+
const createdColumn = columns[0];
|
|
24
|
+
const rendered = render(createdColumn.fieldDecorator(scoreGroup));
|
|
25
|
+
|
|
26
|
+
expect(rendered.container.querySelector("a")).toHaveAttribute(
|
|
27
|
+
"href",
|
|
28
|
+
expect.stringContaining(`/scoreGroups/${scoreGroup.id}`)
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("should render status labels", async () => {
|
|
33
|
+
const state = {
|
|
34
|
+
scores: [scoreGroupData({ status_summary: { PENDING: 1 } })],
|
|
35
|
+
};
|
|
36
|
+
const columns = getMyScoreGroupsColumns({ ...state });
|
|
37
|
+
const statusColumn = columns[1];
|
|
38
|
+
|
|
39
|
+
const rendered = render(statusColumn.fieldDecorator(1));
|
|
40
|
+
|
|
41
|
+
expect(
|
|
42
|
+
rendered.container.querySelector(".ui.yellow.circular.label")
|
|
43
|
+
).toHaveTextContent("1");
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("should not render status label when count is 0", async () => {
|
|
47
|
+
const state = {
|
|
48
|
+
scores: [scoreGroupData({ status_summary: { PENDING: 0 } })],
|
|
49
|
+
};
|
|
50
|
+
const columns = getMyScoreGroupsColumns({ ...state });
|
|
51
|
+
const statusColumn = columns[1];
|
|
52
|
+
|
|
53
|
+
const rendered = render(statusColumn.fieldDecorator(0));
|
|
54
|
+
|
|
55
|
+
expect(
|
|
56
|
+
rendered.container.querySelector(".ui.label")
|
|
57
|
+
).not.toBeInTheDocument();
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import { defaultQualityControlScoresColumns } from "../getQualityControlScoresColumns";
|
|
4
|
+
import { getQualityControlScoresColumns } from "../getQualityControlScoresColumns";
|
|
5
|
+
import { scoreData } from "@truedat/qx/components/scores/__tests__/__fixtures__/scoreHelper";
|
|
6
|
+
|
|
7
|
+
describe("selectors: getQualityControlScoresColumns", () => {
|
|
8
|
+
it("should return default columns when no state is provided", () => {
|
|
9
|
+
const state = { scores: [scoreData()] };
|
|
10
|
+
const columns = getQualityControlScoresColumns({ ...state });
|
|
11
|
+
expect(_.map("name")(columns)).toEqual(
|
|
12
|
+
_.map("name")(defaultQualityControlScoresColumns)
|
|
13
|
+
);
|
|
14
|
+
expect(columns).toMatchSnapshot();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("should render score link with execution timestamp", async () => {
|
|
18
|
+
const bar = scoreData();
|
|
19
|
+
const state = { scores: [bar] };
|
|
20
|
+
const columns = getQualityControlScoresColumns({ ...state });
|
|
21
|
+
|
|
22
|
+
const executionTimestampColumn = columns[0];
|
|
23
|
+
|
|
24
|
+
const rendered = render(executionTimestampColumn.fieldDecorator(bar));
|
|
25
|
+
|
|
26
|
+
expect(rendered.container.querySelector("a")).toHaveAttribute(
|
|
27
|
+
"href",
|
|
28
|
+
expect.stringContaining(`/scores/${bar.id}`)
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
expect(rendered.container).toHaveTextContent("2024-11-19 16:34");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("should render status message", async () => {
|
|
35
|
+
const state = { scores: [scoreData({ status: "PENDING" })] };
|
|
36
|
+
const columns = getQualityControlScoresColumns({ ...state });
|
|
37
|
+
const statusColumn = columns[1];
|
|
38
|
+
|
|
39
|
+
const rendered = render(statusColumn.fieldDecorator("PENDING"));
|
|
40
|
+
|
|
41
|
+
expect(rendered.container).toHaveTextContent("score.status.PENDING");
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Label } from "semantic-ui-react";
|
|
4
|
+
import { createSelector } from "reselect";
|
|
5
|
+
import ScoreGroupLink from "@truedat/qx/components/scores/ScoreGroupLink";
|
|
6
|
+
|
|
7
|
+
const statusDecorator = (field, color) => {
|
|
8
|
+
return field ? (
|
|
9
|
+
<Label
|
|
10
|
+
circular
|
|
11
|
+
color={
|
|
12
|
+
{
|
|
13
|
+
PENDING: "yellow",
|
|
14
|
+
QUEUED: "yellow",
|
|
15
|
+
STARTED: "yellow",
|
|
16
|
+
SUCCEEDED: "green",
|
|
17
|
+
FAILED: "red",
|
|
18
|
+
TIMEOUT: "red",
|
|
19
|
+
}[color]
|
|
20
|
+
}
|
|
21
|
+
>
|
|
22
|
+
{field}
|
|
23
|
+
</Label>
|
|
24
|
+
) : null;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const statusColumns = _.map((status) => ({
|
|
28
|
+
name: `score.status.${status}`,
|
|
29
|
+
fieldSelector: _.pathOr(null, `status_summary.${status}`),
|
|
30
|
+
fieldDecorator: (field) => statusDecorator(field, status),
|
|
31
|
+
textAlign: "center",
|
|
32
|
+
width: 2,
|
|
33
|
+
}))(["PENDING", "QUEUED", "STARTED", "SUCCEEDED", "FAILED", "TIMEOUT"]);
|
|
34
|
+
|
|
35
|
+
export const defaultMyScoreGroupsColumns = [
|
|
36
|
+
{
|
|
37
|
+
name: "score_groups.table.header.created",
|
|
38
|
+
width: 4,
|
|
39
|
+
fieldSelector: _.identity,
|
|
40
|
+
fieldDecorator: ScoreGroupLink,
|
|
41
|
+
},
|
|
42
|
+
...statusColumns,
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
const getColumns = (state) => state.myScoreGroupsColumns;
|
|
46
|
+
|
|
47
|
+
export const getMyScoreGroupsColumns = createSelector(
|
|
48
|
+
getColumns,
|
|
49
|
+
_.defaultTo(defaultMyScoreGroupsColumns)
|
|
50
|
+
);
|
|
@@ -2,9 +2,10 @@ import _ from "lodash/fp";
|
|
|
2
2
|
import { Link } from "react-router";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { FormattedMessage } from "react-intl";
|
|
5
|
-
import { DateDecorator } from "@truedat/core/services/columnDecorators";
|
|
6
5
|
import { linkTo } from "@truedat/core/routes";
|
|
7
|
-
import
|
|
6
|
+
import { DateDecorator } from "@truedat/core/services/columnDecorators";
|
|
7
|
+
import { createSelector } from "reselect";
|
|
8
|
+
import QualityBadge from "@truedat/qx/components/qualityControls/QualityBadge";
|
|
8
9
|
|
|
9
10
|
const ScoreLink = ({ id, execution_timestamp }) => (
|
|
10
11
|
<Link to={linkTo.SCORE({ id })}>
|
|
@@ -15,13 +16,16 @@ const ScoreLink = ({ id, execution_timestamp }) => (
|
|
|
15
16
|
)}
|
|
16
17
|
</Link>
|
|
17
18
|
);
|
|
19
|
+
const createdAtDecorator = ({ created_at }) => {
|
|
20
|
+
return DateDecorator({ date: created_at });
|
|
21
|
+
};
|
|
18
22
|
|
|
19
23
|
ScoreLink.propTypes = {
|
|
20
24
|
id: PropTypes.number,
|
|
21
25
|
execution_timestamp: PropTypes.string,
|
|
22
26
|
};
|
|
23
27
|
|
|
24
|
-
export
|
|
28
|
+
export const defaultQualityControlScoresColumns = [
|
|
25
29
|
{
|
|
26
30
|
name: "execution_timestamp",
|
|
27
31
|
fieldSelector: _.identity,
|
|
@@ -41,11 +45,15 @@ export default [
|
|
|
41
45
|
{
|
|
42
46
|
name: "control_mode",
|
|
43
47
|
fieldSelector: ({ quality_control: { control_mode } }) => control_mode,
|
|
44
|
-
|
|
45
48
|
fieldDecorator: (controlMode) => (
|
|
46
49
|
<FormattedMessage id={`quality_control.control_mode.${controlMode}`} />
|
|
47
50
|
),
|
|
48
51
|
},
|
|
52
|
+
{
|
|
53
|
+
name: "created_at",
|
|
54
|
+
fieldSelector: _.pick(["created_at"]),
|
|
55
|
+
fieldDecorator: createdAtDecorator,
|
|
56
|
+
},
|
|
49
57
|
{
|
|
50
58
|
name: "quality_control_status",
|
|
51
59
|
fieldDecorator: (quality_control_status) =>
|
|
@@ -56,3 +64,10 @@ export default [
|
|
|
56
64
|
) : null,
|
|
57
65
|
},
|
|
58
66
|
];
|
|
67
|
+
|
|
68
|
+
const getColumns = (state) => state.qualityControlScoresColumns;
|
|
69
|
+
|
|
70
|
+
export const getQualityControlScoresColumns = createSelector(
|
|
71
|
+
getColumns,
|
|
72
|
+
_.defaultTo(defaultQualityControlScoresColumns)
|
|
73
|
+
);
|
package/src/hooks/useScores.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { compile } from "path-to-regexp";
|
|
2
2
|
import useSWR from "swr";
|
|
3
3
|
import useSWRMutations from "swr/mutation";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
apiJson,
|
|
6
|
+
apiJsonDelete,
|
|
7
|
+
apiJsonPost,
|
|
8
|
+
} from "@truedat/core/services/api";
|
|
5
9
|
import { API_SCORE, API_QUALITY_CONTROL_SCORES } from "../api";
|
|
6
10
|
|
|
7
11
|
export const useQualityControlScores = (id) => {
|
|
8
12
|
const url = compile(API_QUALITY_CONTROL_SCORES)({ id: `${id}` });
|
|
9
|
-
|
|
10
|
-
return { data: data?.data, error, loading: !error && !data, mutate };
|
|
13
|
+
return useSWRMutations(url, (_url, { arg }) => apiJsonPost(url, arg));
|
|
11
14
|
};
|
|
12
15
|
|
|
13
16
|
export const useScoreShow = (id) => {
|