@truedat/dd 7.0.3 → 7.0.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/dd",
3
- "version": "7.0.3",
3
+ "version": "7.0.4",
4
4
  "description": "Truedat Web Data Dictionary",
5
5
  "sideEffects": false,
6
6
  "jsnext:main": "src/index.js",
@@ -34,7 +34,7 @@
34
34
  "@testing-library/jest-dom": "^5.16.5",
35
35
  "@testing-library/react": "^12.0.0",
36
36
  "@testing-library/user-event": "^13.2.1",
37
- "@truedat/test": "7.0.3",
37
+ "@truedat/test": "7.0.4",
38
38
  "babel-jest": "^28.1.0",
39
39
  "babel-plugin-dynamic-import-node": "^2.3.3",
40
40
  "babel-plugin-lodash": "^3.3.4",
@@ -88,9 +88,9 @@
88
88
  },
89
89
  "dependencies": {
90
90
  "@apollo/client": "^3.7.1",
91
- "@truedat/auth": "7.0.3",
92
- "@truedat/core": "7.0.3",
93
- "@truedat/df": "7.0.3",
91
+ "@truedat/auth": "7.0.4",
92
+ "@truedat/core": "7.0.4",
93
+ "@truedat/df": "7.0.4",
94
94
  "lodash": "^4.17.21",
95
95
  "moment": "^2.29.4",
96
96
  "path-to-regexp": "^1.7.0",
@@ -115,5 +115,5 @@
115
115
  "react-dom": ">= 16.8.6 < 17",
116
116
  "semantic-ui-react": ">= 2.0.3 < 2.2"
117
117
  },
118
- "gitHead": "871005135545e304fa6ba9a5d49fa31b46e28a7c"
118
+ "gitHead": "b2c0938fa6ea458e3009c82e4e91b7bc79c8ffed"
119
119
  }
@@ -4,7 +4,7 @@ import PropTypes from "prop-types";
4
4
  import { connect } from "react-redux";
5
5
  import { Link } from "react-router-dom";
6
6
  import { linkTo } from "@truedat/core/routes";
7
- import { FormattedMessage, useIntl } from "react-intl";
7
+ import { useIntl } from "react-intl";
8
8
  import { Grid, Segment, List, Label } from "semantic-ui-react";
9
9
  import GenericCrumbs from "@truedat/core/components/GenericCrumbs";
10
10
  import { getGrantRequestTemplate } from "../selectors";
@@ -1,7 +1,7 @@
1
1
  import _ from "lodash/fp";
2
2
  import React, { useState, useEffect } from "react";
3
3
  import PropTypes from "prop-types";
4
- import { connect } from "react-redux";
4
+ import { connect, useSelector } from "react-redux";
5
5
  import { Segment } from "semantic-ui-react";
6
6
  import SearchWidget from "@truedat/core/search/SearchWidget";
7
7
  import {
@@ -13,6 +13,8 @@ import {
13
13
  useDataStructureFilters,
14
14
  useDataStructureSearch,
15
15
  } from "../hooks/useStructures";
16
+ import { defaultColumnsForStructureSelector } from "../selectors";
17
+
16
18
  import StructuresSearchResults from "./StructuresSearchResults";
17
19
 
18
20
  function StructureSelectorContent({
@@ -70,6 +72,13 @@ export const StructureSelector = (props) => {
70
72
  const pageSize = _.prop("pageSize")(props);
71
73
  const withGrantRequests = _.prop("withGrantRequests")(props);
72
74
  const withDataFields = _.prop("withDataFields")(props);
75
+ const defaultOverwriteColumns = useSelector(
76
+ defaultColumnsForStructureSelector
77
+ );
78
+ const overwriteColumns = _.propOr(
79
+ defaultOverwriteColumns,
80
+ "overwriteColumns"
81
+ )(props);
73
82
 
74
83
  const enrichSearchPayload = {
75
84
  my_grant_requests: !!withGrantRequests,
@@ -90,10 +99,12 @@ export const StructureSelector = (props) => {
90
99
  enrichSearchPayload,
91
100
  };
92
101
 
102
+ const selectorProps = { ...props, overwriteColumns };
103
+
93
104
  return (
94
105
  <>
95
106
  <SearchContextProvider {...searchProps}>
96
- <StructureSelectorContent {...props} />
107
+ <StructureSelectorContent {...selectorProps} />
97
108
  </SearchContextProvider>
98
109
  </>
99
110
  );
@@ -142,12 +142,7 @@ exports[`<StructureSelector /> matches the latest snapshot 1`] = `
142
142
  <td
143
143
  class="structure-cell-overflow"
144
144
  >
145
- <a
146
- href="/structures/1"
147
- title="1"
148
- >
149
- 1
150
- </a>
145
+ 1
151
146
  </td>
152
147
  <td
153
148
  class=""
@@ -179,12 +174,7 @@ exports[`<StructureSelector /> matches the latest snapshot 1`] = `
179
174
  <td
180
175
  class="structure-cell-overflow"
181
176
  >
182
- <a
183
- href="/structures/2"
184
- title="2"
185
- >
186
- 2
187
- </a>
177
+ 2
188
178
  </td>
189
179
  <td
190
180
  class=""
@@ -1,4 +1,7 @@
1
- import { structureColumnsSelector } from "..";
1
+ import {
2
+ defaultColumnsForStructureSelector,
3
+ structureColumnsSelector,
4
+ } from "..";
2
5
 
3
6
  describe("selectors: structureColumnsSelector", () => {
4
7
  it("should return default structuresColumns when present", () => {
@@ -28,3 +31,28 @@ describe("selectors: structureColumnsSelector", () => {
28
31
  expect(res).toEqual([{ name: "foo" }, { name: "bar" }]);
29
32
  });
30
33
  });
34
+
35
+ describe("selectors: defaultColumnsForStructureSelector", () => {
36
+ it("should replace name from object with decorator ", () => {
37
+ const structuresColumns = [
38
+ {
39
+ name: "name",
40
+ sort: { name: "name.sort" },
41
+ fieldDecorator: { foo: "bar" },
42
+ width: 2,
43
+ },
44
+ { name: "group", width: 1 },
45
+ ];
46
+ const res = defaultColumnsForStructureSelector({ structuresColumns }, {});
47
+
48
+ expect(res).toHaveLength(2);
49
+ expect(res).toEqual([
50
+ {
51
+ name: "name",
52
+ sort: { name: "name.sort" },
53
+ width: 2,
54
+ },
55
+ { name: "group", width: 1 },
56
+ ]);
57
+ });
58
+ });
@@ -1,6 +1,7 @@
1
1
  export {
2
2
  defaultStructureColumns,
3
3
  structureColumnsSelector,
4
+ defaultColumnsForStructureSelector,
4
5
  } from "./structureColumnsSelector";
5
6
  export {
6
7
  defaultBusinessConceptsLinksToStructuresColumns,
@@ -81,3 +81,14 @@ export const structureColumnsSelector = (state, defaultFilters, ownColumns) =>
81
81
  )(columns);
82
82
  return res;
83
83
  })(state);
84
+
85
+ const rawName = {
86
+ name: "name",
87
+ sort: { name: "name.sort" },
88
+ width: 2,
89
+ };
90
+ export const defaultColumnsForStructureSelector = (state) =>
91
+ createSelector(
92
+ (state) => structureColumnsSelector(state, null, null),
93
+ _.map((item) => (item?.name === "name" ? rawName : item))
94
+ )(state);