Skip to content

Commit

Permalink
feat: added check to update only internal menuitem urls (onecx#59)
Browse files Browse the repository at this point in the history
* feat: added check to update only internal menuitem urls

* fix: boolean expression
  • Loading branch information
JordenReuter authored Apr 18, 2024
1 parent 5bee8cf commit 54905a0
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ default UserWorkspaceMenuStructureDTO mapTree(Workspace workspace, Collection<Me
}
items.forEach(menuItem -> {
if (menuItem.getUrl() != null) {
menuItem.setUrl(workspace.getBaseUrl() + menuItem.getUrl());
menuItem.setUrl(updateInternalUrl(workspace.getBaseUrl(), menuItem.getUrl(), menuItem.isExternal()));
}
menuItem = updateUrl(menuItem, workspace.getBaseUrl());
});
Expand All @@ -54,13 +54,21 @@ default UserWorkspaceMenuStructureDTO mapTree(Workspace workspace, Collection<Me
default MenuItem updateUrl(MenuItem menuItem, String workspaceUrl) {
if (!menuItem.getChildren().isEmpty()) {
menuItem.getChildren().forEach(menuItemChild -> {
menuItemChild.setUrl(workspaceUrl + menuItemChild.getUrl());
menuItemChild.setUrl(updateInternalUrl(workspaceUrl, menuItemChild.getUrl(), menuItemChild.isExternal()));
updateUrl(menuItemChild, workspaceUrl);
});
}
return menuItem;
}

default String updateInternalUrl(String workspaceUrl, String menuItemUrl, Boolean isExternal) {
if (Boolean.TRUE.equals(isExternal)) {
return menuItemUrl;
} else {
return workspaceUrl + menuItemUrl;
}
}

default Set<MenuItem> filterMenu(Set<MenuItem> items, Map<String, Set<String>> mapping, Set<String> roles) {
Set<MenuItem> tmp = new HashSet<>(items);
tmp.forEach(m -> {
Expand Down

0 comments on commit 54905a0

Please sign in to comment.