Skip to content

Commit

Permalink
Add Observability guides category and make sure empty categories are …
Browse files Browse the repository at this point in the history
…not visible on guides page (#531)

Part-of: keycloak/keycloak#35127

Signed-off-by: Michal Hajas <[email protected]>
  • Loading branch information
mhajas authored Nov 21, 2024
1 parent 172c9e6 commit e1b68ed
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 2 additions & 0 deletions guides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ guides:
title: Server
- id: operator
title: Operator
- id: observability
title: Observability
- id: securing-apps
title: Securing applications
- id: high-availability
Expand Down
4 changes: 2 additions & 2 deletions pages/guides.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<ul class="nav navbar-nav">
<#list guides.categories as c>
<#list guides.getCategories(false) as c>
<li>
<a class="nav-link" href="#${c.id}">${c.title}</a>
</li>
Expand All @@ -23,7 +23,7 @@

<div class="jumbotron jumbotron-fluid bg-light kc-bg-triangles pt-4">
<div class="container">
<#list guides.categories as c>
<#list guides.getCategories(false) as c>
<div class="row guide-category" id="${c.id}">
<h2>${c.title}</h2>
<#list guides.getGuides(c) as g>
Expand Down
4 changes: 2 additions & 2 deletions pages/nightly/guides.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<ul class="nav navbar-nav">
<#list guides.categories as c>
<#list guides.getCategories(true) as c>
<li>
<a class="nav-link" href="#${c.id}">${c.title}</a>
</li>
Expand All @@ -30,7 +30,7 @@
These guides are for the unstable nightly release, for the latest release go <a href="${links.guides}">here</a>.
</div>

<#list guides.categories as c>
<#list guides.getCategories(true) as c>
<div class="row guide-category" id="${c.id}">
<h2>${c.title}</h2>
<#list guides.getGuides(c) as g>
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/org/keycloak/webbuilder/Guides.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Predicate;
import java.util.stream.Collectors;

public class Guides {
Expand Down Expand Up @@ -132,8 +133,12 @@ public List<Guide> getGuides() {
return guides;
}

public List<GuidesMetadata.GuideMetadata> getCategories() {
return categories;
public List<GuidesMetadata.GuideMetadata> getCategories(boolean wantSnapshots) {
return categories.stream().filter(filterEmptyCategories(wantSnapshots)).collect(Collectors.toList());
}

private Predicate<GuidesMetadata.GuideMetadata> filterEmptyCategories(boolean wantSnapshots) {
return cat -> getGuides(cat).stream().anyMatch(guide-> guide.isSnapshot() == wantSnapshots);
}

public class Guide {
Expand Down

0 comments on commit e1b68ed

Please sign in to comment.