@truedat/bg 7.12.5 → 7.12.7
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/concepts/components/EventRow.js +14 -10
- package/src/concepts/components/__tests__/Events.spec.js +26 -0
- package/src/concepts/components/__tests__/__snapshots__/Events.spec.js.snap +77 -11
- package/src/concepts/relations/components/ConceptLinkActions.js +14 -9
- package/src/concepts/relations/components/__tests__/ConceptLinkActions.spec.js +116 -0
- package/src/concepts/relations/components/__tests__/__snapshots__/ConceptLinkActions.spec.js.snap +23 -0
- package/src/concepts/selectors/__tests__/getParsedEvents.spec.js +892 -2
- package/src/concepts/selectors/getParsedEvents.js +127 -63
- package/src/concepts/styles/conceptAuditEventVia.less +7 -0
|
@@ -11,39 +11,40 @@ const toStr = (field) =>
|
|
|
11
11
|
? _.toString(field)
|
|
12
12
|
: field;
|
|
13
13
|
|
|
14
|
-
const getDeleteConceptDraftEvent = (e) => {
|
|
14
|
+
const getDeleteConceptDraftEvent = ({ payload, ...e }) => {
|
|
15
15
|
const msg_key = "deleted_version";
|
|
16
|
-
const { version } =
|
|
16
|
+
const { version, event_via } = payload;
|
|
17
17
|
const msg_params = [toStr(version)];
|
|
18
|
-
return { ...e, payload: [{ msg_key, msg_params }] };
|
|
18
|
+
return { ...e, payload: [{ msg_key, msg_params, msg_via: event_via }] };
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
const getNewConceptDraftEvent = (e) => {
|
|
21
|
+
const getNewConceptDraftEvent = ({ payload, ...e }) => {
|
|
22
22
|
const msg_key = "created_version";
|
|
23
|
-
const { version } =
|
|
23
|
+
const { version, event_via } = payload;
|
|
24
24
|
const msg_params = [toStr(version)];
|
|
25
|
-
return { ...e, payload: [{ msg_key, msg_params }] };
|
|
25
|
+
return { ...e, payload: [{ msg_key, msg_params, msg_via: event_via }] };
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
const getConceptFieldChanges = (
|
|
29
29
|
msg_key,
|
|
30
30
|
fields,
|
|
31
31
|
templateFields,
|
|
32
|
-
fieldsWithoutValue
|
|
32
|
+
fieldsWithoutValue,
|
|
33
|
+
event_via
|
|
33
34
|
) =>
|
|
34
35
|
_.flow(
|
|
35
36
|
_.toPairs,
|
|
36
|
-
_.
|
|
37
|
+
_.sortBy(([fieldName, _]) => fieldName),
|
|
38
|
+
_.map(([k, { value: v }]) => ({
|
|
37
39
|
msg_key: fromValueType(msg_key, k, v, fieldsWithoutValue),
|
|
38
40
|
msg_params: [getFieldLabel(k, templateFields), toStr(v)],
|
|
41
|
+
msg_via: event_via,
|
|
39
42
|
}))
|
|
40
43
|
)(fields);
|
|
41
44
|
|
|
42
45
|
const fromValueType = (msg_key, field, value, fieldsWithoutValue) =>
|
|
43
46
|
_.includes(field)(fieldsWithoutValue) ||
|
|
44
|
-
|
|
45
|
-
_.isArray(value) ||
|
|
46
|
-
_.isNil(value)
|
|
47
|
+
_.isNil(value)
|
|
47
48
|
? msg_key + "_without_target"
|
|
48
49
|
: msg_key;
|
|
49
50
|
|
|
@@ -54,77 +55,95 @@ const getFieldLabel = (field, fields) =>
|
|
|
54
55
|
_.prop("label")
|
|
55
56
|
)(fields) || field;
|
|
56
57
|
|
|
57
|
-
const getUpdateConceptEvent = (
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
const getUpdateConceptEvent = (
|
|
59
|
+
{ payload, ...e },
|
|
60
|
+
templateFields,
|
|
61
|
+
fieldsWithoutValue,
|
|
62
|
+
options = {}
|
|
63
|
+
) => {
|
|
60
64
|
if (!payload) return { ...e, payload: [] };
|
|
61
65
|
|
|
62
|
-
const {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
const {
|
|
67
|
+
content,
|
|
68
|
+
domain_id,
|
|
69
|
+
domain_old,
|
|
70
|
+
domain_new,
|
|
71
|
+
shared_to,
|
|
72
|
+
event_via,
|
|
73
|
+
confidential,
|
|
74
|
+
name,
|
|
75
|
+
description,
|
|
76
|
+
} = payload;
|
|
77
|
+
|
|
78
|
+
if (options.isDraft && !content) {
|
|
79
|
+
return { ...e, payload: [] };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Asegurar que content tenga un valor por defecto después de la validación
|
|
83
|
+
const contentData = content || {};
|
|
66
84
|
|
|
67
85
|
// eslint-disable-next-line fp/no-let
|
|
68
86
|
let field_config = [];
|
|
69
87
|
|
|
88
|
+
if (!options.isDraft && confidential !== undefined) {
|
|
89
|
+
const isConfidential = toStr(confidential);
|
|
90
|
+
const msg_key = `confidential_${isConfidential}`;
|
|
91
|
+
// eslint-disable-next-line fp/no-mutation
|
|
92
|
+
field_config = _.concat({
|
|
93
|
+
msg_key,
|
|
94
|
+
msg_via: event_via,
|
|
95
|
+
})(field_config);
|
|
96
|
+
}
|
|
97
|
+
|
|
70
98
|
if (shared_to) {
|
|
71
99
|
const domainNames = _.flow(_.map("name"), _.join(", "))(shared_to);
|
|
72
100
|
// eslint-disable-next-line fp/no-mutation
|
|
73
101
|
field_config = _.concat({
|
|
74
102
|
msg_key: "shared_to",
|
|
75
103
|
msg_params: [domainNames],
|
|
104
|
+
msg_via: event_via,
|
|
76
105
|
})(field_config);
|
|
77
106
|
}
|
|
78
107
|
|
|
79
|
-
if (
|
|
80
|
-
const { name: domain_new_name } = domain_new;
|
|
81
|
-
const { name: domain_old_name } = domain_old;
|
|
108
|
+
if (options.isDraft && description) {
|
|
82
109
|
// eslint-disable-next-line fp/no-mutation
|
|
83
110
|
field_config = _.concat({
|
|
84
|
-
msg_key: "
|
|
85
|
-
msg_params: [
|
|
111
|
+
msg_key: "changed_field_without_target",
|
|
112
|
+
msg_params: ["description"],
|
|
113
|
+
msg_via: event_via,
|
|
86
114
|
})(field_config);
|
|
87
115
|
}
|
|
88
116
|
|
|
89
|
-
if (
|
|
117
|
+
if (options.isDraft && name) {
|
|
90
118
|
// eslint-disable-next-line fp/no-mutation
|
|
91
119
|
field_config = _.concat({
|
|
92
|
-
msg_key: "
|
|
93
|
-
msg_params: [
|
|
120
|
+
msg_key: "changed_field",
|
|
121
|
+
msg_params: ["name", payload["name"]],
|
|
122
|
+
msg_via: event_via,
|
|
94
123
|
})(field_config);
|
|
95
124
|
}
|
|
96
125
|
|
|
97
|
-
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
const getUpdateConceptDraftEvent = (e, templateFields, fieldsWithoutValue) => {
|
|
101
|
-
const { payload } = e;
|
|
102
|
-
if (!payload) return { ...e, payload: [] };
|
|
103
|
-
|
|
104
|
-
const { content } = payload;
|
|
105
|
-
if (!content) return { ...e, payload: [] };
|
|
106
|
-
|
|
107
|
-
const { name } = payload;
|
|
108
|
-
const { description } = payload;
|
|
109
|
-
|
|
110
|
-
// eslint-disable-next-line fp/no-let
|
|
111
|
-
let field_config = [];
|
|
112
|
-
if (description)
|
|
126
|
+
if (domain_new) {
|
|
127
|
+
const { name: domain_new_name } = domain_new;
|
|
128
|
+
const { name: domain_old_name } = domain_old;
|
|
113
129
|
// eslint-disable-next-line fp/no-mutation
|
|
114
130
|
field_config = _.concat({
|
|
115
|
-
msg_key: "
|
|
116
|
-
msg_params: [
|
|
131
|
+
msg_key: "domain_updated_with_names",
|
|
132
|
+
msg_params: [domain_old_name, domain_new_name],
|
|
133
|
+
msg_via: event_via,
|
|
117
134
|
})(field_config);
|
|
135
|
+
}
|
|
118
136
|
|
|
119
|
-
if (
|
|
137
|
+
if (domain_id && !domain_new) {
|
|
120
138
|
// eslint-disable-next-line fp/no-mutation
|
|
121
139
|
field_config = _.concat({
|
|
122
|
-
msg_key: "
|
|
123
|
-
msg_params: [
|
|
140
|
+
msg_key: "domain_updated_with_id",
|
|
141
|
+
msg_params: [domain_id],
|
|
142
|
+
msg_via: event_via,
|
|
124
143
|
})(field_config);
|
|
144
|
+
}
|
|
125
145
|
|
|
126
|
-
const { removed, added, changed } =
|
|
127
|
-
|
|
146
|
+
const { removed, added, changed } = contentData;
|
|
128
147
|
if (removed || added || changed) {
|
|
129
148
|
// eslint-disable-next-line fp/no-mutation
|
|
130
149
|
field_config = _.flow(
|
|
@@ -134,41 +153,66 @@ const getUpdateConceptDraftEvent = (e, templateFields, fieldsWithoutValue) => {
|
|
|
134
153
|
"changed_field",
|
|
135
154
|
changed,
|
|
136
155
|
templateFields,
|
|
137
|
-
fieldsWithoutValue
|
|
156
|
+
fieldsWithoutValue,
|
|
157
|
+
event_via
|
|
138
158
|
),
|
|
139
159
|
getConceptFieldChanges(
|
|
140
160
|
"added_field",
|
|
141
161
|
added,
|
|
142
162
|
templateFields,
|
|
143
|
-
fieldsWithoutValue
|
|
163
|
+
fieldsWithoutValue,
|
|
164
|
+
event_via
|
|
144
165
|
),
|
|
145
166
|
getConceptFieldChanges(
|
|
146
167
|
"removed_field",
|
|
147
168
|
removed,
|
|
148
169
|
templateFields,
|
|
149
|
-
fieldsWithoutValue
|
|
170
|
+
fieldsWithoutValue,
|
|
171
|
+
event_via
|
|
150
172
|
),
|
|
151
173
|
]),
|
|
152
174
|
_.flatten
|
|
153
175
|
)([]);
|
|
154
176
|
}
|
|
155
177
|
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
if (field_config.length === 0) {
|
|
181
|
+
return { ...e, payload: [{ msg_via: event_via }] };
|
|
182
|
+
}
|
|
183
|
+
|
|
156
184
|
return { ...e, payload: field_config };
|
|
157
185
|
};
|
|
158
186
|
|
|
159
|
-
const getConceptFieldEvent = (e) => {
|
|
187
|
+
const getConceptFieldEvent = ({ payload, ...e }) => {
|
|
160
188
|
const msg_key = "concept_field";
|
|
161
|
-
const { system, group, structure, field } =
|
|
189
|
+
const { system, group, structure, field } = payload.field;
|
|
190
|
+
const { event_via } = payload;
|
|
162
191
|
const msg_params = [system, group, structure, field];
|
|
163
|
-
return { ...e, payload: [{ msg_key, msg_params }] };
|
|
192
|
+
return { ...e, payload: [{ msg_key, msg_params, msg_via: event_via }] };
|
|
164
193
|
};
|
|
165
194
|
|
|
166
|
-
const getRelationFromConceptToFieldEvent = (e) => {
|
|
195
|
+
const getRelationFromConceptToFieldEvent = ({ payload, ...e }) => {
|
|
167
196
|
const msg_key = "concept_field";
|
|
168
|
-
const
|
|
169
|
-
const {
|
|
197
|
+
const { system, group, structure, field } = payload.context.target.field;
|
|
198
|
+
const { event_via } = payload;
|
|
170
199
|
const msg_params = [system, group, structure, field];
|
|
171
|
-
return { ...e, payload: [{ msg_key, msg_params }] };
|
|
200
|
+
return { ...e, payload: [{ msg_key, msg_params, msg_via: event_via }] };
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
const enrichEvent = ({ payload, ...e }, event_message_key) => {
|
|
205
|
+
const { event_via, target_id, target_type, target_name } = payload;
|
|
206
|
+
const msg_key = target_type
|
|
207
|
+
? `${event_message_key}_${toStr(target_type)}`
|
|
208
|
+
: event_message_key;
|
|
209
|
+
const msg_params = [target_name || toStr(target_id)];
|
|
210
|
+
return { ...e, payload: [{ msg_key, msg_params: msg_params, msg_via: event_via }] };
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
const addEventVia = ({ payload, ...e }) => {
|
|
214
|
+
const { event_via } = payload;
|
|
215
|
+
return { ...e, payload: [{ msg_via: event_via }] };
|
|
172
216
|
};
|
|
173
217
|
|
|
174
218
|
const getEmptyPayloadEvent = (e) => ({ ...e, payload: [] });
|
|
@@ -199,13 +243,17 @@ const getParsedEvents = createSelector(
|
|
|
199
243
|
if (event === "create_concept_draft") {
|
|
200
244
|
return getNewConceptDraftEvent(e);
|
|
201
245
|
} else if (event === "update_concept_draft") {
|
|
202
|
-
return
|
|
246
|
+
return getUpdateConceptEvent(
|
|
203
247
|
e,
|
|
204
248
|
templateFields,
|
|
205
|
-
fieldsWithoutValue
|
|
206
|
-
|
|
249
|
+
fieldsWithoutValue,
|
|
250
|
+
{ isDraft: true });
|
|
207
251
|
} else if (event === "update_concept") {
|
|
208
|
-
return getUpdateConceptEvent(
|
|
252
|
+
return getUpdateConceptEvent(
|
|
253
|
+
e,
|
|
254
|
+
templateFields,
|
|
255
|
+
fieldsWithoutValue,
|
|
256
|
+
{ isDraft: false });
|
|
209
257
|
} else if (event === "delete_concept_draft") {
|
|
210
258
|
return getDeleteConceptDraftEvent(e);
|
|
211
259
|
} else if (event === "new_concept_draft") {
|
|
@@ -217,6 +265,22 @@ const getParsedEvents = createSelector(
|
|
|
217
265
|
return getConceptFieldEvent(e);
|
|
218
266
|
} else if (event === "add_relation" || event === "delete_relation") {
|
|
219
267
|
return getRelationFromConceptToFieldEvent(e);
|
|
268
|
+
} else if (event === "concept_published") {
|
|
269
|
+
return addEventVia(e);
|
|
270
|
+
} else if (event === "concept_deprecated") {
|
|
271
|
+
return addEventVia(e);
|
|
272
|
+
} else if (event === "concept_rejection_canceled") {
|
|
273
|
+
return addEventVia(e);
|
|
274
|
+
} else if (event === "concept_rejected") {
|
|
275
|
+
return addEventVia(e);
|
|
276
|
+
} else if (event === "concept_submitted") {
|
|
277
|
+
return addEventVia(e);
|
|
278
|
+
} else if (event === "relation_created") {
|
|
279
|
+
return enrichEvent(e, "relation_created");
|
|
280
|
+
} else if (event === "relation_deleted") {
|
|
281
|
+
return enrichEvent(e, "relation_deleted");
|
|
282
|
+
} else if (event === "relation_deprecated") {
|
|
283
|
+
return enrichEvent(e, "relation_deprecated");
|
|
220
284
|
} else {
|
|
221
285
|
return getEmptyPayloadEvent(e);
|
|
222
286
|
}
|