@truedat/dd 5.2.0 → 5.2.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/CHANGELOG.md +6 -0
- package/package.json +6 -6
- package/src/api/queries.js +241 -0
- package/src/components/StructureLoader.js +17 -43
- package/src/components/StructureNotes.js +1 -1
- package/src/components/StructureNotesEdit.js +2 -4
- package/src/components/__tests__/StructureFieldRow.spec.js +1 -1
- package/src/components/__tests__/StructureLoader.spec.js +11 -42
- package/src/components/__tests__/StructureMetadata.spec.js +1 -1
- package/src/components/__tests__/__snapshots__/StructureFieldRow.spec.js.snap +0 -3
- package/src/components/__tests__/__snapshots__/StructureLoader.spec.js.snap +1 -1
- package/src/messages/en.js +0 -1
- package/src/messages/es.js +0 -1
- package/src/reducers/structure.js +1 -1
- package/src/sagas/__tests__/fetchStructure.spec.js +65 -14
- package/src/sagas/fetchStructure.js +33 -12
- package/src/selectors/__tests__/getParsedEvents.spec.js +19 -19
- package/src/selectors/__tests__/getStructuresFields.spec.js +13 -23
- package/src/selectors/__tests__/getTabVisibility.spec.js +1 -1
- package/src/selectors/__tests__/metadataViewsSelector.spec.js +2 -2
- package/src/selectors/getParsedEvents.js +22 -22
- package/src/selectors/getStructureFieldColumns.js +0 -6
- package/src/selectors/getStructureProperties.js +3 -3
- package/src/selectors/getStructureRelations.js +12 -12
- package/src/selectors/getTabVisibility.js +1 -1
- package/src/selectors/metadataViewsSelector.js +1 -1
- package/src/selectors/structureColumnsSelector.js +5 -7
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/dd",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.1",
|
|
4
4
|
"description": "Truedat Web Data Dictionary",
|
|
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": "5.2.
|
|
37
|
+
"@truedat/test": "5.2.1",
|
|
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",
|
|
@@ -87,9 +87,9 @@
|
|
|
87
87
|
},
|
|
88
88
|
"dependencies": {
|
|
89
89
|
"@apollo/client": "^3.7.1",
|
|
90
|
-
"@truedat/auth": "5.2.
|
|
91
|
-
"@truedat/core": "5.2.
|
|
92
|
-
"@truedat/df": "5.2.
|
|
90
|
+
"@truedat/auth": "5.2.1",
|
|
91
|
+
"@truedat/core": "5.2.1",
|
|
92
|
+
"@truedat/df": "5.2.1",
|
|
93
93
|
"lodash": "^4.17.21",
|
|
94
94
|
"moment": "^2.29.4",
|
|
95
95
|
"path-to-regexp": "^1.7.0",
|
|
@@ -114,5 +114,5 @@
|
|
|
114
114
|
"react-dom": ">= 16.8.6 < 17",
|
|
115
115
|
"semantic-ui-react": ">= 2.0.3 < 2.2"
|
|
116
116
|
},
|
|
117
|
-
"gitHead": "
|
|
117
|
+
"gitHead": "1f9ce2ad2fb29d1d8dc5ccb8940a7f573e7127bc"
|
|
118
118
|
}
|
package/src/api/queries.js
CHANGED
|
@@ -205,3 +205,244 @@ export const STRUCTURE_STRUCTURE_LINKS_QUERY = gql`
|
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
`;
|
|
208
|
+
|
|
209
|
+
export const DATA_STRUCTURE_VERSION_QUERY = gql`
|
|
210
|
+
query DataStructureVersion(
|
|
211
|
+
$dataStructureId: ID!
|
|
212
|
+
$version: String!
|
|
213
|
+
$note_fields: [String]
|
|
214
|
+
) {
|
|
215
|
+
dataStructureVersion(dataStructureId: $dataStructureId, version: $version) {
|
|
216
|
+
id
|
|
217
|
+
version
|
|
218
|
+
class
|
|
219
|
+
description
|
|
220
|
+
name
|
|
221
|
+
type
|
|
222
|
+
group
|
|
223
|
+
deleted_at
|
|
224
|
+
metadata
|
|
225
|
+
data_structure {
|
|
226
|
+
alias
|
|
227
|
+
confidential
|
|
228
|
+
domain_ids
|
|
229
|
+
domains {
|
|
230
|
+
external_id
|
|
231
|
+
id
|
|
232
|
+
name
|
|
233
|
+
parent_id
|
|
234
|
+
parents {
|
|
235
|
+
external_id
|
|
236
|
+
id
|
|
237
|
+
name
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
external_id
|
|
241
|
+
id
|
|
242
|
+
inserted_at
|
|
243
|
+
latest_note
|
|
244
|
+
source {
|
|
245
|
+
external_id
|
|
246
|
+
id
|
|
247
|
+
}
|
|
248
|
+
source_id
|
|
249
|
+
system_id
|
|
250
|
+
updated_at
|
|
251
|
+
id
|
|
252
|
+
alias
|
|
253
|
+
confidential
|
|
254
|
+
domain_ids
|
|
255
|
+
domains {
|
|
256
|
+
id
|
|
257
|
+
name
|
|
258
|
+
}
|
|
259
|
+
external_id
|
|
260
|
+
inserted_at
|
|
261
|
+
updated_at
|
|
262
|
+
}
|
|
263
|
+
parents {
|
|
264
|
+
alias
|
|
265
|
+
classes
|
|
266
|
+
data_structure_id
|
|
267
|
+
deleted_at
|
|
268
|
+
id
|
|
269
|
+
metadata
|
|
270
|
+
name
|
|
271
|
+
type
|
|
272
|
+
}
|
|
273
|
+
children {
|
|
274
|
+
alias
|
|
275
|
+
classes
|
|
276
|
+
data_structure_id
|
|
277
|
+
deleted_at
|
|
278
|
+
id
|
|
279
|
+
metadata
|
|
280
|
+
name
|
|
281
|
+
type
|
|
282
|
+
}
|
|
283
|
+
siblings {
|
|
284
|
+
alias
|
|
285
|
+
classes
|
|
286
|
+
data_structure_id
|
|
287
|
+
deleted_at
|
|
288
|
+
id
|
|
289
|
+
metadata
|
|
290
|
+
name
|
|
291
|
+
type
|
|
292
|
+
}
|
|
293
|
+
versions {
|
|
294
|
+
deleted_at
|
|
295
|
+
inserted_at
|
|
296
|
+
updated_at
|
|
297
|
+
version
|
|
298
|
+
}
|
|
299
|
+
ancestry
|
|
300
|
+
|
|
301
|
+
grants {
|
|
302
|
+
data_structure {
|
|
303
|
+
external_id
|
|
304
|
+
id
|
|
305
|
+
system_id
|
|
306
|
+
}
|
|
307
|
+
data_structure_version {
|
|
308
|
+
ancestry
|
|
309
|
+
name
|
|
310
|
+
}
|
|
311
|
+
detail
|
|
312
|
+
end_date
|
|
313
|
+
external_ref
|
|
314
|
+
id
|
|
315
|
+
inserted_at
|
|
316
|
+
pending_removal
|
|
317
|
+
source_user_name
|
|
318
|
+
start_date
|
|
319
|
+
system {
|
|
320
|
+
external_id
|
|
321
|
+
id
|
|
322
|
+
name
|
|
323
|
+
}
|
|
324
|
+
updated_at
|
|
325
|
+
user {
|
|
326
|
+
email
|
|
327
|
+
full_name
|
|
328
|
+
user_name
|
|
329
|
+
}
|
|
330
|
+
user_id
|
|
331
|
+
}
|
|
332
|
+
grant {
|
|
333
|
+
data_structure {
|
|
334
|
+
external_id
|
|
335
|
+
id
|
|
336
|
+
system_id
|
|
337
|
+
}
|
|
338
|
+
data_structure_version {
|
|
339
|
+
ancestry
|
|
340
|
+
name
|
|
341
|
+
}
|
|
342
|
+
detail
|
|
343
|
+
end_date
|
|
344
|
+
external_ref
|
|
345
|
+
id
|
|
346
|
+
inserted_at
|
|
347
|
+
pending_removal
|
|
348
|
+
source_user_name
|
|
349
|
+
start_date
|
|
350
|
+
system {
|
|
351
|
+
external_id
|
|
352
|
+
id
|
|
353
|
+
name
|
|
354
|
+
}
|
|
355
|
+
updated_at
|
|
356
|
+
user {
|
|
357
|
+
email
|
|
358
|
+
full_name
|
|
359
|
+
user_name
|
|
360
|
+
}
|
|
361
|
+
user_id
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
classes
|
|
365
|
+
implementation_count
|
|
366
|
+
data_structure_link_count
|
|
367
|
+
|
|
368
|
+
note
|
|
369
|
+
profile {
|
|
370
|
+
max
|
|
371
|
+
min
|
|
372
|
+
null_count
|
|
373
|
+
most_frequent
|
|
374
|
+
value
|
|
375
|
+
}
|
|
376
|
+
source {
|
|
377
|
+
id
|
|
378
|
+
external_id
|
|
379
|
+
}
|
|
380
|
+
system {
|
|
381
|
+
id
|
|
382
|
+
name
|
|
383
|
+
}
|
|
384
|
+
structure_type {
|
|
385
|
+
metadata_views {
|
|
386
|
+
name
|
|
387
|
+
fields
|
|
388
|
+
}
|
|
389
|
+
template_id
|
|
390
|
+
translation
|
|
391
|
+
}
|
|
392
|
+
degree {
|
|
393
|
+
in
|
|
394
|
+
out
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
data_fields {
|
|
398
|
+
alias
|
|
399
|
+
classes
|
|
400
|
+
data_structure_id
|
|
401
|
+
deleted_at
|
|
402
|
+
id
|
|
403
|
+
metadata
|
|
404
|
+
name
|
|
405
|
+
type
|
|
406
|
+
note(select_fields: $note_fields)
|
|
407
|
+
}
|
|
408
|
+
relations {
|
|
409
|
+
parents {
|
|
410
|
+
id
|
|
411
|
+
structure {
|
|
412
|
+
id
|
|
413
|
+
data_structure_id
|
|
414
|
+
name
|
|
415
|
+
type
|
|
416
|
+
structure_type {
|
|
417
|
+
translation
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
relation_type {
|
|
421
|
+
name
|
|
422
|
+
description
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
children {
|
|
426
|
+
id
|
|
427
|
+
structure {
|
|
428
|
+
id
|
|
429
|
+
data_structure_id
|
|
430
|
+
name
|
|
431
|
+
type
|
|
432
|
+
structure_type {
|
|
433
|
+
translation
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
relation_type {
|
|
437
|
+
name
|
|
438
|
+
description
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
links
|
|
444
|
+
_actions
|
|
445
|
+
user_permissions
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
`;
|
|
@@ -1,51 +1,25 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { withRouter } from "react-router-dom";
|
|
1
|
+
import React, { useEffect } from "react";
|
|
3
2
|
import PropTypes from "prop-types";
|
|
4
|
-
import { compose } from "redux";
|
|
5
3
|
import { connect } from "react-redux";
|
|
4
|
+
import { useParams } from "react-router-dom";
|
|
6
5
|
import { clearStructure, fetchStructure } from "../routines";
|
|
7
6
|
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
fetchStructure: PropTypes.func,
|
|
11
|
-
clearStructure: PropTypes.func,
|
|
12
|
-
match: PropTypes.object,
|
|
13
|
-
};
|
|
7
|
+
export const StructureLoader = ({ fetchStructure, clearStructure }) => {
|
|
8
|
+
const { id, version } = useParams();
|
|
14
9
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
fetchStructure({ id, version });
|
|
12
|
+
return () => clearStructure();
|
|
13
|
+
}, [id, version]);
|
|
18
14
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
}
|
|
15
|
+
return null;
|
|
16
|
+
};
|
|
23
17
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
StructureLoader.propTypes = {
|
|
19
|
+
fetchStructure: PropTypes.func,
|
|
20
|
+
clearStructure: PropTypes.func,
|
|
21
|
+
};
|
|
28
22
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
componentWillUnmount() {
|
|
37
|
-
const { clearStructure } = this.props;
|
|
38
|
-
clearStructure();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
render() {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const mapStateToProps = ({ structureLoading }) => ({ structureLoading });
|
|
47
|
-
|
|
48
|
-
export default compose(
|
|
49
|
-
withRouter,
|
|
50
|
-
connect(mapStateToProps, { clearStructure, fetchStructure })
|
|
51
|
-
)(StructureLoader);
|
|
23
|
+
export default connect(null, { fetchStructure, clearStructure })(
|
|
24
|
+
StructureLoader
|
|
25
|
+
);
|
|
@@ -171,7 +171,7 @@ const mapStateToProps = (state) => {
|
|
|
171
171
|
structureNotes,
|
|
172
172
|
structure,
|
|
173
173
|
template: _.find(
|
|
174
|
-
_.propEq("id", _.path("
|
|
174
|
+
_.propEq("id", _.path("structure_type.template_id")(structure))
|
|
175
175
|
)(templates),
|
|
176
176
|
};
|
|
177
177
|
};
|
|
@@ -99,12 +99,10 @@ StructureNotesEdit.propTypes = {
|
|
|
99
99
|
latestDfContent: PropTypes.object,
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
-
const findTemplate = ({ templates, structure: {
|
|
102
|
+
const findTemplate = ({ templates, structure: { structure_type } = {} }) =>
|
|
103
103
|
_.defaultTo(
|
|
104
104
|
_.head(templates),
|
|
105
|
-
_.find(_.propEq("id", _.prop("template_id")(
|
|
106
|
-
templates
|
|
107
|
-
)
|
|
105
|
+
_.find(_.propEq("id", _.prop("template_id")(structure_type)))(templates)
|
|
108
106
|
);
|
|
109
107
|
|
|
110
108
|
const mapStateToProps = (state) => {
|
|
@@ -1,53 +1,22 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
3
|
import { StructureLoader } from "../StructureLoader";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
jest.mock("react-router-dom", () => ({
|
|
6
|
+
...jest.requireActual("react-router-dom"),
|
|
7
|
+
useParams: () => ({ id: 1, version: 8 }),
|
|
8
|
+
}));
|
|
9
|
+
|
|
10
|
+
const props = {
|
|
7
11
|
clearStructure: jest.fn(),
|
|
8
|
-
structureLoading: false,
|
|
9
12
|
fetchStructure: jest.fn(),
|
|
10
|
-
}
|
|
13
|
+
};
|
|
11
14
|
|
|
12
15
|
describe("<StructureLoader />", () => {
|
|
13
16
|
it("matches the latest snapshot", () => {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
expect(wrapper).toMatchSnapshot();
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("calls fetchStructure when component mounts with an informed id", () => {
|
|
20
|
-
const props = getProps();
|
|
21
|
-
jest.spyOn(StructureLoader.prototype, "componentDidMount");
|
|
22
|
-
const wrapper = shallow(<StructureLoader {...props} />);
|
|
23
|
-
expect(StructureLoader.prototype.componentDidMount.mock.calls.length).toBe(
|
|
24
|
-
1
|
|
25
|
-
);
|
|
26
|
-
expect(props.fetchStructure).toHaveBeenCalledTimes(1);
|
|
27
|
-
wrapper.unmount();
|
|
28
|
-
expect(props.fetchStructure).toHaveBeenCalledTimes(1);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("calls fetchStructure when id updates", () => {
|
|
32
|
-
const props = getProps();
|
|
33
|
-
jest.spyOn(StructureLoader.prototype, "componentDidUpdate");
|
|
34
|
-
const wrapper = shallow(<StructureLoader {...props} />);
|
|
35
|
-
wrapper.setProps({ match: { params: { id: 2 } } });
|
|
36
|
-
expect(StructureLoader.prototype.componentDidUpdate.mock.calls.length).toBe(
|
|
37
|
-
1
|
|
38
|
-
);
|
|
39
|
-
expect(props.fetchStructure).toHaveBeenCalledTimes(2);
|
|
40
|
-
});
|
|
17
|
+
const { container } = render(<StructureLoader {...props} />);
|
|
18
|
+
expect(container).toMatchSnapshot();
|
|
41
19
|
|
|
42
|
-
|
|
43
|
-
const props = getProps();
|
|
44
|
-
jest.spyOn(StructureLoader.prototype, "componentWillUnmount");
|
|
45
|
-
const wrapper = shallow(<StructureLoader {...props} />);
|
|
46
|
-
expect(props.clearStructure).toHaveBeenCalledTimes(0);
|
|
47
|
-
wrapper.unmount();
|
|
48
|
-
expect(
|
|
49
|
-
StructureLoader.prototype.componentWillUnmount.mock.calls.length
|
|
50
|
-
).toBe(1);
|
|
51
|
-
expect(props.clearStructure).toHaveBeenCalledTimes(1);
|
|
20
|
+
expect(props.fetchStructure).toHaveBeenCalledWith({ id: 1, version: 8 });
|
|
52
21
|
});
|
|
53
22
|
});
|
package/src/messages/en.js
CHANGED
|
@@ -286,7 +286,6 @@ export default {
|
|
|
286
286
|
"structure.field.graph.percentage": "Percentage: ",
|
|
287
287
|
"structure.field.graph.title": "Frequency chart",
|
|
288
288
|
"structure.field.graph.value": "Value: ",
|
|
289
|
-
"structure.field.has_df_content": "Extra info",
|
|
290
289
|
"structure.field.links": "Concepts",
|
|
291
290
|
"structure.field.menu.link": "Link to Concept",
|
|
292
291
|
"structure.field.name": "Field",
|
package/src/messages/es.js
CHANGED
|
@@ -294,7 +294,6 @@ export default {
|
|
|
294
294
|
"structure.field.graph.percentage": "Porcentaje: ",
|
|
295
295
|
"structure.field.graph.title": "Gráfico de frecuencias",
|
|
296
296
|
"structure.field.graph.value": "Valor: ",
|
|
297
|
-
"structure.field.has_df_content": "Info adicional",
|
|
298
297
|
"structure.field.links": "Términos",
|
|
299
298
|
"structure.field.menu.link": "Vincular a concepto",
|
|
300
299
|
"structure.field.metadata.nullable": "Opcional",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { compile } from "path-to-regexp";
|
|
2
1
|
import { testSaga } from "redux-saga-test-plan";
|
|
3
|
-
import { apiJson, JSON_OPTS } from "@truedat/core/services/api";
|
|
4
2
|
import {
|
|
5
3
|
fetchStructureRequestSaga,
|
|
6
4
|
fetchStructureSaga,
|
|
7
5
|
} from "../fetchStructure";
|
|
6
|
+
|
|
8
7
|
import { fetchStructure } from "../../routines";
|
|
9
|
-
import {
|
|
8
|
+
import { DATA_STRUCTURE_VERSION_QUERY } from "../../api/queries";
|
|
9
|
+
import { getStructureFieldColumns } from "../../selectors";
|
|
10
10
|
|
|
11
11
|
describe("sagas: fetchStructureRequestSaga", () => {
|
|
12
12
|
it("should invoke fetchStructureSaga on trigger", () => {
|
|
@@ -29,11 +29,34 @@ describe("sagas: fetchStructureRequestSaga", () => {
|
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
describe("sagas: fetchStructureSaga", () => {
|
|
32
|
+
const client = { query: jest.fn() };
|
|
32
33
|
const id = 1;
|
|
33
34
|
const version = "latest";
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
|
|
35
|
+
const payload = { id };
|
|
36
|
+
const variables = {
|
|
37
|
+
dataStructureId: id,
|
|
38
|
+
version,
|
|
39
|
+
note_fields: ["note_field"],
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const structureFieldColumns = [{ name: "id" }, { name: "note.note_field" }];
|
|
43
|
+
|
|
44
|
+
const _actions = { test: true };
|
|
45
|
+
const user_permissions = { permission1: true };
|
|
46
|
+
|
|
47
|
+
const dataStructureVersion = {
|
|
48
|
+
id,
|
|
49
|
+
name: "Structure 1",
|
|
50
|
+
description: "desc1",
|
|
51
|
+
_actions,
|
|
52
|
+
user_permissions,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const data = {
|
|
56
|
+
data: dataStructureVersion,
|
|
57
|
+
_actions,
|
|
58
|
+
user_permissions,
|
|
59
|
+
};
|
|
37
60
|
|
|
38
61
|
it("should put a success action when a response is returned", () => {
|
|
39
62
|
const meta = { version };
|
|
@@ -41,10 +64,19 @@ describe("sagas: fetchStructureSaga", () => {
|
|
|
41
64
|
expect(() => {
|
|
42
65
|
testSaga(fetchStructureSaga, { payload })
|
|
43
66
|
.next()
|
|
67
|
+
.select(getStructureFieldColumns)
|
|
68
|
+
.next(structureFieldColumns)
|
|
69
|
+
.getContext("client")
|
|
70
|
+
.next(client)
|
|
44
71
|
.put(fetchStructure.request())
|
|
45
72
|
.next()
|
|
46
|
-
|
|
47
|
-
.
|
|
73
|
+
|
|
74
|
+
.call(client.query, {
|
|
75
|
+
fetchPolicy: "network-only",
|
|
76
|
+
query: DATA_STRUCTURE_VERSION_QUERY,
|
|
77
|
+
variables,
|
|
78
|
+
})
|
|
79
|
+
.next({ data: { dataStructureVersion } })
|
|
48
80
|
.put({ meta, ...fetchStructure.success(data) })
|
|
49
81
|
.next()
|
|
50
82
|
.put(fetchStructure.fulfill())
|
|
@@ -57,17 +89,28 @@ describe("sagas: fetchStructureSaga", () => {
|
|
|
57
89
|
const version = 23;
|
|
58
90
|
const payload = { id, version };
|
|
59
91
|
const meta = { version };
|
|
60
|
-
|
|
61
|
-
|
|
92
|
+
|
|
93
|
+
const variables = {
|
|
94
|
+
dataStructureId: id,
|
|
62
95
|
version,
|
|
63
|
-
|
|
96
|
+
note_fields: ["note_field"],
|
|
97
|
+
};
|
|
98
|
+
|
|
64
99
|
expect(() => {
|
|
65
100
|
testSaga(fetchStructureSaga, { payload })
|
|
66
101
|
.next()
|
|
102
|
+
.select(getStructureFieldColumns)
|
|
103
|
+
.next(structureFieldColumns)
|
|
104
|
+
.getContext("client")
|
|
105
|
+
.next(client)
|
|
67
106
|
.put(fetchStructure.request())
|
|
68
107
|
.next()
|
|
69
|
-
.call(
|
|
70
|
-
|
|
108
|
+
.call(client.query, {
|
|
109
|
+
fetchPolicy: "network-only",
|
|
110
|
+
query: DATA_STRUCTURE_VERSION_QUERY,
|
|
111
|
+
variables,
|
|
112
|
+
})
|
|
113
|
+
.next({ data: { dataStructureVersion } })
|
|
71
114
|
.put({ meta, ...fetchStructure.success(data) })
|
|
72
115
|
.next()
|
|
73
116
|
.put(fetchStructure.fulfill())
|
|
@@ -83,9 +126,17 @@ describe("sagas: fetchStructureSaga", () => {
|
|
|
83
126
|
expect(() => {
|
|
84
127
|
testSaga(fetchStructureSaga, { payload })
|
|
85
128
|
.next()
|
|
129
|
+
.select(getStructureFieldColumns)
|
|
130
|
+
.next(structureFieldColumns)
|
|
131
|
+
.getContext("client")
|
|
132
|
+
.next(client)
|
|
86
133
|
.put(fetchStructure.request())
|
|
87
134
|
.next()
|
|
88
|
-
.call(
|
|
135
|
+
.call(client.query, {
|
|
136
|
+
fetchPolicy: "network-only",
|
|
137
|
+
query: DATA_STRUCTURE_VERSION_QUERY,
|
|
138
|
+
variables,
|
|
139
|
+
})
|
|
89
140
|
.throw(error)
|
|
90
141
|
.put(fetchStructure.failure(message))
|
|
91
142
|
.next()
|
|
@@ -1,21 +1,42 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
-
import {
|
|
3
|
-
import { call, put, takeLatest } from "redux-saga/effects";
|
|
4
|
-
import { apiJson, JSON_OPTS } from "@truedat/core/services/api";
|
|
2
|
+
import { call, put, takeLatest, select, getContext } from "redux-saga/effects";
|
|
5
3
|
import { fetchStructure } from "../routines";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
const structureVersionPath = compile(API_DATA_STRUCTURE_VERSION);
|
|
4
|
+
import { DATA_STRUCTURE_VERSION_QUERY } from "../api/queries";
|
|
5
|
+
import { getStructureFieldColumns } from "../selectors";
|
|
9
6
|
|
|
10
7
|
export function* fetchStructureSaga({ payload }) {
|
|
11
8
|
try {
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
const structureFieldColumns = yield select(getStructureFieldColumns);
|
|
10
|
+
const note_fields = _.flow(
|
|
11
|
+
_.filter(({ name }) => name.startsWith("note.")),
|
|
12
|
+
_.map(({ name }) => name.split(".")[1])
|
|
13
|
+
)(structureFieldColumns);
|
|
14
|
+
|
|
15
|
+
const client = yield getContext("client");
|
|
16
|
+
|
|
17
17
|
yield put(fetchStructure.request());
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
const { id, version = "latest" } = payload;
|
|
20
|
+
const {
|
|
21
|
+
data: { dataStructureVersion },
|
|
22
|
+
} = yield call(client.query, {
|
|
23
|
+
fetchPolicy: "network-only",
|
|
24
|
+
query: DATA_STRUCTURE_VERSION_QUERY,
|
|
25
|
+
variables: {
|
|
26
|
+
dataStructureId: id,
|
|
27
|
+
version,
|
|
28
|
+
note_fields,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const data = {
|
|
33
|
+
data: dataStructureVersion,
|
|
34
|
+
_actions: dataStructureVersion._actions,
|
|
35
|
+
user_permissions: dataStructureVersion.user_permissions,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const meta = { version };
|
|
39
|
+
|
|
19
40
|
yield put({ meta, ...fetchStructure.success(data) });
|
|
20
41
|
} catch (error) {
|
|
21
42
|
if (error.response) {
|
|
@@ -5,19 +5,19 @@ describe("selectors: getParsedEvents", () => {
|
|
|
5
5
|
{
|
|
6
6
|
id: 1,
|
|
7
7
|
content: [
|
|
8
|
-
{ fields: [{ type: "system", name: "field_1", label: "Label" }] }
|
|
9
|
-
]
|
|
10
|
-
}
|
|
8
|
+
{ fields: [{ type: "system", name: "field_1", label: "Label" }] },
|
|
9
|
+
],
|
|
10
|
+
},
|
|
11
11
|
];
|
|
12
|
-
const structure = {
|
|
12
|
+
const structure = { structure_type: { template_id: 1 } };
|
|
13
13
|
const r1 = {
|
|
14
14
|
id: 1,
|
|
15
15
|
service: "My invented service 1",
|
|
16
16
|
resource_id: 2,
|
|
17
17
|
payload: [
|
|
18
18
|
{ field: "field", value: 5, action: "changed" },
|
|
19
|
-
{ field: "id", value: 6, action: "changed" }
|
|
20
|
-
]
|
|
19
|
+
{ field: "id", value: 6, action: "changed" },
|
|
20
|
+
],
|
|
21
21
|
};
|
|
22
22
|
const r2 = {
|
|
23
23
|
id: 2,
|
|
@@ -25,8 +25,8 @@ describe("selectors: getParsedEvents", () => {
|
|
|
25
25
|
resource_id: 2,
|
|
26
26
|
payload: [
|
|
27
27
|
{ field: "field", value: 7, action: "changed" },
|
|
28
|
-
{ field: "id", value: 3, action: "changed" }
|
|
29
|
-
]
|
|
28
|
+
{ field: "id", value: 3, action: "changed" },
|
|
29
|
+
],
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
const r3 = {
|
|
@@ -34,7 +34,7 @@ describe("selectors: getParsedEvents", () => {
|
|
|
34
34
|
id: 3,
|
|
35
35
|
payload: [{ action: "changed", field: "Label", value: null }],
|
|
36
36
|
resource_id: 3,
|
|
37
|
-
service: "My invented service 3"
|
|
37
|
+
service: "My invented service 3",
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
const r4 = {
|
|
@@ -42,7 +42,7 @@ describe("selectors: getParsedEvents", () => {
|
|
|
42
42
|
id: 4,
|
|
43
43
|
payload: [{ action: "tag_linked", field: "foo", value: "bar" }],
|
|
44
44
|
resource_id: 4,
|
|
45
|
-
service: "My invented service 4"
|
|
45
|
+
service: "My invented service 4",
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
const r5 = {
|
|
@@ -50,7 +50,7 @@ describe("selectors: getParsedEvents", () => {
|
|
|
50
50
|
id: 5,
|
|
51
51
|
payload: [{ action: "tag_updated", field: "foo", value: "bar" }],
|
|
52
52
|
resource_id: 5,
|
|
53
|
-
service: "My invented service 5"
|
|
53
|
+
service: "My invented service 5",
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
const r6 = {
|
|
@@ -58,7 +58,7 @@ describe("selectors: getParsedEvents", () => {
|
|
|
58
58
|
id: 6,
|
|
59
59
|
payload: [{ field: "foo", action: "tag_deleted" }],
|
|
60
60
|
resource_id: 6,
|
|
61
|
-
service: "My invented service 6"
|
|
61
|
+
service: "My invented service 6",
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
const events = [
|
|
@@ -66,42 +66,42 @@ describe("selectors: getParsedEvents", () => {
|
|
|
66
66
|
id: 1,
|
|
67
67
|
service: "My invented service 1",
|
|
68
68
|
resource_id: 2,
|
|
69
|
-
payload: { field: 5, id: 6 }
|
|
69
|
+
payload: { field: 5, id: 6 },
|
|
70
70
|
},
|
|
71
71
|
{
|
|
72
72
|
id: 2,
|
|
73
73
|
service: "My invented service 2",
|
|
74
74
|
resource_id: 2,
|
|
75
|
-
payload: { field: 7, id: 3 }
|
|
75
|
+
payload: { field: 7, id: 3 },
|
|
76
76
|
},
|
|
77
77
|
{
|
|
78
78
|
id: 3,
|
|
79
79
|
service: "My invented service 3",
|
|
80
80
|
event: "data_structure_updated",
|
|
81
81
|
resource_id: 3,
|
|
82
|
-
payload: { content: { changed: { field_1: { id: 1, name: "foo" } } } }
|
|
82
|
+
payload: { content: { changed: { field_1: { id: 1, name: "foo" } } } },
|
|
83
83
|
},
|
|
84
84
|
{
|
|
85
85
|
id: 4,
|
|
86
86
|
service: "My invented service 4",
|
|
87
87
|
event: "structure_tag_linked",
|
|
88
88
|
resource_id: 4,
|
|
89
|
-
payload: { tag: "foo", description: "bar", xyz: "xyz" }
|
|
89
|
+
payload: { tag: "foo", description: "bar", xyz: "xyz" },
|
|
90
90
|
},
|
|
91
91
|
{
|
|
92
92
|
id: 5,
|
|
93
93
|
service: "My invented service 5",
|
|
94
94
|
event: "structure_tag_link_updated",
|
|
95
95
|
resource_id: 5,
|
|
96
|
-
payload: { tag: "foo", description: "bar", xyz: "xyz" }
|
|
96
|
+
payload: { tag: "foo", description: "bar", xyz: "xyz" },
|
|
97
97
|
},
|
|
98
98
|
{
|
|
99
99
|
id: 6,
|
|
100
100
|
service: "My invented service 6",
|
|
101
101
|
event: "structure_tag_link_deleted",
|
|
102
102
|
resource_id: 6,
|
|
103
|
-
payload: { tag: "foo", description: "bar" }
|
|
104
|
-
}
|
|
103
|
+
payload: { tag: "foo", description: "bar" },
|
|
104
|
+
},
|
|
105
105
|
];
|
|
106
106
|
|
|
107
107
|
it("should return all the events with the new payload", () => {
|
|
@@ -10,63 +10,58 @@ describe("selectors: getStructuresFields", () => {
|
|
|
10
10
|
deleted_at: null,
|
|
11
11
|
description: "Código de Mes",
|
|
12
12
|
external_id: null,
|
|
13
|
-
has_df_content: false,
|
|
14
13
|
inserted_at: "2019-10-22T10:37:54Z",
|
|
15
14
|
links: [],
|
|
16
15
|
name: "CMESANO",
|
|
17
16
|
nullable: true,
|
|
18
17
|
precision: "8.0",
|
|
19
|
-
type: "num"
|
|
18
|
+
type: "num",
|
|
20
19
|
},
|
|
21
20
|
{
|
|
22
21
|
data_structure_id: 5373,
|
|
23
22
|
deleted_at: null,
|
|
24
23
|
description: "Text Field",
|
|
25
24
|
external_id: null,
|
|
26
|
-
has_df_content: false,
|
|
27
25
|
inserted_at: "2019-10-22T10:37:55Z",
|
|
28
26
|
links: [],
|
|
29
27
|
name: "TEXT",
|
|
30
28
|
nullable: false,
|
|
31
|
-
type: "char"
|
|
29
|
+
type: "char",
|
|
32
30
|
},
|
|
33
31
|
{
|
|
34
32
|
data_structure_id: 5374,
|
|
35
33
|
deleted_at: null,
|
|
36
34
|
description: "Some Date",
|
|
37
35
|
external_id: null,
|
|
38
|
-
has_df_content: false,
|
|
39
36
|
inserted_at: "2019-10-22T10:37:55Z",
|
|
40
37
|
links: [],
|
|
41
38
|
name: "DATE",
|
|
42
39
|
nullable: false,
|
|
43
|
-
type: "datetime"
|
|
40
|
+
type: "datetime",
|
|
44
41
|
},
|
|
45
42
|
{
|
|
46
43
|
data_structure_id: 5375,
|
|
47
44
|
deleted_at: null,
|
|
48
45
|
description: "Some Timestamp",
|
|
49
46
|
external_id: null,
|
|
50
|
-
has_df_content: false,
|
|
51
47
|
inserted_at: "2019-10-22T10:37:55Z",
|
|
52
48
|
links: [],
|
|
53
49
|
name: "DATE_AND_HOUR",
|
|
54
50
|
nullable: false,
|
|
55
|
-
type: "time"
|
|
51
|
+
type: "time",
|
|
56
52
|
},
|
|
57
53
|
{
|
|
58
54
|
data_structure_id: 5376,
|
|
59
55
|
deleted_at: null,
|
|
60
56
|
description: "Default",
|
|
61
57
|
external_id: null,
|
|
62
|
-
has_df_content: false,
|
|
63
58
|
inserted_at: "2019-10-22T10:37:55Z",
|
|
64
59
|
links: [],
|
|
65
60
|
name: "default",
|
|
66
61
|
nullable: false,
|
|
67
|
-
type: "foo"
|
|
68
|
-
}
|
|
69
|
-
]
|
|
62
|
+
type: "foo",
|
|
63
|
+
},
|
|
64
|
+
],
|
|
70
65
|
};
|
|
71
66
|
const res = getStructuresFields({ structuresFields, parentStructures });
|
|
72
67
|
expect(res).toHaveLength(5);
|
|
@@ -76,7 +71,6 @@ describe("selectors: getStructuresFields", () => {
|
|
|
76
71
|
deleted_at: null,
|
|
77
72
|
description: "Código de Mes",
|
|
78
73
|
external_id: null,
|
|
79
|
-
has_df_content: false,
|
|
80
74
|
inserted_at: "2019-10-22T10:37:54Z",
|
|
81
75
|
links: [],
|
|
82
76
|
name: "CMESANO",
|
|
@@ -84,64 +78,60 @@ describe("selectors: getStructuresFields", () => {
|
|
|
84
78
|
precision: "8.0",
|
|
85
79
|
type: "num",
|
|
86
80
|
field_type: "number",
|
|
87
|
-
label: "Parent Structure"
|
|
81
|
+
label: "Parent Structure",
|
|
88
82
|
},
|
|
89
83
|
{
|
|
90
84
|
data_structure_id: 5373,
|
|
91
85
|
deleted_at: null,
|
|
92
86
|
description: "Text Field",
|
|
93
87
|
external_id: null,
|
|
94
|
-
has_df_content: false,
|
|
95
88
|
inserted_at: "2019-10-22T10:37:55Z",
|
|
96
89
|
links: [],
|
|
97
90
|
name: "TEXT",
|
|
98
91
|
nullable: false,
|
|
99
92
|
type: "char",
|
|
100
93
|
field_type: "string",
|
|
101
|
-
label: "Parent Structure"
|
|
94
|
+
label: "Parent Structure",
|
|
102
95
|
},
|
|
103
96
|
{
|
|
104
97
|
data_structure_id: 5374,
|
|
105
98
|
deleted_at: null,
|
|
106
99
|
description: "Some Date",
|
|
107
100
|
external_id: null,
|
|
108
|
-
has_df_content: false,
|
|
109
101
|
inserted_at: "2019-10-22T10:37:55Z",
|
|
110
102
|
links: [],
|
|
111
103
|
name: "DATE",
|
|
112
104
|
nullable: false,
|
|
113
105
|
type: "datetime",
|
|
114
106
|
field_type: "date",
|
|
115
|
-
label: "Parent Structure"
|
|
107
|
+
label: "Parent Structure",
|
|
116
108
|
},
|
|
117
109
|
{
|
|
118
110
|
data_structure_id: 5375,
|
|
119
111
|
deleted_at: null,
|
|
120
112
|
description: "Some Timestamp",
|
|
121
113
|
external_id: null,
|
|
122
|
-
has_df_content: false,
|
|
123
114
|
inserted_at: "2019-10-22T10:37:55Z",
|
|
124
115
|
links: [],
|
|
125
116
|
name: "DATE_AND_HOUR",
|
|
126
117
|
nullable: false,
|
|
127
118
|
type: "time",
|
|
128
119
|
field_type: "timestamp",
|
|
129
|
-
label: "Parent Structure"
|
|
120
|
+
label: "Parent Structure",
|
|
130
121
|
},
|
|
131
122
|
{
|
|
132
123
|
data_structure_id: 5376,
|
|
133
124
|
deleted_at: null,
|
|
134
125
|
description: "Default",
|
|
135
126
|
external_id: null,
|
|
136
|
-
has_df_content: false,
|
|
137
127
|
inserted_at: "2019-10-22T10:37:55Z",
|
|
138
128
|
links: [],
|
|
139
129
|
name: "default",
|
|
140
130
|
nullable: false,
|
|
141
131
|
type: "foo",
|
|
142
132
|
field_type: "string",
|
|
143
|
-
label: "Parent Structure"
|
|
144
|
-
}
|
|
133
|
+
label: "Parent Structure",
|
|
134
|
+
},
|
|
145
135
|
]);
|
|
146
136
|
});
|
|
147
137
|
});
|
|
@@ -84,7 +84,7 @@ describe("selectors: getTabVisibility", () => {
|
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
it("should include notes if template_id is in structure_note", () => {
|
|
87
|
-
const structure = { type: "foo",
|
|
87
|
+
const structure = { type: "foo", structure_type: { template_id: 1 } };
|
|
88
88
|
const templates = [{ name: "foo", id: 1 }];
|
|
89
89
|
expect(getTabVisibility({ templatesLoading: true })).toMatchObject({
|
|
90
90
|
notes: false,
|
|
@@ -25,7 +25,7 @@ describe("selectors: metadataViewsSelector", () => {
|
|
|
25
25
|
const selectedMetadata = "m1";
|
|
26
26
|
const metadataViews = [{ name: "m1", fields: [] }];
|
|
27
27
|
const structure = {
|
|
28
|
-
|
|
28
|
+
structure_type: { metadata_views: metadataViews },
|
|
29
29
|
};
|
|
30
30
|
const res = metadataViewsSelector({
|
|
31
31
|
structure,
|
|
@@ -41,7 +41,7 @@ describe("selectors: metadataViewsSelector", () => {
|
|
|
41
41
|
const selectedMetadata = "m1";
|
|
42
42
|
const metadataViews = [{ name: "m1", fields: ["foo", "xyzzy"] }];
|
|
43
43
|
const structure = {
|
|
44
|
-
|
|
44
|
+
structure_type: { metadata_views: metadataViews },
|
|
45
45
|
};
|
|
46
46
|
const res = metadataViewsSelector({
|
|
47
47
|
structure,
|
|
@@ -5,10 +5,10 @@ const getEvents = ({ events }) => events;
|
|
|
5
5
|
|
|
6
6
|
const getTemplate = ({ structure, templates }) =>
|
|
7
7
|
_.find(
|
|
8
|
-
t => _.path("
|
|
8
|
+
(t) => _.path("structure_type.template_id")(structure) == _.prop("id")(t)
|
|
9
9
|
)(templates);
|
|
10
10
|
|
|
11
|
-
const transformFieldFormat = field =>
|
|
11
|
+
const transformFieldFormat = (field) =>
|
|
12
12
|
_.isBoolean(field) ? _.toString(field) : field;
|
|
13
13
|
|
|
14
14
|
const transformContentField = (field, value, fieldsWithoutValue) =>
|
|
@@ -21,7 +21,7 @@ const transformContentField = (field, value, fieldsWithoutValue) =>
|
|
|
21
21
|
|
|
22
22
|
const getFieldLabel = (field, fields) =>
|
|
23
23
|
_.flow(
|
|
24
|
-
_.find(f => _.prop("name")(f) == field),
|
|
24
|
+
_.find((f) => _.prop("name")(f) == field),
|
|
25
25
|
_.defaultTo({}),
|
|
26
26
|
_.prop("label")
|
|
27
27
|
)(fields) || field;
|
|
@@ -34,7 +34,7 @@ const payloadForAction = (action, content, fields, fieldsWithoutValue) =>
|
|
|
34
34
|
_.map(([field, value]) => ({
|
|
35
35
|
field: getFieldLabel(field, fields),
|
|
36
36
|
value: transformContentField(field, value, fieldsWithoutValue),
|
|
37
|
-
action
|
|
37
|
+
action,
|
|
38
38
|
}))
|
|
39
39
|
)(content);
|
|
40
40
|
|
|
@@ -42,7 +42,7 @@ const buildUpdatePayload = (payload, template) => {
|
|
|
42
42
|
const content = payload.content || {
|
|
43
43
|
added: [],
|
|
44
44
|
removed: [],
|
|
45
|
-
changed: []
|
|
45
|
+
changed: [],
|
|
46
46
|
};
|
|
47
47
|
const templateFields = _.flow(
|
|
48
48
|
_.prop("content"),
|
|
@@ -51,13 +51,13 @@ const buildUpdatePayload = (payload, template) => {
|
|
|
51
51
|
)(template);
|
|
52
52
|
|
|
53
53
|
const fieldsWithoutValue = _.flow(
|
|
54
|
-
_.filter(f =>
|
|
54
|
+
_.filter((f) =>
|
|
55
55
|
_.includes(_.prop("type")(f))([
|
|
56
56
|
"enriched_text",
|
|
57
57
|
"url",
|
|
58
58
|
"table",
|
|
59
59
|
"system",
|
|
60
|
-
"image"
|
|
60
|
+
"image",
|
|
61
61
|
])
|
|
62
62
|
),
|
|
63
63
|
_.map(_.prop("name"))
|
|
@@ -92,7 +92,7 @@ const buildUpdatePayload = (payload, template) => {
|
|
|
92
92
|
_.map(([k, v]) => ({
|
|
93
93
|
field: k,
|
|
94
94
|
action: "changed",
|
|
95
|
-
value: transformFieldFormat(v)
|
|
95
|
+
value: transformFieldFormat(v),
|
|
96
96
|
}))
|
|
97
97
|
)(payload);
|
|
98
98
|
|
|
@@ -102,24 +102,24 @@ const buildUpdatePayload = (payload, template) => {
|
|
|
102
102
|
const getParsedEvents = createSelector(
|
|
103
103
|
[getEvents, getTemplate],
|
|
104
104
|
(events, template) => {
|
|
105
|
-
return _.map(d => {
|
|
105
|
+
return _.map((d) => {
|
|
106
106
|
switch (d.event) {
|
|
107
107
|
case "data_structure_updated":
|
|
108
108
|
return {
|
|
109
109
|
...d,
|
|
110
|
-
payload: buildUpdatePayload(d.payload, template)
|
|
110
|
+
payload: buildUpdatePayload(d.payload, template),
|
|
111
111
|
};
|
|
112
112
|
case "update_data_structure":
|
|
113
113
|
return {
|
|
114
114
|
...d,
|
|
115
|
-
payload: buildUpdatePayload(d.payload, template)
|
|
115
|
+
payload: buildUpdatePayload(d.payload, template),
|
|
116
116
|
};
|
|
117
117
|
case "structure_tag_link_deleted":
|
|
118
118
|
return {
|
|
119
119
|
...d,
|
|
120
120
|
payload: [
|
|
121
|
-
{ field: _.path("payload.tag")(d), action: "tag_deleted" }
|
|
122
|
-
]
|
|
121
|
+
{ field: _.path("payload.tag")(d), action: "tag_deleted" },
|
|
122
|
+
],
|
|
123
123
|
};
|
|
124
124
|
case "structure_tag_link_updated":
|
|
125
125
|
return {
|
|
@@ -128,9 +128,9 @@ const getParsedEvents = createSelector(
|
|
|
128
128
|
{
|
|
129
129
|
field: _.path("payload.tag")(d),
|
|
130
130
|
action: "tag_updated",
|
|
131
|
-
value: _.path("payload.description")(d)
|
|
132
|
-
}
|
|
133
|
-
]
|
|
131
|
+
value: _.path("payload.description")(d),
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
134
|
};
|
|
135
135
|
case "structure_tag_linked":
|
|
136
136
|
return {
|
|
@@ -139,18 +139,18 @@ const getParsedEvents = createSelector(
|
|
|
139
139
|
{
|
|
140
140
|
field: _.path("payload.tag")(d),
|
|
141
141
|
action: "tag_linked",
|
|
142
|
-
value: _.path("payload.description")(d)
|
|
143
|
-
}
|
|
144
|
-
]
|
|
142
|
+
value: _.path("payload.description")(d),
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
145
|
};
|
|
146
146
|
default:
|
|
147
147
|
return {
|
|
148
148
|
...d,
|
|
149
|
-
payload: _.map(e => ({
|
|
149
|
+
payload: _.map((e) => ({
|
|
150
150
|
field: e,
|
|
151
151
|
action: "changed",
|
|
152
|
-
value: transformFieldFormat(d["payload"][e])
|
|
153
|
-
}))(_.keys(d["payload"]))
|
|
152
|
+
value: transformFieldFormat(d["payload"][e]),
|
|
153
|
+
}))(_.keys(d["payload"])),
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
156
|
})(events);
|
|
@@ -25,11 +25,6 @@ const nullableDecorator = (field) =>
|
|
|
25
25
|
? translateDecorator("structure.field.metadata.nullable.true")
|
|
26
26
|
: translateDecorator("structure.field.metadata.nullable.false");
|
|
27
27
|
|
|
28
|
-
const hasDfContentDecorator = (has_df_content) =>
|
|
29
|
-
has_df_content
|
|
30
|
-
? translateDecorator("structure.field.metadata.nullable.true")
|
|
31
|
-
: null;
|
|
32
|
-
|
|
33
28
|
const lineageLinkDecorator = ({ degree, data_structure_id: id }) =>
|
|
34
29
|
id && degree ? (
|
|
35
30
|
<Link
|
|
@@ -73,7 +68,6 @@ export const defaultStructureFieldColumns = [
|
|
|
73
68
|
{ name: "metadata.precision" },
|
|
74
69
|
{ name: "metadata.nullable", fieldDecorator: nullableDecorator },
|
|
75
70
|
{ name: "description" },
|
|
76
|
-
{ name: "has_df_content", fieldDecorator: hasDfContentDecorator },
|
|
77
71
|
{
|
|
78
72
|
name: "degree",
|
|
79
73
|
fieldSelector: _.pick(["degree", "data_structure_id"]),
|
|
@@ -23,10 +23,10 @@ const domainDecorator = (domains) => (
|
|
|
23
23
|
</>
|
|
24
24
|
);
|
|
25
25
|
|
|
26
|
-
const typeDecorator = ({ type,
|
|
26
|
+
const typeDecorator = ({ type, structure_type }) => (
|
|
27
27
|
<FormattedMessage
|
|
28
28
|
id={`structure.type.${type}.text`}
|
|
29
|
-
defaultMessage={_.get("translation")(
|
|
29
|
+
defaultMessage={_.get("translation")(structure_type) || type}
|
|
30
30
|
/>
|
|
31
31
|
);
|
|
32
32
|
export const defaultStructureProperties = [
|
|
@@ -38,7 +38,7 @@ export const defaultStructureProperties = [
|
|
|
38
38
|
{ name: "group" },
|
|
39
39
|
{
|
|
40
40
|
name: "type",
|
|
41
|
-
fieldSelector: _.pick(["type", "
|
|
41
|
+
fieldSelector: _.pick(["type", "structure_type"]),
|
|
42
42
|
fieldDecorator: typeDecorator,
|
|
43
43
|
},
|
|
44
44
|
];
|
|
@@ -12,43 +12,43 @@ const translateDecoratorWithDefault = (text, default_text) => (
|
|
|
12
12
|
const relationTypeDecorator = (field, direction) =>
|
|
13
13
|
translateDecoratorWithDefault(`relation.type.${direction}.${field}`, field);
|
|
14
14
|
|
|
15
|
-
const structureTypeDecorator = ({ structure: { type,
|
|
15
|
+
const structureTypeDecorator = ({ structure: { type, structure_type } }) =>
|
|
16
16
|
translateDecoratorWithDefault(
|
|
17
17
|
`structure.type.${type}.text`,
|
|
18
|
-
_.prop("translation")(
|
|
18
|
+
_.prop("translation")(structure_type) || type
|
|
19
19
|
);
|
|
20
20
|
|
|
21
21
|
const linkToStructureDecorator = ({
|
|
22
|
-
structure: { data_structure_id: id, name }
|
|
22
|
+
structure: { data_structure_id: id, name },
|
|
23
23
|
}) => <Link to={linkTo.STRUCTURE({ id })}>{name}</Link>;
|
|
24
24
|
|
|
25
|
-
const directedMessageDecorator = direction => field =>
|
|
25
|
+
const directedMessageDecorator = (direction) => (field) =>
|
|
26
26
|
relationTypeDecorator(field, direction);
|
|
27
27
|
|
|
28
28
|
export const defaultRelationColumns = [
|
|
29
29
|
{
|
|
30
30
|
name: "name",
|
|
31
31
|
fieldSelector: _.pick(["structure.data_structure_id", "structure.name"]),
|
|
32
|
-
fieldDecorator: linkToStructureDecorator
|
|
32
|
+
fieldDecorator: linkToStructureDecorator,
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
35
|
name: "type",
|
|
36
|
-
fieldSelector: _.pick(["structure.type", "structure.
|
|
37
|
-
fieldDecorator: structureTypeDecorator
|
|
36
|
+
fieldSelector: _.pick(["structure.type", "structure.structure_type"]),
|
|
37
|
+
fieldDecorator: structureTypeDecorator,
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
40
|
name: "relation_type_name",
|
|
41
41
|
fieldSelector: _.path("relation_type.name"),
|
|
42
|
-
fieldDecorator: directedMessageDecorator
|
|
42
|
+
fieldDecorator: directedMessageDecorator,
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
45
|
name: "relation_description",
|
|
46
|
-
fieldSelector: _.path("relation_type.description")
|
|
47
|
-
}
|
|
46
|
+
fieldSelector: _.path("relation_type.description"),
|
|
47
|
+
},
|
|
48
48
|
];
|
|
49
49
|
|
|
50
|
-
const mapDirection = direction =>
|
|
51
|
-
_.map(c =>
|
|
50
|
+
const mapDirection = (direction) =>
|
|
51
|
+
_.map((c) =>
|
|
52
52
|
c.name === "relation_type_name" && _.isFunction(c.fieldDecorator)
|
|
53
53
|
? { ...c, fieldDecorator: c.fieldDecorator(direction) }
|
|
54
54
|
: c
|
|
@@ -30,7 +30,7 @@ const notesTabVisible = ({ templatesLoading, templates, structure }) =>
|
|
|
30
30
|
_.has("type")(structure) &&
|
|
31
31
|
_.flow(
|
|
32
32
|
_.find({
|
|
33
|
-
id: _.propOr(null, "
|
|
33
|
+
id: _.propOr(null, "structure_type.template_id")(structure),
|
|
34
34
|
}),
|
|
35
35
|
_.negate(_.isNil)
|
|
36
36
|
)(templates);
|
|
@@ -5,7 +5,7 @@ const pickFields = (fields) =>
|
|
|
5
5
|
_.isEmpty(fields) ? _.identity : _.pick(fields);
|
|
6
6
|
|
|
7
7
|
export const metadataViewsSelector = createSelector(
|
|
8
|
-
_.path(["structure", "
|
|
8
|
+
_.path(["structure", "structure_type", "metadata_views"]),
|
|
9
9
|
_.prop("structureMetadata"),
|
|
10
10
|
(metadataViews, structureMetadata) =>
|
|
11
11
|
_.isEmpty(metadataViews) || _.isEmpty(structureMetadata)
|
|
@@ -4,10 +4,10 @@ import { createSelector } from "reselect";
|
|
|
4
4
|
import { FormattedMessage } from "react-intl";
|
|
5
5
|
import Moment from "react-moment";
|
|
6
6
|
|
|
7
|
-
const typeTranslateDecorator = ({ type,
|
|
7
|
+
const typeTranslateDecorator = ({ type, structure_type }) => (
|
|
8
8
|
<FormattedMessage
|
|
9
9
|
id={`structure.type.${type}.text`}
|
|
10
|
-
defaultMessage={_.prop("translation")(
|
|
10
|
+
defaultMessage={_.prop("translation")(structure_type) || type}
|
|
11
11
|
/>
|
|
12
12
|
);
|
|
13
13
|
|
|
@@ -23,7 +23,7 @@ export const defaultStructureColumns = [
|
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
25
|
name: "type",
|
|
26
|
-
fieldSelector: _.pick(["type", "
|
|
26
|
+
fieldSelector: _.pick(["type", "structure_type"]),
|
|
27
27
|
fieldDecorator: typeTranslateDecorator,
|
|
28
28
|
width: 1,
|
|
29
29
|
},
|
|
@@ -47,9 +47,7 @@ const getStructures = (state) => {
|
|
|
47
47
|
const structureTypes = state.structureTypes;
|
|
48
48
|
return _.map((structure) => {
|
|
49
49
|
return {
|
|
50
|
-
|
|
51
|
-
structureTypes
|
|
52
|
-
),
|
|
50
|
+
structure_type: _.find(_.propEq("name")(structure.type))(structureTypes),
|
|
53
51
|
...structure,
|
|
54
52
|
};
|
|
55
53
|
})(structures);
|
|
@@ -79,7 +77,7 @@ export const structureColumnsSelector = createSelector(
|
|
|
79
77
|
|
|
80
78
|
const getStructureColumnNames = createSelector(
|
|
81
79
|
structureColumnsSelector,
|
|
82
|
-
(columns) => _.concat("
|
|
80
|
+
(columns) => _.concat("structure_type")(_.map("name")(columns))
|
|
83
81
|
);
|
|
84
82
|
|
|
85
83
|
export const structureRowsSelector = createSelector(
|