@truedat/bg 4.39.0 → 4.40.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.40.0] 2022-03-27
4
+
5
+ ### Changed
6
+
7
+ - [TD-4491] Simplified `getDomainSelectorOptions` selector
8
+
3
9
  ## [4.38.8] 2022-02-22
4
10
 
5
11
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/bg",
3
- "version": "4.39.0",
3
+ "version": "4.40.0",
4
4
  "description": "Truedat Web Business Glossary",
5
5
  "sideEffects": false,
6
6
  "jsnext:main": "src/index.js",
@@ -83,8 +83,8 @@
83
83
  ]
84
84
  },
85
85
  "dependencies": {
86
- "@truedat/core": "4.39.0",
87
- "@truedat/df": "4.39.0",
86
+ "@truedat/core": "4.40.0",
87
+ "@truedat/df": "4.40.0",
88
88
  "file-saver": "^2.0.5",
89
89
  "moment": "^2.24.0",
90
90
  "path-to-regexp": "^1.7.0",
@@ -104,5 +104,5 @@
104
104
  "react-dom": ">= 16.8.6 < 17",
105
105
  "semantic-ui-react": ">= 0.88.2 < 2.1"
106
106
  },
107
- "gitHead": "f3d2fe3fcdec546afc22d0a79c4f4f3dfb91ea48"
107
+ "gitHead": "0bd677584da73a5021a5c96f2e5525fde9a1958a"
108
108
  }
@@ -0,0 +1,66 @@
1
+ import { getDomainSelectorOptions } from "..";
2
+
3
+ describe("selectors: getDomainSelectorOptions", () => {
4
+ const domains = [
5
+ { id: 1, name: "domain1" },
6
+ { id: 2, name: "domain2", parent_id: 1 },
7
+ { id: 3, name: "domain3" },
8
+ { id: 4, name: "domain4", parent_id: 0 },
9
+ { id: 5, name: "domain2", parent_id: 2 },
10
+ ];
11
+
12
+ it("foo", () => {
13
+ const options = getDomainSelectorOptions({ domains });
14
+ expect(options).toEqual([
15
+ {
16
+ ancestors: [],
17
+ children: [{ id: 2, name: "domain2", parent_id: 1 }],
18
+ descendents: [
19
+ { id: 2, name: "domain2", parent_id: 1 },
20
+ { id: 5, name: "domain2", parent_id: 2 },
21
+ ],
22
+ id: 1,
23
+ level: 0,
24
+ name: "domain1",
25
+ },
26
+ {
27
+ ancestors: [{ id: 1, name: "domain1" }],
28
+ children: [{ id: 5, name: "domain2", parent_id: 2 }],
29
+ descendents: [{ id: 5, name: "domain2", parent_id: 2 }],
30
+ id: 2,
31
+ level: 1,
32
+ name: "domain2",
33
+ parent_id: 1,
34
+ },
35
+ {
36
+ ancestors: [
37
+ { id: 1, name: "domain1" },
38
+ { id: 2, name: "domain2", parent_id: 1 },
39
+ ],
40
+ children: [],
41
+ descendents: [],
42
+ id: 5,
43
+ level: 2,
44
+ name: "domain2",
45
+ parent_id: 2,
46
+ },
47
+ {
48
+ ancestors: [],
49
+ children: [],
50
+ descendents: [],
51
+ id: 3,
52
+ level: 0,
53
+ name: "domain3",
54
+ },
55
+ {
56
+ ancestors: [],
57
+ children: [],
58
+ descendents: [],
59
+ id: 4,
60
+ level: 0,
61
+ name: "domain4",
62
+ parent_id: 0,
63
+ },
64
+ ]);
65
+ });
66
+ });
@@ -148,9 +148,10 @@ const reduceTaxonomy = (domains) => (domainsInLevel, level) => {
148
148
  };
149
149
 
150
150
  const getDomainSelectorOptions = createSelector([getDomains], (domains) => {
151
- const roots = getChildOrRootDomains({
152
- domains: _.sortBy(accentInsensitivePathOrder("name"))(domains),
153
- });
151
+ const roots = _.flow(
152
+ _.filter(hasNoParentIn(domains)),
153
+ _.sortBy(accentInsensitivePathOrder("name"))
154
+ )(domains);
154
155
  return reduceTaxonomy(domains)(roots, 0);
155
156
  });
156
157