Skip to content

Commit 83ccb0c

Browse files
vaadin-bottltv
andauthored
fix: change type of Menu order to double (#19332) (#19357)
Changing `Menu#order` type double and `MenuData#order` type to Double to match it with Hilla's `ViewConfig` type `number`. Fixes: #19320 Co-authored-by: Tomi Virtanen <tltv@vaadin.com>
1 parent e09dd4f commit 83ccb0c

File tree

7 files changed

+14
-11
lines changed

7 files changed

+14
-11
lines changed

flow-server/src/main/java/com/vaadin/flow/router/Menu.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@
5050
/**
5151
* Used to determine the order in the menu. Ties are resolved based on the
5252
* used title. Entries without explicitly defined ordering are put below
53-
* entries with an order. {@link Long#MIN_VALUE} is the default value and
53+
* entries with an order. {@link Double#MIN_VALUE} is the default value and
5454
* considered as undefined.
5555
*
56-
* @return the order of the item in the menu. {@link Long#MIN_VALUE} by
56+
* @return the order of the item in the menu. {@link Double#MIN_VALUE} by
5757
* default.
5858
*/
59-
long order() default Long.MIN_VALUE;
59+
double order() default Double.MIN_VALUE;
6060

6161
/**
6262
* Icon to use in the menu. Value can go inside a {@code <vaadin-icon>}

flow-server/src/main/java/com/vaadin/flow/router/MenuData.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
public class MenuData implements Serializable {
2828

2929
private final String title;
30-
private final Long order;
30+
private final Double order;
3131
private final boolean exclude;
3232
private final String icon;
3333

@@ -43,7 +43,7 @@ public class MenuData implements Serializable {
4343
* @param icon
4444
* the icon of the menu item
4545
*/
46-
public MenuData(String title, Long order, boolean exclude, String icon) {
46+
public MenuData(String title, Double order, boolean exclude, String icon) {
4747
this.title = title;
4848
this.order = order;
4949
this.exclude = exclude;
@@ -64,7 +64,7 @@ public String getTitle() {
6464
*
6565
* @return the order of the menu item
6666
*/
67-
public Long getOrder() {
67+
public Double getOrder() {
6868
return order;
6969
}
7070

flow-server/src/main/java/com/vaadin/flow/router/internal/AbstractRouteRegistry.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,8 @@ private void populateRegisteredRoutes(ConfiguredRoutes configuration,
309309
MenuData menuData = AnnotationReader
310310
.getAnnotationFor(target, Menu.class)
311311
.map(menu -> new MenuData(menu.title(),
312-
(menu.order() == Long.MIN_VALUE) ? null : menu.order(),
312+
(Objects.equals(menu.order(), Double.MIN_VALUE)) ? null
313+
: menu.order(),
313314
false, menu.icon()))
314315
.orElse(null);
315316

flow-tests/vaadin-spring-tests/test-spring-security-flow-routepathaccesschecker/src/main/java/com/vaadin/flow/spring/flowsecurity/views/AdminView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
@Route(value = "admin", layout = MainView.class)
1515
@RouteAlias(value = "alias-for-admin", layout = MainView.class)
1616
@PageTitle("Admin View")
17-
@Menu(order = 3)
17+
@Menu(order = 1.10001)
1818
public class AdminView extends VerticalLayout {
1919

2020
public AdminView(SecurityUtils securityUtils) {

flow-tests/vaadin-spring-tests/test-spring-security-flow-routepathaccesschecker/src/main/java/com/vaadin/flow/spring/flowsecurity/views/PrivateView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
@Route(value = "private", layout = MainView.class)
3636
@RouteAlias(value = "privateAndForbiddenForAll")
3737
@PageTitle("Private View")
38-
@Menu(order = 2)
38+
@Menu(order = 1.1)
3939
public class PrivateView extends VerticalLayout {
4040

4141
private BankService bankService;

flow-tests/vaadin-spring-tests/test-spring-security-flow-routepathaccesschecker/src/test/java/com/vaadin/flow/spring/flowsecurity/AppViewIT.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,9 @@ public void client_menu_routes_correct_for_admin() {
341341
private void assertMenuListContains(String expected) {
342342
TestBenchElement menuList = waitUntil(driver -> $("*").id("menu-list"));
343343
String menuListText = menuList.getText();
344-
Assert.assertTrue(menuListText.contains(expected));
344+
Assert.assertTrue(
345+
"Expected " + expected + " but actual is " + menuListText,
346+
menuListText.contains(expected));
345347
}
346348

347349
private void navigateToClientMenuList() {

flow-tests/vaadin-spring-tests/test-spring-security-flow/src/main/java/com/vaadin/flow/spring/flowsecurity/views/PrivateView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
@Route(value = "private", layout = MainView.class)
3535
@PageTitle("Private View")
3636
@PermitAll
37-
@Menu(order = 2)
37+
@Menu(order = 1.5)
3838
public class PrivateView extends VerticalLayout {
3939

4040
private BankService bankService;

0 commit comments

Comments
 (0)