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