Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/support-3.7' into support-3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Jul 26, 2018
2 parents 4c3d99c + 0ad7321 commit 35312cf
Show file tree
Hide file tree
Showing 12 changed files with 1,171 additions and 57 deletions.
Expand Up @@ -25,6 +25,8 @@
import com.evolveum.midpoint.prism.PrismContainerValue;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.objectdetails.FocusMainPanel;
import com.evolveum.midpoint.web.component.prism.*;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
Expand Down Expand Up @@ -86,6 +88,8 @@ public abstract class AssignmentPanel extends BasePanel<ContainerWrapper<Assignm
private final static String ID_DONE_BUTTON = "doneButton";
private final static String ID_CANCEL_BUTTON = "cancelButton";

private static final Trace LOGGER = TraceManager.getTrace(AssignmentPanel.class);

protected boolean assignmentDetailsVisible;
private List<ContainerValueWrapper<AssignmentType>> detailsPanelAssignmentsList = new ArrayList<>();

Expand Down Expand Up @@ -185,7 +189,8 @@ protected List<ContainerValueWrapper<AssignmentType>> searchThroughList() {
};

List<IColumn<ContainerValueWrapper<AssignmentType>, String>> columns = initBasicColumns();
columns.add(new InlineMenuButtonColumn<ContainerValueWrapper<AssignmentType>>(getAssignmentMenuActions(), 2, getPageBase()));
List<InlineMenuItem> menuActionsList = getAssignmentMenuActions();
columns.add(new InlineMenuButtonColumn<>(menuActionsList, menuActionsList.size(), getPageBase()));

BoxedTablePanel<ContainerValueWrapper<AssignmentType>> assignmentTable = new BoxedTablePanel<ContainerValueWrapper<AssignmentType>>(ID_ASSIGNMENTS_TABLE,
assignmentsProvider, columns, getTableId(), getItemsPerPage()) {
Expand Down Expand Up @@ -375,12 +380,31 @@ private List<ContainerValueWrapper<AssignmentType>> getSelectedAssignments() {

private List<InlineMenuItem> getAssignmentMenuActions() {
List<InlineMenuItem> menuItems = new ArrayList<>();
menuItems.add(new InlineMenuItem(createStringResource("PageBase.button.unassign"), new Model<Boolean>(true),
new Model<Boolean>(true), false, createDeleteColumnAction(), 0, GuiStyleConstants.CLASS_DELETE_MENU_ITEM,
DoubleButtonColumn.BUTTON_COLOR_CLASS.DANGER.toString()));
menuItems.add(new InlineMenuItem(createStringResource("PageBase.button.edit"), new Model<Boolean>(true),
new Model<Boolean>(true), false, createEditColumnAction(), 1, GuiStyleConstants.CLASS_EDIT_MENU_ITEM,
DoubleButtonColumn.BUTTON_COLOR_CLASS.DEFAULT.toString()));
PrismObject obj = getFocusObject();
boolean isUnassignMenuAdded = false;
try {
boolean isUnassignAuthorized = getParentPage().isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_UNASSIGN_ACTION_URI,
AuthorizationPhaseType.REQUEST, obj,
null, null, null);
if (isUnassignAuthorized) {
menuItems.add(new InlineMenuItem(createStringResource("PageBase.button.unassign"), new Model<Boolean>(true),
new Model<Boolean>(true), false, createDeleteColumnAction(), 0, GuiStyleConstants.CLASS_DELETE_MENU_ITEM,
DoubleButtonColumn.BUTTON_COLOR_CLASS.DANGER.toString()));
isUnassignMenuAdded = true;
}

} catch (Exception ex){
LOGGER.error("Couldn't check unassign authorization for the object: {}, {}", obj.getName(), ex.getLocalizedMessage());
if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_ASSIGN_ACTION_URI)){
menuItems.add(new InlineMenuItem(createStringResource("PageBase.button.unassign"), new Model<>(true),
new Model<>(true), false, createDeleteColumnAction(), 0, GuiStyleConstants.CLASS_DELETE_MENU_ITEM,
DoubleButtonColumn.BUTTON_COLOR_CLASS.DANGER.toString()));
isUnassignMenuAdded = true;
}
}
menuItems.add(new InlineMenuItem(createStringResource("PageBase.button.edit"), new Model<Boolean>(true),
new Model<Boolean>(true), false, createEditColumnAction(), isUnassignMenuAdded ? 1 : 0, GuiStyleConstants.CLASS_EDIT_MENU_ITEM,
DoubleButtonColumn.BUTTON_COLOR_CLASS.DEFAULT.toString()));
return menuItems;
}

Expand Down

0 comments on commit 35312cf

Please sign in to comment.