Skip to content

Commit

Permalink
Merge branch 'main' into issues/19321-menu-api
Browse files Browse the repository at this point in the history
  • Loading branch information
caalador authored May 13, 2024
2 parents bfa8575 + e8f91fc commit 70cc592
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 11 deletions.
6 changes: 3 additions & 3 deletions flow-server/src/main/java/com/vaadin/flow/router/Menu.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@
/**
* Used to determine the order in the menu. Ties are resolved based on the
* used title. Entries without explicitly defined ordering are put below
* entries with an order. {@link Long#MIN_VALUE} is the default value and
* entries with an order. {@link Double#MIN_VALUE} is the default value and
* considered as undefined.
*
* @return the order of the item in the menu. {@link Long#MIN_VALUE} by
* @return the order of the item in the menu. {@link Double#MIN_VALUE} by
* default.
*/
long order() default Long.MIN_VALUE;
double order() default Double.MIN_VALUE;

/**
* Icon to use in the menu. Value can go inside a {@code <vaadin-icon>}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/
public record MenuData(String title, Long order, boolean exclude, String icon) implements Serializable {


/**
* Gets the title of the menu item.
*
Expand All @@ -40,7 +41,7 @@ public String getTitle() {
*
* @return the order of the menu item
*/
public Long getOrder() {
public Double getOrder() {
return order;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,8 @@ private void populateRegisteredRoutes(ConfiguredRoutes configuration,
MenuData menuData = AnnotationReader
.getAnnotationFor(target, Menu.class)
.map(menu -> new MenuData(menu.title(),
(menu.order() == Long.MIN_VALUE) ? null : menu.order(),
(Objects.equals(menu.order(), Double.MIN_VALUE)) ? null
: menu.order(),
false, menu.icon()))
.orElse(null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ interface Properties {
* @param onload optional callback to be called for script onload
* @param onerror optional callback for error loading the script
*/
export const createWebComponent = (tag: string, props?: Properties, onload?: () => void, onerror?: (err:any) => void) => {
export const reactElement = (tag: string, props?: Properties, onload?: () => void, onerror?: (err:any) => void) => {
loadComponentScript(tag).then(() => onload?.(), (err) => {
if(onerror) {
onerror(err);
Expand Down
2 changes: 1 addition & 1 deletion flow-tests/vaadin-spring-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<properties>
<maven.deploy.skip>true</maven.deploy.skip>
<component.version>24.3.11</component.version>
<nimbus-jose-jwt.version>9.38</nimbus-jose-jwt.version>
<nimbus-jose-jwt.version>9.39</nimbus-jose-jwt.version>
</properties>

<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@Route(value = "admin", layout = MainView.class)
@RouteAlias(value = "alias-for-admin", layout = MainView.class)
@PageTitle("Admin View")
@Menu(order = 3)
@Menu(order = 1.10001)
public class AdminView extends VerticalLayout {

public AdminView(SecurityUtils securityUtils) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
@Route(value = "private", layout = MainView.class)
@RouteAlias(value = "privateAndForbiddenForAll")
@PageTitle("Private View")
@Menu(order = 2)
@Menu(order = 1.1)
public class PrivateView extends VerticalLayout {

private BankService bankService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,9 @@ public void client_menu_routes_correct_for_admin() {
private void assertMenuListContains(String expected) {
TestBenchElement menuList = waitUntil(driver -> $("*").id("menu-list"));
String menuListText = menuList.getText();
Assert.assertTrue(menuListText.contains(expected));
Assert.assertTrue(
"Expected " + expected + " but actual is " + menuListText,
menuListText.contains(expected));
}

private void navigateToClientMenuList() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
@Route(value = "private", layout = MainView.class)
@PageTitle("Private View")
@PermitAll
@Menu(order = 2)
@Menu(order = 1.5)
public class PrivateView extends VerticalLayout {

private BankService bankService;
Expand Down

0 comments on commit 70cc592

Please sign in to comment.