Skip to content

Commit

Permalink
disabling link for "edit" menu items (related to MID-8075)
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Sep 6, 2022
1 parent 6925541 commit b578f6f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ private void createFocusPageNewEditMenu(MainMenuItem mainMenuItem, String newKey
boolean editActive = classMatches(newPageClass) && (isEditForAdminObjectDetails() || isEditForResourceWizzard());
if (editActive) {
MenuItem edit = new MenuItem(editKey, newPageClass);
edit.setDynamic(true);
mainMenuItem.addMenuItem(edit);
}
}
Expand All @@ -518,7 +519,9 @@ private boolean classMatches(Class<? extends PageBase> page) {
private void createFocusPageViewMenu(MainMenuItem mainMenuItem, String viewKey, final Class<? extends PageBase> newPageType) {
boolean editActive = classMatches(newPageType);
if (editActive) {
mainMenuItem.addMenuItem(new MenuItem(viewKey, newPageType));
MenuItem editMenuItem = new MenuItem(viewKey, newPageType);
editMenuItem.setDynamic(true);
mainMenuItem.addMenuItem(editMenuItem);
}
}

Expand Down Expand Up @@ -547,7 +550,9 @@ private MainMenuItem createRepositoryObjectsMenu() {
repositoryObjectsMenu.addMenuItem(new MenuItem("PageAdmin.menu.top.configuration.repositoryObjectsList", PageDebugList.class));
boolean editActive = classMatches(PageDebugView.class);
if (editActive) {
repositoryObjectsMenu.addMenuItem(new MenuItem("PageAdmin.menu.top.configuration.repositoryObjectView", PageDebugView.class));
MenuItem editMenuItem = new MenuItem("PageAdmin.menu.top.configuration.repositoryObjectView", PageDebugView.class);
editMenuItem.setDynamic(true);
repositoryObjectsMenu.addMenuItem(editMenuItem);
}
return repositoryObjectsMenu;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ public class BaseMenuItem implements Serializable {
*/
private transient Integer displayOrder;

/**
* if the menu is generated dynamically, typically it is edit user, edit role, ...
*/
private boolean dynamic;

public BaseMenuItem(String nameModel, String iconClass, Class<? extends WebPage> pageClass,
PageParameters params, Class<? extends WebPage>... aliases) {
this.aliases = aliases;
Expand Down Expand Up @@ -131,5 +136,12 @@ public String toString() {
+ ", active=" + active + ", aliases=" + Arrays.toString(aliases) + ")";
}

public void setDynamic(boolean dynamic) {
this.dynamic = dynamic;
}

public boolean isDynamic() {
return dynamic;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ public void onClick() {
}
};
listItem.add(subLink);
subLink.setEnabled(!menuItem.getObject().isDynamic());


WebMarkupContainer subLinkIcon = new WebMarkupContainer(ID_SUB_LINK_ICON);
subLinkIcon.add(AttributeAppender.append("class", new PropertyModel<>(menuItem, MainMenuItem.F_ICON_CLASS)));
Expand Down

0 comments on commit b578f6f

Please sign in to comment.