@truedat/dd 7.13.4 → 7.13.5

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.13.4",
3
+ "version": "7.13.5",
4
4
  "description": "Truedat Web Data Dictionary",
5
5
  "sideEffects": false,
6
6
  "module": "src/index.js",
@@ -48,7 +48,7 @@
48
48
  "@testing-library/jest-dom": "^6.6.3",
49
49
  "@testing-library/react": "^16.3.0",
50
50
  "@testing-library/user-event": "^14.6.1",
51
- "@truedat/test": "7.13.4",
51
+ "@truedat/test": "7.13.5",
52
52
  "identity-obj-proxy": "^3.0.0",
53
53
  "jest": "^29.7.0",
54
54
  "redux-saga-test-plan": "^4.0.6"
@@ -83,5 +83,5 @@
83
83
  "svg-pan-zoom": "^3.6.2",
84
84
  "swr": "^2.3.3"
85
85
  },
86
- "gitHead": "6040831e5a3ad34db35c7233cb3b630a1ad81c4e"
86
+ "gitHead": "a82fdfd07c75632206f6639dd7c3b3072a3a9379"
87
87
  }
@@ -169,11 +169,11 @@ const mapStateToProps = ({
169
169
  structure,
170
170
  structureAncestry: ancestry,
171
171
  structureVersion: version,
172
- structureSystem: system,
172
+ structureSystem,
173
173
  }) => ({
174
174
  ...structure,
175
175
  ancestry,
176
- system,
176
+ system: structureSystem || structure?.system,
177
177
  version,
178
178
  });
179
179
 
@@ -5,7 +5,6 @@ import Moment from "react-moment";
5
5
  import { connect } from "react-redux";
6
6
  import { useIntl } from "react-intl";
7
7
  import ShareLinkPopup from "@truedat/audit/components/ShareLinkPopup";
8
- import { getStructureUpdatedAt } from "../selectors";
9
8
  import StructureProperties from "./StructureProperties";
10
9
  import StructureConfidentialButton from "./StructureConfidentialButton";
11
10
  import StructureDeleteButton from "./StructureDeleteButton";
@@ -35,7 +34,7 @@ Date.propTypes = {
35
34
  label: PropTypes.string,
36
35
  };
37
36
 
38
- const dateProperties = (deleted_at, updatedAt) =>
37
+ const dateProperties = (deleted_at, updated_at) =>
39
38
  deleted_at
40
39
  ? {
41
40
  label: "deleted_at",
@@ -47,7 +46,7 @@ const dateProperties = (deleted_at, updatedAt) =>
47
46
  label: "updated_at",
48
47
  className: "basic",
49
48
  icon: <Icon name="sync alternate" />,
50
- date: updatedAt,
49
+ date: updated_at,
51
50
  };
52
51
 
53
52
  export const StructureSummary = ({
@@ -58,14 +57,14 @@ export const StructureSummary = ({
58
57
  alias,
59
58
  description,
60
59
  userPermissions,
61
- updatedAt,
60
+ updated_at,
62
61
  deleted_at,
63
62
  isAdmin,
64
63
  }) => {
65
64
  const { formatMessage } = useIntl();
66
65
  const shareUrl = window.location.href;
67
66
  const shareTitle = formatMessage({ id: "structure.share.title" });
68
-
67
+
69
68
  return (
70
69
  <>
71
70
  <Grid>
@@ -81,8 +80,8 @@ export const StructureSummary = ({
81
80
  </Header>
82
81
  </Grid.Column>
83
82
  <Grid.Column width={6} textAlign="right">
84
- {(deleted_at || updatedAt) && (
85
- <Date {...dateProperties(deleted_at, updatedAt)} />
83
+ {(deleted_at || updated_at) && (
84
+ <Date {...dateProperties(deleted_at, updated_at)} />
86
85
  )}
87
86
  <Divider hidden fitted />
88
87
  {structureClasses?._grantable ? (
@@ -122,14 +121,13 @@ StructureSummary.propTypes = {
122
121
  alias: PropTypes.string,
123
122
  description: PropTypes.string,
124
123
  userPermissions: PropTypes.object,
125
- updatedAt: PropTypes.string,
124
+ updated_at: PropTypes.string,
126
125
  deleted_at: PropTypes.string,
127
126
  isAdmin: PropTypes.bool,
128
127
  };
129
128
 
130
129
  const mapStateToProps = (state) => ({
131
130
  userPermissions: state.userPermissions,
132
- updatedAt: getStructureUpdatedAt(state),
133
131
  ...state.structure,
134
132
  isAdmin: state.authentication.role === "admin",
135
133
  });
@@ -24,11 +24,16 @@ const versionsLink = ({ id }, version) =>
24
24
  export const StructureTabs = ({ path }) => {
25
25
  const { formatMessage } = useIntl();
26
26
  const customTabs = useStructureCustomTabs();
27
- const version = useSelector(state => state.structureVersion);
28
- const structure = useSelector(state => state.structure);
29
- const structureTabsOrder = useSelector(state => state.structureTabsOrder);
27
+ const version = useSelector((state) => state.structureVersion);
28
+ const structure = useSelector((state) => state.structure);
29
+ const structureTabsOrder = useSelector((state) => state.structureTabsOrder);
30
30
  const tabVisibility = useSelector(getTabVisibility);
31
- const activeTab = getActiveTab({ tabVisibility, path, structureTabsOrder, customTabs });
31
+ const activeTab = getActiveTab({
32
+ tabVisibility,
33
+ path,
34
+ structureTabsOrder,
35
+ customTabs,
36
+ });
32
37
 
33
38
  const customTabsItems = _.map((tab) => ({
34
39
  active: activeTab === tab.name,
@@ -40,132 +45,160 @@ export const StructureTabs = ({ path }) => {
40
45
 
41
46
  const items = !_.isEmpty(structure)
42
47
  ? _.filter("content")([
43
- {
44
- active: activeTab === "fields",
45
- as: Link,
46
- to: structureFields(structure, version),
47
- content: tabVisibility?.fields ? formatMessage({ id: "tabs.dd.fields" }) : false,
48
- key: "fields",
49
- },
50
- {
51
- active: activeTab === "children",
52
- as: Link,
53
- to: linkTo.STRUCTURE_CHILDREN(structure),
54
- content: tabVisibility?.children ? formatMessage({ id: "tabs.dd.children" }) : false,
55
- key: "children",
56
- },
57
- {
58
- active: activeTab === "notes",
59
- as: Link,
60
- to: linkTo.STRUCTURE_NOTES(structure),
61
- content: tabVisibility?.notes ? formatMessage({ id: "tabs.dd.notes" }) : false,
62
- key: "notes",
63
- },
64
- {
65
- active: activeTab === "parents",
66
- as: Link,
67
- to: linkTo.STRUCTURE_PARENTS(structure),
68
- content: tabVisibility?.parents ? formatMessage({ id: "tabs.dd.parents" }) : false,
69
- key: "parents",
70
- },
71
- {
72
- active: activeTab === "grants",
73
- as: Link,
74
- to: linkTo.STRUCTURE_GRANTS(structure),
75
- content: tabVisibility?.grants ? formatMessage({ id: "tabs.dd.grants" }) : false,
76
- key: "grants",
77
- },
78
- {
79
- active: activeTab === "metadata",
80
- as: Link,
81
- to: linkTo.STRUCTURE_METADATA(structure),
82
- content: tabVisibility?.metadata ? formatMessage({ id: "tabs.dd.metadata" }) : false,
83
- key: "metadata",
84
- },
85
- {
86
- active: activeTab === "profile",
87
- as: Link,
88
- to: linkTo.STRUCTURE_PROFILE(structure),
89
- content: tabVisibility?.profile ? formatMessage({ id: "tabs.dd.profile" }) : false,
90
- key: "profile",
91
- },
92
- {
93
- active: activeTab === "rules",
94
- as: Link,
95
- to: linkTo.STRUCTURE_RULES(structure),
96
- content: tabVisibility?.rules ? formatMessage({ id: "tabs.dd.rules" }) : false,
97
- key: "rules",
98
- },
99
- {
100
- active: activeTab === "links",
101
- as: Link,
102
- to: linkTo.STRUCTURE_LINKS(structure),
103
- content: tabVisibility?.links ? formatMessage({ id: "tabs.dd.links" }) : false,
104
- key: "links",
105
- },
106
- {
107
- active: activeTab === "structureLinks",
108
- as: Link,
109
- to: linkTo.STRUCTURE_STRUCTURE_LINKS(structure),
110
- content: tabVisibility?.structureLinks
111
- ? formatMessage({ id: "tabs.dd.structureLinks" })
112
- : false,
113
- key: "structureLinks",
114
- },
115
- {
116
- active: activeTab === "lineage",
117
- as: Link,
118
- to: linkTo.STRUCTURE_LINEAGE(structure),
119
- content: tabVisibility?.lineage ? formatMessage({ id: "tabs.dd.lineage" }) : false,
120
- key: "lineage",
121
- },
122
- {
123
- active: activeTab === "impact",
124
- as: Link,
125
- to: linkTo.STRUCTURE_IMPACT(structure),
126
- content: tabVisibility?.impact ? formatMessage({ id: "tabs.dd.impact" }) : false,
127
- key: "impact",
128
- },
129
- {
130
- active: activeTab === "versions",
131
- as: Link,
132
- to: versionsLink(structure, version),
133
- content: tabVisibility?.versions ? formatMessage({ id: "tabs.dd.versions" }) : false,
134
- key: "versions",
135
- },
136
- {
137
- active: activeTab === "events",
138
- as: Link,
139
- to: linkTo.STRUCTURE_EVENTS(structure),
140
- content: tabVisibility?.events ? formatMessage({ id: "tabs.dd.audit" }) : false,
141
- key: "events",
142
- },
143
- {
144
- active: activeTab === "roles",
145
- as: Link,
146
- to: linkTo.STRUCTURE_MEMBERS(structure),
147
- content: tabVisibility?.roles ? formatMessage({ id: "tabs.dd.roles" }) : false,
148
- key: "roles",
149
- },
150
- ...customTabsItems,
151
- ])
48
+ {
49
+ active: activeTab === "fields",
50
+ as: Link,
51
+ to: structureFields(structure, version),
52
+ content: tabVisibility?.fields
53
+ ? formatMessage({ id: "tabs.dd.fields" })
54
+ : false,
55
+ key: "fields",
56
+ },
57
+ {
58
+ active: activeTab === "children",
59
+ as: Link,
60
+ to: linkTo.STRUCTURE_CHILDREN(structure),
61
+ content: tabVisibility?.children
62
+ ? formatMessage({ id: "tabs.dd.children" })
63
+ : false,
64
+ key: "children",
65
+ },
66
+ {
67
+ active: activeTab === "notes",
68
+ as: Link,
69
+ to: linkTo.STRUCTURE_NOTES(structure),
70
+ content: tabVisibility?.notes
71
+ ? formatMessage({ id: "tabs.dd.notes" })
72
+ : false,
73
+ key: "notes",
74
+ },
75
+ {
76
+ active: activeTab === "parents",
77
+ as: Link,
78
+ to: linkTo.STRUCTURE_PARENTS(structure),
79
+ content: tabVisibility?.parents
80
+ ? formatMessage({ id: "tabs.dd.parents" })
81
+ : false,
82
+ key: "parents",
83
+ },
84
+ {
85
+ active: activeTab === "grants",
86
+ as: Link,
87
+ to: linkTo.STRUCTURE_GRANTS(structure),
88
+ content: tabVisibility?.grants
89
+ ? formatMessage({ id: "tabs.dd.grants" })
90
+ : false,
91
+ key: "grants",
92
+ },
93
+ {
94
+ active: activeTab === "metadata",
95
+ as: Link,
96
+ to: linkTo.STRUCTURE_METADATA(structure),
97
+ content: tabVisibility?.metadata
98
+ ? formatMessage({ id: "tabs.dd.metadata" })
99
+ : false,
100
+ key: "metadata",
101
+ },
102
+ {
103
+ active: activeTab === "profile",
104
+ as: Link,
105
+ to: linkTo.STRUCTURE_PROFILE(structure),
106
+ content: tabVisibility?.profile
107
+ ? formatMessage({ id: "tabs.dd.profile" })
108
+ : false,
109
+ key: "profile",
110
+ },
111
+ {
112
+ active: activeTab === "rules",
113
+ as: Link,
114
+ to: linkTo.STRUCTURE_RULES(structure),
115
+ content: tabVisibility?.rules
116
+ ? formatMessage({ id: "tabs.dd.rules" })
117
+ : false,
118
+ key: "rules",
119
+ },
120
+ {
121
+ active: activeTab === "links",
122
+ as: Link,
123
+ to: linkTo.STRUCTURE_LINKS(structure),
124
+ content: tabVisibility?.links
125
+ ? formatMessage({ id: "tabs.dd.links" })
126
+ : false,
127
+ key: "links",
128
+ },
129
+ {
130
+ active: activeTab === "structureLinks",
131
+ as: Link,
132
+ to: linkTo.STRUCTURE_STRUCTURE_LINKS(structure),
133
+ content: tabVisibility?.structureLinks
134
+ ? formatMessage({ id: "tabs.dd.structureLinks" })
135
+ : false,
136
+ key: "structureLinks",
137
+ },
138
+ {
139
+ active: activeTab === "lineage",
140
+ as: Link,
141
+ to: linkTo.STRUCTURE_LINEAGE(structure),
142
+ content: tabVisibility?.lineage
143
+ ? formatMessage({ id: "tabs.dd.lineage" })
144
+ : false,
145
+ key: "lineage",
146
+ },
147
+ {
148
+ active: activeTab === "impact",
149
+ as: Link,
150
+ to: linkTo.STRUCTURE_IMPACT(structure),
151
+ content: tabVisibility?.impact
152
+ ? formatMessage({ id: "tabs.dd.impact" })
153
+ : false,
154
+ key: "impact",
155
+ },
156
+ {
157
+ active: activeTab === "versions",
158
+ as: Link,
159
+ to: versionsLink(structure, version),
160
+ content: tabVisibility?.versions
161
+ ? formatMessage({ id: "tabs.dd.versions" })
162
+ : false,
163
+ key: "versions",
164
+ },
165
+ {
166
+ active: activeTab === "events",
167
+ as: Link,
168
+ to: linkTo.STRUCTURE_EVENTS(structure),
169
+ content: tabVisibility?.events
170
+ ? formatMessage({ id: "tabs.dd.audit" })
171
+ : false,
172
+ key: "events",
173
+ },
174
+ {
175
+ active: activeTab === "roles",
176
+ as: Link,
177
+ to: linkTo.STRUCTURE_MEMBERS(structure),
178
+ content: tabVisibility?.roles
179
+ ? formatMessage({ id: "tabs.dd.roles" })
180
+ : false,
181
+ key: "roles",
182
+ },
183
+ ...customTabsItems,
184
+ ])
152
185
  : null;
153
186
 
154
187
  structureTabsOrder
155
188
  ? items.sort((a, b) => {
156
- const aIndex = _.indexOf(a.key)(structureTabsOrder);
157
- const bIndex = _.indexOf(b.key)(structureTabsOrder);
158
- if (aIndex !== -1 && bIndex !== -1) {
159
- return aIndex - bIndex;
160
- }
161
- if (aIndex !== -1) {
162
- return -1;
163
- }
164
- if (bIndex !== -1) {
165
- return 1;
166
- }
167
- return 0;
168
- })
189
+ const aIndex = _.indexOf(a.key)(structureTabsOrder);
190
+ const bIndex = _.indexOf(b.key)(structureTabsOrder);
191
+ if (aIndex !== -1 && bIndex !== -1) {
192
+ return aIndex - bIndex;
193
+ }
194
+ if (aIndex !== -1) {
195
+ return -1;
196
+ }
197
+ if (bIndex !== -1) {
198
+ return 1;
199
+ }
200
+ return 0;
201
+ })
169
202
  : items;
170
203
 
171
204
  return (
@@ -183,6 +216,6 @@ export const StructureTabs = ({ path }) => {
183
216
  );
184
217
  };
185
218
 
186
- StructureTabs.propTypes = { path: PropTypes.string, };
219
+ StructureTabs.propTypes = { path: PropTypes.string };
187
220
 
188
221
  export default StructureTabs;
@@ -28,6 +28,7 @@ describe("<StructureSummary />", () => {
28
28
  classes: {
29
29
  _grantable: true,
30
30
  },
31
+ updated_at: "2019-01-02T03:04:05Z",
31
32
  };
32
33
 
33
34
  const renderOpts = {
@@ -1,4 +1,4 @@
1
- import { clearStructure, fetchStructureChildrens, fetchStructureParents } from "../../routines";
1
+ import { clearStructure, fetchStructure } from "../../routines";
2
2
  import { childrenRelations, parentRelations } from "..";
3
3
 
4
4
  const fooState = { foo: "bar" };
@@ -6,36 +6,36 @@ const fooState = { foo: "bar" };
6
6
  const relation_type = {
7
7
  description: "relation type 1",
8
8
  id: 1,
9
- name: "used_by"
9
+ name: "used_by",
10
10
  };
11
11
  const children = [
12
12
  {
13
13
  id: 1,
14
14
  relation_type,
15
- structure: { id: 1, name: "Structure 1", type: "Some Type 1" }
15
+ structure: { id: 1, name: "Structure 1", type: "Some Type 1" },
16
16
  },
17
17
  {
18
18
  id: 2,
19
19
  relation_type,
20
- structure: { id: 1, name: "Structure 2", type: "Some Type 2" }
21
- }
20
+ structure: { id: 1, name: "Structure 2", type: "Some Type 2" },
21
+ },
22
22
  ];
23
23
 
24
24
  const parents = [
25
25
  {
26
26
  id: 1,
27
27
  relation_type,
28
- structure: { id: 1, name: "Structure 3", type: "Some Type 3" }
28
+ structure: { id: 1, name: "Structure 3", type: "Some Type 3" },
29
29
  },
30
30
  {
31
31
  id: 2,
32
32
  relation_type,
33
- structure: { id: 1, name: "Structure 4", type: "Some Type 4" }
34
- }
33
+ structure: { id: 1, name: "Structure 4", type: "Some Type 4" },
34
+ },
35
35
  ];
36
36
 
37
37
  const data = {
38
- relations: { children, parents }
38
+ relations: { children, parents },
39
39
  };
40
40
 
41
41
  describe("reducers: childrenRelations", () => {
@@ -48,8 +48,8 @@ describe("reducers: childrenRelations", () => {
48
48
  it("should handle the fetchStructures.SUCCESS action", () => {
49
49
  expect(
50
50
  childrenRelations(fooState, {
51
- type: fetchStructureChildrens.SUCCESS,
52
- payload: { data }
51
+ type: fetchStructure.SUCCESS,
52
+ payload: { data },
53
53
  })
54
54
  ).toMatchObject(children);
55
55
  });
@@ -57,7 +57,7 @@ describe("reducers: childrenRelations", () => {
57
57
  it("should handle the clearStructure.TRIGGER action", () => {
58
58
  expect(
59
59
  childrenRelations(fooState, {
60
- type: clearStructure.TRIGGER
60
+ type: clearStructure.TRIGGER,
61
61
  })
62
62
  ).toMatchObject([]);
63
63
  });
@@ -77,8 +77,8 @@ describe("reducers: parentRelations", () => {
77
77
  it("should handle the fetchStructures.SUCCESS action", () => {
78
78
  expect(
79
79
  parentRelations(fooState, {
80
- type: fetchStructureParents.SUCCESS,
81
- payload: { data }
80
+ type: fetchStructure.SUCCESS,
81
+ payload: { data },
82
82
  })
83
83
  ).toMatchObject(parents);
84
84
  });
@@ -86,7 +86,7 @@ describe("reducers: parentRelations", () => {
86
86
  it("should handle the clearStructure.TRIGGER action", () => {
87
87
  expect(
88
88
  childrenRelations(fooState, {
89
- type: clearStructure.TRIGGER
89
+ type: clearStructure.TRIGGER,
90
90
  })
91
91
  ).toMatchObject([]);
92
92
  });
@@ -42,6 +42,7 @@ const structureVersionFields = _.pick([
42
42
  "source",
43
43
  "system",
44
44
  "type",
45
+ "relations",
45
46
  "_actions",
46
47
  "version_count",
47
48
  ]);
@@ -1,5 +1,5 @@
1
1
  import _ from "lodash/fp";
2
- import { clearStructure, fetchStructureChildrens, fetchStructureParents } from "../routines";
2
+ import { clearStructure, fetchStructure } from "../routines";
3
3
 
4
4
  export const initialState = [];
5
5
 
@@ -7,9 +7,9 @@ export const childrenRelations = (state = initialState, { type, payload }) => {
7
7
  switch (type) {
8
8
  case clearStructure.TRIGGER:
9
9
  return initialState;
10
- case fetchStructureChildrens.TRIGGER:
10
+ case fetchStructure.TRIGGER:
11
11
  return initialState;
12
- case fetchStructureChildrens.SUCCESS:
12
+ case fetchStructure.SUCCESS:
13
13
  return _.pathOr([], "data.relations.children")(payload);
14
14
  default:
15
15
  return state;
@@ -20,7 +20,7 @@ export const parentRelations = (state = initialState, { type, payload }) => {
20
20
  switch (type) {
21
21
  case clearStructure.TRIGGER:
22
22
  return initialState;
23
- case fetchStructureParents.SUCCESS:
23
+ case fetchStructure.SUCCESS:
24
24
  return _.pathOr([], "data.relations.parents")(payload);
25
25
  default:
26
26
  return state;
package/src/routines.js CHANGED
@@ -90,8 +90,6 @@ export const fetchProfileExecution = createRoutine("FETCH_EXECUTION_PROFILE");
90
90
  export const fetchProfileGroup = createRoutine("FETCH_PROFILE_GROUP");
91
91
  export const fetchStructure = createRoutine("FETCH_STRUCTURE");
92
92
  export const legacyFetchStructure = createRoutine("LEGACY_FETCH_STRUCTURE");
93
- export const fetchStructureParents = createRoutine("FETCH_STRUCTURE_PARENTS");
94
- export const fetchStructureChildrens = createRoutine("FETCH_STRUCTURE_CHILDREN");
95
93
  export const fetchStructureVersions = createRoutine("FETCH_STRUCTURE_VERSIONS");
96
94
  export const fetchStructureGraph = createRoutine("FETCH_STRUCTURE_GRAPH");
97
95
  export const fetchStructureNotes = createRoutine("FETCH_STRUCTURE_NOTES");
@@ -1,48 +0,0 @@
1
- import _ from "lodash/fp";
2
- import { call, put, takeLatest, select, getContext } from "redux-saga/effects";
3
- import { fetchStructureChildrens } from "../routines";
4
- import { DATA_STRUCTURE_CHILDREN_QUERY } from "../api/queries";
5
- import { getStructureFieldColumns } from "../selectors";
6
-
7
- export function* fetchStructureChildrenSaga({ payload }) {
8
- try {
9
- const client = yield getContext("client");
10
-
11
- yield put(fetchStructureChildrens.request());
12
-
13
- const { id, version = "latest" } = payload;
14
- const {
15
- data: { dataStructureVersion },
16
- } = yield call(client.query, {
17
- fetchPolicy: "network-only",
18
- query: DATA_STRUCTURE_CHILDREN_QUERY,
19
- variables: {
20
- dataStructureId: id,
21
- version,
22
- },
23
- });
24
-
25
- const data = {
26
- data: dataStructureVersion,
27
- _actions: dataStructureVersion._actions,
28
- user_permissions: dataStructureVersion.user_permissions,
29
- };
30
-
31
- const meta = { version };
32
-
33
- yield put({ meta, ...fetchStructureChildrens.success(data) });
34
- } catch (error) {
35
- if (error.response) {
36
- const { status, data } = error.response;
37
- yield put(fetchStructureChildrens.failure({ status, data }));
38
- } else {
39
- yield put(fetchStructureChildrens.failure(error.message));
40
- }
41
- } finally {
42
- yield put(fetchStructureChildrens.fulfill());
43
- }
44
- }
45
-
46
- export function* fetchStructureChildrensRequestSaga() {
47
- yield takeLatest(fetchStructureChildrens.TRIGGER, fetchStructureChildrensSaga);
48
- }
@@ -1,48 +0,0 @@
1
- import _ from "lodash/fp";
2
- import { call, put, takeLatest, select, getContext } from "redux-saga/effects";
3
- import { fetchStructureParents } from "../routines";
4
- import { DATA_STRUCTURE_PARENTS_QUERY } from "../api/queries";
5
- import { getStructureFieldColumns } from "../selectors";
6
-
7
- export function* fetchStructureParentsSaga({ payload }) {
8
- try {
9
- const client = yield getContext("client");
10
-
11
- yield put(fetchStructureParents.request());
12
-
13
- const { id, version = "latest" } = payload;
14
- const {
15
- data: { dataStructureVersion },
16
- } = yield call(client.query, {
17
- fetchPolicy: "network-only",
18
- query: DATA_STRUCTURE_PARENTS_QUERY,
19
- variables: {
20
- dataStructureId: id,
21
- version,
22
- },
23
- });
24
-
25
- const data = {
26
- data: dataStructureVersion,
27
- _actions: dataStructureVersion._actions,
28
- user_permissions: dataStructureVersion.user_permissions,
29
- };
30
-
31
- const meta = { version };
32
-
33
- yield put({ meta, ...fetchStructureParents.success(data) });
34
- } catch (error) {
35
- if (error.response) {
36
- const { status, data } = error.response;
37
- yield put(fetchStructureParents.failure({ status, data }));
38
- } else {
39
- yield put(fetchStructureParents.failure(error.message));
40
- }
41
- } finally {
42
- yield put(fetchStructureParents.fulfill());
43
- }
44
- }
45
-
46
- export function* fetchStructureParentsRequestSaga() {
47
- yield takeLatest(fetchStructureParents.TRIGGER, fetchStructureParentsSaga);
48
- }