Conversation
fa62b71 to
1b08c4e
Compare
ecc1a6e to
f108d68
Compare
711d788 to
c39b150
Compare
| dataRefs: { | ||
| filterFunction: entityFilterFunctionDataRef, | ||
| filterExpression: entityFilterExpressionDataRef, | ||
| area: entityCardAreaDataRef, |
There was a problem hiding this comment.
@Rugvip I could not name it variant because it conflicts with cards that already expect that prop:
Should we use the info card variant as default values?
There was a problem hiding this comment.
Hmm, I don't quite see how this would actually result in a conflict. I'll need to dig a bit deeper. I do prefer variant still
| }); | ||
|
|
||
| /** @alpha */ | ||
| export const EntityCardLayoutBlueprint = createExtensionBlueprint({ |
There was a problem hiding this comment.
We were unsure if we should rename to EntityContentLayout as the current name could be interpreted as individual card elements layout. I would particularly recommend renaming to EntityContentLayout if people can attach a layout to multiple parents or even EntityOverviewContentLayout if they can only attach this to the overview tab layout.
There was a problem hiding this comment.
Yep let's go with EntityContentLayout, might leave for a followup depending on the potential for conflict with #28845
c39b150 to
8c5e9d6
Compare
| - `peek`: used for cards containing infrastucture information (e.g. last builds, deployments, etc.). | ||
| - `info`: used for cards that contain entity metadata (e.g. about, links); | ||
| - `full`: Contains information that plugins add to an entity (e.g. PagerDuty incidents and on-call escalation). |
There was a problem hiding this comment.
Names like these are not really areas. They are more variant names, but the variant term is overused, and we encountered conflicts like the one mentioned here:
https://github.com/backstage/backstage/pull/28758/files#r1954130876
Open to suggestions.
d781239 to
22ce741
Compare
8c5e9d6 to
0a1ce97
Compare
Signed-off-by: Camila Belo <camilaibs@gmail.com>
Co-authored-by: Patrik Oldsberg <poldsberg@gmail.com> Signed-off-by: Camila Belo <camilaibs@gmail.com>
0a1ce97 to
a3d93ca
Compare
Rugvip
left a comment
There was a problem hiding this comment.
👌 ✨
Couple of notes for followups but let's 🚢 & 🇮🇹
| ### Usage example | ||
|
|
||
| Creating a custom overview tab layout: | ||
|
|
||
| ```tsx | ||
| import { | ||
| EntityCardLayoutProps, | ||
| EntityCardLayoutBlueprint, | ||
| } from '@backstage/plugin-catalog-react/alpha'; | ||
| // ... | ||
|
|
||
| function StickyEntityContentOverviewLayout(props: EntityCardLayoutProps) { | ||
| const { cards } = props; | ||
| const classes = useStyles(); | ||
| return ( | ||
| <Grid container spacing={3}> | ||
| <Grid | ||
| className={classes.infoArea} | ||
| xs={12} | ||
| md={4} | ||
| item | ||
| > | ||
| <Grid container spacing={3}> | ||
| {cards | ||
| .filter(card => card.area === 'info') | ||
| .map((card, index) => ( | ||
| <Grid key={index} xs={12} item> | ||
| {card.element} | ||
| </Grid> | ||
| ))} | ||
| </Grid> | ||
| </Grid> | ||
| <Grid xs={12} md={8} item> | ||
| <Grid container spacing={3}> | ||
| {cards | ||
| .filter(card => card.area === 'peek') | ||
| .map((card, index) => ( | ||
| <Grid key={index} className={classes.card} xs={12} md={6} item> | ||
| {card.element} | ||
| </Grid> | ||
| ))} | ||
| {cards | ||
| .filter(card => !card.area || card.area === 'full') | ||
| .map((card, index) => ( | ||
| <Grid key={index} className={classes.card} xs={12} md={6} item> | ||
| {card.element} | ||
| </Grid> | ||
| ))} | ||
| </Grid> | ||
| </Grid> | ||
| </Grid> | ||
| ); | ||
| } | ||
|
|
||
| export const customEntityContentOverviewStickyLayoutModule = createFrontendModule({ | ||
| pluginId: 'app', | ||
| extensions: [ | ||
| EntityCardLayoutBlueprint.make({ | ||
| name: 'sticky', | ||
| params: { | ||
| // (optional) defaults the `() => false` filter function | ||
| defaultFilter: 'kind:template' | ||
| loader: async () => StickyEntityContentOverviewLayout, | ||
| }, | ||
| }), | ||
| ], | ||
| ``` | ||
|
|
||
| Disabling the custom layout: | ||
|
|
||
| ```yaml | ||
| # app-config.yaml | ||
| app: | ||
| extensions: | ||
| - entity-card-layout:app/sticky: false | ||
| ``` | ||
|
|
||
| Overriding the custom layout filter: | ||
|
|
||
| ```yaml | ||
| # app-config.yaml | ||
| app: | ||
| extensions: | ||
| - entity-card-layout:app/sticky: | ||
| config: | ||
| # This layout will be used only with component entities | ||
| filter: 'kind:component' | ||
| ``` |
There was a problem hiding this comment.
Followup: let's move this to docs instead. It's a bit much for a changeset but useful content that should live longer than just the release notes. Some with some of the other changesets
| }, | ||
| })); | ||
|
|
||
| function StickyEntityContentOverviewLayout(props: EntityCardLayoutProps) { |
There was a problem hiding this comment.
Followup: Move this to be the default layout and add a different example here
| kind: 'entity-card-layout'; | ||
| name: undefined; | ||
| params: { | ||
| defaultFilter?: string | ((entity: Entity) => boolean) | undefined; |
There was a problem hiding this comment.
This doesn't line up with the rest, but might be better 🤔
Leaving as a followup to align these
| const entityCardLayoutComponentDataRef = createExtensionDataRef< | ||
| (props: EntityCardLayoutProps) => React.JSX.Element | ||
| >().with({ | ||
| id: 'catalog.entity-card-layout.component', |
| const ExtensionComponent = reactLazy(() => | ||
| loader().then(component => ({ default: component })), | ||
| ); |
There was a problem hiding this comment.
I think we can switch to ExtensionBoundary.lazy here
|
Thank you for contributing to Backstage! The changes in this pull request will be part of the |
Warning
Merge after #28701
Hey, I just made a Pull Request!
Implements the ability to install custom layouts for the default entity page overview tab.
Usage example
Creating this custom overview tab layout:
Disabling the custom layout:
Overriding the custom layout filter:
Overriding the about card default area, so it gets rendered in the info area:
Overriding the links card default area, so it gets rendered in the info area:
✔️ Checklist
Signed-off-byline in the message. (more info)