Skip to content

Commit

Permalink
fix: add usage stats for dynamic menu entries (#20212)
Browse files Browse the repository at this point in the history
Fixes: #20209
  • Loading branch information
tltv authored Oct 11, 2024
1 parent b2993c2 commit cc926d5
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.Tag;
import com.vaadin.flow.component.UI;
import com.vaadin.flow.internal.UsageStatistics;
import com.vaadin.flow.internal.menu.MenuRegistry;
import com.vaadin.flow.router.HasDynamicTitle;
import com.vaadin.flow.router.PageTitle;
Expand All @@ -39,13 +40,16 @@
*/
public final class MenuConfiguration {

private static final String STATISTICS_DYNAMIC_MENU_ENTRIES = "flow/dynamic-menu-entries";

/**
* Collect ordered list of menu entries for menu population. All client
* views are collected and any accessible server views.
*
* @return ordered list of {@link MenuEntry} instances
*/
public static List<MenuEntry> getMenuEntries() {
UsageStatistics.markAsUsed(STATISTICS_DYNAMIC_MENU_ENTRIES, null);
return MenuRegistry.collectMenuItemsList().stream()
.map(MenuConfiguration::createMenuEntry).toList();
}
Expand All @@ -60,6 +64,7 @@ public static List<MenuEntry> getMenuEntries() {
* @return ordered list of {@link MenuEntry} instances
*/
public static List<MenuEntry> getMenuEntries(Locale locale) {
UsageStatistics.markAsUsed(STATISTICS_DYNAMIC_MENU_ENTRIES, null);
return MenuRegistry.collectMenuItemsList(locale).stream()
.map(MenuConfiguration::createMenuEntry).toList();
}
Expand Down

0 comments on commit cc926d5

Please sign in to comment.