Skip to content

[NFS] Entity Page Content Layouts#28758

Merged
Rugvip merged 2 commits intomasterfrom
camilaibs/nfs-entity-page-layout
Feb 19, 2025
Merged

[NFS] Entity Page Content Layouts#28758
Rugvip merged 2 commits intomasterfrom
camilaibs/nfs-entity-page-layout

Conversation

@camilaibs
Copy link
Copy Markdown
Contributor

@camilaibs camilaibs commented Feb 7, 2025

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:

sticky entity content layout

import { StickyEntityContentOverviewLayout } from './StickyEntityContentOverviewLayout';
// ...

const customEntityContentOverviewStickyLayoutModule = createFrontendModule({
  pluginId: 'app',
  extensions: [
    EntityCardLayoutBlueprint.make({
      name: 'sticky',
      params: {
        loader: async () => StickyEntityContentOverviewLayout,
      },
    }),
  ],
});

Disabling the custom layout:

# app-config.yaml
app:
  extensions:
     - entity-card-layout:app/sticky: false

Overriding the custom layout filter:

# app-config.yaml
app:
  extensions:
     - entity-card-layout:app/sticky:
        config:
          # This layout will be used only with component entities
          filter: 'kind:component'

Overriding the about card default area, so it gets rendered in the info area:

# app-config-yaml
app:
  extensions:
    - entity-card:catalog/about:
        config:
          area: info

Overriding the links card default area, so it gets rendered in the info area:

# app-config-yaml
app:
  extensions:
    - entity-card:catalog/links:
        config:
          area: info

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)
  • All your commits have a Signed-off-by line in the message. (more info)

@camilaibs camilaibs changed the title [NFS] Custom Entity Page Overview Tab lLayout [NFS] Custom Entity Page Overview Tab Layout Feb 7, 2025
@github-actions github-actions Bot added the area:catalog Related to the Catalog Project Area label Feb 7, 2025
@camilaibs camilaibs force-pushed the camilaibs/nfs-entity-page-layout branch 4 times, most recently from fa62b71 to 1b08c4e Compare February 7, 2025 09:49
Comment thread plugins/catalog/src/alpha/entityContents.tsx Outdated
@camilaibs camilaibs force-pushed the camilaibs/nfs-entity-page-layout branch 4 times, most recently from ecc1a6e to f108d68 Compare February 13, 2025 07:46
@camilaibs camilaibs marked this pull request as ready for review February 13, 2025 08:14
@camilaibs camilaibs requested review from a team as code owners February 13, 2025 08:14
@camilaibs camilaibs requested review from freben and vinzscam and removed request for a team February 13, 2025 08:14
@camilaibs camilaibs force-pushed the camilaibs/nfs-entity-page-layout branch 4 times, most recently from 711d788 to c39b150 Compare February 13, 2025 09:22
dataRefs: {
filterFunction: entityFilterFunctionDataRef,
filterExpression: entityFilterExpressionDataRef,
area: entityCardAreaDataRef,
Copy link
Copy Markdown
Contributor Author

@camilaibs camilaibs Feb 13, 2025

Choose a reason for hiding this comment

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

@Rugvip I could not name it variant because it conflicts with cards that already expect that prop:

card variant name conflict

Should we use the info card variant as default values?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Followup in #28930

});

/** @alpha */
export const EntityCardLayoutBlueprint = createExtensionBlueprint({
Copy link
Copy Markdown
Contributor Author

@camilaibs camilaibs Feb 13, 2025

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yep let's go with EntityContentLayout, might leave for a followup depending on the potential for conflict with #28845

@camilaibs camilaibs force-pushed the camilaibs/nfs-entity-page-layout branch from c39b150 to 8c5e9d6 Compare February 13, 2025 09:32
Comment on lines +9 to +11
- `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).
Copy link
Copy Markdown
Contributor Author

@camilaibs camilaibs Feb 13, 2025

Choose a reason for hiding this comment

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

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.

@camilaibs camilaibs changed the title [NFS] Custom Entity Page Overview Tab Layout [NFS] Entit Page Content Layout Feb 15, 2025
@camilaibs camilaibs changed the title [NFS] Entit Page Content Layout [NFS] Entity Page Content Layout Feb 15, 2025
@camilaibs camilaibs changed the title [NFS] Entity Page Content Layout [NFS] Entity Page Content Layouts Feb 15, 2025
@camilaibs camilaibs added the workflow:after-release This is a bit too scary to merge until after the next release label Feb 15, 2025
@camilaibs camilaibs force-pushed the camilaibs/nfs-entity-content-groups branch from d781239 to 22ce741 Compare February 16, 2025 07:14
@camilaibs camilaibs requested review from a team and backstage-service as code owners February 16, 2025 07:14
@camilaibs camilaibs force-pushed the camilaibs/nfs-entity-page-layout branch from 8c5e9d6 to 0a1ce97 Compare February 16, 2025 07:14
camilaibs and others added 2 commits February 16, 2025 08:15
Signed-off-by: Camila Belo <camilaibs@gmail.com>
Co-authored-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: Camila Belo <camilaibs@gmail.com>
@camilaibs camilaibs force-pushed the camilaibs/nfs-entity-page-layout branch from 0a1ce97 to a3d93ca Compare February 16, 2025 07:16
@camilaibs camilaibs mentioned this pull request Feb 16, 2025
5 tasks
Base automatically changed from camilaibs/nfs-entity-content-groups to master February 19, 2025 14:19
Copy link
Copy Markdown
Member

@Rugvip Rugvip left a comment

Choose a reason for hiding this comment

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

👌 ✨

Couple of notes for followups but let's 🚢 & 🇮🇹

Comment on lines +12 to +99
### 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'
```
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Followup: Move this to be the default layout and add a different example here

Comment thread plugins/catalog-react/src/alpha/blueprints/EntityCardBlueprint.ts
kind: 'entity-card-layout';
name: undefined;
params: {
defaultFilter?: string | ((entity: Entity) => boolean) | undefined;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This doesn't line up with the rest, but might be better 🤔

Leaving as a followup to align these

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Followup in #28923

const entityCardLayoutComponentDataRef = createExtensionDataRef<
(props: EntityCardLayoutProps) => React.JSX.Element
>().with({
id: 'catalog.entity-card-layout.component',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reminder to update this too

Comment on lines +85 to +87
const ExtensionComponent = reactLazy(() =>
loader().then(component => ({ default: component })),
);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we can switch to ExtensionBoundary.lazy here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Followup in #28927

@Rugvip Rugvip merged commit 8f236fe into master Feb 19, 2025
@Rugvip Rugvip deleted the camilaibs/nfs-entity-page-layout branch February 19, 2025 19:59
@github-actions
Copy link
Copy Markdown
Contributor

Thank you for contributing to Backstage! The changes in this pull request will be part of the 1.37.0 release, scheduled for Tue, 18 Mar 2025.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:catalog Related to the Catalog Project Area workflow:after-release This is a bit too scary to merge until after the next release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants