diff --git a/plugins/plugin-radius/src/components/applications/ApplicationListPage.tsx b/plugins/plugin-radius/src/components/applications/ApplicationListPage.tsx index a278ffb..f716ace 100644 --- a/plugins/plugin-radius/src/components/applications/ApplicationListPage.tsx +++ b/plugins/plugin-radius/src/components/applications/ApplicationListPage.tsx @@ -1,12 +1,25 @@ import React from 'react'; -import { Grid } from '@material-ui/core'; -import { Header, Page, Content } from '@backstage/core-components'; +import { Grid, Typography, Box } from '@material-ui/core'; +import { + Header, + Page, + Content, + Breadcrumbs, + Link, +} from '@backstage/core-components'; import { ResourceTable } from '../resourcetable'; export const ApplicationListPage = () => (
+ + + Home + Environments + Applications + + ( @@ -10,6 +16,12 @@ export const EnvironmentListPage = () => ( subtitle="Displaying environments where applications can be deployed." /> + + + Home + Environments + + { + it('should render breadcrumbs', async () => { + const resource: Resource<{ [key: string]: unknown }> = { + id: '/planes/radius/local/resourcegroups/default/providers/Applications.Datastores/redisCaches/uiCache', + name: 'uiCache', + type: 'Applications.Datastores/redisCaches', + properties: { + application: + '/planes/radius/local/resourceGroups/default/providers/applications.core/applications/dashboard-app', + environment: + '/planes/radius/local/resourceGroups/default/providers/applications.core/environments/default', + }, + systemData: {}, + }; + const rendered = await renderInTestApp( + , + { + mountedRoutes: { + '/resource/:group/:namespace/:type/:name': resourcePageRouteRef, + }, + }, + ); + expect(rendered.getByText('default')).toBeVisible(); + expect(screen.getByRole('link', { name: 'default' })).toHaveAttribute( + 'href', + '/resource/default/applications.core/environments/default', + ); + expect(rendered.getByText('dashboard-app')).toBeVisible(); + expect(screen.getByRole('link', { name: 'dashboard-app' })).toHaveAttribute( + 'href', + '/resource/default/applications.core/applications/dashboard-app', + ); + }); +}); diff --git a/plugins/plugin-radius/src/components/resourcebreadcrumbs/ResourceBreadcrumbs.tsx b/plugins/plugin-radius/src/components/resourcebreadcrumbs/ResourceBreadcrumbs.tsx new file mode 100644 index 0000000..7f1cf4e --- /dev/null +++ b/plugins/plugin-radius/src/components/resourcebreadcrumbs/ResourceBreadcrumbs.tsx @@ -0,0 +1,19 @@ +import React from 'react'; +import { Resource } from '../../resources'; +import { ResourceLink } from '../resourcelink'; +import { Breadcrumbs } from '@backstage/core-components'; +import { Typography } from '@material-ui/core'; + +export const ResourceBreadcrumbs = (props: { resource: Resource }) => { + return ( + + {props.resource.properties?.environment && ( + + )} + {props.resource.properties?.application && ( + + )} + {props.resource.name} + + ); +}; diff --git a/plugins/plugin-radius/src/components/resourcebreadcrumbs/index.ts b/plugins/plugin-radius/src/components/resourcebreadcrumbs/index.ts new file mode 100644 index 0000000..35a0051 --- /dev/null +++ b/plugins/plugin-radius/src/components/resourcebreadcrumbs/index.ts @@ -0,0 +1 @@ +export { ResourceBreadcrumbs } from './ResourceBreadcrumbs'; diff --git a/plugins/plugin-radius/src/components/resources/ApplicationResourcesTab.tsx b/plugins/plugin-radius/src/components/resources/ApplicationResourcesTab.tsx index 6d2b09d..dfe537b 100644 --- a/plugins/plugin-radius/src/components/resources/ApplicationResourcesTab.tsx +++ b/plugins/plugin-radius/src/components/resources/ApplicationResourcesTab.tsx @@ -1,6 +1,8 @@ import React from 'react'; +import { Box } from '@material-ui/core'; import { Resource } from '../../resources'; import { ResourceTable } from '../resourcetable'; +import { ResourceBreadcrumbs } from '../resourcebreadcrumbs'; export const ApplicationResourcesTab = ({ resource, @@ -8,9 +10,14 @@ export const ApplicationResourcesTab = ({ resource: Resource; }) => { return ( - + <> + + + + + ); }; diff --git a/plugins/plugin-radius/src/components/resources/DetailsTab.tsx b/plugins/plugin-radius/src/components/resources/DetailsTab.tsx index 3429e4e..e122686 100644 --- a/plugins/plugin-radius/src/components/resources/DetailsTab.tsx +++ b/plugins/plugin-radius/src/components/resources/DetailsTab.tsx @@ -1,11 +1,18 @@ import React from 'react'; -import { Resource } from '../../resources'; +import { Box } from '@material-ui/core'; import { InfoCard } from '@backstage/core-components'; +import { Resource } from '../../resources'; +import { ResourceBreadcrumbs } from '../resourcebreadcrumbs'; export const DetailsTab = (props: { resource: Resource }) => { return ( - -
{JSON.stringify(props.resource, null, 2)}
-
+ <> + + + + +
{JSON.stringify(props.resource, null, 2)}
+
+ ); }; diff --git a/plugins/plugin-radius/src/components/resources/OverviewTab.tsx b/plugins/plugin-radius/src/components/resources/OverviewTab.tsx index 15e5d17..414e77e 100644 --- a/plugins/plugin-radius/src/components/resources/OverviewTab.tsx +++ b/plugins/plugin-radius/src/components/resources/OverviewTab.tsx @@ -1,7 +1,9 @@ import React from 'react'; -import { Resource, parseResourceId } from '../../resources'; import { InfoCard, StructuredMetadataTable } from '@backstage/core-components'; +import { Box } from '@material-ui/core'; +import { Resource, parseResourceId } from '../../resources'; import { ResourceLink } from '../resourcelink/ResourceLink'; +import { ResourceBreadcrumbs } from '../resourcebreadcrumbs'; export const OverviewTab = (props: { resource: Resource }) => { const metadata: { [key: string]: unknown } = { @@ -10,20 +12,25 @@ export const OverviewTab = (props: { resource: Resource }) => { group: parseResourceId(props.resource.id)?.group, }; - if (props.resource.properties?.application as string) { - metadata.application = ( - - ); - } if (props.resource.properties?.environment as string) { metadata.environment = ( ); } + if (props.resource.properties?.application as string) { + metadata.application = ( + + ); + } return ( - - - + <> + + + + + + + ); };