Conversation
Add a "Download graph as PNG" button to the application graph controls, next to zoom in, zoom out and fit view. It renders the whole graph at its natural size on a white background with html-to-image, following React Flow's download-image example, and downloads it as <application>-graph.png. html-to-image is pinned to 1.11.11 because 1.11.12 and 1.11.13 leave React Flow's SVG edges out of the image; a test records the pin. The getGraph response has no name, so the application tab now names the graph after the application. Fixes radius-project#33 Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com> Assisted-by: claude-opus-5-5 (via Claude Code)
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a Download graph as PNG button to the application graph's controls, under zoom in, zoom out and fit view. It exports the whole graph, not just the part in view, as a PNG at its natural size on a white background. The file is named
<application>-graph.png.Reason for change
#33 asks for buttons next to the app graph that export the current diagram as an image or PDF, so it can be shared outside the dashboard. In the issue thread, willtsai pointed to React Flow's download image example, and this PR follows it:
html-to-image'stoPngon.react-flow__viewport, with a transform built from the node bounds. The bounds come fromgetNodesBounds, the current name ofgetRectOfNodesin reactflow 11.11.Fixes #33
Details
ControlButtoninside the existing React Flow<Controls>in@radapp.io/rad-components. That keeps the package free of Backstage and MUI, as described in the code organization docs.@radapp.io/rad-componentsnow depends onhtml-to-image, pinned to exactly1.11.11(MIT, no dependencies, released February 2023, no known advisories). I tested the latest versions in the browser: 1.11.12 and 1.11.13 leave React Flow's SVG edges out of the image, so the export shows only the nodes. 1.11.11 keeps them, and it is also the version React Flow's own example pins..github/dependabot.ymlis synced fromradius-project/.github, so I didn't add an ignore rule there. Instead, a unit test checks the installed version and explains why, so a Dependabot bump to 1.11.12 or later fails CI with that reason. The onlyyarn.lockchange is the new entry, andyarn install --immutablepasses.getGraphresponse (ApplicationGraphResponse) has onlyresourcesand no name.ApplicationTabnow fills in the graph name from the application ID, so the file is named after the application.role="alert"message, which clears on the next attempt.How to test
kubectl proxyandyarn dev, then open an application and go to its App Graph tab.<application>-graph.pngdownloads. It shows every node and edge, even if you zoomed or panned first.Screenshots
Taken in headless Chromium at a 1440x1000 viewport against
yarn start. The Radius API responses were route-mocked in the same way aspackages/app/e2e-tests/radiusGraph.test.ts, using the repo'smulti-tier.jsongraph fixture without aname, matching the real API.main)Close-up of the control:
The downloaded file:
todo-app-graph.png, 439x770. It has all four nodes and three edges.Tests run
yarn install --immutable: passes.yarn tsc: passes.yarn lint:all: passes.yarn format:check: passes.yarn test:all: 55 suites and 484 tests pass. The skipped suite and tests were already skipped onmain. Coverage thresholds are met, including therad-componentsones.AppGraphtests mockhtml-to-image. They cover the labelled control, the download and its file name, the failure alert and retry, the disabled state while exporting and for an empty graph, the image size and transform from the node bounds, the file name rules, and the version pin.ApplicationTabtest that names the graph after the application.Not verified
docs/design/2026-09-radius-backstage-plugin.md, which is a draft, proposes moving the graph renderer into a sharedgraph-reactpackage later. This control is self-contained inAppGraph.tsx, so it should move along with the renderer.File change summary
packages/rad-components/src/components/appgraph/AppGraph.tsxexportGraphToPng(whole-graph bounds plus padding, white background) andgraphImageFileName. Adds the "Download graph as PNG"ControlButtonwith its in-progress and empty-graph guards, and arole="alert"panel shown when the export failspackages/rad-components/src/components/appgraph/__test__/AppGraph.test.tsxpackages/rad-components/package.json,yarn.lockhtml-to-image1.11.11plugins/plugin-radius/src/components/resources/ApplicationTab.tsxgetGraphresponse has no nameplugins/plugin-radius/src/components/resources/ApplicationTab.test.tsx