Skip to content

Commit

Permalink
disabling link for "edit" menu items.
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Sep 6, 2022
1 parent 5fa2279 commit 7bf02ef
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import java.util.*;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.gui.api.component.result.MessagePanel;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
Expand Down Expand Up @@ -1028,4 +1030,10 @@ public PrismObject<? extends FocusType> loadFocusSelf() {

return focus;
}

protected MessagePanel createMessagePanel(String panelId, MessagePanel.MessagePanelType type, String message, Object... params) {
MessagePanel panel = new MessagePanel(panelId, type,
createStringResource(message, params), false);
return panel;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,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 Down Expand Up @@ -622,7 +623,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 @@ -655,7 +658,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 @@ -40,6 +40,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 @@ -132,5 +137,11 @@ 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 @@ -6,6 +6,8 @@
*/
package com.evolveum.midpoint.web.component.menu;

import com.evolveum.midpoint.web.component.util.EnableBehaviour;

import org.apache.wicket.AttributeModifier;
import org.apache.wicket.IPageFactory;
import org.apache.wicket.Session;
Expand Down Expand Up @@ -130,6 +132,7 @@ public void onClick() {
menuItemPerformed(menuItem.getObject());
}
};
subLink.setEnabled(!menuItem.getObject().isDynamic());
subLink.add(AttributeModifier.append("class", () -> menuItem.getObject().isMenuActive(getPageBase()) ? "active" : null));
listItem.add(subLink);

Expand Down

0 comments on commit 7bf02ef

Please sign in to comment.