orc-shared 5.10.0-dev.16 → 5.10.0-dev.17

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.
@@ -81,7 +81,9 @@ var TableWithInMemoryPaging = function TableWithInMemoryPaging(_ref) {
81
81
  _ref$placeholderTitle = _ref.placeholderTitle,
82
82
  placeholderTitle = _ref$placeholderTitle === void 0 ? null : _ref$placeholderTitle,
83
83
  _ref$placeholderSubti = _ref.placeholderSubtitle,
84
- placeholderSubtitle = _ref$placeholderSubti === void 0 ? null : _ref$placeholderSubti;
84
+ placeholderSubtitle = _ref$placeholderSubti === void 0 ? null : _ref$placeholderSubti,
85
+ _ref$rowKeyField = _ref.rowKeyField,
86
+ rowKeyField = _ref$rowKeyField === void 0 ? "id" : _ref$rowKeyField;
85
87
  var _useIntl = (0, _reactIntl.useIntl)(),
86
88
  formatMessage = _useIntl.formatMessage;
87
89
  var tableRef = (0, _react.useRef)(null);
@@ -106,7 +108,7 @@ var TableWithInMemoryPaging = function TableWithInMemoryPaging(_ref) {
106
108
  filters = _useInMemoryPaging.filters,
107
109
  setFilter = _useInMemoryPaging.setFilter,
108
110
  totalCount = _useInMemoryPaging.totalCount;
109
- var _buildHeaderAndRowFro = (0, _tableHelpers.default)(columnDefs, rowsSlice, isReadMode),
111
+ var _buildHeaderAndRowFro = (0, _tableHelpers.default)(columnDefs, rowsSlice, isReadMode, rowKeyField),
110
112
  headers = _buildHeaderAndRowFro.headers,
111
113
  rows = _buildHeaderAndRowFro.rows;
112
114
  var placeholder = /*#__PURE__*/_react.default.createElement(_Placeholder.default, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orc-shared",
3
- "version": "5.10.0-dev.16",
3
+ "version": "5.10.0-dev.17",
4
4
  "description": "Shared code for Orckestra applications",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
@@ -50,6 +50,7 @@ const TableWithInMemoryPaging = ({
50
50
  placeholderIcon = null,
51
51
  placeholderTitle = null,
52
52
  placeholderSubtitle = null,
53
+ rowKeyField = "id",
53
54
  }) => {
54
55
  const { formatMessage } = useIntl();
55
56
  const tableRef = useRef(null);
@@ -79,7 +80,7 @@ const TableWithInMemoryPaging = ({
79
80
  sortAndFilterFn: sortAndFilter,
80
81
  });
81
82
 
82
- const { headers, rows } = buildHeaderAndRowFromConfig(columnDefs, rowsSlice, isReadMode);
83
+ const { headers, rows } = buildHeaderAndRowFromConfig(columnDefs, rowsSlice, isReadMode, rowKeyField);
83
84
  const placeholder = (
84
85
  <Placeholder
85
86
  icon={placeholderIcon}
@@ -4,7 +4,7 @@ import { mount } from "enzyme";
4
4
  import Table from "./Table";
5
5
  import { buildHeaderAndRowFromConfig } from "./tableHelpers";
6
6
  import TableInfoBar from "./PredefinedElements/TableInfoBar";
7
- import { extractMessages } from "../../../utils/testUtils";
7
+ import { extractMessages, spyOnConsole } from "../../../utils/testUtils";
8
8
  import TableProps from "./TableProps";
9
9
  import { createMuiTheme } from "./../../../utils/testUtils";
10
10
  import { TestWrapper } from "../../../utils/testUtils";
@@ -15,6 +15,7 @@ import SectionToolbar from "./PredefinedElements/SectionToolbar";
15
15
  import buildStore from "../../../buildStore";
16
16
  import { fireEvent, render, getByPlaceholderText, getByTestId, queryAllByRole } from "@testing-library/react";
17
17
  import Placeholder from "./PredefinedElements/Placeholder";
18
+ import { cloneDeep } from "lodash";
18
19
 
19
20
  const messages = extractMessages(sharedMessages);
20
21
 
@@ -33,6 +34,8 @@ describe("TableWithInMemoryPaging", () => {
33
34
 
34
35
  let store;
35
36
 
37
+ spyOnConsole(["error"]);
38
+
36
39
  beforeEach(() => {
37
40
  global.SUPPORTED_LOCALES = undefined;
38
41
  store = buildStore([]); // use the real reducers
@@ -418,4 +421,37 @@ describe("TableWithInMemoryPaging", () => {
418
421
 
419
422
  expect(component, "when mounted", "to satisfy", expected);
420
423
  });
424
+
425
+ it("Renders TableWithInMemoryPaging with a different key", () => {
426
+ const configDefs = getColumnDefs();
427
+ const records = cloneDeep(standardListRecords);
428
+ records.forEach(record => {
429
+ record.anotherId = record.id;
430
+ delete record.id;
431
+ });
432
+
433
+ const component = (
434
+ <TestWrapper
435
+ provider={{ store }}
436
+ memoryRouter
437
+ intlProvider={{ messages }}
438
+ stylesProvider
439
+ muiThemeProvider={{ theme }}
440
+ >
441
+ <div>
442
+ <TableWithInMemoryPaging
443
+ sortedRows={records}
444
+ tableName={"StateName"}
445
+ columnDefs={configDefs}
446
+ searchProperties={["name"]}
447
+ rowKeyField="anotherId"
448
+ />
449
+ </div>
450
+ </TestWrapper>
451
+ );
452
+
453
+ render(component);
454
+
455
+ expect(console.error, "was not called");
456
+ });
421
457
  });