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

chore: remove exclude from MenuEntry #20166

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ public static List<MenuEntry> getMenuEntries(Locale locale) {

private static MenuEntry createMenuEntry(AvailableViewInfo viewInfo) {
if (viewInfo.menu() == null) {
return new MenuEntry(viewInfo.route(), viewInfo.title(), null,
false, null, null);
return new MenuEntry(viewInfo.route(), viewInfo.title(), null, null,
null);
}
return new MenuEntry(viewInfo.route(),
(viewInfo.menu().title() != null
&& !viewInfo.menu().title().isBlank()
? viewInfo.menu().title()
: viewInfo.title()),
viewInfo.menu().order(), viewInfo.menu().exclude(),
viewInfo.menu().icon(), viewInfo.menu().menuClass());
viewInfo.menu().order(), viewInfo.menu().icon(),
viewInfo.menu().menuClass());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
* the title to display
* @param order
* the order in the menu or null for default order
* @param exclude
* whether to exclude the menu entry
* @param icon
* Icon to use in the menu or null for no icon. Value can go inside a
* {@code <vaadin-icon>} element's {@code icon} attribute which
Expand All @@ -43,5 +41,5 @@
* Hilla/TypeScript client views.
*/
public record MenuEntry(String path, String title, Double order,
boolean exclude, String icon, Class<? extends Component> menuClass) implements Serializable {
String icon, Class<? extends Component> menuClass) implements Serializable {
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void getMenuItemsList_returnsCorrectPaths() throws IOException {

Map<String, MenuEntry> mapMenuItems = menuEntries.stream()
.collect(Collectors.toMap(MenuEntry::path, item -> item));
assertClientRoutes(mapMenuItems, false, false, true);
assertClientRoutes(mapMenuItems, false, false);
assertServerRoutes(mapMenuItems);
assertServerRoutesWithParameters(mapMenuItems, true);
}
Expand Down Expand Up @@ -188,7 +188,7 @@ private void assertOrder(List<MenuEntry> menuEntries,
}

private void assertClientRoutes(Map<String, MenuEntry> menuOptions,
boolean authenticated, boolean hasRole, boolean excludeExpected) {
boolean authenticated, boolean hasRole) {
Assert.assertTrue("Client route '' missing",
menuOptions.containsKey(""));
Assert.assertEquals("Public", menuOptions.get("").title());
Expand Down Expand Up @@ -221,17 +221,8 @@ private void assertClientRoutes(Map<String, MenuEntry> menuOptions,
menuOptions.containsKey("/hilla"));
}

if (excludeExpected) {
Assert.assertFalse("Client route 'login' should be excluded",
menuOptions.containsKey("/login"));
} else {
Assert.assertTrue("Client route 'login' missing",
menuOptions.containsKey("/login"));
Assert.assertEquals("Login", menuOptions.get("/login").title());
Assert.assertNull(menuOptions.get("/login").title());
Assert.assertTrue("Login view should be excluded",
menuOptions.get("/login").exclude());
}
Assert.assertFalse("Client route 'login' should be excluded",
menuOptions.containsKey("/login"));
}

private void assertServerRoutes(Map<String, MenuEntry> menuItems) {
Expand All @@ -257,32 +248,14 @@ private void assertServerRoutesWithParameters(
Assert.assertFalse(
"Server route '/param/:param1' should be excluded",
menuItems.containsKey("/param/:param1"));
} else {
Assert.assertTrue("Server route '/param/:param' missing",
menuItems.containsKey("/param/:param"));
Assert.assertTrue(
"Server route '/param/:param' should be excluded from menu",
menuItems.get("/param/:param").exclude());

Assert.assertTrue("Server route '/param/:param1' missing",
menuItems.containsKey("/param/:param1"));
Assert.assertTrue(
"Server route '/param/:param1' should be excluded from menu",
menuItems.get("/param/:param1").exclude());
}

Assert.assertTrue(
"Server route with optional parameters '/param' missing",
menuItems.containsKey("/param"));
Assert.assertFalse(
"Server route '/param' should be included in the menu",
menuItems.get("/param").exclude());

Assert.assertTrue(
"Server route with optional parameters '/param/varargs' missing",
menuItems.containsKey("/param/varargs"));
Assert.assertFalse(
"Server route '/param/varargs' should be included in the menu",
menuItems.get("/param/varargs").exclude());
}
}
Loading