Skip to content
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

🚀 Explore: Customize card list rendering (grouping, filtering, ordering, etc.) #2913

Open
2 tasks done
dotboris opened this issue Feb 14, 2025 · 0 comments
Open
2 tasks done
Labels
contribfest enhancement New feature or request help wanted Extra attention is needed

Comments

@dotboris
Copy link

dotboris commented Feb 14, 2025

Workspace

explore

🔖 Feature description

I'd like to be able to customize the Tools tab in the explore plugin. Specifically, I'd like to be able to groups into sections. While my use case is about grouping, I think that it's reasonable to also allow more in-depth customization including filtering, ordering and so on.

🎤 Context

In my org, we have a lot of tools and the tools page ends up being pretty large and overwhelming. We'd like to be able to organize it in groups / sections.

✌️ Possible Implementation

Mimic the Scaffolder plugin

The template list page supports something like this: https://backstage.io/docs/features/software-templates/configuration#customizing-the-scaffolderpage-with-grouping-and-filtering we could mimic this implementation. It would look something like this:

<ToolExplorerContent
  groups={[
    {
      title: "Section 1",
      filter: (tool) => tool.tags.includes("foo"),
    },
    {
      title: "Section 2",
      filter: (tool) => tool.tags.includes("bar"),
    },
  ]}
  filter={(tool) => tool.tags.include("hide-me")}
/>

This approach feels pretty easy to use and configure but every kind of customization requires changes to <ToolExplorerContent>.

Render props / Function as children

Another idea is to allow users to pass in a function to <ToolExplorerContent> to control the rendering. For example, it could look something like this:

<ToolExplorerContent>
  {({ tools, Card } => {
    const section1 = tools.filter(tool => tool.tags.includes("foo"))
    const section2 = tools.filter(tool => tool.tags.includes("bar"))
    const others = tools.filter(tool => !tool.tags.includes("foo") && !tool.tags.includes("bar")) // This logic is pretty messy not sure how to make this more elegant
    return (
      <>
        <Typography variant="h2">Section 1</Typography>
        <ItemCardGrid>
          {section1.map((tool, index) => <Card tool={tool} key={index}/>}
        </ItemCardGrid>
        <Typography variant="h2">Section 2</Typography>
        <ItemCardGrid>
          {section2.map((tool, index) => <Card tool={tool} key={index}/>}
        </ItemCardGrid>
        <Typography variant="h2">Others</Typography>
        <ItemCardGrid>
          {others.map((tool, index) => <Card tool={tool} key={index}/>}
        </ItemCardGrid>
      </>
    )
  }}
</ToolExplorerContent>

This pattern is very flexible because it allows grouping, sorting, filtering and so on. I think that it's a nice experience for people familiar with React but it's likely more cumbersome than the approach taken by the templates page.

👀 Have you spent some time to check if this feature request has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Are you willing to submit PR?

No, I don't have time to work on this right now

@dotboris dotboris added the enhancement New feature or request label Feb 14, 2025
@vinzscam vinzscam added help wanted Extra attention is needed contribfest labels Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribfest enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants