Skip to content

Commit 828e49d

Browse files
authored
[7.17] [ML][APM] Fix Cytoscape listener typing, Update Cytoscape versions (elastic#205726) (elastic#205867)
# Backport This will backport the following commits from `main` to `7.17`: - [[ML][APM] Fix Cytoscape listener typing, Update Cytoscape versions (elastic#205726)](elastic#205726) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Gonçalo Rica Pais da Silva","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-01-08T09:16:17Z","message":"[ML][APM] Fix Cytoscape listener typing, Update Cytoscape versions (elastic#205726)\n\n## Summary\r\n\r\nUpdates Cytoscape to newer versions, requiring one change with some\r\n`removeListener` usage no longer being valid typing.\r\n\r\nSupersedes elastic#205444\r\n\r\n## How to test\r\n\r\n- Passes CI with no type errors or failed CI jobs for ML\r\n- Job Map or wherever cytoscape is being used on ML doesn't leak event\r\nlisteners.\r\n- Usages in APM also do not break.","sha":"7363f03d81835f70f39caa27e7096b8a0361ae69","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:all-open","Team:obs-ux-infra_services"],"title":"[ML][APM] Fix Cytoscape listener typing, Update Cytoscape versions","number":205726,"url":"https://github.com/elastic/kibana/pull/205726","mergeCommit":{"message":"[ML][APM] Fix Cytoscape listener typing, Update Cytoscape versions (elastic#205726)\n\n## Summary\r\n\r\nUpdates Cytoscape to newer versions, requiring one change with some\r\n`removeListener` usage no longer being valid typing.\r\n\r\nSupersedes elastic#205444\r\n\r\n## How to test\r\n\r\n- Passes CI with no type errors or failed CI jobs for ML\r\n- Job Map or wherever cytoscape is being used on ML doesn't leak event\r\nlisteners.\r\n- Usages in APM also do not break.","sha":"7363f03d81835f70f39caa27e7096b8a0361ae69"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/205726","number":205726,"mergeCommit":{"message":"[ML][APM] Fix Cytoscape listener typing, Update Cytoscape versions (elastic#205726)\n\n## Summary\r\n\r\nUpdates Cytoscape to newer versions, requiring one change with some\r\n`removeListener` usage no longer being valid typing.\r\n\r\nSupersedes elastic#205444\r\n\r\n## How to test\r\n\r\n- Passes CI with no type errors or failed CI jobs for ML\r\n- Job Map or wherever cytoscape is being used on ML doesn't leak event\r\nlisteners.\r\n- Usages in APM also do not break.","sha":"7363f03d81835f70f39caa27e7096b8a0361ae69"}}]}] BACKPORT-->
1 parent 8c5bfe7 commit 828e49d

File tree

7 files changed

+26
-40
lines changed

7 files changed

+26
-40
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@
212212
"copy-to-clipboard": "^3.0.8",
213213
"core-js": "^3.19.1",
214214
"cronstrue": "^1.51.0",
215-
"cytoscape": "^3.10.0",
216-
"cytoscape-dagre": "^2.2.2",
215+
"cytoscape": "^3.30.4",
216+
"cytoscape-dagre": "^2.5.0",
217217
"d3": "3.5.17",
218218
"d3-array": "1.2.4",
219219
"d3-cloud": "1.2.5",
@@ -514,7 +514,7 @@
514514
"@types/cmd-shim": "^2.0.0",
515515
"@types/color": "^3.0.0",
516516
"@types/compression-webpack-plugin": "^2.0.2",
517-
"@types/cytoscape": "^3.14.0",
517+
"@types/cytoscape": "^3.21.8",
518518
"@types/d3": "^3.5.43",
519519
"@types/d3-array": "^1.2.7",
520520
"@types/d3-interpolate": "^2.0.0",

x-pack/plugins/apm/public/components/app/service_map/Controls.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function useDebugDownloadUrl(cy?: cytoscape.Core) {
8686

8787
return () => {
8888
if (cy) {
89-
cy.off('add remove', undefined, elementsHandler);
89+
cy.off('add remove', elementsHandler);
9090
}
9191
};
9292
}, [cy, debug]);
@@ -127,7 +127,7 @@ export function Controls() {
127127

128128
return () => {
129129
if (cy) {
130-
cy.off('zoom', undefined, zoomHandler);
130+
cy.off('zoom', zoomHandler);
131131
}
132132
};
133133
}, [cy]);

x-pack/plugins/apm/public/components/app/service_map/Popover/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export function Popover({ focusedServiceName, environment, kuery, start, end }:
106106
if (cy) {
107107
cy.removeListener('select', 'node', selectHandler);
108108
cy.removeListener('unselect', 'node', deselect);
109-
cy.removeListener('viewport', undefined, deselect);
109+
cy.removeListener('viewport', deselect);
110110
cy.removeListener('drag', 'node', deselect);
111111
}
112112
};

x-pack/plugins/apm/public/components/app/service_map/cytoscape_options.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,12 @@ const getStyle = (theme: EuiTheme): cytoscape.Stylesheet[] => {
178178
'source-arrow-shape': isIE11 ? 'none' : 'triangle',
179179
'source-arrow-color': lineColor,
180180
'target-arrow-shape': isIE11 ? 'none' : 'triangle',
181-
// @ts-expect-error
182181
'source-distance-from-node': isIE11 ? undefined : parseInt(theme.eui.paddingSizes.xs, 10),
183182
'target-distance-from-node': isIE11 ? undefined : parseInt(theme.eui.paddingSizes.xs, 10),
184183
},
185184
},
186185
{
187186
selector: 'edge[isInverseEdge]',
188-
// @ts-expect-error DefinitelyTyped says visibility is "none" but it's
189-
// actually "hidden"
190187
style: { visibility: 'hidden' },
191188
},
192189
{

x-pack/plugins/apm/public/components/app/service_map/use_cytoscape_event_handlers.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ function getLayoutOptions({
4747
}): cytoscape.LayoutOptions {
4848
const animationOptions = getAnimationOptions(theme);
4949

50-
// @ts-expect-error Some of the dagre-specific layout options don't work with
51-
// the types.
5250
return {
5351
animationDuration: animationOptions.duration,
5452
animationEasing: animationOptions.easing,
@@ -62,7 +60,7 @@ function getLayoutOptions({
6260
rankSep: 128,
6361
rankDir: 'LR',
6462
ranker: 'network-simplex',
65-
};
63+
} as cytoscape.LayoutOptions;
6664
}
6765

6866
function setCursor(cursor: string, event: cytoscape.EventObjectCore) {
@@ -202,19 +200,18 @@ export function useCytoscapeEventHandlers({
202200
if (cy) {
203201
cy.removeListener(
204202
'custom:data drag dragfree layoutstop select tapstart tapend unselect',
205-
undefined,
206203
debugHandler
207204
);
208-
cy.removeListener('custom:data', undefined, dataHandler);
209-
cy.removeListener('layoutstop', undefined, layoutstopHandler);
205+
cy.removeListener('custom:data', dataHandler);
206+
cy.removeListener('layoutstop', layoutstopHandler);
210207
cy.removeListener('mouseover', 'edge, node', mouseoverHandler);
211208
cy.removeListener('mouseout', 'edge, node', mouseoutHandler);
212209
cy.removeListener('select', 'node', selectHandler);
213210
cy.removeListener('unselect', 'node', unselectHandler);
214211
cy.removeListener('drag', 'node', dragHandler);
215212
cy.removeListener('dragfree', 'node', dragfreeHandler);
216-
cy.removeListener('tapstart', undefined, tapstartHandler);
217-
cy.removeListener('tapend', undefined, tapendHandler);
213+
cy.removeListener('tapstart', tapstartHandler);
214+
cy.removeListener('tapend', tapendHandler);
218215
}
219216
};
220217
}, [cy, serviceName, trackApmEvent, theme]);

x-pack/plugins/ml/public/application/data_frame_analytics/pages/job_map/components/cytoscape.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export function Cytoscape({
105105

106106
return () => {
107107
if (cy) {
108-
cy.removeListener('data', undefined, dataHandler as cytoscape.EventHandler);
108+
cy.removeListener('data', dataHandler);
109109
}
110110
};
111111
}, [cy, elements, height, width]);

yarn.lock

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5504,10 +5504,10 @@
55045504
resolved "https://registry.yarnpkg.com/@types/cookiejar/-/cookiejar-2.1.2.tgz#66ad9331f63fe8a3d3d9d8c6e3906dd10f6446e8"
55055505
integrity sha512-t73xJJrvdTjXrn4jLS9VSGRbz0nUY3cl2DMGDU48lKl+HR9dbbjW2A9r3g40VA++mQpy6uuHg33gy7du2BKpog==
55065506

5507-
"@types/cytoscape@^3.14.0":
5508-
version "3.14.0"
5509-
resolved "https://registry.yarnpkg.com/@types/cytoscape/-/cytoscape-3.14.0.tgz#346b5430a7a1533784bcf44fcbe6c5255b948d36"
5510-
integrity sha512-qOhhZFGb35457vmCu9YHqwjqleraSAEikaIFmMUPWzTC7FrwkS7VR/6ymqRHW7Z8wivHuzsZDYCoePIepd69qg==
5507+
"@types/cytoscape@^3.21.8":
5508+
version "3.21.8"
5509+
resolved "https://registry.yarnpkg.com/@types/cytoscape/-/cytoscape-3.21.8.tgz#6166a2eabd66d3ae3259024875e037492adb8db6"
5510+
integrity sha512-6Bo9ZDrv0vfwe8Sg/ERc5VL0yU0gYvP4dgZi0fAXYkKHfyHaNqWRMcwYm3mu4sLsXbB8ZuXE75sR7qnaOL5JgQ==
55115511

55125512
"@types/d3-array@^1.2.7":
55135513
version "1.2.7"
@@ -10768,20 +10768,17 @@ cypress@^13.3.0:
1076810768
untildify "^4.0.0"
1076910769
yauzl "^2.10.0"
1077010770

10771-
cytoscape-dagre@^2.2.2:
10772-
version "2.2.2"
10773-
resolved "https://registry.yarnpkg.com/cytoscape-dagre/-/cytoscape-dagre-2.2.2.tgz#5f32a85c0ba835f167efee531df9e89ac58ff411"
10774-
integrity sha512-zsg36qNwua/L2stJSWkcbSDcvW3E6VZf6KRe6aLnQJxuXuz89tMqI5EVYVKEcNBgzTEzFMFv0PE3T0nD4m6VDw==
10771+
cytoscape-dagre@^2.5.0:
10772+
version "2.5.0"
10773+
resolved "https://registry.yarnpkg.com/cytoscape-dagre/-/cytoscape-dagre-2.5.0.tgz#47d9835ab64dd0b596d9c94731f070282f82fc5a"
10774+
integrity sha512-VG2Knemmshop4kh5fpLO27rYcyUaaDkRw+6PiX4bstpB+QFt0p2oauMrsjVbUamGWQ6YNavh7x2em2uZlzV44g==
1077510775
dependencies:
10776-
dagre "^0.8.2"
10776+
dagre "^0.8.5"
1077710777

10778-
cytoscape@^3.10.0:
10779-
version "3.10.0"
10780-
resolved "https://registry.yarnpkg.com/cytoscape/-/cytoscape-3.10.0.tgz#3b462e0d35121ecd2d2702f470915fd6dae01777"
10781-
integrity sha512-lWOnG4HJQD0cy+tCiBmbV/QRknInuZ8HvjcUifQZ7E4LWmKMvl6d5eP0LaaRLfBJAplXWcJfwc17ZJ/nwPeaYg==
10782-
dependencies:
10783-
heap "^0.2.6"
10784-
lodash.debounce "^4.0.8"
10778+
cytoscape@^3.30.4:
10779+
version "3.30.4"
10780+
resolved "https://registry.yarnpkg.com/cytoscape/-/cytoscape-3.30.4.tgz#3404da0a159c00a1a3df2c85b2b43fdc66a0e28e"
10781+
integrity sha512-OxtlZwQl1WbwMmLiyPSEBuzeTIQnwZhJYYWFzZ2PhEHVFwpeaqNIkUzSiso00D98qk60l8Gwon2RP304d3BJ1A==
1078510782

1078610783
"d3-array@1 - 3", "d3-array@2 - 3", "[email protected] - 3", "[email protected] - 3", [email protected], d3-array@^3.2.2:
1078710784
version "3.2.2"
@@ -11022,7 +11019,7 @@ d@1, d@^1.0.1, d@^1.0.2:
1102211019
es5-ext "^0.10.64"
1102311020
type "^2.7.2"
1102411021

11025-
dagre@^0.8.2:
11022+
dagre@^0.8.5:
1102611023
version "0.8.5"
1102711024
resolved "https://registry.yarnpkg.com/dagre/-/dagre-0.8.5.tgz#ba30b0055dac12b6c1fcc247817442777d06afee"
1102811025
integrity sha512-/aTqmnRta7x7MCCpExk7HQL2O4owCT2h8NT//9I1OQ9vt29Pa0BzSAkR5lwFUcQ7491yVi/3CXU9jQ5o0Mn2Sw==
@@ -15095,11 +15092,6 @@ he@^1.2.0:
1509515092
resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f"
1509615093
integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==
1509715094

15098-
heap@^0.2.6:
15099-
version "0.2.6"
15100-
resolved "https://registry.yarnpkg.com/heap/-/heap-0.2.6.tgz#087e1f10b046932fc8594dd9e6d378afc9d1e5ac"
15101-
integrity sha1-CH4fELBGky/IWU3Z5tN4r8nR5aw=
15102-
1510315095
hexoid@^1.0.0:
1510415096
version "1.0.0"
1510515097
resolved "https://registry.yarnpkg.com/hexoid/-/hexoid-1.0.0.tgz#ad10c6573fb907de23d9ec63a711267d9dc9bc18"

0 commit comments

Comments
 (0)