@truedat/dd 8.1.1 → 8.1.4

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/dd",
3
- "version": "8.1.1",
3
+ "version": "8.1.4",
4
4
  "description": "Truedat Web Data Dictionary",
5
5
  "sideEffects": false,
6
6
  "module": "src/index.js",
@@ -48,7 +48,7 @@
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": "8.1.1",
51
+ "@truedat/test": "8.1.4",
52
52
  "identity-obj-proxy": "^3.0.0",
53
53
  "jest": "^29.7.0",
54
54
  "redux-saga-test-plan": "^4.0.6"
@@ -83,5 +83,5 @@
83
83
  "svg-pan-zoom": "^3.6.2",
84
84
  "swr": "^2.3.3"
85
85
  },
86
- "gitHead": "26ff4767ae2a60605d4958208ca73d91cfe7f81a"
86
+ "gitHead": "49d0d43e081d0f631f221d8f5992e390098b3630"
87
87
  }
@@ -11,7 +11,6 @@ import {
11
11
  PROFILE_GROUP,
12
12
  REFERENCE_DATASETS,
13
13
  STRUCTURES,
14
- STRUCTURES_UPLOAD_EVENTS,
15
14
  STRUCTURE_TAGS,
16
15
  STRUCTURE_TYPES,
17
16
  SYSTEMS,
@@ -40,6 +39,8 @@ import {
40
39
  } from "./CatalogViewConfigForm";
41
40
  import StructuresView from "./StructuresView";
42
41
  import BucketView from "./BucketView";
42
+ import UploadJobs from "@truedat/core/components/UploadJobs";
43
+ import UploadJob from "@truedat/core/components/UploadJob";
43
44
 
44
45
  const TemplatesLoader = React.lazy(
45
46
  () => import("@truedat/core/components/TemplatesLoader")
@@ -99,19 +100,25 @@ export default function DictionaryRoutes() {
99
100
  </ProtectedRoute>
100
101
  }
101
102
  />
102
- <Route
103
- path="/structureNotes"
104
- element={
105
- <>
106
- <SystemsLoader />
107
- <PendingStructureNotes
108
- defaultFilters={{
109
- note_status: ["rejected", "draft", "pending_approval"],
110
- }}
111
- />
112
- </>
113
- }
114
- />
103
+ <Route path="/structureNotes/*">
104
+ <Route
105
+ index
106
+ element={
107
+ <>
108
+ <SystemsLoader />
109
+ <PendingStructureNotes
110
+ defaultFilters={{
111
+ note_status: ["rejected", "draft", "pending_approval"],
112
+ }}
113
+ />
114
+ </>
115
+ }
116
+ />
117
+ <Route path="uploadJobs">
118
+ <Route index element={<UploadJobs scope="notes" />} />
119
+ <Route path=":id" element={<UploadJob scope="notes" />} />
120
+ </Route>
121
+ </Route>
115
122
 
116
123
  <Route path="/bucketViewConfigs">
117
124
  <Route index element={<CatalogViewConfigs />} />
@@ -0,0 +1,19 @@
1
+ import PropTypes from "prop-types";
2
+ import { Link } from "react-router";
3
+ import { linkTo } from "@truedat/core/routes";
4
+
5
+ export const StructureNoteLink = ({ data_structure_id, external_id }) =>
6
+ data_structure_id ? (
7
+ <Link to={linkTo.STRUCTURE_NOTES({ id: data_structure_id })}>
8
+ {external_id}
9
+ </Link>
10
+ ) : (
11
+ external_id
12
+ );
13
+
14
+ StructureNoteLink.propTypes = {
15
+ data_structure_id: PropTypes.number,
16
+ external_id: PropTypes.string,
17
+ };
18
+
19
+ export default StructureNoteLink;
@@ -4,13 +4,30 @@ import { Dropdown } from "semantic-ui-react";
4
4
  import { useIntl } from "react-intl";
5
5
  import { UploadModal } from "@truedat/core/components";
6
6
  import { useDataStructureUpload } from "../hooks/useStructures";
7
- import { getUploadAlertMessage } from "../selectors/messages";
7
+ import { linkTo } from "@truedat/core/routes";
8
+
9
+ const buildAlertResult =
10
+ (setAlertMessage) =>
11
+ ({ data }) => {
12
+ setAlertMessage({
13
+ error: false,
14
+ header: "structures.bulkUpload.alert.success.header",
15
+ icon: "check",
16
+ color: "blue",
17
+ text: "",
18
+ anchor: {
19
+ reference: linkTo.STRUCTURE_NOTES_UPLOAD_JOB({ id: data.job_id }),
20
+ label: "structures.bulkUpload.job.header",
21
+ },
22
+ });
23
+ };
8
24
 
9
25
  export const StructuresUploadOption = ({ canAutoPublish }) => {
10
26
  const { formatMessage, locale } = useIntl();
11
27
  const { trigger: triggerUpload, isMutating: structuresUploading } =
12
28
  useDataStructureUpload();
13
29
  const { setAlertMessage } = useWebContext();
30
+ const alertResult = buildAlertResult(setAlertMessage);
14
31
  const extraAction = {
15
32
  key: "yesWithAutoPublish",
16
33
  primary: true,
@@ -18,10 +35,7 @@ export const StructuresUploadOption = ({ canAutoPublish }) => {
18
35
  onClick: (data) => {
19
36
  data.append("auto_publish", canAutoPublish);
20
37
  data.append("lang", locale);
21
- triggerUpload(data).then(({ status, data }) => {
22
- const alertMessate = getUploadAlertMessage({ status, data });
23
- setAlertMessage(alertMessate);
24
- });
38
+ triggerUpload(data).then(alertResult);
25
39
  },
26
40
  };
27
41
 
@@ -45,10 +59,7 @@ export const StructuresUploadOption = ({ canAutoPublish }) => {
45
59
  param="structures"
46
60
  handleSubmit={(data) => {
47
61
  data.append("lang", locale);
48
- triggerUpload(data).then(({ status, data }) => {
49
- const alertMessate = getUploadAlertMessage({ status, data });
50
- setAlertMessage(alertMessate);
51
- });
62
+ triggerUpload(data).then(alertResult);
52
63
  }}
53
64
  />
54
65
  );
@@ -10,7 +10,7 @@ import {
10
10
  SYSTEMS,
11
11
  STRUCTURE_TAGS,
12
12
  STRUCTURE_TYPES,
13
- STRUCTURES_UPLOAD_EVENTS,
13
+ STRUCTURE_NOTES_UPLOAD_JOBS,
14
14
  PENDING_STRUCTURE_NOTES,
15
15
  REFERENCE_DATASETS,
16
16
  PROFILE_GROUP,
@@ -156,7 +156,7 @@ describe("<DictionaryRoutes />", () => {
156
156
 
157
157
  it("renders correctly with structures upload events route", async () => {
158
158
  const rendered = render(<DictionaryRoutes />, {
159
- routes: [STRUCTURES_UPLOAD_EVENTS],
159
+ routes: [STRUCTURE_NOTES_UPLOAD_JOBS],
160
160
  });
161
161
  await waitForLoad(rendered);
162
162
  expect(rendered.container).toMatchSnapshot();
@@ -0,0 +1,45 @@
1
+ import { render } from "@truedat/test/render";
2
+ import { StructureNoteLink } from "../StructureNoteLink";
3
+
4
+ describe("<StructureNoteLink />", () => {
5
+ it("renders a link to structure notes when data_structure_id is provided", () => {
6
+ const rendered = render(
7
+ <StructureNoteLink
8
+ data_structure_id={42}
9
+ external_id="my-structure-id"
10
+ />
11
+ );
12
+ const link = rendered.container.querySelector('a[href="/structures/42/notes"]');
13
+ expect(link).toBeInTheDocument();
14
+ expect(rendered.getByText(/my-structure-id/i)).toBeInTheDocument();
15
+ });
16
+
17
+ it("renders only external_id as text when data_structure_id is not provided", () => {
18
+ const rendered = render(
19
+ <StructureNoteLink external_id="some-external-id" />
20
+ );
21
+ expect(rendered.getByText(/some-external-id/i)).toBeInTheDocument();
22
+ expect(rendered.container.querySelector("a")).not.toBeInTheDocument();
23
+ });
24
+
25
+ it("renders only external_id when data_structure_id is zero", () => {
26
+ const rendered = render(
27
+ <StructureNoteLink data_structure_id={0} external_id="zero-id" />
28
+ );
29
+ expect(rendered.getByText(/zero-id/i)).toBeInTheDocument();
30
+ expect(rendered.container.querySelector("a")).not.toBeInTheDocument();
31
+ });
32
+
33
+ it("renders link with correct href for different structure id", () => {
34
+ const rendered = render(
35
+ <StructureNoteLink
36
+ data_structure_id={100}
37
+ external_id="structure-100"
38
+ />
39
+ );
40
+ expect(
41
+ rendered.container.querySelector('a[href="/structures/100/notes"]')
42
+ ).toBeInTheDocument();
43
+ expect(rendered.getByText(/structure-100/i)).toBeInTheDocument();
44
+ });
45
+ });
@@ -120,8 +120,45 @@ exports[`<DictionaryRoutes /> renders correctly with structures route 1`] = `
120
120
 
121
121
  exports[`<DictionaryRoutes /> renders correctly with structures upload events route 1`] = `
122
122
  <div>
123
- <div>
124
- StructuresUploadEvents
123
+ <div
124
+ class="ui breadcrumb"
125
+ >
126
+ <a
127
+ class="section"
128
+ data-discover="true"
129
+ href="/structureNotes/uploadJobs"
130
+ >
131
+ uploadJobs.notes.header
132
+ </a>
133
+ </div>
134
+ <div
135
+ class="ui segment"
136
+ >
137
+ <h2
138
+ class="ui header"
139
+ >
140
+ <i
141
+ aria-hidden="true"
142
+ class="cogs circular icon"
143
+ />
144
+ <div
145
+ class="content"
146
+ >
147
+ uploadJobs.notes.header
148
+ <div
149
+ class="sub header"
150
+ >
151
+ uploadJobs.subheader
152
+ </div>
153
+ </div>
154
+ </h2>
155
+ <div
156
+ class="dimmable"
157
+ >
158
+ <div
159
+ class="ui bottom attached segment"
160
+ />
161
+ </div>
125
162
  </div>
126
163
  </div>
127
164
  `;
@@ -22,6 +22,7 @@ import StructureItemRoot from "./StructureItemRoot";
22
22
  import StructureStructureLinks from "./StructureStructureLinks";
23
23
  import StructureLoader from "./StructureLoader";
24
24
  import StructureNav from "./StructureNav";
25
+ import StructureNoteLink from "./StructureNoteLink";
25
26
  import StructureNotes from "./StructureNotes";
26
27
  import StructureNotesEdit from "./StructureNotesEdit";
27
28
  import StructureProperties from "./StructureProperties";
@@ -75,6 +76,7 @@ export {
75
76
  StructureStructureLinks,
76
77
  StructureLoader,
77
78
  StructureNav,
79
+ StructureNoteLink,
78
80
  StructureNotes,
79
81
  StructureNotesEdit,
80
82
  StructureProperties,
@@ -1,5 +1,5 @@
1
1
 
2
- import { STRUCTURES_UPLOAD_EVENTS } from "@truedat/core/routes";
2
+ import { STRUCTURE_NOTES_UPLOAD_JOBS } from "@truedat/core/routes";
3
3
 
4
4
  const uploadWithErrors = (data) => {
5
5
  const messagesImp = _.has("errors")(data)
@@ -42,7 +42,7 @@ const uploadAccepted = () => {
42
42
  color: "blue",
43
43
  text: "",
44
44
  anchor: {
45
- reference: STRUCTURES_UPLOAD_EVENTS,
45
+ reference: STRUCTURE_NOTES_UPLOAD_JOBS,
46
46
  label: "sidemenu.structures_upload_events",
47
47
  },
48
48
  };