Repository navigation
feat(codescene): migrate plugin from Material-UI to Backstage UI - #11609
deepthi-28 wants to merge 3 commits into
Conversation
Replace MUI Grid, Typography, Button, Card, Chip and Input with their Backstage UI equivalents, and lab Alert with the BUI Alert. Convert makeStyles usages to CSS modules. Drop the @material-ui/lab dependency and add @backstage/ui. The icon and gauge components still use Material-UI: CodeSceneIcon exposes SvgIconProps as public API, and Gauge reads status colours from the Backstage theme palette, neither of which Backstage UI provides. Wire a mock CodeScene API into the dev app so the plugin can be previewed locally without a backend. Signed-off-by: deepthi-ajith_infosys <[email protected]>
|
Important This PR includes changes that affect public-facing API. Please ensure you are adding/updating documentation for new features or behavior. Changed Packages
|
AmbrishRamachandiran
left a comment
There was a problem hiding this comment.
Thanks for the migration @deepthi-28! The component mapping looks right against @backstage/[email protected] (Alert with status/title, ButtonLink, Card with href/label, TagGroup/Tag, SearchField with value-based onChange). Adding a mocked CodeSceneApi to the dev app is a nice touch, since it makes the pages reviewable locally.
I left a few comments, mostly to line this up with feedback maintainers have given on other MUI → BUI PRs in this repo:
- Partial migration:
Gauge.tsx(used byCodeHealthKpisCard) still uses MUImakeStyles/Tooltip/useTheme, so@material-ui/corestays a dependency. Could this be completed here? - Peer dependencies:
@backstage/[email protected]needs React 18 andreact-router-dom ^6.30.2, but the plugin still advertises older versions. - Changeset: mark it as BREAKING and link to the BUI installation docs, as in the other migrations.
- Smaller items on the CSS modules, the dev-app stylesheet import, and a filter test.
Could you also link the tracking issue #7869 in the PR description? Maintainers have asked for that on the other migration PRs.
| '@backstage-community/plugin-codescene': minor | ||
| --- | ||
|
|
||
| Migrated the CodeScene plugin from Material-UI to Backstage UI. |
There was a problem hiding this comment.
Could we use the same wording as the other BUI migrations (e.g. apollo-explorer, badges)? Apps now need Backstage UI and its stylesheet installed, so adopters should see it called out as breaking:
| Migrated the CodeScene plugin from Material-UI to Backstage UI. | |
| **BREAKING** Migrated from Material UI (MUI) to Backstage UI (BUI). This means that Backstage UI is now a requirement for this plugin, see the Backstage UI [installation documentation](https://ui.backstage.io/get-started/installation) for more details. |
On the bump level: minor has been accepted for pre-1.0 plugins (this one is 0.22.0) on recent migrations like adr and entity-feedback, though some maintainers have asked for major to move plugins to v1. I'll leave that call to the workspace maintainers.
There was a problem hiding this comment.
Addressed in aa953eb: added the requested BREAKING wording and BUI installation link, plus React/router migration requirements. Kept the pre-1.0 minor bump for maintainer confirmation.
| "@backstage/frontend-plugin-api": "backstage:^", | ||
| "@backstage/plugin-catalog-react": "backstage:^", | ||
| "@backstage/theme": "backstage:^", | ||
| "@backstage/ui": "backstage:^", |
There was a problem hiding this comment.
@backstage/[email protected] (the version resolved in yarn.lock) declares peer dependencies react ^18.0.0, react-dom ^18.0.0, react-router-dom ^6.30.2 and @types/react ^18.0.0. This package still advertises react ^16.13.1 || ^17.0.0 || ^18.0.0 and react-router-dom 6.0.0-beta.0 || ^6.3.0 (peer and dev), and @types/react ^16.13.1 || ^17.0.0 || ^18.0.0. A React 17 app could install it and end up with unmet peers. Could you narrow these, as was requested on the firehydrant migration?
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-router-dom": "^6.30.2"and "@types/react": "^18.0.0".
Also, @material-ui/core (next line) is still needed only because of Gauge.tsx and CodeSceneIcon.tsx. See my comment on CodeHealthKpisCard.tsx.
There was a problem hiding this comment.
Addressed in aa953eb: narrowed React and React DOM peer/dev ranges and React types to ^18.0.0, and React Router DOM to ^6.30.2. Updated the lockfile; immutable resolution passes. MUI core remains only for the public icon API.
| <Grid.Root columns={{ sm: '12' }} gap="4"> | ||
| <Grid.Item colSpan={{ sm: '4' }}> | ||
| <div className={styles.gauge}> | ||
| <Gauge value={kpi.value} max={10} tooltipText={kpi.description} /> |
There was a problem hiding this comment.
Gauge (src/components/Gauge/Gauge.tsx) is still fully MUI: makeStyles, @material-ui/core/Tooltip, and useTheme().palette for the colours. Since Gauge isn't part of the public exports, it should be possible to migrate it here without an API change:
- Tooltip:
TooltipTrigger+Tooltipfrom@backstage/ui. This also removes the manualmouseenter/mouseleave+openstate handling. - Styles: a CSS module (or BUI
Boxprops) instead ofmakeStyles. - Colours:
getProgressColorcould return BUI tokens (var(--bui-fg-negative),var(--bui-fg-warning),var(--bui-fg-positive)) instead of MUIpalette.status.*, which also drops thePalettetype import.
Maintainers have asked about partial versus full migration on other PRs (e.g. gcalendar), so it would be good to finish it here, or explain in the PR why it's left out. CodeSceneIcon can reasonably stay on SvgIcon for now, because it's a public export typed with SvgIconProps and changing it would be an API break.
There was a problem hiding this comment.
Addressed in aa953eb: migrated the gauge to BUI TooltipTrigger/Tooltip, a React Aria Focusable trigger, CSS-module styling, and BUI status-color tokens. Removed MUI theme access and manual hover state/listeners. Added passing keyboard-tooltip and color-threshold tests. The public icon is intentionally unchanged.
| @@ -0,0 +1,7 @@ | |||
| @layer components { | |||
There was a problem hiding this comment.
Two small things on the CSS modules:
- Maintainers have asked to drop the
@layer componentswrapper from CSS modules in migration PRs (opencost, entity-validation, explore). The same applies toProjectsComponent.module.css. - Reviewers have also preferred BUI layout props over new CSS modules where possible. This one could probably be removed completely:
<Box width="100px" height="100%" mt="3" ml="12">
<Gauge value={kpi.value} max={10} tooltipText={kpi.description} />
</Box>There was a problem hiding this comment.
Addressed in aa953eb: removed the KPI CSS module in favor of BUI Box sizing/spacing props and removed the layer wrapper from the project CSS module. The gauge CSS module also uses no layer wrapper.
| import { codesceneApiRef, CodeSceneApi } from '../src/api/api'; | ||
| import { Analysis, Project } from '../src/api/types'; | ||
| // eslint-disable-next-line @backstage/no-ui-css-imports-in-non-frontend | ||
| import '@backstage/ui/css/styles.css'; |
There was a problem hiding this comment.
Nit: I think this import (and the eslint-disable above it) isn't needed. createDevApp from @backstage/[email protected] already lazy-loads @backstage/ui/css/styles.css (dist/devApp/BuiCss.esm.js), and the repo's mui-to-bui-migration skill says to skip the import for createDevApp workspaces.
There was a problem hiding this comment.
Addressed in aa953eb: removed the redundant dev-app stylesheet import and its ESLint suppression. Added adopter-facing BUI setup instructions to the README.
| placeholder="Filter" | ||
| onChange={e => setSearchText(e.target.value)} | ||
| value={searchText} | ||
| onChange={value => setSearchText(value)} |
There was a problem hiding this comment.
Nit: the onChange contract changed here (MUI Input passed an event, BUI SearchField passes the value), and nothing in ProjectsComponent.test.tsx exercises the filter. Could you add a small regression test, for example two projects where typing into the Filter projects search box hides the one that doesn't match?
There was a problem hiding this comment.
Addressed in aa953eb: added a passing two-project regression test covering case-insensitive name filtering, multi-term name/description matching, hiding nonmatches, and clearing the search.
There was a problem hiding this comment.
🟡 Changes recommended
The new Text components default to inline spans, causing KPI names, scores, and analysis metrics to run together while removing the score heading semantics.
1 open issue
What changed in this PR
Updates the CodeScene plugin’s project and entity views to use Backstage UI while retaining existing Backstage core components.
Changes:
- Replaces Material-UI layouts, alerts, cards, search input, and typography with Backstage UI components.
- Moves component styling to CSS modules and adds mock data for local previews.
- Updates dependencies and includes a minor-release changeset.
| File | Description |
|---|---|
workspaces/codescene/yarn.lock |
Records the updated plugin dependencies. |
workspaces/codescene/plugins/codescene/src/components/ProjectsComponent/ProjectsComponent.tsx |
Migrates project cards, search, tags, and grid layout. |
workspaces/codescene/plugins/codescene/src/components/ProjectsComponent/ProjectsComponent.module.css |
Adds scrolling and full-height card styles. |
workspaces/codescene/plugins/codescene/src/components/CodeSceneProjectDetailsPage/CodeSceneProjectDetailsPage.tsx |
Converts detail-page layout, alerts, and text to BUI. |
workspaces/codescene/plugins/codescene/src/components/CodeScenePageComponent/CodeScenePageComponent.tsx |
Replaces the page’s outer grid with BUI. |
workspaces/codescene/plugins/codescene/src/components/CodeSceneEntityKPICard/CodeSceneEntityKPICard.tsx |
Migrates entity KPI layout, alerts, and typography. |
workspaces/codescene/plugins/codescene/src/components/CodeSceneEntityFileSummary/CodeSceneEntityFileSummary.tsx |
Uses BUI layout and error alerts. |
workspaces/codescene/plugins/codescene/src/components/CodeHealthKpisCard/CodeHealthKpisCard.tsx |
Migrates KPI layout, text, and configuration link. |
workspaces/codescene/plugins/codescene/src/components/CodeHealthKpisCard/CodeHealthKpisCard.module.css |
Moves gauge sizing and spacing into CSS. |
workspaces/codescene/plugins/codescene/package.json |
Adds @backstage/ui and removes @material-ui/lab. |
workspaces/codescene/plugins/codescene/dev/index.tsx |
Adds mock API data and a BUI stylesheet import. |
workspaces/codescene/.changeset/codescene-mui-to-bui.md |
Declares a minor release for the UI migration. |
Review effort: Balanced
| <Text variant="body-medium">{kpi.name}</Text> | ||
| <Text variant="title-small"> |
There was a problem hiding this comment.
Addressed in aa953eb: KPI names and analysis metrics now render as paragraphs, and KPI scores retain h6 heading semantics. Added regression assertions to the details-page test. That suite and full type-checking are currently blocked locally by stale installed frontend-plugin-api dependencies; registry downloads return HTTP 403. The other 8 targeted tests, ESLint, and Prettier pass.
awanlin
left a comment
There was a problem hiding this comment.
Thanks for the contribution @deepthi-28, there's a merge conflict that needs to be address. @AmbrishRamachandiran's feedback also needs to be followed along with the Copilot comments.
@AmbrishRamachandiran, thanks for the review, appreciate the initial set of eyes on this 🙏
…into mui-bui-migration-codescene Signed-off-by: deepthi-ajith_infosys <[email protected]> Co-authored-by: Copilot <[email protected]> # Conflicts: # workspaces/codescene/plugins/codescene/src/components/CodeSceneEntityFileSummary/CodeSceneEntityFileSummary.tsx # workspaces/codescene/plugins/codescene/src/components/CodeSceneEntityKPICard/CodeSceneEntityKPICard.tsx # workspaces/codescene/plugins/codescene/src/components/CodeScenePageComponent/CodeScenePageComponent.tsx # workspaces/codescene/plugins/codescene/src/components/CodeSceneProjectDetailsPage/CodeSceneProjectDetailsPage.tsx # workspaces/codescene/plugins/codescene/src/components/ProjectsComponent/ProjectsComponent.tsx # workspaces/codescene/yarn.lock
Signed-off-by: deepthi-ajith_infosys <[email protected]> Co-authored-by: Copilot <[email protected]>
|
@AmbrishRamachandiran @awanlin, both Ambrish’s and Copilot’s feedback have been addressed in aa953eb. Please re-review when you have a chance. Thank you! |
AmbrishRamachandiran
left a comment
There was a problem hiding this comment.
Thanks for the thorough update! All my points, and Copilot's, are addressed, and the gauge migration and new tests look good. LGTM 🚀
cc @backstage/community-plugins-maintainers for a final look.
| .addPage({ | ||
| element: <CodeSceneProjectDetailsPage />, | ||
| element: ( | ||
| <TestApiProvider apis={[[codesceneApiRef, mockCodeSceneApi]]}> |
| <CardFooter> | ||
| <TagGroup aria-label={`Top languages for ${project.name}`}> | ||
| {languages.map(lang => ( | ||
| <Tag key={lang} size="small"> |

Hey, I just made a Pull Request!
Migrates the CodeScene plugin from Material-UI to Backstage UI, including the gauge, accessible tooltips, and compatible React/router peers. The public icon retains its existing MUI-based API to avoid a separate API break.
Related to #7869.
✔️ Checklist
Signed-off-byline in the message. (more info)Validation: 8 targeted tests, ESLint, Prettier, and immutable lockfile resolution pass. Full type-checking and the details-page test remain blocked by stale installed dependencies: registry downloads return HTTP 403. Light/dark visual verification remains outstanding.