Skip to content

Commit

Permalink
frontend: Filter out invalid link groups (#2906)
Browse files Browse the repository at this point in the history
<!--- TITLE FORMAT: "component: short description", e.g. "k8s: add pod
log reader" -->

### Description
<!-- Describe your change below. -->

Prevent malformed link groups to show up in QuickLinksCard component by
filtering out the invalid ones.

<!-- Reference previous related pull requests below. -->

<!-- [OPTIONAL] Include screenshots below for frontend changes. -->

### Testing Performed
<!-- Describe how you tested this change below. -->

Manual

### GitHub Issue
<!-- Link to any existing GitHub issues related to this PR. -->

N/A

### TODOs
<!-- Include any TODOs outstanding for the submission of this pull
request below. -->

<!--
Example:
- [ ] This is an item on my TODO list.
- [x] This is a completed item.
-->
  • Loading branch information
septum authored Jan 19, 2024
1 parent 986a3a4 commit a8b10a5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions frontend/packages/core/src/quick-links.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,15 @@ const SlicedLinkGroup = ({ slicedLinkGroups }: SlicedLinkGroupProps) => {
const QuickLinksCard = ({ linkGroups }: QuickLinksProps) => {
const anchorRef = React.useRef(null);
const [open, setOpen] = React.useState(false);

const filteredLinkGroups = linkGroups.filter(
lg => lg.links?.length > 0 && lg.name && lg.imagePath
);

// Show only the first five quick links, and put the rest in
// an overflow popper
const firstFive = linkGroups.slice(0, 5);
const overflow = linkGroups.slice(5);
const firstFive = filteredLinkGroups.slice(0, 5);
const overflow = filteredLinkGroups.slice(5);

return (
<Card>
Expand Down

0 comments on commit a8b10a5

Please sign in to comment.