@truedat/qx 8.3.6 → 8.4.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.
- package/package.json +2 -2
- package/src/api.js +2 -0
- package/src/components/qualityControls/QualityControl.js +1 -1
- package/src/components/qualityControls/QualityControlActions.js +1 -0
- package/src/components/qualityControls/QualityControlManageDomain.js +4 -4
- package/src/components/qualityControls/__tests__/QualityControl.spec.js +2 -2
- package/src/components/qualityControls/__tests__/QualityControlManageDomain.spec.js +9 -8
- package/src/components/qualityControls/events/getParsedEvents.js +5 -5
- package/src/hooks/useQualityControls.js +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/qx",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.4.0",
|
|
4
4
|
"description": "Truedat Web Quality Experience package",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"semantic-ui-react": "^3.0.0-beta.2",
|
|
90
90
|
"swr": "^2.3.3"
|
|
91
91
|
},
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "d5bf6e90b3e11093255962cbd47534f2a67fe313"
|
|
93
93
|
}
|
package/src/api.js
CHANGED
|
@@ -5,6 +5,7 @@ const API_FUNCTIONS = "/api/quality_functions";
|
|
|
5
5
|
const API_QUALITY_CONTROL_DRAFT = "/api/quality_controls/:id/draft";
|
|
6
6
|
const API_QUALITY_CONTROL_FILTERS = "/api/quality_controls/filters";
|
|
7
7
|
const API_QUALITY_CONTROL_MAIN = "/api/quality_controls/:id/main";
|
|
8
|
+
const API_QUALITY_CONTROL_DOMAIN = "/api/quality_controls/:id/domain";
|
|
8
9
|
const API_QUALITY_CONTROL_PUBLISHED = "/api/quality_controls/:id/published";
|
|
9
10
|
const API_QUALITY_CONTROL_QUERIES = "/api/quality_controls/:id/queries";
|
|
10
11
|
const API_QUALITY_CONTROL_SEARCH = "/api/quality_controls/search";
|
|
@@ -33,6 +34,7 @@ export {
|
|
|
33
34
|
API_QUALITY_CONTROL_DRAFT,
|
|
34
35
|
API_QUALITY_CONTROL_FILTERS,
|
|
35
36
|
API_QUALITY_CONTROL_MAIN,
|
|
37
|
+
API_QUALITY_CONTROL_DOMAIN,
|
|
36
38
|
API_QUALITY_CONTROL_PUBLISHED,
|
|
37
39
|
API_QUALITY_CONTROL_QUERIES,
|
|
38
40
|
API_QUALITY_CONTROL_SEARCH,
|
|
@@ -37,7 +37,7 @@ const DomainPopup = () => {
|
|
|
37
37
|
|
|
38
38
|
export default function QualityControl() {
|
|
39
39
|
const { qualityControl, actions, loading } = use(QxContext);
|
|
40
|
-
const canUpdateDomain = _.includes("
|
|
40
|
+
const canUpdateDomain = _.includes("update_domain")(actions);
|
|
41
41
|
return (
|
|
42
42
|
<>
|
|
43
43
|
{loading ? (
|
|
@@ -5,14 +5,14 @@ import { useForm, Controller } from "react-hook-form";
|
|
|
5
5
|
import { useIntl } from "react-intl";
|
|
6
6
|
import { DomainSelector } from "@truedat/core/components";
|
|
7
7
|
import QxContext from "../QxContext";
|
|
8
|
-
import {
|
|
8
|
+
import { useQualityControlUpdateDomain } from "../../hooks/useQualityControls";
|
|
9
9
|
|
|
10
10
|
export default function QualityControlManageDomain({ handleOpen }) {
|
|
11
11
|
const { formatMessage } = useIntl();
|
|
12
12
|
const { qualityControl, mutate } = use(QxContext);
|
|
13
13
|
|
|
14
|
-
const { trigger:
|
|
15
|
-
|
|
14
|
+
const { trigger: updateDomainQualityControl, isMutating: isMutatingMain } =
|
|
15
|
+
useQualityControlUpdateDomain(qualityControl.id);
|
|
16
16
|
|
|
17
17
|
const domainIds = qualityControl.domain_ids;
|
|
18
18
|
const [loading, setLoading] = useState(true);
|
|
@@ -24,7 +24,7 @@ export default function QualityControlManageDomain({ handleOpen }) {
|
|
|
24
24
|
const { isDirty, isValid } = formState;
|
|
25
25
|
|
|
26
26
|
const onSubmit = ({ domainIds }) => {
|
|
27
|
-
|
|
27
|
+
updateDomainQualityControl({
|
|
28
28
|
quality_control: { domain_ids: domainIds },
|
|
29
29
|
}).then(() => {
|
|
30
30
|
handleOpen(false);
|
|
@@ -45,7 +45,7 @@ describe("<QualityControl />", () => {
|
|
|
45
45
|
it("matches the latest snapshot", async () => {
|
|
46
46
|
const context = {
|
|
47
47
|
qualityControl: qualityControlData(),
|
|
48
|
-
actions: ["update_main"],
|
|
48
|
+
actions: ["update_main", "update_domain"],
|
|
49
49
|
};
|
|
50
50
|
const rendered = render(
|
|
51
51
|
<TestFormWrapper context={context}>
|
|
@@ -74,7 +74,7 @@ describe("<QualityControl />", () => {
|
|
|
74
74
|
it("render popup when edit domain", async () => {
|
|
75
75
|
const context = {
|
|
76
76
|
qualityControl: qualityControlData(),
|
|
77
|
-
actions: ["update_main"],
|
|
77
|
+
actions: ["update_main", "update_domain"],
|
|
78
78
|
};
|
|
79
79
|
const rendered = render(
|
|
80
80
|
<TestFormWrapper context={context}>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { render } from "@truedat/test/render";
|
|
2
2
|
import { waitFor } from "@testing-library/react";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
3
4
|
import TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
|
|
4
5
|
import { messages } from "@truedat/qx/components/__tests__/__fixtures__/helper";
|
|
5
|
-
import userEvent from "@testing-library/user-event";
|
|
6
6
|
import { DOMAINS_QUERY } from "@truedat/core/api/queries";
|
|
7
|
-
import {
|
|
7
|
+
import { useQualityControlUpdateDomain } from "@truedat/qx/hooks/useQualityControls";
|
|
8
8
|
import QualityControlManageDomain from "../QualityControlManageDomain";
|
|
9
9
|
import { qualityControlData } from "./__fixtures__/qualityControlHelper";
|
|
10
10
|
|
|
@@ -14,7 +14,7 @@ jest.mock("@truedat/qx/hooks/useQualityControls", () => {
|
|
|
14
14
|
);
|
|
15
15
|
|
|
16
16
|
return {
|
|
17
|
-
|
|
17
|
+
useQualityControlUpdateDomain: jest.fn(() => ({
|
|
18
18
|
trigger: jest.fn(() => Promise.resolve()),
|
|
19
19
|
data: qualityControlData(),
|
|
20
20
|
isMutating: false,
|
|
@@ -77,13 +77,14 @@ describe("<QualityControlManageDomain />", () => {
|
|
|
77
77
|
expect(container).toMatchSnapshot();
|
|
78
78
|
});
|
|
79
79
|
|
|
80
|
-
it("calls
|
|
80
|
+
it("calls updateDomain when update button is clicked", async () => {
|
|
81
81
|
const trigger = jest.fn(() =>
|
|
82
82
|
Promise.resolve({ data: { data: { id: "9" } } })
|
|
83
83
|
);
|
|
84
|
-
|
|
84
|
+
useQualityControlUpdateDomain.mockImplementation(() => ({
|
|
85
85
|
trigger,
|
|
86
86
|
}));
|
|
87
|
+
const user = userEvent.setup({ delay: null });
|
|
87
88
|
|
|
88
89
|
const { container, queryByText, getByRole, getByText } = render(
|
|
89
90
|
<TestFormWrapper context={context}>
|
|
@@ -98,14 +99,14 @@ describe("<QualityControlManageDomain />", () => {
|
|
|
98
99
|
|
|
99
100
|
expect(getByRole("button", { name: "Update" })).toBeDisabled();
|
|
100
101
|
|
|
101
|
-
|
|
102
|
-
|
|
102
|
+
await user.click(getByRole("listbox"));
|
|
103
|
+
await user.click(getByRole("option", { name: "fooDomain" }));
|
|
103
104
|
|
|
104
105
|
await waitFor(() => {
|
|
105
106
|
expect(getByRole("button", { name: "Update" })).toBeEnabled();
|
|
106
107
|
});
|
|
107
108
|
|
|
108
|
-
|
|
109
|
+
await user.click(getByText(/update/i));
|
|
109
110
|
|
|
110
111
|
await waitFor(() => expect(trigger).toHaveBeenCalledTimes(1));
|
|
111
112
|
await waitFor(() => expect(handleOpen).toHaveBeenCalledTimes(1));
|
|
@@ -30,10 +30,10 @@ const getDomainNames = (path) => (event) =>
|
|
|
30
30
|
const getPayloadFromDomainChange = (event) => {
|
|
31
31
|
if (_.has("payload.changes.domains")(event)) {
|
|
32
32
|
const changedDomainNames = _.join(", ")(
|
|
33
|
-
getDomainNames("payload.changes.domains")(event)
|
|
33
|
+
getDomainNames("payload.changes.domains")(event),
|
|
34
34
|
);
|
|
35
35
|
const currentDomainNames = _.join(", ")(
|
|
36
|
-
getDomainNames("payload.current_domains")(event)
|
|
36
|
+
getDomainNames("payload.current_domains")(event),
|
|
37
37
|
);
|
|
38
38
|
return [
|
|
39
39
|
[
|
|
@@ -88,7 +88,7 @@ const getPayloadFromScoreCriteriaChange = (event) => {
|
|
|
88
88
|
b: bold,
|
|
89
89
|
},
|
|
90
90
|
];
|
|
91
|
-
})
|
|
91
|
+
}),
|
|
92
92
|
)(event?.payload?.changes?.score_criteria);
|
|
93
93
|
}
|
|
94
94
|
return [];
|
|
@@ -120,7 +120,7 @@ const getPayloadFromDynamicContentChange = (event) => {
|
|
|
120
120
|
_.map(([field, value]) => [
|
|
121
121
|
{ id: "quality_controls.events.action_dynamic_field_changed" },
|
|
122
122
|
{ field, value: normalizeValue(value?.value), b: bold },
|
|
123
|
-
])
|
|
123
|
+
]),
|
|
124
124
|
)(content);
|
|
125
125
|
}
|
|
126
126
|
return [];
|
|
@@ -150,7 +150,7 @@ const getPayloadFromRegularFields = (event) => {
|
|
|
150
150
|
_.map(([field, value]) => [
|
|
151
151
|
{ id: "quality_controls.events.action_field_changed" },
|
|
152
152
|
{ field, value: normalizeValue(value), b: bold },
|
|
153
|
-
])
|
|
153
|
+
]),
|
|
154
154
|
)(event?.payload?.changes);
|
|
155
155
|
}
|
|
156
156
|
return [];
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
API_QUALITY_CONTROL_DRAFT,
|
|
13
13
|
API_QUALITY_CONTROL_STATUS,
|
|
14
14
|
API_QUALITY_CONTROL_MAIN,
|
|
15
|
+
API_QUALITY_CONTROL_DOMAIN,
|
|
15
16
|
API_QUALITY_CONTROL_SEARCH,
|
|
16
17
|
API_QUALITY_CONTROL_FILTERS,
|
|
17
18
|
API_QUALITY_CONTROL_QUERIES,
|
|
@@ -53,6 +54,11 @@ export const useQualityControlUpdateMain = (id) => {
|
|
|
53
54
|
return useSWRMutations(url, (url, { arg }) => apiJsonPatch(url, arg));
|
|
54
55
|
};
|
|
55
56
|
|
|
57
|
+
export const useQualityControlUpdateDomain = (id) => {
|
|
58
|
+
const url = compile(API_QUALITY_CONTROL_DOMAIN)({ id: `${id}` });
|
|
59
|
+
return useSWRMutations(url, (url, { arg }) => apiJsonPatch(url, arg));
|
|
60
|
+
};
|
|
61
|
+
|
|
56
62
|
export const useQualityControlDelete = (qualityControl) => {
|
|
57
63
|
const id = qualityControl?.id || 0;
|
|
58
64
|
const version = qualityControl?.version || 0;
|