Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/ready-taxis-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@openchoreo/backstage-portal-app': patch
---

Add composable home page widget grid (Recently Visited, My Projects, Quick Actions, Recent Deployments) with Edit/Add Widget/Save controls; default view matches the existing home page layout
1 change: 1 addition & 0 deletions packages/portal-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"@backstage/plugin-catalog-import": "^0.13.13",
"@backstage/plugin-catalog-react": "^3.0.0",
"@backstage/plugin-home": "^0.9.6",
Comment thread
coderabbitai[bot] marked this conversation as resolved.
"@backstage/plugin-home-react": "^0.1.38",
"@backstage/plugin-kubernetes": "^0.12.19",
"@backstage/plugin-org": "^0.7.4",
"@backstage/plugin-permission-common": "^0.9.9",
Expand Down
75 changes: 41 additions & 34 deletions packages/portal-app/src/components/Home/HomePage.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
import { Content, Page, Header } from '@backstage/core-components';
import { HomePageStarredEntities } from '@backstage/plugin-home';
import { RecentlyVisitedCard } from './RecentlyVisitedCard';
import {
HomePageStarredEntities,
CustomHomepageGrid,
type LayoutConfiguration,
} from '@backstage/plugin-home';
import { HomePageSearchBar } from '@backstage/plugin-search';
import { SearchContextProvider } from '@backstage/plugin-search-react';
import { Grid, Typography, Box } from '@material-ui/core';
import { useStyles } from './styles';
import { useUserInfo } from '../../hooks';
import { useNamespacePermission } from '@openchoreo/backstage-plugin-react';
import { HomePagePlatformDetailsCard } from '@openchoreo/backstage-plugin-platform-engineer-core';
import {
RecentlyVisitedHomeWidget,
MyProjectsHomeWidget,
QuickActionsHomeWidget,
RecentDeploymentsHomeWidget,
} from './homeWidgets';

/**
* Custom HomePage that shows content based on user permissions
*/
const defaultLayout: LayoutConfiguration[] = [
{ component: 'HomePageStarredEntities', x: 0, y: 0, width: 6, height: 4 },
{ component: 'RecentlyVisited', x: 6, y: 0, width: 6, height: 4 },
];
Comment on lines +24 to +27

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default layout should match our exact layout that we have today. No need to add 'MyProjects', 'QuickActions' and 'RecentDeployments'


export const HomePage = () => {
const classes = useStyles();
const { userName, loading } = useUserInfo();
Expand All @@ -33,45 +47,38 @@ export const HomePage = () => {
<Page themeId="home">
<Header title={`Welcome, ${userName}!`} />
<Content>
<Grid container spacing={3}>
{/* Search Bar */}
<Grid item xs={12}>
<HomePageSearchBar
InputProps={{
classes: {
root: classes.searchBarInput,
notchedOutline: classes.searchBarOutline,
},
}}
placeholder="Search"
/>
</Grid>
{/* Search Bar */}
<Box mb={3}>
<HomePageSearchBar
InputProps={{
classes: {
root: classes.searchBarInput,
notchedOutline: classes.searchBarOutline,
},
}}
placeholder="Search"
/>
</Box>

{/* Starred Entities and Recently Visited */}
<Grid item xs={12}>
<Grid container spacing={3} alignItems="stretch">
<Grid item xs={12} md={6} style={{ display: 'flex' }}>
<Box className={classes.starredEntitiesWrapper}>
<HomePageStarredEntities />
</Box>
</Grid>
<Grid item xs={12} md={6} style={{ display: 'flex' }}>
<Box className={classes.starredEntitiesWrapper}>
<RecentlyVisitedCard />
</Box>
</Grid>
</Grid>
</Grid>
{/* Customizable widget grid. */}
<CustomHomepageGrid config={defaultLayout}>
<HomePageStarredEntities />
<RecentlyVisitedHomeWidget />
<MyProjectsHomeWidget />
<QuickActionsHomeWidget />
<RecentDeploymentsHomeWidget />
</CustomHomepageGrid>

{/* Platform Details - visible only with namespace read permission */}
{canViewPlatformDetails && (
{/* Platform Details stays outside the grid on purpose. */}
{canViewPlatformDetails && (
<Grid container spacing={3} style={{ marginTop: 24 }}>
<Grid item xs={12}>
<Box className={classes.platformDetailsSection}>
<HomePagePlatformDetailsCard />
</Box>
</Grid>
)}
</Grid>
</Grid>
)}
</Content>
</Page>
</SearchContextProvider>
Expand Down
53 changes: 53 additions & 0 deletions packages/portal-app/src/components/Home/homeWidgets.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { homePlugin } from '@backstage/plugin-home';
import { createCardExtension } from '@backstage/plugin-home-react';
import { RecentlyVisitedCard } from './RecentlyVisitedCard';
import { RecentDeploymentsCard } from './RecentDeploymentsCard';
import {
MyProjectsWidget,
QuickActionsSection,
} from '@openchoreo/backstage-plugin';

export const RecentlyVisitedHomeWidget = homePlugin.provide(
createCardExtension({
name: 'RecentlyVisited',
components: async () => ({ Content: RecentlyVisitedCard }),
layout: {
height: { minRows: 4 },
width: { minColumns: 4 },
},
}),
);

export const MyProjectsHomeWidget = homePlugin.provide(
createCardExtension({
name: 'MyProjects',
components: async () => ({ Content: MyProjectsWidget }),
layout: {
height: { minRows: 4 },
width: { minColumns: 4 },
},
}),
);

export const QuickActionsHomeWidget = homePlugin.provide(
createCardExtension({
name: 'QuickActions',
title: 'Quick Actions',
components: async () => ({ Content: QuickActionsSection }),
layout: {
height: { minRows: 4 },
width: { minColumns: 4 },
},
}),
);

export const RecentDeploymentsHomeWidget = homePlugin.provide(
createCardExtension({
name: 'RecentDeployments',
components: async () => ({ Content: RecentDeploymentsCard }),
layout: {
height: { minRows: 4 },
width: { minColumns: 4 },
},
}),
);
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { Link } from 'react-router-dom';
import { useComponentCreatePermission } from '@openchoreo/backstage-plugin-react';
import { useStyles } from './styles';

export const QuickActionsSection: React.FC = () => {
export const QuickActionsSection = () => {
const classes = useStyles();
const { canCreate, loading: createPermLoading } =
useComponentCreatePermission();
Expand Down
Loading
Loading