From 828e49db669c29d8cc4f3a30f6abe5e8f69a4290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Rica=20Pais=20da=20Silva?= Date: Wed, 8 Jan 2025 15:01:24 +0100 Subject: [PATCH] [7.17] [ML][APM] Fix Cytoscape listener typing, Update Cytoscape versions (#205726) (#205867) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Backport This will backport the following commits from `main` to `7.17`: - [[ML][APM] Fix Cytoscape listener typing, Update Cytoscape versions (#205726)](https://github.com/elastic/kibana/pull/205726) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) --- package.json | 6 ++-- .../components/app/service_map/Controls.tsx | 4 +-- .../app/service_map/Popover/index.tsx | 2 +- .../app/service_map/cytoscape_options.ts | 3 -- .../use_cytoscape_event_handlers.ts | 13 +++---- .../pages/job_map/components/cytoscape.tsx | 2 +- yarn.lock | 36 ++++++++----------- 7 files changed, 26 insertions(+), 40 deletions(-) diff --git a/package.json b/package.json index f513603dc7219..3d25bcf9a0b5d 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/x-pack/plugins/apm/public/components/app/service_map/Controls.tsx b/x-pack/plugins/apm/public/components/app/service_map/Controls.tsx index 9077f9bc9058e..fa77386912545 100644 --- a/x-pack/plugins/apm/public/components/app/service_map/Controls.tsx +++ b/x-pack/plugins/apm/public/components/app/service_map/Controls.tsx @@ -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]); @@ -127,7 +127,7 @@ export function Controls() { return () => { if (cy) { - cy.off('zoom', undefined, zoomHandler); + cy.off('zoom', zoomHandler); } }; }, [cy]); diff --git a/x-pack/plugins/apm/public/components/app/service_map/Popover/index.tsx b/x-pack/plugins/apm/public/components/app/service_map/Popover/index.tsx index 71a1426d130a7..f140d2189107b 100644 --- a/x-pack/plugins/apm/public/components/app/service_map/Popover/index.tsx +++ b/x-pack/plugins/apm/public/components/app/service_map/Popover/index.tsx @@ -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); } }; diff --git a/x-pack/plugins/apm/public/components/app/service_map/cytoscape_options.ts b/x-pack/plugins/apm/public/components/app/service_map/cytoscape_options.ts index 05102e0aa037a..9b8050d9c57de 100644 --- a/x-pack/plugins/apm/public/components/app/service_map/cytoscape_options.ts +++ b/x-pack/plugins/apm/public/components/app/service_map/cytoscape_options.ts @@ -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' }, }, { diff --git a/x-pack/plugins/apm/public/components/app/service_map/use_cytoscape_event_handlers.ts b/x-pack/plugins/apm/public/components/app/service_map/use_cytoscape_event_handlers.ts index c40ca28665f88..1a3ef7eeeeec4 100644 --- a/x-pack/plugins/apm/public/components/app/service_map/use_cytoscape_event_handlers.ts +++ b/x-pack/plugins/apm/public/components/app/service_map/use_cytoscape_event_handlers.ts @@ -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, @@ -62,7 +60,7 @@ function getLayoutOptions({ rankSep: 128, rankDir: 'LR', ranker: 'network-simplex', - }; + } as cytoscape.LayoutOptions; } function setCursor(cursor: string, event: cytoscape.EventObjectCore) { @@ -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]); diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/job_map/components/cytoscape.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/job_map/components/cytoscape.tsx index 16d312f44b863..20ef387a6aad9 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/job_map/components/cytoscape.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/job_map/components/cytoscape.tsx @@ -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]); diff --git a/yarn.lock b/yarn.lock index 131b08298145c..07649128a0ecd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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", "d3-array@2.10.0 - 3", "d3-array@2.5.0 - 3", d3-array@3.2.2, d3-array@^3.2.2: version "3.2.2" @@ -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== @@ -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"