dce-reactkit 3.2.2-beta.44 → 3.2.2-beta.47

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.
@@ -36,6 +36,8 @@ import LogAction from '../types/LogAction';
36
36
  import ParamType from '../types/ParamType';
37
37
  import IntelliTableColumn from '../types/IntelliTableColumn';
38
38
  import LogBuiltInMetadata from '../types/LogBuiltInMetadata';
39
+ import LogMetadataContextMap from '../types/LogMetadataContextMap';
40
+ import LogMetadataTargetMap from '../types/LogMetadataTargetMap';
39
41
 
40
42
  // Import shared components
41
43
  import SimpleDateChooser from './SimpleDateChooser';
@@ -262,6 +264,197 @@ const style = `
262
264
  }
263
265
  `;
264
266
 
267
+ /*------------------------------------------------------------------------*/
268
+ /* Constants */
269
+ /*------------------------------------------------------------------------*/
270
+
271
+ const columns: IntelliTableColumn[] = [
272
+ {
273
+ title: 'First Name',
274
+ param: 'userFirstName',
275
+ type: ParamType.String,
276
+ },
277
+ {
278
+ title: 'Last Name',
279
+ param: 'userLastName',
280
+ type: ParamType.String,
281
+ },
282
+ {
283
+ title: 'Email',
284
+ param: 'userEmail',
285
+ type: ParamType.String,
286
+ },
287
+ {
288
+ title: 'Canvas Id',
289
+ param: 'userId',
290
+ type: ParamType.Int,
291
+ },
292
+ {
293
+ title: 'Student?',
294
+ param: 'isLearner',
295
+ type: ParamType.Boolean,
296
+ },
297
+ {
298
+ title: 'Teaching Staff?',
299
+ param: 'isTTM',
300
+ type: ParamType.Boolean,
301
+ startsHidden: true,
302
+ },
303
+ {
304
+ title: 'Admin?',
305
+ param: 'isAdmin',
306
+ type: ParamType.Boolean,
307
+ startsHidden: true,
308
+ },
309
+ {
310
+ title: 'Course Canvas Id',
311
+ param: 'courseId',
312
+ type: ParamType.Int,
313
+ startsHidden: true,
314
+ },
315
+ {
316
+ title: 'Course Name',
317
+ param: 'courseName',
318
+ type: ParamType.String,
319
+ },
320
+ {
321
+ title: 'Browser Name',
322
+ param: 'browser.name',
323
+ type: ParamType.String,
324
+ startsHidden: true,
325
+ },
326
+ {
327
+ title: 'Browser Version',
328
+ param: 'browser.version',
329
+ type: ParamType.String,
330
+ startsHidden: true,
331
+ },
332
+ {
333
+ title: 'OS',
334
+ param: 'device.os',
335
+ type: ParamType.String,
336
+ startsHidden: true,
337
+ },
338
+ {
339
+ title: 'Mobile?',
340
+ param: 'device.isMobile',
341
+ type: ParamType.Boolean,
342
+ startsHidden: true,
343
+ },
344
+ {
345
+ title: 'Year',
346
+ param: 'year',
347
+ type: ParamType.Int,
348
+ },
349
+ {
350
+ title: 'Month',
351
+ param: 'month',
352
+ type: ParamType.Int,
353
+ },
354
+ {
355
+ title: 'Day',
356
+ param: 'day',
357
+ type: ParamType.Int,
358
+ },
359
+ {
360
+ title: 'Hour',
361
+ param: 'hour',
362
+ type: ParamType.Int,
363
+ },
364
+ {
365
+ title: 'Minute',
366
+ param: 'minute',
367
+ type: ParamType.Int,
368
+ startsHidden: true,
369
+ },
370
+ {
371
+ title: 'Timestamp',
372
+ param: 'timestamp',
373
+ type: ParamType.Int,
374
+ startsHidden: true,
375
+ },
376
+ {
377
+ title: 'Context',
378
+ param: 'context',
379
+ type: ParamType.String,
380
+ },
381
+ {
382
+ title: 'Subcontext',
383
+ param: 'subcontext',
384
+ type: ParamType.String,
385
+ },
386
+ {
387
+ title: 'Tags',
388
+ param: 'tags',
389
+ type: ParamType.JSON,
390
+ startsHidden: true,
391
+ },
392
+ {
393
+ title: 'Log Level',
394
+ param: 'level',
395
+ type: ParamType.String,
396
+ startsHidden: true,
397
+ },
398
+ {
399
+ title: 'Metadata',
400
+ param: 'metadata',
401
+ type: ParamType.JSON,
402
+ startsHidden: true,
403
+ },
404
+ {
405
+ title: 'Source',
406
+ param: 'source',
407
+ type: ParamType.String,
408
+ },
409
+ {
410
+ title: 'Server Route Path',
411
+ param: 'routePath',
412
+ type: ParamType.String,
413
+ startsHidden: true,
414
+ },
415
+ {
416
+ title: 'Server Route Template',
417
+ param: 'routeTemplate',
418
+ type: ParamType.String,
419
+ startsHidden: true,
420
+ },
421
+ {
422
+ title: 'Type',
423
+ param: 'type',
424
+ type: ParamType.String,
425
+ },
426
+ {
427
+ title: 'Error Message',
428
+ param: 'errorMessage',
429
+ type: ParamType.String,
430
+ startsHidden: true,
431
+ },
432
+ {
433
+ title: 'Error Code',
434
+ param: 'errorCode',
435
+ type: ParamType.String,
436
+ startsHidden: true,
437
+ },
438
+ {
439
+ title: 'Error Stack',
440
+ param: 'errorStack',
441
+ type: ParamType.String,
442
+ startsHidden: true,
443
+ },
444
+ {
445
+ title: 'Action Target',
446
+ param: 'target',
447
+ type: ParamType.String,
448
+ startsHidden: true,
449
+ },
450
+ {
451
+ title: 'Action Type',
452
+ param: 'action',
453
+ type: ParamType.String,
454
+ startsHidden: true,
455
+ },
456
+ ];
457
+
265
458
  /*------------------------------------------------------------------------*/
266
459
  /* Static Functions */
267
460
  /*------------------------------------------------------------------------*/
@@ -521,33 +714,34 @@ const LogReviewer: React.FC<Props> = (props) => {
521
714
  onClose,
522
715
  } = props;
523
716
 
524
- // Add built-in LogMetadata
525
- // > Add "uncategorized" subcontext to each context
526
- Object.keys(LogMetadata.Context ?? {}).forEach((context) => {
527
- if (
528
- // Context exists
529
- LogMetadata.Context
530
- // Context has children already
531
- && typeof LogMetadata.Context[context] !== 'string'
532
- ) {
533
- (LogMetadata.Context as any)[context][LogBuiltInMetadata.Context.Uncategorized] = (
534
- LogBuiltInMetadata.Context.Uncategorized
535
- );
536
- }
537
- })
538
- // > Add built-in contexts
539
- LogMetadata.Context = (LogMetadata.Context ?? {});
540
- Object.keys(LogBuiltInMetadata.Context).forEach((context) => {
541
- if (LogMetadata.Context) {
542
- LogMetadata.Context[context] = context;
543
- }
717
+ // Create complete map of contexts
718
+ const contextMap: LogMetadataContextMap = {};
719
+ [
720
+ (LogMetadata.Context ?? {}),
721
+ LogBuiltInMetadata.Context,
722
+ ].forEach((contextMap) => {
723
+ Object.keys(contextMap).forEach((context) => {
724
+ // Add context
725
+ contextMap[context] = context;
726
+
727
+ // If context has children, add an "uncategorized" subcontext
728
+ if (typeof contextMap[context] !== 'string') {
729
+ (contextMap[context] as any)[LogBuiltInMetadata.Context.Uncategorized] = (
730
+ LogBuiltInMetadata.Context.Uncategorized
731
+ );
732
+ }
733
+ });
544
734
  });
545
- // > Add built-in targets
546
- LogMetadata.Target = (LogMetadata.Target ?? {});
547
- Object.keys(LogBuiltInMetadata.Target).forEach((target) => {
548
- if (LogMetadata.Target) {
549
- LogMetadata.Target[target] = target;
550
- }
735
+
736
+ // Create complete map of targets
737
+ const targetMap: LogMetadataTargetMap = {};
738
+ [
739
+ (LogMetadata.Target ?? {}),
740
+ LogBuiltInMetadata.Target,
741
+ ].forEach((targetMap) => {
742
+ Object.keys(targetMap).forEach((target) => {
743
+ targetMap[target] = target;
744
+ });
551
745
  });
552
746
 
553
747
  /* -------------- State ------------- */
@@ -934,7 +1128,7 @@ const LogReviewer: React.FC<Props> = (props) => {
934
1128
  });
935
1129
  }}
936
1130
  >
937
- Reset All
1131
+ Reset
938
1132
  </button>
939
1133
  </div>
940
1134
  </div>
@@ -996,45 +1190,63 @@ const LogReviewer: React.FC<Props> = (props) => {
996
1190
  );
997
1191
  } else if (expandedFilterDrawer === FilterDrawer.Context) {
998
1192
  // Create item picker items
999
- const pickableItems: PickableItem[] = (
1000
- Object.keys(LogMetadata.Context ?? {})
1001
- .map((context) => {
1002
- const value = (LogMetadata.Context ?? {})[context];
1003
- if (typeof value === 'string') {
1004
- // No subcategories
1005
- const item: PickableItem = {
1006
- id: context,
1007
- name: genHumanReadableName(context),
1008
- isGroup: false,
1009
- checked: !!contextFilterState[context],
1010
- };
1011
- return item;
1012
- }
1013
-
1014
- // Has subcategories
1015
- const children: PickableItem[] = (
1016
- Object.keys(value)
1017
- .filter((subcontext) => {
1018
- return subcontext !== '_';
1019
- })
1020
- .map((subcontext) => {
1021
- return {
1022
- id: subcontext,
1023
- name: genHumanReadableName(subcontext),
1024
- isGroup: false,
1025
- checked: (contextFilterState[context] as any)[subcontext],
1026
- };
1027
- })
1028
- );
1193
+ const builtInPickableItem: PickableItem = {
1194
+ id: '_',
1195
+ name: 'Auto-logged',
1196
+ isGroup: true,
1197
+ children: [],
1198
+ };
1199
+ const pickableItems: PickableItem[] = [];
1200
+ Object.keys(contextMap)
1201
+ .forEach((context) => {
1202
+ const value = (contextMap)[context];
1203
+ if (typeof value === 'string') {
1204
+ // No subcategories
1029
1205
  const item: PickableItem = {
1030
1206
  id: context,
1031
1207
  name: genHumanReadableName(context),
1032
- isGroup: true,
1033
- children,
1208
+ isGroup: false,
1209
+ checked: !!contextFilterState[context],
1034
1210
  };
1035
- return item;
1036
- })
1037
- );
1211
+
1212
+ // Add built-in items to its own folder
1213
+ const isBuiltIn = context in LogBuiltInMetadata.Context;
1214
+ if (isBuiltIn) {
1215
+ // Add to built-in pickable item
1216
+ builtInPickableItem.children.push(item);
1217
+ } else {
1218
+ // Add to pickable items list
1219
+ pickableItems.push(item);
1220
+ }
1221
+ }
1222
+
1223
+ // Has subcategories
1224
+ const children: PickableItem[] = (
1225
+ Object.keys(value)
1226
+ // Remove parent name
1227
+ .filter((subcontext) => {
1228
+ return subcontext !== '_';
1229
+ })
1230
+ // Create child pickable items
1231
+ .map((subcontext) => {
1232
+ return {
1233
+ id: subcontext,
1234
+ name: genHumanReadableName(subcontext),
1235
+ isGroup: false,
1236
+ checked: (contextFilterState[context] as any)[subcontext],
1237
+ };
1238
+ })
1239
+ );
1240
+ const item: PickableItem = {
1241
+ id: context,
1242
+ name: genHumanReadableName(context),
1243
+ isGroup: true,
1244
+ children,
1245
+ };
1246
+ pickableItems.push(item);
1247
+ });
1248
+ // Add built-in contexts to end ofl ist
1249
+ pickableItems.push(builtInPickableItem);
1038
1250
 
1039
1251
  // Create filter UI
1040
1252
  filterDrawer = (
@@ -1046,15 +1258,30 @@ const LogReviewer: React.FC<Props> = (props) => {
1046
1258
  updatedItems.forEach((pickableItem) => {
1047
1259
  if (pickableItem.isGroup) {
1048
1260
  // Has subcontexts
1049
- pickableItem.children.forEach((subcontextItem) => {
1050
- if (!subcontextItem.isGroup) {
1051
- (
1052
- contextFilterState[pickableItem.id] as { [k: string]: boolean }
1053
- )[subcontextItem.id] = (
1054
- subcontextItem.checked
1261
+
1262
+
1263
+ if (pickableItem.id === '_') {
1264
+ // Built-in
1265
+
1266
+ // Treat as if these were top-level contexts
1267
+ pickableItem.children.forEach((subcontextItem) => {
1268
+ contextFilterState[subcontextItem.id] = (
1269
+ 'checked' in subcontextItem
1270
+ && subcontextItem.checked
1055
1271
  );
1056
- }
1057
- });
1272
+ });
1273
+ } else {
1274
+ // Not built-in
1275
+ pickableItem.children.forEach((subcontextItem) => {
1276
+ if (!subcontextItem.isGroup) {
1277
+ (
1278
+ contextFilterState[pickableItem.id] as { [k: string]: boolean }
1279
+ )[subcontextItem.id] = (
1280
+ subcontextItem.checked
1281
+ );
1282
+ }
1283
+ });
1284
+ }
1058
1285
  } else {
1059
1286
  // No subcontexts
1060
1287
  (contextFilterState as any)[pickableItem.id] = (
@@ -1073,6 +1300,11 @@ const LogReviewer: React.FC<Props> = (props) => {
1073
1300
  // Create filter UI
1074
1301
  filterDrawer = (
1075
1302
  <TabBox title="Tags">
1303
+ <div>
1304
+ If any are selected, logs must contain at least one
1305
+ but not necessarily all of the
1306
+ selected tags.
1307
+ </div>
1076
1308
  {
1077
1309
  Object.keys(LogMetadata.Tag ?? {})
1078
1310
  .map((tag, i) => {
@@ -1183,15 +1415,9 @@ const LogReviewer: React.FC<Props> = (props) => {
1183
1415
  </ButtonInputGroup>
1184
1416
  {/* Target */}
1185
1417
  <ButtonInputGroup label="Target">
1186
- {/* Nothing here */}
1187
- {(Object.keys(LogMetadata.Target ?? {}).length === 0) && (
1188
- <div>
1189
- This app does not have any targets yet.
1190
- </div>
1191
- )}
1192
1418
  {/* List of targets */}
1193
1419
  {
1194
- Object.keys(LogMetadata.Target ?? {})
1420
+ Object.keys(targetMap)
1195
1421
  .map((target, i) => {
1196
1422
  const description = genHumanReadableName(target);
1197
1423
  return (
@@ -1209,7 +1435,7 @@ const LogReviewer: React.FC<Props> = (props) => {
1209
1435
  actionErrorFilterState,
1210
1436
  });
1211
1437
  }}
1212
- noMarginOnRight={i === Object.keys(LogMetadata.Target ?? {}).length - 1}
1438
+ noMarginOnRight={i === Object.keys(targetMap).length - 1}
1213
1439
  />
1214
1440
  );
1215
1441
  })
@@ -1942,194 +2168,6 @@ const LogReviewer: React.FC<Props> = (props) => {
1942
2168
  /* Data */
1943
2169
  /*----------------------------------------*/
1944
2170
 
1945
- // Create data table
1946
- const columns: IntelliTableColumn[] = [
1947
- {
1948
- title: 'First Name',
1949
- param: 'userFirstName',
1950
- type: ParamType.String,
1951
- },
1952
- {
1953
- title: 'Last Name',
1954
- param: 'userLastName',
1955
- type: ParamType.String,
1956
- },
1957
- {
1958
- title: 'Email',
1959
- param: 'userEmail',
1960
- type: ParamType.String,
1961
- },
1962
- {
1963
- title: 'Canvas Id',
1964
- param: 'userId',
1965
- type: ParamType.Int,
1966
- },
1967
- {
1968
- title: 'Student?',
1969
- param: 'isLearner',
1970
- type: ParamType.Boolean,
1971
- },
1972
- {
1973
- title: 'Teaching Staff?',
1974
- param: 'isTTM',
1975
- type: ParamType.Boolean,
1976
- startsHidden: true,
1977
- },
1978
- {
1979
- title: 'Admin?',
1980
- param: 'isAdmin',
1981
- type: ParamType.Boolean,
1982
- startsHidden: true,
1983
- },
1984
- {
1985
- title: 'Course Canvas Id',
1986
- param: 'courseId',
1987
- type: ParamType.Int,
1988
- startsHidden: true,
1989
- },
1990
- {
1991
- title: 'Course Name',
1992
- param: 'courseName',
1993
- type: ParamType.String,
1994
- },
1995
- {
1996
- title: 'Browser Name',
1997
- param: 'browser.name',
1998
- type: ParamType.String,
1999
- startsHidden: true,
2000
- },
2001
- {
2002
- title: 'Browser Version',
2003
- param: 'browser.version',
2004
- type: ParamType.String,
2005
- startsHidden: true,
2006
- },
2007
- {
2008
- title: 'OS',
2009
- param: 'device.os',
2010
- type: ParamType.String,
2011
- startsHidden: true,
2012
- },
2013
- {
2014
- title: 'Mobile?',
2015
- param: 'device.isMobile',
2016
- type: ParamType.Boolean,
2017
- startsHidden: true,
2018
- },
2019
- {
2020
- title: 'Year',
2021
- param: 'year',
2022
- type: ParamType.Int,
2023
- },
2024
- {
2025
- title: 'Month',
2026
- param: 'month',
2027
- type: ParamType.Int,
2028
- },
2029
- {
2030
- title: 'Day',
2031
- param: 'day',
2032
- type: ParamType.Int,
2033
- },
2034
- {
2035
- title: 'Hour',
2036
- param: 'hour',
2037
- type: ParamType.Int,
2038
- },
2039
- {
2040
- title: 'Minute',
2041
- param: 'minute',
2042
- type: ParamType.Int,
2043
- startsHidden: true,
2044
- },
2045
- {
2046
- title: 'Timestamp',
2047
- param: 'timestamp',
2048
- type: ParamType.Int,
2049
- startsHidden: true,
2050
- },
2051
- {
2052
- title: 'Context',
2053
- param: 'context',
2054
- type: ParamType.String,
2055
- },
2056
- {
2057
- title: 'Subcontext',
2058
- param: 'subcontext',
2059
- type: ParamType.String,
2060
- },
2061
- {
2062
- title: 'Tags',
2063
- param: 'tags',
2064
- type: ParamType.JSON,
2065
- startsHidden: true,
2066
- },
2067
- {
2068
- title: 'Log Level',
2069
- param: 'level',
2070
- type: ParamType.String,
2071
- startsHidden: true,
2072
- },
2073
- {
2074
- title: 'Metadata',
2075
- param: 'metadata',
2076
- type: ParamType.JSON,
2077
- startsHidden: true,
2078
- },
2079
- {
2080
- title: 'Source',
2081
- param: 'source',
2082
- type: ParamType.String,
2083
- },
2084
- {
2085
- title: 'Server Route Path',
2086
- param: 'routePath',
2087
- type: ParamType.String,
2088
- startsHidden: true,
2089
- },
2090
- {
2091
- title: 'Server Route Template',
2092
- param: 'routeTemplate',
2093
- type: ParamType.String,
2094
- startsHidden: true,
2095
- },
2096
- {
2097
- title: 'Type',
2098
- param: 'type',
2099
- type: ParamType.String,
2100
- },
2101
- {
2102
- title: 'Error Message',
2103
- param: 'errorMessage',
2104
- type: ParamType.String,
2105
- startsHidden: true,
2106
- },
2107
- {
2108
- title: 'Error Code',
2109
- param: 'errorCode',
2110
- type: ParamType.String,
2111
- startsHidden: true,
2112
- },
2113
- {
2114
- title: 'Error Stack',
2115
- param: 'errorStack',
2116
- type: ParamType.String,
2117
- startsHidden: true,
2118
- },
2119
- {
2120
- title: 'Action Target',
2121
- param: 'target',
2122
- type: ParamType.String,
2123
- startsHidden: true,
2124
- },
2125
- {
2126
- title: 'Action Type',
2127
- param: 'action',
2128
- type: ParamType.String,
2129
- startsHidden: true,
2130
- },
2131
- ];
2132
-
2133
2171
  // Nothing to show notice
2134
2172
  const noLogsNotice = (
2135
2173
  logs.length === 0
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Type of the context map in a LogMetadata file
3
+ * @author Gabe Abrams
4
+ */
5
+ type LogMetadataContextMap = {
6
+ [k: string]: (
7
+ | string
8
+ | {
9
+ _: string,
10
+ [k: string]: string
11
+ }
12
+ )
13
+ };
14
+
15
+ export default LogMetadataContextMap;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Type of the tag map inside a LogMetadata file
3
+ * @author Gabe Abrams
4
+ */
5
+ type LogMetadataTagMap = {
6
+ [k: string]: string
7
+ };
8
+
9
+ export default LogMetadataTagMap;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Type of the target map inside a LogMetadata file
3
+ * @author Gabe Abrams
4
+ */
5
+ type LogMetadataTargetMap = {
6
+ [k: string]: string
7
+ };
8
+
9
+ export default LogMetadataTargetMap;