@truedat/audit 8.2.2 → 8.2.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/audit",
3
- "version": "8.2.2",
3
+ "version": "8.2.4",
4
4
  "description": "Truedat Web Audit Module",
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.2.2",
51
+ "@truedat/test": "8.2.4",
52
52
  "identity-obj-proxy": "^3.0.0",
53
53
  "jest": "^29.7.0",
54
54
  "redux-saga-test-plan": "^4.0.6"
@@ -80,5 +80,5 @@
80
80
  "semantic-ui-react": "^3.0.0-beta.2",
81
81
  "swr": "^2.3.3"
82
82
  },
83
- "gitHead": "ef27133e5868b9aad2d95d7f2c69f36063d4327b"
83
+ "gitHead": "b98f63284093c90c57faa1794b6ccc1fcf761d89"
84
84
  }
@@ -9,6 +9,8 @@ import {
9
9
  CONCEPT_EVENTS,
10
10
  DEFAULT_ICON,
11
11
  EVENTS_BY_TYPE,
12
+ isQualityControlSubscriptionsEnabled,
13
+ RESOURCE_TYPES,
12
14
  RESOURCE_TYPE_ICONS,
13
15
  STATUSES_BY_EVENT,
14
16
  SUBSCRIBER_TYPE_ICONS,
@@ -36,16 +38,12 @@ const SourceSelector = lazy(
36
38
  () => import("@truedat/cx/sources/components/SourceSelector")
37
39
  );
38
40
 
41
+ const QualityControlSelector = lazy(
42
+ () => import("@truedat/qx/components/qualityControls/QualityControlSelector")
43
+ );
44
+
39
45
  const SUBSCRIBER_TYPES = ["role", "taxonomy_role", "email", "user"];
40
46
  const PERIODICITIES = ["daily", "minutely", "hourly"];
41
- const RESOURCE_TYPES = [
42
- "domain",
43
- "domains",
44
- "concept",
45
- "data_structure",
46
- "source",
47
- "rule",
48
- ];
49
47
  const DEFAULT_VALUES = {
50
48
  periodicity: null,
51
49
  subscriber: {
@@ -80,7 +78,11 @@ const withoutFilters = ({ filtersEnabled, ...data }) =>
80
78
  : _.set("scope.filters", null)(data);
81
79
  const withResourceName = (resource) => (data) =>
82
80
  resource &&
83
- _.includes(data?.scope?.resource_type)(["data_structure", "source"])
81
+ _.includes(data?.scope?.resource_type)([
82
+ "data_structure",
83
+ "source",
84
+ "quality_control",
85
+ ])
84
86
  ? {
85
87
  ...data,
86
88
  scope: {
@@ -90,6 +92,7 @@ const withResourceName = (resource) => (data) =>
90
92
  },
91
93
  }
92
94
  : data;
95
+
93
96
  const doPayload = (data, resource) =>
94
97
  _.flow(withoutFilters, withResourceName(resource))(data);
95
98
 
@@ -112,9 +115,25 @@ export const SubscriptionForm = ({
112
115
  });
113
116
  const { isDirty, errors } = formState;
114
117
 
115
- const [subscriberType, resourceType, events] = useWatch({
118
+ const [
119
+ subscriberType,
120
+ resourceType,
121
+ events,
122
+ subscriberIdentifier,
123
+ resourceId,
124
+ periodicity,
125
+ scopeStatus,
126
+ ] = useWatch({
116
127
  control,
117
- name: ["subscriber.type", "scope.resource_type", "scope.events"],
128
+ name: [
129
+ "subscriber.type",
130
+ "scope.resource_type",
131
+ "scope.events",
132
+ "subscriber.identifier",
133
+ "scope.resource_id",
134
+ "periodicity",
135
+ "scope.status",
136
+ ],
118
137
  });
119
138
 
120
139
  const isEditForm = !!subscription?.id;
@@ -123,6 +142,8 @@ export const SubscriptionForm = ({
123
142
 
124
143
  useEffect(() => {
125
144
  const exclusiveEvents = [
145
+ "score_status_updated",
146
+ "quality_control_version_status_updated",
126
147
  "rule_result_created",
127
148
  "implementation_status_updated",
128
149
  "grant_request_group_creation",
@@ -147,6 +168,17 @@ export const SubscriptionForm = ({
147
168
  _.flatten
148
169
  )(STATUSES_BY_EVENT);
149
170
 
171
+ const isFormFilled =
172
+ !!resourceType &&
173
+ notEmpty(subscriberIdentifier) &&
174
+ (isEditForm || !!resourceId) &&
175
+ !!periodicity &&
176
+ notEmpty(events) &&
177
+ (_.isEmpty(statuses) || notEmpty(scopeStatus));
178
+
179
+ const disabled =
180
+ isLoading || notEmpty(errors) || (isEditForm ? !isDirty : !isFormFilled);
181
+
150
182
  const doHandleSubmit = handleSubmit((data) => {
151
183
  const payload = doPayload(data, resource);
152
184
  onSubmit(payload);
@@ -173,8 +205,6 @@ export const SubscriptionForm = ({
173
205
  onChange(value);
174
206
  };
175
207
 
176
- const disabled = isLoading || !isDirty || notEmpty(errors);
177
-
178
208
  return (
179
209
  <Form onSubmit={doHandleSubmit}>
180
210
  <Controller
@@ -385,6 +415,26 @@ export const SubscriptionForm = ({
385
415
  )}
386
416
  />
387
417
  )}
418
+ {resourceType === "quality_control" &&
419
+ isQualityControlSubscriptionsEnabled() &&
420
+ !isEditForm && (
421
+ <Controller
422
+ control={control}
423
+ name="scope.resource_id"
424
+ rules={{ required: true }}
425
+ render={({ field: { onChange } }) => (
426
+ <QualityControlSelector
427
+ disabled={isEditForm}
428
+ defaultFilters={{ latest: [true] }}
429
+ pageSize={7}
430
+ onSelect={({ quality_control_id, name }) => {
431
+ onChange(quality_control_id);
432
+ setResource({ id: quality_control_id, name });
433
+ }}
434
+ />
435
+ )}
436
+ />
437
+ )}
388
438
  <Controller
389
439
  control={control}
390
440
  name="periodicity"
@@ -18,20 +18,12 @@ import {
18
18
  } from "semantic-ui-react";
19
19
  import {
20
20
  DEFAULT_ICON,
21
+ RESOURCE_TYPES,
21
22
  RESOURCE_TYPE_ICONS,
22
23
  SUBSCRIBER_TYPE_ICONS,
23
24
  } from "../subscriptionConstants";
24
25
 
25
26
  const SUBSCRIBER_TYPES = ["role", "email", "user", "taxonomy_role"];
26
- const RESOURCE_TYPES = [
27
- "data_structure",
28
- "domain",
29
- "domains",
30
- "concept",
31
- "rule",
32
- "implementation",
33
- "source",
34
- ];
35
27
 
36
28
  export const SubscriptionsHeader = () => {
37
29
  const { formatMessage } = useIntl();
@@ -184,6 +184,25 @@ exports[`<SubscriptionEdit /> matches the latest snapshot 1`] = `
184
184
  <label>
185
185
  subscriptions.resource
186
186
  </label>
187
+ <div
188
+ class="ui radio checkbox"
189
+ >
190
+ <input
191
+ class="hidden"
192
+ readonly=""
193
+ role="radio"
194
+ tabindex="0"
195
+ type="radio"
196
+ value="data_structure"
197
+ />
198
+ <label>
199
+ <i
200
+ aria-hidden="true"
201
+ class="block layout icon"
202
+ />
203
+ data_structure
204
+ </label>
205
+ </div>
187
206
  <div
188
207
  class="ui radio checkbox"
189
208
  >
@@ -241,6 +260,26 @@ exports[`<SubscriptionEdit /> matches the latest snapshot 1`] = `
241
260
  concept
242
261
  </label>
243
262
  </div>
263
+ <div
264
+ class="ui disabled radio checkbox"
265
+ >
266
+ <input
267
+ class="hidden"
268
+ disabled=""
269
+ readonly=""
270
+ role="radio"
271
+ tabindex="-1"
272
+ type="radio"
273
+ value="rule"
274
+ />
275
+ <label>
276
+ <i
277
+ aria-hidden="true"
278
+ class="clipboard check icon"
279
+ />
280
+ rule
281
+ </label>
282
+ </div>
244
283
  <div
245
284
  class="ui radio checkbox"
246
285
  >
@@ -250,14 +289,14 @@ exports[`<SubscriptionEdit /> matches the latest snapshot 1`] = `
250
289
  role="radio"
251
290
  tabindex="0"
252
291
  type="radio"
253
- value="data_structure"
292
+ value="implementation"
254
293
  />
255
294
  <label>
256
295
  <i
257
296
  aria-hidden="true"
258
- class="block layout icon"
297
+ class="tags icon"
259
298
  />
260
- data_structure
299
+ implementation
261
300
  </label>
262
301
  </div>
263
302
  <div
@@ -280,23 +319,22 @@ exports[`<SubscriptionEdit /> matches the latest snapshot 1`] = `
280
319
  </label>
281
320
  </div>
282
321
  <div
283
- class="ui disabled radio checkbox"
322
+ class="ui radio checkbox"
284
323
  >
285
324
  <input
286
325
  class="hidden"
287
- disabled=""
288
326
  readonly=""
289
327
  role="radio"
290
- tabindex="-1"
328
+ tabindex="0"
291
329
  type="radio"
292
- value="rule"
330
+ value="quality_control"
293
331
  />
294
332
  <label>
295
333
  <i
296
334
  aria-hidden="true"
297
- class="clipboard check icon"
335
+ class="archive icon"
298
336
  />
299
- rule
337
+ quality_control
300
338
  </label>
301
339
  </div>
302
340
  </div>
@@ -158,6 +158,25 @@ exports[`<SubscriptionForm /> matches the latest snapshot 1`] = `
158
158
  <label>
159
159
  subscriptions.resource
160
160
  </label>
161
+ <div
162
+ class="ui radio checkbox"
163
+ >
164
+ <input
165
+ class="hidden"
166
+ readonly=""
167
+ role="radio"
168
+ tabindex="0"
169
+ type="radio"
170
+ value="data_structure"
171
+ />
172
+ <label>
173
+ <i
174
+ aria-hidden="true"
175
+ class="block layout icon"
176
+ />
177
+ data_structure
178
+ </label>
179
+ </div>
161
180
  <div
162
181
  class="ui radio checkbox"
163
182
  >
@@ -215,6 +234,26 @@ exports[`<SubscriptionForm /> matches the latest snapshot 1`] = `
215
234
  concept
216
235
  </label>
217
236
  </div>
237
+ <div
238
+ class="ui disabled radio checkbox"
239
+ >
240
+ <input
241
+ class="hidden"
242
+ disabled=""
243
+ readonly=""
244
+ role="radio"
245
+ tabindex="-1"
246
+ type="radio"
247
+ value="rule"
248
+ />
249
+ <label>
250
+ <i
251
+ aria-hidden="true"
252
+ class="clipboard check icon"
253
+ />
254
+ rule
255
+ </label>
256
+ </div>
218
257
  <div
219
258
  class="ui radio checkbox"
220
259
  >
@@ -224,14 +263,14 @@ exports[`<SubscriptionForm /> matches the latest snapshot 1`] = `
224
263
  role="radio"
225
264
  tabindex="0"
226
265
  type="radio"
227
- value="data_structure"
266
+ value="implementation"
228
267
  />
229
268
  <label>
230
269
  <i
231
270
  aria-hidden="true"
232
- class="block layout icon"
271
+ class="tags icon"
233
272
  />
234
- data_structure
273
+ implementation
235
274
  </label>
236
275
  </div>
237
276
  <div
@@ -255,23 +294,22 @@ exports[`<SubscriptionForm /> matches the latest snapshot 1`] = `
255
294
  </label>
256
295
  </div>
257
296
  <div
258
- class="ui disabled radio checkbox"
297
+ class="ui radio checkbox"
259
298
  >
260
299
  <input
261
300
  class="hidden"
262
- disabled=""
263
301
  readonly=""
264
302
  role="radio"
265
- tabindex="-1"
303
+ tabindex="0"
266
304
  type="radio"
267
- value="rule"
305
+ value="quality_control"
268
306
  />
269
307
  <label>
270
308
  <i
271
309
  aria-hidden="true"
272
- class="clipboard check icon"
310
+ class="archive icon"
273
311
  />
274
- rule
312
+ quality_control
275
313
  </label>
276
314
  </div>
277
315
  </div>
@@ -173,6 +173,25 @@ exports[`<SubscriptionNew /> matches the latest snapshot 1`] = `
173
173
  <label>
174
174
  subscriptions.resource
175
175
  </label>
176
+ <div
177
+ class="ui radio checkbox"
178
+ >
179
+ <input
180
+ class="hidden"
181
+ readonly=""
182
+ role="radio"
183
+ tabindex="0"
184
+ type="radio"
185
+ value="data_structure"
186
+ />
187
+ <label>
188
+ <i
189
+ aria-hidden="true"
190
+ class="block layout icon"
191
+ />
192
+ data_structure
193
+ </label>
194
+ </div>
176
195
  <div
177
196
  class="ui radio checkbox"
178
197
  >
@@ -230,6 +249,26 @@ exports[`<SubscriptionNew /> matches the latest snapshot 1`] = `
230
249
  concept
231
250
  </label>
232
251
  </div>
252
+ <div
253
+ class="ui disabled radio checkbox"
254
+ >
255
+ <input
256
+ class="hidden"
257
+ disabled=""
258
+ readonly=""
259
+ role="radio"
260
+ tabindex="-1"
261
+ type="radio"
262
+ value="rule"
263
+ />
264
+ <label>
265
+ <i
266
+ aria-hidden="true"
267
+ class="clipboard check icon"
268
+ />
269
+ rule
270
+ </label>
271
+ </div>
233
272
  <div
234
273
  class="ui radio checkbox"
235
274
  >
@@ -239,14 +278,14 @@ exports[`<SubscriptionNew /> matches the latest snapshot 1`] = `
239
278
  role="radio"
240
279
  tabindex="0"
241
280
  type="radio"
242
- value="data_structure"
281
+ value="implementation"
243
282
  />
244
283
  <label>
245
284
  <i
246
285
  aria-hidden="true"
247
- class="block layout icon"
286
+ class="tags icon"
248
287
  />
249
- data_structure
288
+ implementation
250
289
  </label>
251
290
  </div>
252
291
  <div
@@ -270,23 +309,22 @@ exports[`<SubscriptionNew /> matches the latest snapshot 1`] = `
270
309
  </label>
271
310
  </div>
272
311
  <div
273
- class="ui disabled radio checkbox"
312
+ class="ui radio checkbox"
274
313
  >
275
314
  <input
276
315
  class="hidden"
277
- disabled=""
278
316
  readonly=""
279
317
  role="radio"
280
- tabindex="-1"
318
+ tabindex="0"
281
319
  type="radio"
282
- value="rule"
320
+ value="quality_control"
283
321
  />
284
322
  <label>
285
323
  <i
286
324
  aria-hidden="true"
287
- class="clipboard check icon"
325
+ class="archive icon"
288
326
  />
289
- rule
327
+ quality_control
290
328
  </label>
291
329
  </div>
292
330
  </div>
@@ -177,6 +177,25 @@ exports[`<SubscriptionRoutes /> matches the latest snapshot for route SUBSCRIPTI
177
177
  <label>
178
178
  subscriptions.resource
179
179
  </label>
180
+ <div
181
+ class="ui radio checkbox"
182
+ >
183
+ <input
184
+ class="hidden"
185
+ readonly=""
186
+ role="radio"
187
+ tabindex="0"
188
+ type="radio"
189
+ value="data_structure"
190
+ />
191
+ <label>
192
+ <i
193
+ aria-hidden="true"
194
+ class="block layout icon"
195
+ />
196
+ data_structure
197
+ </label>
198
+ </div>
180
199
  <div
181
200
  class="ui radio checkbox"
182
201
  >
@@ -234,6 +253,26 @@ exports[`<SubscriptionRoutes /> matches the latest snapshot for route SUBSCRIPTI
234
253
  concept
235
254
  </label>
236
255
  </div>
256
+ <div
257
+ class="ui disabled radio checkbox"
258
+ >
259
+ <input
260
+ class="hidden"
261
+ disabled=""
262
+ readonly=""
263
+ role="radio"
264
+ tabindex="-1"
265
+ type="radio"
266
+ value="rule"
267
+ />
268
+ <label>
269
+ <i
270
+ aria-hidden="true"
271
+ class="clipboard check icon"
272
+ />
273
+ rule
274
+ </label>
275
+ </div>
237
276
  <div
238
277
  class="ui radio checkbox"
239
278
  >
@@ -243,14 +282,14 @@ exports[`<SubscriptionRoutes /> matches the latest snapshot for route SUBSCRIPTI
243
282
  role="radio"
244
283
  tabindex="0"
245
284
  type="radio"
246
- value="data_structure"
285
+ value="implementation"
247
286
  />
248
287
  <label>
249
288
  <i
250
289
  aria-hidden="true"
251
- class="block layout icon"
290
+ class="tags icon"
252
291
  />
253
- data_structure
292
+ implementation
254
293
  </label>
255
294
  </div>
256
295
  <div
@@ -274,23 +313,22 @@ exports[`<SubscriptionRoutes /> matches the latest snapshot for route SUBSCRIPTI
274
313
  </label>
275
314
  </div>
276
315
  <div
277
- class="ui disabled radio checkbox"
316
+ class="ui radio checkbox"
278
317
  >
279
318
  <input
280
319
  class="hidden"
281
- disabled=""
282
320
  readonly=""
283
321
  role="radio"
284
- tabindex="-1"
322
+ tabindex="0"
285
323
  type="radio"
286
- value="rule"
324
+ value="quality_control"
287
325
  />
288
326
  <label>
289
327
  <i
290
328
  aria-hidden="true"
291
- class="clipboard check icon"
329
+ class="archive icon"
292
330
  />
293
- rule
331
+ quality_control
294
332
  </label>
295
333
  </div>
296
334
  </div>
@@ -671,6 +709,24 @@ exports[`<SubscriptionRoutes /> matches the latest snapshot for route SUBSCRIPTI
671
709
  source
672
710
  </label>
673
711
  </div>
712
+ <div
713
+ class="ui checked checkbox"
714
+ >
715
+ <input
716
+ checked=""
717
+ class="hidden"
718
+ readonly=""
719
+ tabindex="0"
720
+ type="checkbox"
721
+ />
722
+ <label>
723
+ <i
724
+ aria-hidden="true"
725
+ class="archive icon"
726
+ />
727
+ quality_control
728
+ </label>
729
+ </div>
674
730
  </div>
675
731
  </form>
676
732
  <div
@@ -250,6 +250,24 @@ exports[`<Subscriptions /> matches the latest snapshot 1`] = `
250
250
  source
251
251
  </label>
252
252
  </div>
253
+ <div
254
+ class="ui checked checkbox"
255
+ >
256
+ <input
257
+ checked=""
258
+ class="hidden"
259
+ readonly=""
260
+ tabindex="0"
261
+ type="checkbox"
262
+ />
263
+ <label>
264
+ <i
265
+ aria-hidden="true"
266
+ class="archive icon"
267
+ />
268
+ quality_control
269
+ </label>
270
+ </div>
253
271
  </div>
254
272
  </form>
255
273
  <div
@@ -1,5 +1,11 @@
1
1
  import _ from "lodash/fp";
2
2
 
3
+ const HIDE_QUALITY_CONTROL_SUBSCRIPTIONS =
4
+ process.env.REACT_APP_HIDE_QUALITY_CONTROLS === "true";
5
+
6
+ export const isQualityControlSubscriptionsEnabled = () =>
7
+ !HIDE_QUALITY_CONTROL_SUBSCRIPTIONS;
8
+
3
9
  export const SUBSCRIBER_TYPE_ICONS = {
4
10
  user: "user",
5
11
  email: "envelope",
@@ -17,6 +23,7 @@ export const RESOURCE_TYPE_ICONS = {
17
23
  implementation: "tags",
18
24
  data_structure: "block layout",
19
25
  source: "plug",
26
+ quality_control: "archive",
20
27
  };
21
28
 
22
29
  export const CONCEPT_EVENTS = [
@@ -61,7 +68,15 @@ export const IMPLEMENTATION_EVENTS = [
61
68
 
62
69
  export const SOURCE_EVENTS = ["status_changed"];
63
70
 
64
- export const DOMAIN_EVENTS = [
71
+ export const QUALITY_CONTROL_EVENTS = [
72
+ "score_status_updated",
73
+ "quality_control_version_status_updated",
74
+ "quality_control_version_draft_created",
75
+ "quality_control_version_deleted",
76
+ "quality_control_created",
77
+ ];
78
+
79
+ const DOMAIN_EVENTS_WITHOUT_QC = [
65
80
  ...CONCEPT_EVENTS,
66
81
  ...RULE_EVENTS,
67
82
  ...IMPLEMENTATION_EVENTS,
@@ -79,7 +94,11 @@ export const DOMAIN_EVENTS = [
79
94
  "ingest_sent_for_approval",
80
95
  ];
81
96
 
82
- export const EVENTS_BY_TYPE = {
97
+ export const DOMAIN_EVENTS = HIDE_QUALITY_CONTROL_SUBSCRIPTIONS
98
+ ? DOMAIN_EVENTS_WITHOUT_QC
99
+ : [...DOMAIN_EVENTS_WITHOUT_QC, ...QUALITY_CONTROL_EVENTS];
100
+
101
+ const EVENTS_BY_TYPE_BASE = {
83
102
  concept: CONCEPT_EVENTS,
84
103
  data_structure: STRUCTURE_EVENTS,
85
104
  domains: DOMAIN_EVENTS,
@@ -89,6 +108,28 @@ export const EVENTS_BY_TYPE = {
89
108
  source: SOURCE_EVENTS,
90
109
  };
91
110
 
111
+ export const EVENTS_BY_TYPE = HIDE_QUALITY_CONTROL_SUBSCRIPTIONS
112
+ ? EVENTS_BY_TYPE_BASE
113
+ : { ...EVENTS_BY_TYPE_BASE, quality_control: QUALITY_CONTROL_EVENTS };
114
+
115
+ const STATUSES_BY_EVENT_QC = {
116
+ quality_control_version_status_updated: [
117
+ { name: "deprecated" },
118
+ { name: "draft" },
119
+ { name: "pending_approval" },
120
+ { name: "published" },
121
+ { name: "rejected" },
122
+ { name: "versioned" },
123
+ ],
124
+ score_status_updated: [
125
+ { name: "no_results", color: "grey" },
126
+ { name: "meets_goal", color: "green" },
127
+ { name: "under_goal", color: "yellow" },
128
+ { name: "under_threshold", color: "yellow" },
129
+ { name: "failed", color: "red" },
130
+ ],
131
+ };
132
+
92
133
  export const STATUSES_BY_EVENT = {
93
134
  rule_result_created: [
94
135
  { name: "fail", color: "red" },
@@ -113,7 +154,22 @@ export const STATUSES_BY_EVENT = {
113
154
  { name: "versioned" },
114
155
  { name: "deprecated" },
115
156
  ],
157
+ ...(HIDE_QUALITY_CONTROL_SUBSCRIPTIONS ? {} : STATUSES_BY_EVENT_QC),
116
158
  };
117
159
 
160
+ const BASE_RESOURCE_TYPES = [
161
+ "data_structure",
162
+ "domain",
163
+ "domains",
164
+ "concept",
165
+ "rule",
166
+ "implementation",
167
+ "source",
168
+ ];
169
+
170
+ export const RESOURCE_TYPES = HIDE_QUALITY_CONTROL_SUBSCRIPTIONS
171
+ ? BASE_RESOURCE_TYPES
172
+ : [...BASE_RESOURCE_TYPES, "quality_control"];
173
+
118
174
  export const isSubset = (first, second) =>
119
175
  !_.isEmpty(first) && _.difference(first, second).length === 0;