dce-reactkit 3.2.2-beta.40 → 3.2.2-beta.42

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.
@@ -12,6 +12,7 @@ declare type Props = {
12
12
  [k: string]: any;
13
13
  }[];
14
14
  columns: IntelliTableColumn[];
15
+ csvName?: string;
15
16
  };
16
17
  declare const IntelliTable: React.FC<Props>;
17
18
  export default IntelliTable;
package/dist/index.d.ts CHANGED
@@ -441,6 +441,7 @@ declare type Props$1 = {
441
441
  [k: string]: any;
442
442
  }[];
443
443
  columns: IntelliTableColumn[];
444
+ csvName?: string;
444
445
  };
445
446
  declare const IntelliTable: React.FC<Props$1>;
446
447
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dce-reactkit",
3
- "version": "3.2.2-beta.40",
3
+ "version": "3.2.2-beta.42",
4
4
  "description": "Shared components for Harvard DCE apps",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -51,6 +51,8 @@ type Props = {
51
51
  }[],
52
52
  // Column information
53
53
  columns: IntelliTableColumn[],
54
+ // Name of the CSV file. If excluded, title is used
55
+ csvName?: string,
54
56
  };
55
57
 
56
58
  // Sort types
@@ -192,6 +194,16 @@ const IntelliTable: React.FC<Props> = (props) => {
192
194
  : [{ id: 'empty-row' }]
193
195
  );
194
196
 
197
+ // Get CSV filename
198
+ let filename = `${title}.csv`;
199
+ if (props.csvName) {
200
+ filename = (
201
+ props.csvName.endsWith('.csv')
202
+ ? props.csvName
203
+ : `${props.csvName}.csv`
204
+ );
205
+ }
206
+
195
207
  /* -------------- State ------------- */
196
208
 
197
209
  // Initial state
@@ -480,16 +492,19 @@ const IntelliTable: React.FC<Props> = (props) => {
480
492
  noValue
481
493
  ? (
482
494
  <FontAwesomeIcon
483
- icon={faCheckCircle}
495
+ icon={faMinus}
484
496
  />
485
497
  )
486
498
  : (
487
499
  <FontAwesomeIcon
488
- icon={faXmarkCircle}
500
+ icon={fullValue ? faCheckCircle : faXmarkCircle}
489
501
  />
490
502
  )
491
503
  );
492
504
  title = (fullValue ? 'True' : 'False');
505
+ if (noValue) {
506
+ title = 'Empty Cell';
507
+ }
493
508
  } else if (column.type === ParamType.Int) {
494
509
  fullValue = Number.parseInt(value, 10);
495
510
  const noValue = Number.isNaN(fullValue);
@@ -503,6 +518,9 @@ const IntelliTable: React.FC<Props> = (props) => {
503
518
  : fullValue
504
519
  );
505
520
  title = String(fullValue);
521
+ if (noValue) {
522
+ title = 'Empty Cell';
523
+ }
506
524
  } else if (column.type === ParamType.Float) {
507
525
  fullValue = Number.parseFloat(value);
508
526
  const noValue = Number.isNaN(fullValue);
@@ -516,6 +534,9 @@ const IntelliTable: React.FC<Props> = (props) => {
516
534
  : roundToNumDecimals(fullValue as number, 2)
517
535
  );
518
536
  title = String(fullValue);
537
+ if (noValue) {
538
+ title = 'Empty Cell';
539
+ }
519
540
  } else if (column.type === ParamType.String) {
520
541
  fullValue = String(value).trim();
521
542
  const noValue = (
@@ -533,6 +554,9 @@ const IntelliTable: React.FC<Props> = (props) => {
533
554
  : fullValue
534
555
  );
535
556
  title = `"${value}"`;
557
+ if (noValue) {
558
+ title = 'Empty Cell';
559
+ }
536
560
  } else if (column.type === ParamType.JSON) {
537
561
  fullValue = JSON.stringify(value);
538
562
  const noValue = (
@@ -549,6 +573,7 @@ const IntelliTable: React.FC<Props> = (props) => {
549
573
  )
550
574
  : fullValue
551
575
  );
576
+ title="JSON Object"
552
577
  }
553
578
 
554
579
  // Create UI
@@ -22,6 +22,7 @@ import {
22
22
  import visitServerEndpoint from '../helpers/visitServerEndpoint';
23
23
  import getTimeInfoInET from '../helpers/getTimeInfoInET';
24
24
  import { alert, showFatalError } from './AppWrapper';
25
+ import getHumanReadableDate from '../helpers/getHumanReadableDate';
25
26
 
26
27
  // Import shared constants
27
28
  import LOG_REVIEW_ROUTE_PATH_PREFIX from '../constants/LOG_REVIEW_ROUTE_PATH_PREFIX';
@@ -901,7 +902,7 @@ const LogReviewer: React.FC<Props> = (props) => {
901
902
  <button
902
903
  type="button"
903
904
  id="LogReviewer-toggle-advanced-filter-drawer"
904
- className={`btn btn-${FilterDrawer.Advanced === expandedFilterDrawer ? 'warning' : 'light'}`}
905
+ className={`btn btn-${FilterDrawer.Advanced === expandedFilterDrawer ? 'warning' : 'light'} me-2`}
905
906
  aria-label="toggle advanced filter drawer"
906
907
  onClick={() => {
907
908
  dispatch({
@@ -916,6 +917,25 @@ const LogReviewer: React.FC<Props> = (props) => {
916
917
  />
917
918
  Advanced
918
919
  </button>
920
+ {/* Reset */}
921
+ <button
922
+ type="button"
923
+ id="LogReviewer-reset-filters-button"
924
+ className="btn btn-light"
925
+ aria-label="reset filters"
926
+ onClick={() => {
927
+ dispatch({
928
+ type: ActionType.ResetFilters,
929
+ initActionErrorFilterState,
930
+ initAdvancedFilterState,
931
+ initContextFilterState,
932
+ initDateFilterState,
933
+ initTagFilterState,
934
+ });
935
+ }}
936
+ >
937
+ Reset All
938
+ </button>
919
939
  </div>
920
940
  </div>
921
941
  );
@@ -1582,7 +1602,7 @@ const LogReviewer: React.FC<Props> = (props) => {
1582
1602
  <>
1583
1603
  {filterToggles}
1584
1604
  {filterDrawer && (
1585
- <Drawer>
1605
+ <Drawer customBackgroundColor="#eee">
1586
1606
  {filterDrawer}
1587
1607
  </Drawer>
1588
1608
  )}
@@ -2131,6 +2151,7 @@ const LogReviewer: React.FC<Props> = (props) => {
2131
2151
  const dataTable = (
2132
2152
  <IntelliTable
2133
2153
  title="Matching Logs:"
2154
+ csvName={`Logs from ${getHumanReadableDate()}`}
2134
2155
  id="logs"
2135
2156
  data={logs}
2136
2157
  columns={columns}
@@ -43,6 +43,7 @@ const genCSV = (
43
43
 
44
44
  // Add each row
45
45
  data.forEach((datum) => {
46
+ csv += '\n';
46
47
  csv += (
47
48
  columns
48
49
  .map((column) => {