@truedat/bg 7.9.1 → 7.10.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 +4 -4
- package/src/concepts/api.js +3 -2
- package/src/concepts/components/ConceptLinksUploadButton.js +61 -0
- package/src/concepts/components/ConceptsUploadEventsTable.js +55 -34
- package/src/concepts/components/__tests__/ConceptLinksUploadButton.spec.js +36 -0
- package/src/concepts/components/__tests__/__snapshots__/ConceptLinksUploadButton.spec.js.snap +15 -0
- package/src/concepts/hooks/useConcepts.js +7 -0
- package/src/concepts/relations/components/ConceptSelector.js +7 -3
- package/src/concepts/relations/components/__tests__/__snapshots__/ConceptSelector.spec.js.snap +9 -0
- package/src/concepts/routines.js +1 -0
- package/src/concepts/selectors/messages.js +41 -27
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/bg",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.10.1",
|
|
4
4
|
"description": "Truedat Web Business Glossary",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -48,14 +48,14 @@
|
|
|
48
48
|
"@testing-library/jest-dom": "^6.6.3",
|
|
49
49
|
"@testing-library/react": "^16.3.0",
|
|
50
50
|
"@testing-library/user-event": "^14.6.1",
|
|
51
|
-
"@truedat/test": "7.
|
|
51
|
+
"@truedat/test": "7.10.1",
|
|
52
52
|
"identity-obj-proxy": "^3.0.0",
|
|
53
53
|
"jest": "^29.7.0",
|
|
54
54
|
"redux-saga-test-plan": "^4.0.6"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@apollo/client": "^3.13.8",
|
|
58
|
-
"axios": "^1.
|
|
58
|
+
"axios": "^1.12.0",
|
|
59
59
|
"file-saver": "^2.0.5",
|
|
60
60
|
"graphql": "^16.11.0",
|
|
61
61
|
"is-hotkey": "^0.2.0",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"semantic-ui-react": "^3.0.0-beta.2",
|
|
82
82
|
"swr": "^2.3.3"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "298f4337db6d49836f8443dd644e80c0d41c05df"
|
|
85
85
|
}
|
package/src/concepts/api.js
CHANGED
|
@@ -10,8 +10,8 @@ const API_BUSINESS_CONCEPT_VERSIONS_SEARCH =
|
|
|
10
10
|
const API_BUSINESS_CONCEPT_VERSIONS_UPLOAD =
|
|
11
11
|
"/api/business_concept_versions/upload";
|
|
12
12
|
const API_CONCEPT_ARCHIVE = "/api/business_concepts/:id/versions";
|
|
13
|
-
const API_CONCEPT_LINKS_DOWNLOAD =
|
|
14
|
-
|
|
13
|
+
const API_CONCEPT_LINKS_DOWNLOAD = "/api/business_concept_versions/links/download";
|
|
14
|
+
const API_CONCEPT_LINKS_UPLOAD = "/api/relations/links/upload";
|
|
15
15
|
const API_CONCEPT_FILTERS = "/api/business_concept_filters/search";
|
|
16
16
|
const API_CONCEPT_SHARED_DOMAINS = "/api/business_concepts/:id/shared_domains";
|
|
17
17
|
const API_BUSINESS_CONCEPT_BULK_UPDATE =
|
|
@@ -30,6 +30,7 @@ export {
|
|
|
30
30
|
API_BUSINESS_CONCEPT_VERSIONS_UPLOAD,
|
|
31
31
|
API_CONCEPT_ARCHIVE,
|
|
32
32
|
API_CONCEPT_LINKS_DOWNLOAD,
|
|
33
|
+
API_CONCEPT_LINKS_UPLOAD,
|
|
33
34
|
API_CONCEPT_FILTERS,
|
|
34
35
|
API_CONCEPT_SHARED_DOMAINS,
|
|
35
36
|
API_BUSINESS_CONCEPT_BULK_UPDATE,
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Button } from "semantic-ui-react";
|
|
2
|
+
import { FormattedMessage, useIntl } from "react-intl";
|
|
3
|
+
import { UploadModal } from "@truedat/core/components";
|
|
4
|
+
import { useConceptLinksUpload } from "../hooks/useConcepts";
|
|
5
|
+
import { useWebContext } from "@truedat/core/webContext";
|
|
6
|
+
import { getUploadAlertMessage } from "../selectors/messages";
|
|
7
|
+
|
|
8
|
+
export const ConceptLinksUploadButton = () => {
|
|
9
|
+
const { formatMessage } = useIntl();
|
|
10
|
+
const { trigger: triggerUpload, isMutating: loading } =
|
|
11
|
+
useConceptLinksUpload();
|
|
12
|
+
const { setAlertMessage } = useWebContext();
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<UploadModal
|
|
16
|
+
icon="upload"
|
|
17
|
+
trigger={
|
|
18
|
+
<Button
|
|
19
|
+
secondary
|
|
20
|
+
floated="right"
|
|
21
|
+
icon="upload"
|
|
22
|
+
loading={loading}
|
|
23
|
+
data-tooltip={formatMessage({
|
|
24
|
+
id: "concepts.actions.upload_links.tooltip",
|
|
25
|
+
})}
|
|
26
|
+
/>
|
|
27
|
+
}
|
|
28
|
+
header={
|
|
29
|
+
<FormattedMessage id="concepts.actions.upload_links.confirmation.header" />
|
|
30
|
+
}
|
|
31
|
+
content={
|
|
32
|
+
<FormattedMessage id="concepts.actions.upload.confirmation.content" />
|
|
33
|
+
}
|
|
34
|
+
param="relations"
|
|
35
|
+
handleSubmit={(data) => {
|
|
36
|
+
data.append("source", "business_concept");
|
|
37
|
+
data.append("target", "data_structure");
|
|
38
|
+
triggerUpload(data)
|
|
39
|
+
.then(({ status, data }) => {
|
|
40
|
+
const alertMessage = getUploadAlertMessage({ status, data });
|
|
41
|
+
console.log("alertMessage --->", alertMessage);
|
|
42
|
+
setAlertMessage(alertMessage);
|
|
43
|
+
})
|
|
44
|
+
.catch((error) => {
|
|
45
|
+
console.log("error --->", error);
|
|
46
|
+
if (error.response) {
|
|
47
|
+
const { status, data } = error.response;
|
|
48
|
+
const alertMessage = getUploadAlertMessage({ status, data });
|
|
49
|
+
console.log("error response alertMessage --->", alertMessage);
|
|
50
|
+
setAlertMessage(alertMessage);
|
|
51
|
+
} else {
|
|
52
|
+
console.log("error.message --->", error.message);
|
|
53
|
+
setAlertMessage(error.message);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}}
|
|
57
|
+
/>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export default ConceptLinksUploadButton;
|
|
@@ -16,18 +16,21 @@ const getColumnsWithData = (conceptsResults, columns) =>
|
|
|
16
16
|
)(columns);
|
|
17
17
|
|
|
18
18
|
const messagesImp = (data) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
const errors = data?.errors ?? [];
|
|
20
|
+
return _.map((error) => {
|
|
21
|
+
if (!error || !error.body)
|
|
22
|
+
return {
|
|
23
|
+
id: "unknown_error",
|
|
24
|
+
context: {},
|
|
25
|
+
defaultMessage: "concepts.upload.failed.success.errors",
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
id: error.body.message ?? "unknown_error",
|
|
30
|
+
context: { ...error.body.context } ?? {},
|
|
31
|
+
defaultMessage: "concepts.upload.failed.success.errors",
|
|
32
|
+
};
|
|
33
|
+
}, errors);
|
|
31
34
|
};
|
|
32
35
|
|
|
33
36
|
const ConceptsUploadEventsTable = ({ getColumns }) => {
|
|
@@ -38,33 +41,51 @@ const ConceptsUploadEventsTable = ({ getColumns }) => {
|
|
|
38
41
|
const events =
|
|
39
42
|
data && !loading
|
|
40
43
|
? _.reduce(
|
|
41
|
-
(acc, event) =>
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
(acc, event) => {
|
|
45
|
+
const eventKey = `${event.task_reference}_${event.status}`;
|
|
46
|
+
|
|
47
|
+
const node = event.node ?? "";
|
|
48
|
+
const hasErrors =
|
|
49
|
+
event.response?.errors && !_.isEmpty(event.response.errors);
|
|
50
|
+
|
|
51
|
+
const messageId = _.startsWith("lm@", node)
|
|
52
|
+
? hasErrors
|
|
53
|
+
? "concepts.upload.success.header_with_errors_without_update"
|
|
54
|
+
: "concepts.upload.success.header"
|
|
55
|
+
: hasErrors
|
|
56
|
+
? "concepts.upload.success.header_with_errors"
|
|
57
|
+
: "concepts.upload.success.header";
|
|
58
|
+
|
|
59
|
+
const translatedHeader = event.response
|
|
60
|
+
? formatMessage(
|
|
61
|
+
{ id: messageId },
|
|
62
|
+
{
|
|
63
|
+
count_created: event.response.created?.length ?? 0,
|
|
64
|
+
count_updated: event.response.updated?.length ?? 0,
|
|
65
|
+
count_errors: event.response.errors?.length ?? 0,
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
: "";
|
|
69
|
+
|
|
70
|
+
const translatedErrors = _.map((error) =>
|
|
71
|
+
formatMessage(
|
|
72
|
+
{ id: error.id ?? "unknown_error" },
|
|
73
|
+
error.context ?? {}
|
|
74
|
+
)
|
|
75
|
+
)(messagesImp(event.response));
|
|
76
|
+
|
|
77
|
+
acc[eventKey] = {
|
|
44
78
|
...event,
|
|
45
79
|
response: {
|
|
46
80
|
...event.response,
|
|
47
|
-
translatedHeader
|
|
48
|
-
|
|
49
|
-
: formatMessage(
|
|
50
|
-
{
|
|
51
|
-
id: _.isEmpty(event.response.errors)
|
|
52
|
-
? "concepts.upload.success.header"
|
|
53
|
-
: "concepts.upload.success.header_with_errors",
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
count_created: event.response.created.length,
|
|
57
|
-
count_updated: event.response.updated.length,
|
|
58
|
-
count_errors: event.response.errors.length,
|
|
59
|
-
}
|
|
60
|
-
),
|
|
61
|
-
translatedErrors: _.map((error) =>
|
|
62
|
-
formatMessage({ id: error.id }, error.context)
|
|
63
|
-
)(messagesImp(event.response)),
|
|
81
|
+
translatedHeader,
|
|
82
|
+
translatedErrors,
|
|
64
83
|
},
|
|
65
84
|
expanded: false,
|
|
66
|
-
}
|
|
67
|
-
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
return acc;
|
|
88
|
+
},
|
|
68
89
|
{},
|
|
69
90
|
data.data
|
|
70
91
|
)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { waitFor } from "@testing-library/react";
|
|
2
|
+
import userEvent from "@testing-library/user-event";
|
|
3
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
4
|
+
import { ConceptLinksUploadButton } from "../ConceptLinksUploadButton";
|
|
5
|
+
|
|
6
|
+
jest.mock("react-dropzone", () => ({
|
|
7
|
+
useDropzone: jest.fn(() => ({
|
|
8
|
+
getRootProps: jest.fn(),
|
|
9
|
+
getInputProps: jest.fn(),
|
|
10
|
+
isDragActive: false,
|
|
11
|
+
open: jest.fn(),
|
|
12
|
+
})),
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
jest.mock("@truedat/core/hooks", () => ({
|
|
16
|
+
useAuthorized: jest.fn(() => true),
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
const props = {
|
|
20
|
+
loading: false,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
describe("<ConceptLinksUploadButton />", () => {
|
|
24
|
+
it("matches the latest snapshot", async () => {
|
|
25
|
+
const user = userEvent.setup({ delay: null });
|
|
26
|
+
const rendered = render(<ConceptLinksUploadButton {...props} />);
|
|
27
|
+
await waitForLoad(rendered);
|
|
28
|
+
|
|
29
|
+
await user.click(rendered.getByRole("button"));
|
|
30
|
+
await waitFor(() =>
|
|
31
|
+
expect(rendered.getByRole("presentation")).toBeInTheDocument()
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
expect(rendered.container).toMatchSnapshot();
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`<ConceptLinksUploadButton /> matches the latest snapshot 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<button
|
|
6
|
+
class="ui icon secondary right floated button"
|
|
7
|
+
data-tooltip="concepts.actions.upload_links.tooltip"
|
|
8
|
+
>
|
|
9
|
+
<i
|
|
10
|
+
aria-hidden="true"
|
|
11
|
+
class="upload icon"
|
|
12
|
+
/>
|
|
13
|
+
</button>
|
|
14
|
+
</div>
|
|
15
|
+
`;
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
API_BUSINESS_CONCEPT_VERSIONS_SEARCH,
|
|
10
10
|
API_BUSINESS_CONCEPT_VERSIONS_ACTIONS,
|
|
11
11
|
API_BUSINESS_CONCEPT_VERSIONS_UPLOAD,
|
|
12
|
+
API_CONCEPT_LINKS_UPLOAD,
|
|
12
13
|
} from "../api";
|
|
13
14
|
|
|
14
15
|
function saveFile({ data, headers }) {
|
|
@@ -60,3 +61,9 @@ export const useConceptsUpload = () => {
|
|
|
60
61
|
apiJsonPost(url, arg)
|
|
61
62
|
);
|
|
62
63
|
};
|
|
64
|
+
|
|
65
|
+
export const useConceptLinksUpload = () => {
|
|
66
|
+
return useSWRMutations(API_CONCEPT_LINKS_UPLOAD, (url, { arg }) =>
|
|
67
|
+
apiJsonPost(url, arg)
|
|
68
|
+
);
|
|
69
|
+
};
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
import ConceptsPagination from "../../components/ConceptsPagination";
|
|
19
19
|
import { mapStatusColor } from "../../constants/mappings";
|
|
20
20
|
import { translations } from "../../utils/filterOptions";
|
|
21
|
+
import ConceptLinksUploadButton from "../../components/ConceptLinksUploadButton";
|
|
21
22
|
|
|
22
23
|
import {
|
|
23
24
|
useConceptLinksDownload,
|
|
@@ -103,7 +104,7 @@ export function ConceptSelectorContent({
|
|
|
103
104
|
)(concept)
|
|
104
105
|
: false;
|
|
105
106
|
};
|
|
106
|
-
|
|
107
|
+
|
|
107
108
|
return (
|
|
108
109
|
<>
|
|
109
110
|
{showTitle && (
|
|
@@ -112,7 +113,8 @@ export function ConceptSelectorContent({
|
|
|
112
113
|
</label>
|
|
113
114
|
)}
|
|
114
115
|
<Segment>
|
|
115
|
-
{conceptsActions?.downloadLinks && (
|
|
116
|
+
{conceptsActions?.downloadLinks && (
|
|
117
|
+
<>
|
|
116
118
|
<Button
|
|
117
119
|
icon="download"
|
|
118
120
|
floated="right"
|
|
@@ -122,7 +124,9 @@ export function ConceptSelectorContent({
|
|
|
122
124
|
data-tooltip={formatMessage({
|
|
123
125
|
id: "concepts.actions.downloadLinks.tooltip",
|
|
124
126
|
})}
|
|
125
|
-
/>
|
|
127
|
+
/>
|
|
128
|
+
<ConceptLinksUploadButton />
|
|
129
|
+
</>
|
|
126
130
|
)}
|
|
127
131
|
<SearchWidget />
|
|
128
132
|
{!_.isEmpty(concepts) || selectedConcept ? (
|
package/src/concepts/relations/components/__tests__/__snapshots__/ConceptSelector.spec.js.snap
CHANGED
|
@@ -17,6 +17,15 @@ exports[`<ConceptSelector /> matches the latest snapshot 1`] = `
|
|
|
17
17
|
class="download icon"
|
|
18
18
|
/>
|
|
19
19
|
</button>
|
|
20
|
+
<button
|
|
21
|
+
class="ui icon secondary right floated button"
|
|
22
|
+
data-tooltip="concepts.actions.upload_links.tooltip"
|
|
23
|
+
>
|
|
24
|
+
<i
|
|
25
|
+
aria-hidden="true"
|
|
26
|
+
class="upload icon"
|
|
27
|
+
/>
|
|
28
|
+
</button>
|
|
20
29
|
<div
|
|
21
30
|
class="ui action left icon input"
|
|
22
31
|
>
|
package/src/concepts/routines.js
CHANGED
|
@@ -5,6 +5,7 @@ export const conceptAction = createRoutine("CONCEPT_ACTION");
|
|
|
5
5
|
export const downloadConcepts = createRoutine("DOWNLOAD_CONCEPTS");
|
|
6
6
|
export const fetchConcept = createRoutine("FETCH_CONCEPT");
|
|
7
7
|
export const fetchConceptArchive = createRoutine("FETCH_CONCEPT_ARCHIVE");
|
|
8
|
+
export const uploadConcepts = createRoutine("UPLOAD_CONCEPTS");
|
|
8
9
|
|
|
9
10
|
export const bulkUpdate = createRoutine("BULK_UPDATE");
|
|
10
11
|
export const bulkUpdateQuery = createRoutine("BULK_UPDATE_QUERY");
|
|
@@ -2,31 +2,45 @@ import _ from "lodash/fp";
|
|
|
2
2
|
import { CONCEPTS_BULK_UPLOAD_EVENTS } from "@truedat/core/routes";
|
|
3
3
|
|
|
4
4
|
export const getUploadAlertMessage = ({ status, data }) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
if (status === 202) {
|
|
6
|
+
return {
|
|
7
|
+
error: false,
|
|
8
|
+
header: "concepts.upload.success.accepted.header",
|
|
9
|
+
icon: "check",
|
|
10
|
+
color: "blue",
|
|
11
|
+
text: "",
|
|
12
|
+
anchor: {
|
|
13
|
+
reference: CONCEPTS_BULK_UPLOAD_EVENTS,
|
|
14
|
+
label: "sidemenu.concepts_upload_events",
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
19
|
+
if (status == 400 && !_.prop("errors")(data)) {
|
|
20
|
+
return {
|
|
21
|
+
error: true,
|
|
22
|
+
header: "concepts.upload.failed.header.default",
|
|
23
|
+
content: `concepts.upload.failed.${
|
|
24
|
+
_.path("error.error")(data) || _.prop("error")(data)
|
|
25
|
+
}`,
|
|
26
|
+
icon: "attention",
|
|
27
|
+
text: "",
|
|
28
|
+
fields: _.prop("error")(data),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (status != 500 && !_.prop("errors")(data)) {
|
|
33
|
+
return {
|
|
34
|
+
error: true,
|
|
35
|
+
header: "concepts.upload.failed.header",
|
|
36
|
+
content: `concepts.upload.failed.${
|
|
37
|
+
_.path("error.error")(data) || _.prop("error")(data)
|
|
38
|
+
}`,
|
|
39
|
+
icon: "attention",
|
|
40
|
+
text: "",
|
|
41
|
+
fields: _.prop("error")(data),
|
|
42
|
+
};
|
|
43
|
+
} else {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
};
|