Skip to content

Commit

Permalink
[7.17] [ML][APM] Fix Cytoscape listener typing, Update Cytoscape vers…
Browse files Browse the repository at this point in the history
…ions (#205726) (#205867)

# Backport

This will backport the following commits from `main` to `7.17`:
- [[ML][APM] Fix Cytoscape listener typing, Update Cytoscape versions
(#205726)](#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 (#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 #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 (#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 #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 (#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 #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-->
  • Loading branch information
Bluefinger authored Jan 8, 2025
1 parent 8c5bfe7 commit 828e49d
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 40 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@
"copy-to-clipboard": "^3.0.8",
"core-js": "^3.19.1",
"cronstrue": "^1.51.0",
"cytoscape": "^3.10.0",
"cytoscape-dagre": "^2.2.2",
"cytoscape": "^3.30.4",
"cytoscape-dagre": "^2.5.0",
"d3": "3.5.17",
"d3-array": "1.2.4",
"d3-cloud": "1.2.5",
Expand Down Expand Up @@ -514,7 +514,7 @@
"@types/cmd-shim": "^2.0.0",
"@types/color": "^3.0.0",
"@types/compression-webpack-plugin": "^2.0.2",
"@types/cytoscape": "^3.14.0",
"@types/cytoscape": "^3.21.8",
"@types/d3": "^3.5.43",
"@types/d3-array": "^1.2.7",
"@types/d3-interpolate": "^2.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function useDebugDownloadUrl(cy?: cytoscape.Core) {

return () => {
if (cy) {
cy.off('add remove', undefined, elementsHandler);
cy.off('add remove', elementsHandler);
}
};
}, [cy, debug]);
Expand Down Expand Up @@ -127,7 +127,7 @@ export function Controls() {

return () => {
if (cy) {
cy.off('zoom', undefined, zoomHandler);
cy.off('zoom', zoomHandler);
}
};
}, [cy]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export function Popover({ focusedServiceName, environment, kuery, start, end }:
if (cy) {
cy.removeListener('select', 'node', selectHandler);
cy.removeListener('unselect', 'node', deselect);
cy.removeListener('viewport', undefined, deselect);
cy.removeListener('viewport', deselect);
cy.removeListener('drag', 'node', deselect);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,12 @@ const getStyle = (theme: EuiTheme): cytoscape.Stylesheet[] => {
'source-arrow-shape': isIE11 ? 'none' : 'triangle',
'source-arrow-color': lineColor,
'target-arrow-shape': isIE11 ? 'none' : 'triangle',
// @ts-expect-error
'source-distance-from-node': isIE11 ? undefined : parseInt(theme.eui.paddingSizes.xs, 10),
'target-distance-from-node': isIE11 ? undefined : parseInt(theme.eui.paddingSizes.xs, 10),
},
},
{
selector: 'edge[isInverseEdge]',
// @ts-expect-error DefinitelyTyped says visibility is "none" but it's
// actually "hidden"
style: { visibility: 'hidden' },
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ function getLayoutOptions({
}): cytoscape.LayoutOptions {
const animationOptions = getAnimationOptions(theme);

// @ts-expect-error Some of the dagre-specific layout options don't work with
// the types.
return {
animationDuration: animationOptions.duration,
animationEasing: animationOptions.easing,
Expand All @@ -62,7 +60,7 @@ function getLayoutOptions({
rankSep: 128,
rankDir: 'LR',
ranker: 'network-simplex',
};
} as cytoscape.LayoutOptions;
}

function setCursor(cursor: string, event: cytoscape.EventObjectCore) {
Expand Down Expand Up @@ -202,19 +200,18 @@ export function useCytoscapeEventHandlers({
if (cy) {
cy.removeListener(
'custom:data drag dragfree layoutstop select tapstart tapend unselect',
undefined,
debugHandler
);
cy.removeListener('custom:data', undefined, dataHandler);
cy.removeListener('layoutstop', undefined, layoutstopHandler);
cy.removeListener('custom:data', dataHandler);
cy.removeListener('layoutstop', layoutstopHandler);
cy.removeListener('mouseover', 'edge, node', mouseoverHandler);
cy.removeListener('mouseout', 'edge, node', mouseoutHandler);
cy.removeListener('select', 'node', selectHandler);
cy.removeListener('unselect', 'node', unselectHandler);
cy.removeListener('drag', 'node', dragHandler);
cy.removeListener('dragfree', 'node', dragfreeHandler);
cy.removeListener('tapstart', undefined, tapstartHandler);
cy.removeListener('tapend', undefined, tapendHandler);
cy.removeListener('tapstart', tapstartHandler);
cy.removeListener('tapend', tapendHandler);
}
};
}, [cy, serviceName, trackApmEvent, theme]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export function Cytoscape({

return () => {
if (cy) {
cy.removeListener('data', undefined, dataHandler as cytoscape.EventHandler);
cy.removeListener('data', dataHandler);
}
};
}, [cy, elements, height, width]);
Expand Down
36 changes: 14 additions & 22 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5504,10 +5504,10 @@
resolved "https://registry.yarnpkg.com/@types/cookiejar/-/cookiejar-2.1.2.tgz#66ad9331f63fe8a3d3d9d8c6e3906dd10f6446e8"
integrity sha512-t73xJJrvdTjXrn4jLS9VSGRbz0nUY3cl2DMGDU48lKl+HR9dbbjW2A9r3g40VA++mQpy6uuHg33gy7du2BKpog==

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

"@types/d3-array@^1.2.7":
version "1.2.7"
Expand Down Expand Up @@ -10768,20 +10768,17 @@ cypress@^13.3.0:
untildify "^4.0.0"
yauzl "^2.10.0"

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

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

"d3-array@1 - 3", "d3-array@2 - 3", "[email protected] - 3", "[email protected] - 3", [email protected], d3-array@^3.2.2:
version "3.2.2"
Expand Down Expand Up @@ -11022,7 +11019,7 @@ d@1, d@^1.0.1, d@^1.0.2:
es5-ext "^0.10.64"
type "^2.7.2"

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

heap@^0.2.6:
version "0.2.6"
resolved "https://registry.yarnpkg.com/heap/-/heap-0.2.6.tgz#087e1f10b046932fc8594dd9e6d378afc9d1e5ac"
integrity sha1-CH4fELBGky/IWU3Z5tN4r8nR5aw=

hexoid@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/hexoid/-/hexoid-1.0.0.tgz#ad10c6573fb907de23d9ec63a711267d9dc9bc18"
Expand Down

0 comments on commit 828e49d

Please sign in to comment.