diff --git a/packages/core/src/layout/Header/Header.stories.tsx b/packages/core/src/layout/Header/Header.stories.tsx index cc0276224a..a99e9e235f 100644 --- a/packages/core/src/layout/Header/Header.stories.tsx +++ b/packages/core/src/layout/Header/Header.stories.tsx @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { customPageTheme } from '@backstage/theme'; +import { pageTheme } from '@backstage/theme'; import React from 'react'; import { Header } from '.'; import { HeaderLabel } from '../HeaderLabel'; @@ -33,7 +33,7 @@ const labels = ( ); export const Home = () => ( - +
{labels}
@@ -47,7 +47,7 @@ export const HomeWithSubtitle = () => ( ); export const Tool = () => ( - +
{labels}
@@ -55,7 +55,7 @@ export const Tool = () => ( ); export const Service = () => ( - +
{labels}
@@ -63,7 +63,7 @@ export const Service = () => ( ); export const Website = () => ( - +
{labels}
@@ -71,7 +71,7 @@ export const Website = () => ( ); export const Library = () => ( - +
{labels}
@@ -79,7 +79,7 @@ export const Library = () => ( ); export const App = () => ( - +
{labels}
@@ -87,7 +87,7 @@ export const App = () => ( ); export const Documentation = () => ( - +
{labels}
@@ -95,7 +95,7 @@ export const Documentation = () => ( ); export const Other = () => ( - +
{labels}
diff --git a/packages/core/src/layout/Header/Header.test.tsx b/packages/core/src/layout/Header/Header.test.tsx index e5dc7fec4d..5d28c6633f 100644 --- a/packages/core/src/layout/Header/Header.test.tsx +++ b/packages/core/src/layout/Header/Header.test.tsx @@ -26,18 +26,18 @@ jest.mock('react-helmet', () => { }); describe('
', () => { - it('should render with title', async () => { + it('should render with title', () => { const rendered = render(wrapInTestApp(
)); rendered.getByText('Title'); }); - it('should set document title', async () => { + it('should set document title', () => { const rendered = render(wrapInTestApp(
)); rendered.getByText('Title1'); rendered.getByText('defaultTitle: Title1 | Backstage'); }); - it('should override document title', async () => { + it('should override document title', () => { const rendered = render( wrapInTestApp(
), ); @@ -45,14 +45,14 @@ describe('
', () => { rendered.getByText('defaultTitle: Title2 | Backstage'); }); - it('should have subtitle', async () => { + it('should have subtitle', () => { const rendered = render( wrapInTestApp(
), ); rendered.getByText('Subtitle'); }); - it('should have type rendered', async () => { + it('should have type rendered', () => { const rendered = render( wrapInTestApp(
), ); diff --git a/packages/core/src/layout/Header/Header.tsx b/packages/core/src/layout/Header/Header.tsx index 41840b6ff0..6fadd0c834 100644 --- a/packages/core/src/layout/Header/Header.tsx +++ b/packages/core/src/layout/Header/Header.tsx @@ -17,11 +17,7 @@ import React, { ReactNode, CSSProperties, FC } from 'react'; import { Helmet } from 'react-helmet'; import { Typography, Tooltip, makeStyles, useTheme } from '@material-ui/core'; -import { - BackstageTheme, - BackstagePageThemeConsumer, - customPageTheme, -} from '@backstage/theme'; +import { BackstageTheme } from '@backstage/theme'; const useStyles = makeStyles( theme => ({ @@ -165,11 +161,9 @@ export const Header: FC = ({ type, typeLink, }) => { - const theme = useTheme(); + const backstageTheme = useTheme(); const classes = useStyles({ - backgroundImage: - theme.pageTheme?.backgroundImage ?? - customPageTheme.pageTheme.home.backgroundImage, + backgroundImage: backstageTheme.page.backgroundImage, }); const documentTitle = pageTitleOverride || title; const pageTitle = title || pageTitleOverride; diff --git a/packages/core/src/layout/SignInPage/SignInPage.tsx b/packages/core/src/layout/SignInPage/SignInPage.tsx index 8a1ff68250..b2b049d161 100644 --- a/packages/core/src/layout/SignInPage/SignInPage.tsx +++ b/packages/core/src/layout/SignInPage/SignInPage.tsx @@ -19,7 +19,8 @@ import { Page } from '../Page'; import { Header } from '../Header'; import { Content } from '../Content/Content'; import { ContentHeader } from '../ContentHeader/ContentHeader'; -import { Grid } from '@material-ui/core'; +import { BackstageTheme } from '@backstage/theme'; +import { Grid, useTheme } from '@material-ui/core'; import { SignInPageProps, useApi, configApiRef } from '@backstage/core-api'; import { useSignInProviders, getSignInProviders } from './providers'; import { IdentityProviders } from './types'; @@ -38,6 +39,7 @@ export const SignInPage: FC = ({ title, align = 'left', }) => { + const backstageTheme = useTheme(); const configApi = useApi(configApiRef); const classes = useStyles(); @@ -52,7 +54,7 @@ export const SignInPage: FC = ({ } return ( - +
{title && } diff --git a/plugins/api-docs/src/components/ApiEntityPage/ApiEntityPage.test.tsx b/plugins/api-docs/src/components/ApiEntityPage/ApiEntityPage.test.tsx index af5213e3f1..9a2bc0cfb1 100644 --- a/plugins/api-docs/src/components/ApiEntityPage/ApiEntityPage.test.tsx +++ b/plugins/api-docs/src/components/ApiEntityPage/ApiEntityPage.test.tsx @@ -13,14 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -import { Entity } from '@backstage/catalog-model'; import { ApiProvider, ApiRegistry, errorApiRef } from '@backstage/core'; import { CatalogApi, catalogApiRef } from '@backstage/plugin-catalog'; import { wrapInTestApp } from '@backstage/test-utils'; import { render, waitFor } from '@testing-library/react'; import * as React from 'react'; -import { ApiEntityPage, getPageTheme } from './ApiEntityPage'; +import { ApiEntityPage } from './ApiEntityPage'; jest.mock('react-router-dom', () => { const actual = jest.requireActual('react-router-dom'); @@ -71,32 +69,3 @@ describe('ApiEntityPage', () => { ); }); }); - -describe('getPageTheme', () => { - const defaultPageTheme = getPageTheme(); - it.each(['service', 'app', 'library', 'tool', 'documentation', 'website'])( - 'should select right theme for predefined type: %p ̰ ', - type => { - const theme = getPageTheme(({ - spec: { - type, - }, - } as any) as Entity); - expect(theme).toBeDefined(); - expect(theme).not.toBe(defaultPageTheme); - }, - ); - - it('should select default theme for unknown/unspecified types', () => { - const theme1 = getPageTheme(({ - spec: { - type: 'unknown-type', - }, - } as any) as Entity); - const theme2 = getPageTheme(({ - spec: {}, - } as any) as Entity); - expect(theme1).toBe(defaultPageTheme); - expect(theme2).toBe(defaultPageTheme); - }); -}); diff --git a/plugins/api-docs/src/components/ApiEntityPage/ApiEntityPage.tsx b/plugins/api-docs/src/components/ApiEntityPage/ApiEntityPage.tsx index edfc3ab08b..85250a8569 100644 --- a/plugins/api-docs/src/components/ApiEntityPage/ApiEntityPage.tsx +++ b/plugins/api-docs/src/components/ApiEntityPage/ApiEntityPage.tsx @@ -23,9 +23,9 @@ import { Progress, useApi, } from '@backstage/core'; -import { customPageTheme, PageTheme } from '@backstage/theme'; +import { BackstageTheme } from '@backstage/theme'; import { catalogApiRef } from '@backstage/plugin-catalog'; -import { Box } from '@material-ui/core'; +import { Box, useTheme } from '@material-ui/core'; import { Alert } from '@material-ui/lab'; import React, { useEffect } from 'react'; import { useNavigate, useParams } from 'react-router-dom'; @@ -53,12 +53,6 @@ function headerProps( }; } -// REUSABLE IN plugins/catalog/src/components/EntityPageLayout/EntityPageLayout.tsx -export const getPageTheme = (entity?: Entity): PageTheme => { - const themeKey = entity?.spec?.type?.toString() ?? 'home'; - return customPageTheme.pageTheme[themeKey] ?? customPageTheme.pageTheme.home; -}; - type EntityPageTitleProps = { title: string; entity: Entity | undefined; @@ -71,6 +65,7 @@ const EntityPageTitle = ({ title }: EntityPageTitleProps) => ( ); export const ApiEntityPage = () => { + const backstageTheme = useTheme(); const { optionalNamespaceAndName } = useParams() as { optionalNamespaceAndName: string; }; @@ -107,7 +102,11 @@ export const ApiEntityPage = () => { ); return ( - +
} pageTitleOverride={headerTitle} diff --git a/plugins/api-docs/src/components/ApiExplorerPage/ApiExplorerLayout.tsx b/plugins/api-docs/src/components/ApiExplorerPage/ApiExplorerLayout.tsx index 53b50f1826..410432d715 100644 --- a/plugins/api-docs/src/components/ApiExplorerPage/ApiExplorerLayout.tsx +++ b/plugins/api-docs/src/components/ApiExplorerPage/ApiExplorerLayout.tsx @@ -15,7 +15,8 @@ */ import { Header, Page } from '@backstage/core'; -import { customPageTheme } from '@backstage/theme'; +import { BackstageTheme } from '@backstage/theme'; +import { useTheme } from '@material-ui/core'; import React from 'react'; type Props = { @@ -23,8 +24,14 @@ type Props = { }; export const ApiExplorerLayout = ({ children }: Props) => { + const backstageTheme = useTheme(); + return ( - +
{ + const backstageTheme = useTheme(); const greeting = getTimeBasedGreeting(); const profile = useApi(identityApiRef).getProfile(); const userId = useApi(identityApiRef).getUserId(); return ( - +
{ - const themeKey = entity?.spec?.type?.toString() ?? 'home'; - return customPageTheme.pageTheme[themeKey] ?? customPageTheme.pageTheme.home; -}; +// const getPageTheme = (entity?: Entity): PageTheme => { +// const themeKey = entity?.spec?.type?.toString() ?? 'home'; +// return customPageTheme.pageTheme[themeKey] ?? customPageTheme.pageTheme.home; +// }; const EntityPageTitle = ({ entity, @@ -69,6 +69,7 @@ export const EntityPageLayout = ({ }: { children?: React.ReactNode; }) => { + const backstageTheme = useTheme(); const { optionalNamespaceAndName, kind } = useParams() as { optionalNamespaceAndName: string; kind: string; @@ -93,7 +94,11 @@ export const EntityPageLayout = ({ const showRemovalDialog = () => setConfirmationDialogOpen(true); return ( - +
} pageTitleOverride={headerTitle} diff --git a/plugins/cost-insights/src/components/AlertInstructionsLayout/AlertInstructionsLayout.tsx b/plugins/cost-insights/src/components/AlertInstructionsLayout/AlertInstructionsLayout.tsx index c0777fc844..d09b130b70 100644 --- a/plugins/cost-insights/src/components/AlertInstructionsLayout/AlertInstructionsLayout.tsx +++ b/plugins/cost-insights/src/components/AlertInstructionsLayout/AlertInstructionsLayout.tsx @@ -14,9 +14,15 @@ * limitations under the License. */ -import { customPageTheme } from '@backstage/theme'; +import { BackstageTheme } from '@backstage/theme'; import React, { ReactNode } from 'react'; -import { Box, Button, Container, makeStyles } from '@material-ui/core'; +import { + Box, + Button, + Container, + makeStyles, + useTheme, +} from '@material-ui/core'; import ChevronLeftIcon from '@material-ui/icons/ChevronLeft'; import { Header, Page } from '@backstage/core'; import { CostInsightsThemeProvider } from '../CostInsightsPage/CostInsightsThemeProvider'; @@ -37,10 +43,15 @@ const AlertInstructionsLayout = ({ title, children, }: AlertInstructionsLayoutProps) => { + const backstageTheme = useTheme(); const classes = useStyles(); return ( - +
diff --git a/plugins/cost-insights/src/components/CostInsightsLayout/CostInsightsLayout.tsx b/plugins/cost-insights/src/components/CostInsightsLayout/CostInsightsLayout.tsx index c95f624bbe..068174cd68 100644 --- a/plugins/cost-insights/src/components/CostInsightsLayout/CostInsightsLayout.tsx +++ b/plugins/cost-insights/src/components/CostInsightsLayout/CostInsightsLayout.tsx @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { customPageTheme } from '@backstage/theme'; +import { BackstageTheme } from '@backstage/theme'; import React from 'react'; -import { makeStyles } from '@material-ui/core'; +import { makeStyles, useTheme } from '@material-ui/core'; import { Header, Page } from '@backstage/core'; import { Group } from '../../types'; import CostInsightsTabs from '../CostInsightsTabs'; @@ -39,9 +39,14 @@ type CostInsightsLayoutProps = { }; const CostInsightsLayout = ({ groups, children }: CostInsightsLayoutProps) => { + const backstageTheme = useTheme(); const classes = useStyles(); return ( - +
(theme => ({ container: { @@ -115,8 +115,14 @@ const toolsCards = [ export const ExplorePluginPage = () => { const classes = useStyles(); + const backstageTheme = useTheme(); + return ( - +
{ @@ -112,8 +112,14 @@ const labels = ( ); export const NewProjectPage = () => { + const backstageTheme = useTheme(); + return ( - +
{labels}
diff --git a/plugins/gcp-projects/src/components/ProjectDetailsPage/ProjectDetailsPage.tsx b/plugins/gcp-projects/src/components/ProjectDetailsPage/ProjectDetailsPage.tsx index e310c27c68..eb86b6fd03 100644 --- a/plugins/gcp-projects/src/components/ProjectDetailsPage/ProjectDetailsPage.tsx +++ b/plugins/gcp-projects/src/components/ProjectDetailsPage/ProjectDetailsPage.tsx @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { customPageTheme } from '@backstage/theme'; +import { BackstageTheme } from '@backstage/theme'; import { Content, ContentHeader, @@ -36,6 +36,7 @@ import { TableRow, Theme, Typography, + useTheme, } from '@material-ui/core'; import React from 'react'; import { useAsync } from 'react-use'; @@ -147,8 +148,13 @@ const labels = ( ); export const ProjectDetailsPage = () => { + const backstageTheme = useTheme(); return ( - +
{labels}
diff --git a/plugins/gcp-projects/src/components/ProjectListPage/ProjectListPage.tsx b/plugins/gcp-projects/src/components/ProjectListPage/ProjectListPage.tsx index 5a404dbb01..33b3813c2a 100644 --- a/plugins/gcp-projects/src/components/ProjectListPage/ProjectListPage.tsx +++ b/plugins/gcp-projects/src/components/ProjectListPage/ProjectListPage.tsx @@ -15,7 +15,7 @@ */ // NEEDS WORK -import { customPageTheme } from '@backstage/theme'; +import { BackstageTheme } from '@backstage/theme'; import { Content, ContentHeader, @@ -38,6 +38,7 @@ import { TableRow, Tooltip, Typography, + useTheme, } from '@material-ui/core'; import React from 'react'; import { useAsync } from 'react-use'; @@ -134,8 +135,14 @@ const PageContents = () => { }; export const ProjectListPage = () => { + const backstageTheme = useTheme(); + return ( - +
{labels}
diff --git a/plugins/gitops-profiles/src/components/ClusterList/ClusterList.tsx b/plugins/gitops-profiles/src/components/ClusterList/ClusterList.tsx index 8926ed3260..3b33320abe 100644 --- a/plugins/gitops-profiles/src/components/ClusterList/ClusterList.tsx +++ b/plugins/gitops-profiles/src/components/ClusterList/ClusterList.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ -import { customPageTheme } from '@backstage/theme'; +import { BackstageTheme } from '@backstage/theme'; import React, { FC, useState } from 'react'; import { Content, @@ -29,12 +29,13 @@ import { } from '@backstage/core'; import ClusterTable from '../ClusterTable/ClusterTable'; -import { Button } from '@material-ui/core'; +import { Button, useTheme } from '@material-ui/core'; import { useAsync } from 'react-use'; import { gitOpsApiRef } from '../../api'; import { Alert } from '@material-ui/lab'; const ClusterList: FC<{}> = () => { + const backstageTheme = useTheme(); const api = useApi(gitOpsApiRef); const githubAuth = useApi(githubAuthApiRef); const [githubUsername, setGithubUsername] = useState(String); @@ -91,7 +92,11 @@ const ClusterList: FC<{}> = () => { } return ( - +
diff --git a/plugins/gitops-profiles/src/components/ClusterPage/ClusterPage.tsx b/plugins/gitops-profiles/src/components/ClusterPage/ClusterPage.tsx index d51fb7656e..f7205c3326 100644 --- a/plugins/gitops-profiles/src/components/ClusterPage/ClusterPage.tsx +++ b/plugins/gitops-profiles/src/components/ClusterPage/ClusterPage.tsx @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { customPageTheme } from '@backstage/theme'; +import { BackstageTheme } from '@backstage/theme'; import React, { FC, useEffect, useState } from 'react'; import { Content, @@ -26,12 +26,13 @@ import { githubAuthApiRef, } from '@backstage/core'; -import { Link } from '@material-ui/core'; +import { Link, useTheme } from '@material-ui/core'; import { useParams } from 'react-router-dom'; import { gitOpsApiRef, Status } from '../../api'; import { transformRunStatus } from '../ProfileCatalog'; const ClusterPage: FC<{}> = () => { + const backstageTheme = useTheme(); const params = useParams() as { owner: string; repo: string }; const [pollingLog, setPollingLog] = useState(true); @@ -84,7 +85,11 @@ const ClusterPage: FC<{}> = () => { }, [pollingLog, api, params, githubAuth, githubAccessToken, githubUsername]); return ( - +
diff --git a/plugins/gitops-profiles/src/components/ProfileCatalog/ProfileCatalog.tsx b/plugins/gitops-profiles/src/components/ProfileCatalog/ProfileCatalog.tsx index 078e1b7601..fe1e97235a 100644 --- a/plugins/gitops-profiles/src/components/ProfileCatalog/ProfileCatalog.tsx +++ b/plugins/gitops-profiles/src/components/ProfileCatalog/ProfileCatalog.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ -import { customPageTheme } from '@backstage/theme'; +import { BackstageTheme } from '@backstage/theme'; import React, { FC, useEffect, useState } from 'react'; import { Header, @@ -37,7 +37,7 @@ import { useApi, githubAuthApiRef, } from '@backstage/core'; -import { TextField, List, ListItem, Link } from '@material-ui/core'; +import { TextField, List, ListItem, Link, useTheme } from '@material-ui/core'; import ClusterTemplateCardList from '../ClusterTemplateCardList'; import ProfileCardList from '../ProfileCardList'; @@ -81,6 +81,8 @@ export const transformRunStatus = (x: Status[]) => { }; const ProfileCatalog: FC<{}> = () => { + const backstageTheme = useTheme(); + // TODO: get data from REST API const [clusterTemplates] = React.useState([ { @@ -259,7 +261,11 @@ const ProfileCatalog: FC<{}> = () => { ]; return ( - +
{ + const backstageTheme = useTheme(); const graphQlBrowseApi = useApi(graphQlBrowseApiRef); const endpoints = useAsync(() => graphQlBrowseApi.getEndpoints()); @@ -59,7 +60,11 @@ export const GraphiQLPage = () => { } return ( - +
diff --git a/plugins/kubernetes/src/components/KubernetesContent/KubernetesContent.tsx b/plugins/kubernetes/src/components/KubernetesContent/KubernetesContent.tsx index 381b942f3d..70edc167f3 100644 --- a/plugins/kubernetes/src/components/KubernetesContent/KubernetesContent.tsx +++ b/plugins/kubernetes/src/components/KubernetesContent/KubernetesContent.tsx @@ -14,9 +14,9 @@ * limitations under the License. */ -import { customPageTheme } from '@backstage/theme'; +import { BackstageTheme } from '@backstage/theme'; import React, { ReactElement, useEffect, useState } from 'react'; -import { Grid, TabProps } from '@material-ui/core'; +import { Grid, TabProps, useTheme } from '@material-ui/core'; import { CardTab, Content, @@ -98,6 +98,7 @@ const groupResponses = (fetchResponse: FetchResponse[]) => { type KubernetesContentProps = { entity: Entity; children?: React.ReactNode }; export const KubernetesContent = ({ entity }: KubernetesContentProps) => { + const backstageTheme = useTheme(); const kubernetesApi = useApi(kubernetesApiRef); const [kubernetesObjects, setKubernetesObjects] = useState< @@ -120,7 +121,11 @@ export const KubernetesContent = ({ entity }: KubernetesContentProps) => { kubernetesObjects?.items.filter(r => r.errors.length > 0) ?? []; return ( - + {kubernetesObjects === undefined && error === undefined && ( diff --git a/plugins/lighthouse/src/components/AuditList/index.tsx b/plugins/lighthouse/src/components/AuditList/index.tsx index 9c38e27fe3..cae1761ecb 100644 --- a/plugins/lighthouse/src/components/AuditList/index.tsx +++ b/plugins/lighthouse/src/components/AuditList/index.tsx @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { customPageTheme } from '@backstage/theme'; +import { BackstageTheme } from '@backstage/theme'; import React, { useState, useMemo, FC, ReactNode } from 'react'; import { useLocalStorage, useAsync } from 'react-use'; import { useNavigate } from 'react-router-dom'; -import { Grid, Button } from '@material-ui/core'; +import { Grid, Button, useTheme } from '@material-ui/core'; import Alert from '@material-ui/lab/Alert'; import Pagination from '@material-ui/lab/Pagination'; import { @@ -41,6 +41,7 @@ import { createAuditRouteRef } from '../../plugin'; export const LIMIT = 10; const AuditList: FC<{}> = () => { + const backstageTheme = useTheme(); const [dismissedStored] = useLocalStorage(LIGHTHOUSE_INTRO_LOCAL_STORAGE); const [dismissed, setDismissed] = useState(dismissedStored); @@ -94,7 +95,11 @@ const AuditList: FC<{}> = () => { } return ( - +
= ({ audit }: { audit?: Audit }) => { }; const ConnectedAuditView: FC<{}> = () => { + const backstageTheme = useTheme(); const lighthouseApi = useApi(lighthouseApiRef); const params = useParams() as { id: string }; const classes = useStyles(); @@ -173,7 +175,11 @@ const ConnectedAuditView: FC<{}> = () => { } return ( - +
({ })); const CreateAudit: FC<{}> = () => { + const backstageTheme = useTheme(); const errorApi = useApi(errorApiRef); const lighthouseApi = useApi(lighthouseApiRef); const classes = useStyles(); @@ -94,7 +96,11 @@ const CreateAudit: FC<{}> = () => { ]); return ( - +
= () => ( - -
- -
- - - - New Relic Application Performance Monitoring - - - - - +const NewRelicComponent: FC<{}> = () => { + const backstageTheme = useTheme(); + return ( + +
+ +
+ + + + New Relic Application Performance Monitoring + + + + + + -
-
-
-); - + + + ); +}; export default NewRelicComponent; diff --git a/plugins/register-component/src/components/RegisterComponentPage/RegisterComponentPage.tsx b/plugins/register-component/src/components/RegisterComponentPage/RegisterComponentPage.tsx index 5e4da3fc35..722e2e1964 100644 --- a/plugins/register-component/src/components/RegisterComponentPage/RegisterComponentPage.tsx +++ b/plugins/register-component/src/components/RegisterComponentPage/RegisterComponentPage.tsx @@ -14,9 +14,9 @@ * limitations under the License. */ -import { customPageTheme } from '@backstage/theme'; +import { BackstageTheme } from '@backstage/theme'; import React, { useState } from 'react'; -import { Grid, makeStyles } from '@material-ui/core'; +import { Grid, makeStyles, useTheme } from '@material-ui/core'; import { InfoCard, Page, @@ -61,6 +61,7 @@ export const RegisterComponentPage = ({ }: { catalogRouteRef: RouteRef; }) => { + const backstageTheme = useTheme(); const classes = useStyles(); const catalogApi = useApi(catalogApiRef); const [formState, setFormState] = useState>( @@ -113,7 +114,11 @@ export const RegisterComponentPage = ({ }; return ( - +
diff --git a/plugins/rollbar/src/components/RollbarHome/RollbarHome.tsx b/plugins/rollbar/src/components/RollbarHome/RollbarHome.tsx index 9f0deca967..f219be9615 100644 --- a/plugins/rollbar/src/components/RollbarHome/RollbarHome.tsx +++ b/plugins/rollbar/src/components/RollbarHome/RollbarHome.tsx @@ -14,17 +14,23 @@ * limitations under the License. */ -import { customPageTheme } from '@backstage/theme'; +import { BackstageTheme } from '@backstage/theme'; +import { useTheme } from '@material-ui/core'; import React from 'react'; import { Content, Header, Page } from '@backstage/core'; import { RollbarProjectTable } from '../RollbarProjectTable/RollbarProjectTable'; import { useRollbarEntities } from '../../hooks/useRollbarEntities'; export const RollbarHome = () => { + const backstageTheme = useTheme(); const { entities, loading, error } = useRollbarEntities(); return ( - +
{ + const backstageTheme = useTheme(); const { entity } = useCatalogEntity(); return ( - +
diff --git a/plugins/scaffolder/src/components/ScaffolderPage/ScaffolderPage.tsx b/plugins/scaffolder/src/components/ScaffolderPage/ScaffolderPage.tsx index 1bd43ded44..bd70fd9565 100644 --- a/plugins/scaffolder/src/components/ScaffolderPage/ScaffolderPage.tsx +++ b/plugins/scaffolder/src/components/ScaffolderPage/ScaffolderPage.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ -import { customPageTheme } from '@backstage/theme'; +import { BackstageTheme } from '@backstage/theme'; import { TemplateEntityV1alpha1 } from '@backstage/catalog-model'; import { Content, @@ -29,7 +29,7 @@ import { WarningPanel, } from '@backstage/core'; import { catalogApiRef } from '@backstage/plugin-catalog'; -import { Button, Grid, Link, Typography } from '@material-ui/core'; +import { Button, Grid, Link, Typography, useTheme } from '@material-ui/core'; import React, { useEffect } from 'react'; import { Link as RouterLink } from 'react-router-dom'; import useStaleWhileRevalidate from 'swr'; @@ -49,6 +49,7 @@ const getTemplateCardProps = ( }; export const ScaffolderPage = () => { + const backstageTheme = useTheme(); const catalogApi = useApi(catalogApiRef); const errorApi = useApi(errorApiRef); @@ -66,7 +67,7 @@ export const ScaffolderPage = () => { }, [error, errorApi]); return ( - +
{ - const theme = - customPageTheme.pageTheme[type] ?? customPageTheme.pageTheme.other; + const backstageTheme = useTheme(); + + const themeId = pageTheme[type] ? type : 'other'; + const theme = backstageTheme.getPageTheme({ themeId }); const classes = useStyles({ backgroundImage: theme.backgroundImage }); const href = generatePath(templateRoute.path, { templateName: name }); diff --git a/plugins/scaffolder/src/components/TemplatePage/TemplatePage.tsx b/plugins/scaffolder/src/components/TemplatePage/TemplatePage.tsx index 5067f7963d..7bfc1b78a2 100644 --- a/plugins/scaffolder/src/components/TemplatePage/TemplatePage.tsx +++ b/plugins/scaffolder/src/components/TemplatePage/TemplatePage.tsx @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { customPageTheme } from '@backstage/theme'; +import { BackstageTheme } from '@backstage/theme'; import { TemplateEntityV1alpha1 } from '@backstage/catalog-model'; import { Content, @@ -25,7 +25,7 @@ import { useApi, } from '@backstage/core'; import { catalogApiRef } from '@backstage/plugin-catalog'; -import { LinearProgress } from '@material-ui/core'; +import { LinearProgress, useTheme } from '@material-ui/core'; import { IChangeEvent } from '@rjsf/core'; import React, { useState } from 'react'; import { useParams } from 'react-router-dom'; @@ -80,6 +80,7 @@ const REPO_FORMAT = { }; export const TemplatePage = () => { + const backstageTheme = useTheme(); const errorApi = useApi(errorApiRef); const catalogApi = useApi(catalogApiRef); const scaffolderApi = useApi(scaffolderApiRef); @@ -145,7 +146,7 @@ export const TemplatePage = () => { } return ( - +
= () => { + const backstageTheme = useTheme(); const [statsFor, setStatsFor] = useState<'12h' | '24h'>('12h'); const toggleStatsFor = () => setStatsFor(statsFor === '12h' ? '12h' : '24h'); const sentryProjectId = 'sample-sentry-project-id'; return ( - +
diff --git a/plugins/tech-radar/src/components/RadarPage.tsx b/plugins/tech-radar/src/components/RadarPage.tsx index 58dcaec9af..d23061b094 100644 --- a/plugins/tech-radar/src/components/RadarPage.tsx +++ b/plugins/tech-radar/src/components/RadarPage.tsx @@ -14,9 +14,9 @@ * limitations under the License. */ -import { customPageTheme } from '@backstage/theme'; +import { BackstageTheme } from '@backstage/theme'; import React from 'react'; -import { Grid } from '@material-ui/core'; +import { Grid, useTheme } from '@material-ui/core'; import { Content, ContentHeader, @@ -39,29 +39,35 @@ export const RadarPage = ({ subtitle, pageTitle, ...props -}: TechRadarPageProps): JSX.Element => ( - -
- - -
- - - - This is used for visualizing the official guidelines of different - areas of software development such as languages, frameworks, - infrastructure and processes. - - - - - +}: TechRadarPageProps): JSX.Element => { + const backstageTheme = useTheme(); + return ( + +
+ + +
+ + + + This is used for visualizing the official guidelines of different + areas of software development such as languages, frameworks, + infrastructure and processes. + + + + + + -
-
-
-); - +
+ + ); +}; RadarPage.defaultProps = { title: 'Tech Radar', subtitle: 'Pick the recommended technologies for your projects', diff --git a/plugins/techdocs/src/reader/components/TechDocsHome.tsx b/plugins/techdocs/src/reader/components/TechDocsHome.tsx index 11211e713c..149117ec00 100644 --- a/plugins/techdocs/src/reader/components/TechDocsHome.tsx +++ b/plugins/techdocs/src/reader/components/TechDocsHome.tsx @@ -14,11 +14,11 @@ * limitations under the License. */ -import { customPageTheme } from '@backstage/theme'; +import { BackstageTheme } from '@backstage/theme'; import React from 'react'; import { useAsync } from 'react-use'; import { useNavigate, generatePath } from 'react-router-dom'; -import { Grid } from '@material-ui/core'; +import { Grid, useTheme } from '@material-ui/core'; import { ItemCard, Progress, @@ -31,6 +31,7 @@ import { catalogApiRef } from '@backstage/plugin-catalog'; import { rootDocsRouteRef } from '../../plugin'; export const TechDocsHome = () => { + const backstageTheme = useTheme(); const catalogApi = useApi(catalogApiRef); const navigate = useNavigate(); @@ -43,7 +44,11 @@ export const TechDocsHome = () => { if (loading) { return ( - +
{ if (error) { return ( - +
{ } return ( - +
{ + const backstageTheme = useTheme(); const [documentReady, setDocumentReady] = useState(false); const { entityId } = useParams(); const [kind, namespace, name] = entityId.split(':'); @@ -47,7 +49,11 @@ export const TechDocsPage = () => { }; return ( - + { + const backstageTheme = useTheme(); const appTitle = useApi(configApiRef).getOptionalString('app.title') ?? 'Backstage'; const profile = { givenName: '' }; return ( - +