@truedat/dd 4.53.8 → 4.53.10

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.53.9] 2022-10-17
4
+
5
+ ### [Fixed]
6
+
7
+ - [TD-4542] Avoid fetching old graph after createGraph.SUCCESS
8
+
3
9
  ## [4.53.5] 2022-10-07
4
10
 
5
11
  ### Changed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/dd",
3
- "version": "4.53.8",
3
+ "version": "4.53.10",
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.4",
35
35
  "@testing-library/react": "^12.0.0",
36
36
  "@testing-library/user-event": "^13.2.1",
37
- "@truedat/test": "4.53.8",
37
+ "@truedat/test": "4.53.10",
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",
@@ -87,10 +87,10 @@
87
87
  ]
88
88
  },
89
89
  "dependencies": {
90
- "@apollo/client": "^3.6.4",
91
- "@truedat/auth": "4.53.8",
92
- "@truedat/core": "4.53.8",
93
- "@truedat/df": "4.53.8",
90
+ "@apollo/client": "^3.7.0",
91
+ "@truedat/auth": "4.53.10",
92
+ "@truedat/core": "4.53.10",
93
+ "@truedat/df": "4.53.10",
94
94
  "lodash": "^4.17.21",
95
95
  "path-to-regexp": "^1.7.0",
96
96
  "prop-types": "^15.8.1",
@@ -112,5 +112,5 @@
112
112
  "react-dom": ">= 16.8.6 < 17",
113
113
  "semantic-ui-react": ">= 0.88.2 < 2.1"
114
114
  },
115
- "gitHead": "56190c74eddc249134cb973cc21470c36a4701d0"
115
+ "gitHead": "66304ff9ac3d25820b3bec2d0147f21cb0a2c579"
116
116
  }
@@ -19,7 +19,8 @@ import {
19
19
  const translations = (formatMessage) => ({
20
20
  "active.raw": (v) =>
21
21
  formatMessage({ id: `filters.active.raw.${v}`, defaultMessage: v }),
22
- "execution_result_info.result_text": (v) => formatMessage({ id: v }),
22
+ "execution_result_info.result_text": (v) =>
23
+ formatMessage({ id: v, defaultMessage: v }),
23
24
  });
24
25
 
25
26
  export const mapStateToProps = (state, ownProps) => {
@@ -6,7 +6,13 @@ import { useRouteMatch, useHistory } from "react-router-dom";
6
6
  import { GRAPH } from "@truedat/core/routes";
7
7
  import { fetchGraph, clearGraph, cancelPoll } from "../routines";
8
8
 
9
- export const GraphLoader = ({ clearGraph, fetchGraph, graph, cancelPoll }) => {
9
+ export const GraphLoader = ({
10
+ clearGraph,
11
+ fetchGraph,
12
+ graph,
13
+ cancelPoll,
14
+ graphRedirect,
15
+ }) => {
10
16
  const match = useRouteMatch(GRAPH);
11
17
  const id = _.path("params.id")(match);
12
18
 
@@ -22,11 +28,15 @@ export const GraphLoader = ({ clearGraph, fetchGraph, graph, cancelPoll }) => {
22
28
  if (id) {
23
29
  if (_.isEmpty(graph)) {
24
30
  fetchGraph({ id });
25
- } else if (id != graph.id) {
31
+ /* If graphRedirect is present, a new graph has already been loaded, so
32
+ * there is no need to fetchGraph. The URL is being changed by
33
+ * GraphLoader history.push to the new graph id.
34
+ */
35
+ } else if (!graphRedirect && id != graph.id) {
26
36
  fetchGraph({ id });
27
37
  }
28
38
  }
29
- }, [graph, fetchGraph, id]);
39
+ }, [graph, graphRedirect, fetchGraph, id]);
30
40
 
31
41
  useEffect(() => {
32
42
  return () => {
@@ -45,9 +55,13 @@ GraphLoader.propTypes = {
45
55
  fetchGraph: PropTypes.func.isRequired,
46
56
  graph: PropTypes.object,
47
57
  cancelPoll: PropTypes.func,
58
+ graphRedirect: PropTypes.string,
48
59
  };
49
60
 
50
- const mapStateToProps = ({ graph }) => ({ graph });
61
+ const mapStateToProps = ({ graph, graphRedirect }) => ({
62
+ graph,
63
+ graphRedirect,
64
+ });
51
65
 
52
66
  export default connect(mapStateToProps, { clearGraph, fetchGraph, cancelPoll })(
53
67
  GraphLoader
@@ -9,15 +9,11 @@ export const GraphRedirector = ({ graph, graphRedirect, clearRedirect }) => {
9
9
  const { pathname } = useLocation();
10
10
  const history = useHistory();
11
11
  useEffect(() => {
12
- if (
13
- graphRedirect &&
14
- graph?.fromLineageContextMenu &&
15
- !_.isEqual(pathname, graphRedirect)
16
- ) {
12
+ if (graphRedirect && !_.isEqual(pathname, graphRedirect)) {
17
13
  history.push(graphRedirect);
18
14
  clearRedirect();
19
15
  }
20
- }, [history, pathname, graphRedirect, graph, clearRedirect]);
16
+ }, [history, pathname, graphRedirect, clearRedirect]);
21
17
  return null;
22
18
  };
23
19
 
@@ -27,7 +27,7 @@ export const LineageContextMenu = ({
27
27
  ids: [id],
28
28
  levels: levels,
29
29
  type: "lineage",
30
- fromLineageContextMenu: true,
30
+ isRedirected: true,
31
31
  })
32
32
  }
33
33
  >
@@ -43,7 +43,7 @@ export const LineageContextMenu = ({
43
43
  ids: [id],
44
44
  levels: levels,
45
45
  type: "impact",
46
- fromLineageContextMenu: true,
46
+ isRedirected: true,
47
47
  })
48
48
  }
49
49
  >
@@ -53,9 +53,7 @@ export const LineageContextMenu = ({
53
53
  defaultMessage="Impact"
54
54
  />
55
55
  </Menu.Item>
56
- <Menu.Item
57
- onClick={() => excludeNode({ id, fromLineageContextMenu: true })}
58
- >
56
+ <Menu.Item onClick={() => excludeNode({ id, isRedirected: true })}>
59
57
  <Icon name="eye slash outline" />
60
58
  <FormattedMessage
61
59
  id="navigation.lineage.exclude"
@@ -49,8 +49,17 @@ export const LineageForm = ({
49
49
  const [levels, setLevels] = useState(lineageLevels);
50
50
  const handleSubmit = (type) => () => {
51
51
  _.isNil(levels)
52
- ? createGraph({ ids: selectedResources, type })
53
- : createGraph({ ids: selectedResources, type, levels });
52
+ ? createGraph({
53
+ ids: selectedResources,
54
+ type,
55
+ isRedirected: true,
56
+ })
57
+ : createGraph({
58
+ ids: selectedResources,
59
+ type,
60
+ levels,
61
+ isRedirected: true,
62
+ });
54
63
  };
55
64
  const disabled = _.isEmpty(selectedResources);
56
65
  useEffect(() => {
@@ -92,7 +92,7 @@ describe("<LineageForm />", () => {
92
92
 
93
93
  expect(createGraph.mock.calls.length).toBe(1);
94
94
  expect(createGraph.mock.calls[0]).toEqual([
95
- { ids: ["id1", "id2"], type: "lineage", levels: 4 },
95
+ { ids: ["id1", "id2"], type: "lineage", levels: 4, isRedirected: true },
96
96
  ]);
97
97
  });
98
98
 
@@ -28,7 +28,7 @@ describe("reducers: graphRedirect", () => {
28
28
  });
29
29
 
30
30
  it("should be the graph url after receiving the createGraph.SUCCESS action", () => {
31
- const data = { id: 42 };
31
+ const data = { id: 42, isRedirected: true };
32
32
  const payload = { data };
33
33
  expect(
34
34
  graphRedirect(fooState, { type: createGraph.SUCCESS, payload })
@@ -21,14 +21,14 @@ describe("reducers: lineageQuery", () => {
21
21
  ).toMatchObject({ excludes: ["bar", "foo"] });
22
22
  });
23
23
 
24
- it("should append a default {fromLineageContextMenu: false} it it was not specified in the excludeNode.TRIGGER action payload", () => {
24
+ it("should append a default {isRedirected: false} it it was not specified in the excludeNode.TRIGGER action payload", () => {
25
25
  const state = { excludes: ["foo"] };
26
26
  const payload = { id: "bar" };
27
27
  expect(
28
28
  lineageQuery(state, { type: excludeNode.TRIGGER, payload })
29
29
  ).toMatchObject({
30
30
  excludes: ["bar", "foo"],
31
- fromLineageContextMenu: false,
31
+ isRedirected: false,
32
32
  });
33
33
  });
34
34
 
@@ -50,7 +50,7 @@ describe("reducers: lineageQuery", () => {
50
50
  ).toMatchObject({ excludes: [], ids, type, levels });
51
51
  });
52
52
 
53
- it("should append a default {fromLineageContextMenu: false} it it was not specified in the createGraph.TRIGGER action payload", () => {
53
+ it("should append a default {isRedirected: false} it it was not specified in the createGraph.TRIGGER action payload", () => {
54
54
  const ids = ["foo", "bar"];
55
55
  const type = "type";
56
56
  const levels = 3;
@@ -63,7 +63,7 @@ describe("reducers: lineageQuery", () => {
63
63
  ids,
64
64
  type,
65
65
  levels,
66
- fromLineageContextMenu: false,
66
+ isRedirected: false,
67
67
  });
68
68
  });
69
69
 
@@ -48,7 +48,7 @@ describe("reducers: structureImpactGraph", () => {
48
48
  });
49
49
 
50
50
  it("should leave the state unchanged if createGraph succeeds and was called from LineageContextMenu", () => {
51
- const data = { opts: { type: "impact" }, fromLineageContextMenu: true };
51
+ const data = { opts: { type: "impact" }, isRedirected: true };
52
52
  const payload = { data };
53
53
  expect(
54
54
  structureImpactGraph(fooState, {
@@ -59,7 +59,7 @@ describe("reducers: structureLineageGraph", () => {
59
59
  });
60
60
 
61
61
  it("should leave the state unchanged if createGraph succeeds and was called from LineageContextMenu", () => {
62
- const data = { opts: { type: "impact" }, fromLineageContextMenu: true };
62
+ const data = { opts: { type: "impact" }, isRedirected: true };
63
63
  const payload = { data };
64
64
  expect(
65
65
  structureLineageGraph(fooState, {
@@ -13,7 +13,9 @@ export const graphRedirect = (state = initialState, { type, payload }) => {
13
13
  case clearRedirect.TRIGGER:
14
14
  return initialState;
15
15
  case createGraph.SUCCESS:
16
- return payload.data.id ? linkTo.GRAPH(payload.data) : initialState;
16
+ return payload.data.id && payload.data?.isRedirected
17
+ ? linkTo.GRAPH(payload.data)
18
+ : initialState;
17
19
  default:
18
20
  return state;
19
21
  }
@@ -6,28 +6,23 @@ export const initialState = { ids: [], type: "lineage", excludes: [] };
6
6
  export const lineageQuery = (state = initialState, { type, payload }) => {
7
7
  switch (type) {
8
8
  case excludeNode.TRIGGER: {
9
- const { id, fromLineageContextMenu } = payload;
9
+ const { id, isRedirected } = payload;
10
10
  const { excludes } = state;
11
11
  return {
12
12
  ...state,
13
13
  excludes: _.concat([id])(excludes),
14
- fromLineageContextMenu: fromLineageContextMenu || false,
14
+ isRedirected: isRedirected || false,
15
15
  };
16
16
  }
17
17
  case createGraph.TRIGGER: {
18
- const {
19
- ids = [],
20
- type = "lineage",
21
- levels,
22
- fromLineageContextMenu,
23
- } = payload;
18
+ const { ids = [], type = "lineage", levels, isRedirected } = payload;
24
19
  return {
25
20
  ...state,
26
21
  ids,
27
22
  type,
28
23
  excludes: [],
29
24
  levels,
30
- fromLineageContextMenu: fromLineageContextMenu || false,
25
+ isRedirected: isRedirected || false,
31
26
  };
32
27
  }
33
28
  case fetchGraph.SUCCESS: {
@@ -19,7 +19,7 @@ export const structureImpactGraph = (
19
19
  return initialState;
20
20
  case createGraph.SUCCESS:
21
21
  case fetchStructureGraph.SUCCESS:
22
- return !payload?.data?.fromLineageContextMenu &&
22
+ return !payload?.data?.isRedirected &&
23
23
  _.pathEq("data.opts.type", "impact")(payload)
24
24
  ? _.prop("data")(payload)
25
25
  : state;
@@ -19,7 +19,7 @@ export const structureLineageGraph = (
19
19
  return initialState;
20
20
  case createGraph.SUCCESS:
21
21
  case fetchStructureGraph.SUCCESS:
22
- return !payload?.data?.fromLineageContextMenu &&
22
+ return !payload?.data?.isRedirected &&
23
23
  _.pathEq("data.opts.type", "lineage")(payload)
24
24
  ? _.prop("data")(payload)
25
25
  : state;
@@ -68,13 +68,13 @@ describe("sagas: createGraphRequestSaga", () => {
68
68
  });
69
69
 
70
70
  describe("sagas: createGraphSaga", () => {
71
- const fromLineageContextMenu = false;
71
+ const isRedirected = false;
72
72
 
73
73
  const query = {
74
74
  ids: ["BASILEAII_HIST_PROA_MOROSIDAD [ 2 ] [ 1 ].SOBREGIROCAPITAL"],
75
75
  type: "lineage",
76
76
  exclude: [],
77
- fromLineageContextMenu,
77
+ isRedirected,
78
78
  };
79
79
 
80
80
  const graphAccepted = {
@@ -83,7 +83,7 @@ describe("sagas: createGraphSaga", () => {
83
83
  };
84
84
 
85
85
  const graphCreated = {
86
- data: { ...graphData, fromLineageContextMenu },
86
+ data: { ...graphData, isRedirected },
87
87
  status: 201,
88
88
  };
89
89
 
@@ -117,7 +117,7 @@ describe("sagas: createGraphSaga", () => {
117
117
  .next(graphAccepted)
118
118
  .put(fetchGraph.request(graphAccepted))
119
119
  .next()
120
- .fork(polling, graphAccepted, fromLineageContextMenu)
120
+ .fork(polling, graphAccepted, isRedirected)
121
121
  .next()
122
122
  .take(cancelPoll.TRIGGER)
123
123
  .next()
@@ -152,7 +152,7 @@ describe("sagas: createGraphSaga", () => {
152
152
  });
153
153
 
154
154
  describe("generator: polling", () => {
155
- const fromLineageContextMenu = false;
155
+ const isRedirected = false;
156
156
 
157
157
  const graphAccepted = {
158
158
  data: graphAcceptedData,
@@ -165,13 +165,13 @@ describe("generator: polling", () => {
165
165
  };
166
166
 
167
167
  const graphCompleted = {
168
- data: { ...graphData, fromLineageContextMenu },
168
+ data: { ...graphData, isRedirected },
169
169
  status: 200,
170
170
  };
171
171
 
172
172
  it("polling should keep requesting by graph hash until graph is received", () => {
173
173
  expect(() => {
174
- testSaga(polling, graphAccepted, fromLineageContextMenu)
174
+ testSaga(polling, graphAccepted, isRedirected)
175
175
  .next()
176
176
  .delay(1000)
177
177
  .next()
@@ -207,7 +207,7 @@ describe("generator: polling", () => {
207
207
 
208
208
  it("cancel should stop polling and return createGraph failure", () => {
209
209
  expect(() => {
210
- testSaga(polling, graphAccepted, fromLineageContextMenu)
210
+ testSaga(polling, graphAccepted, isRedirected)
211
211
  .next()
212
212
  .delay(1000)
213
213
  .next()
@@ -51,7 +51,7 @@ export function* createGraphSaga() {
51
51
  const pollingTask = yield fork(
52
52
  polling,
53
53
  graphAcceptedOrCreated,
54
- body.fromLineageContextMenu
54
+ body.isRedirected
55
55
  );
56
56
 
57
57
  // wait for the user stop action
@@ -65,7 +65,7 @@ export function* createGraphSaga() {
65
65
  ...graphAcceptedOrCreated,
66
66
  data: {
67
67
  ...graphAcceptedOrCreated.data,
68
- fromLineageContextMenu: body.fromLineageContextMenu,
68
+ isRedirected: body.isRedirected,
69
69
  },
70
70
  })
71
71
  );
@@ -82,7 +82,7 @@ export function* createGraphSaga() {
82
82
  }
83
83
  }
84
84
 
85
- export function* polling(graphAccepted, fromLineageContextMenu) {
85
+ export function* polling(graphAccepted, isRedirected) {
86
86
  const backoff = exponentialBackoff(1.2, 0);
87
87
  let backoffTime,
88
88
  retry = 0,
@@ -128,7 +128,7 @@ export function* polling(graphAccepted, fromLineageContextMenu) {
128
128
  ? yield put(
129
129
  createGraph.success({
130
130
  ...graphResp,
131
- data: { ...graphResp.data, fromLineageContextMenu },
131
+ data: { ...graphResp.data, isRedirected },
132
132
  })
133
133
  )
134
134
  : yield put(createGraph.failure({}));