diff --git a/.changeset/purple-insects-cross.md b/.changeset/purple-insects-cross.md new file mode 100644 index 0000000000..d0371e18ed --- /dev/null +++ b/.changeset/purple-insects-cross.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-devtools': patch +--- + +Migrated `ConfigContent` component from Material UI to Backstage UI (BUI). diff --git a/plugins/devtools/src/components/Content/ConfigContent/ConfigContent.tsx b/plugins/devtools/src/components/Content/ConfigContent/ConfigContent.tsx index 0130d9fda2..bb5902c7ac 100644 --- a/plugins/devtools/src/components/Content/ConfigContent/ConfigContent.tsx +++ b/plugins/devtools/src/components/Content/ConfigContent/ConfigContent.tsx @@ -15,42 +15,26 @@ */ import { Progress, WarningPanel } from '@backstage/core-components'; -import Box from '@material-ui/core/Box'; -import Paper from '@material-ui/core/Paper'; -import Typography from '@material-ui/core/Typography'; -import { - createStyles, - makeStyles, - Theme, - useTheme, -} from '@material-ui/core/styles'; -import Alert from '@material-ui/lab/Alert'; +import { appThemeApiRef, useApi } from '@backstage/core-plugin-api'; +import { Alert, Box, Text } from '@backstage/ui'; +import useObservable from 'react-use/esm/useObservable'; import ReactJson from 'react-json-view'; import { useConfig } from '../../../hooks'; import { ConfigError } from '@backstage/plugin-devtools-common'; -const useStyles = makeStyles((theme: Theme) => - createStyles({ - warningStyle: { - paddingBottom: theme.spacing(2), - }, - paperStyle: { - padding: theme.spacing(2), - }, - }), -); - export const WarningContent = ({ error }: { error: ConfigError }) => { if (!error.messages) { - return {error.message}; + return {error.message}; } - const messages = error.messages as string[]; + const messages = error.messages; return ( {messages.map(message => ( - {message} + + {message} + ))} ); @@ -58,37 +42,44 @@ export const WarningContent = ({ error }: { error: ConfigError }) => { /** @public */ export const ConfigContent = () => { - const classes = useStyles(); - const theme = useTheme(); + const appThemeApi = useApi(appThemeApiRef); + const activeThemeId = useObservable( + appThemeApi.activeThemeId$(), + appThemeApi.getActiveThemeId(), + ); + const activeTheme = appThemeApi + .getInstalledThemes() + .find(t => t.id === activeThemeId); + const isDark = activeTheme?.variant === 'dark'; const { configInfo, loading, error } = useConfig(); if (loading) { return ; } else if (error) { - return {error.message}; + return ; } if (!configInfo) { - return Unable to load config data; + return ; } return ( {configInfo && configInfo.error && ( - + )} - + - + ); };