@truedat/dd 8.7.1 → 8.7.3

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": "8.7.1",
3
+ "version": "8.7.3",
4
4
  "description": "Truedat Web Data Dictionary",
5
5
  "sideEffects": false,
6
6
  "module": "src/index.js",
@@ -51,7 +51,7 @@
51
51
  "@testing-library/jest-dom": "^6.6.3",
52
52
  "@testing-library/react": "^16.3.0",
53
53
  "@testing-library/user-event": "^14.6.1",
54
- "@truedat/test": "8.7.1",
54
+ "@truedat/test": "8.7.3",
55
55
  "identity-obj-proxy": "^3.0.0",
56
56
  "jest": "^29.7.0",
57
57
  "redux-saga-test-plan": "^4.0.6"
@@ -86,5 +86,5 @@
86
86
  "svg-pan-zoom": "^3.6.2",
87
87
  "swr": "^2.3.3"
88
88
  },
89
- "gitHead": "f7605a6ea3f78839b42bb7d8339eec125ba49acb"
89
+ "gitHead": "fcd75ad6b4e43440c4889fb3d968f4cd84fc672d"
90
90
  }
@@ -515,6 +515,7 @@ export const buildDSVQuery = (loadStructureMetadata) => gql`
515
515
  }
516
516
  external_id
517
517
  id
518
+ links_count
518
519
  inserted_at
519
520
  latest_note
520
521
  roles
@@ -13,6 +13,7 @@ const structureFields = (fn) =>
13
13
  "domains",
14
14
  "external_id",
15
15
  "id",
16
+ "links_count",
16
17
  "roles",
17
18
  "inserted_at",
18
19
  "updated_at",
@@ -68,27 +68,28 @@ describe("selectors: getTabVisibility", () => {
68
68
  ).toMatchObject({ profile: true });
69
69
  });
70
70
 
71
- it("should include links iff structure has links", () => {
71
+ it("should include links tab if user has create_link permission", () => {
72
72
  expect(
73
- getTabVisibility({ structureLinks: [{ resource_type: "concept" }] }),
73
+ getTabVisibility({ structureActions: { create_link: {} } }),
74
74
  ).toMatchObject({
75
75
  links: true,
76
76
  });
77
- expect(
78
- getTabVisibility({ structureLinks: [{ resource_type: "foo" }] }),
79
- ).toMatchObject({
80
- links: false,
81
- });
82
- expect(
83
- getTabVisibility({
84
- structureLinks: [{ resource_type: "foo" }],
85
- structureActions: { create_link: {} },
86
- }),
87
- ).toMatchObject({
77
+ });
78
+
79
+ it("should include links tab if structure has links_count > 0", () => {
80
+ expect(getTabVisibility({ structure: { links_count: 2 } })).toMatchObject({
88
81
  links: true,
89
82
  });
90
83
  });
91
84
 
85
+ it("should not include links tab if no permission and no links", () => {
86
+ expect(getTabVisibility({})).toMatchObject({ links: false });
87
+ expect(getTabVisibility({ structure: {} })).toMatchObject({ links: false });
88
+ expect(getTabVisibility({ structure: { links_count: 0 } })).toMatchObject({
89
+ links: false,
90
+ });
91
+ });
92
+
92
93
  it("should include notes if template_id is in structure_note", () => {
93
94
  const structure = { type: "foo", structure_type: { template_id: 1 } };
94
95
  const templates = [{ name: "foo", id: 1 }];
@@ -19,10 +19,9 @@ const profileTabVisible = ({
19
19
  notEmpty(structureProfile?.patterns));
20
20
 
21
21
  const linksTabVisible = (state) => {
22
- const structureLinks = getStructureToConceptLinks(state);
23
- return (
24
- _.has("create_link", state?.structureActions) || !_.isEmpty(structureLinks)
25
- );
22
+ const hasPermission = _.has("create_link", state?.structureActions);
23
+ const hasLinks = (state?.structure?.links_count || 0) > 0;
24
+ return hasPermission || hasLinks;
26
25
  };
27
26
 
28
27
  const notesTabVisible = ({ templatesLoading, templates, structure }) =>