Repository navigation
feat(home): add composable home page widget grid #789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
achinthajayaweera
wants to merge
5
commits into
openchoreo:main
from
achinthajayaweera:feature/composable-home-page
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5121441
feat(home): add composable home page widget grid
achinthajayaweera 22f8ba3
fix(home): resolve CI failures - TypeScript errors, formatting, defau…
achinthajayaweera 9d84f09
fix(home): remove yarn patch, match default layout to pre-PR home page
achinthajayaweera 0aef7d0
fix(home): update changeset to remove stale patch reference
achinthajayaweera d73ee4a
fix(home): remove duplicate card titles
achinthajayaweera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(); | ||
|
|
@@ -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> | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }, | ||
| }, | ||
| }), | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.