Skip to content

Commit

Permalink
MID-9380 Save and Preview changes buttons are always enabled when the…
Browse files Browse the repository at this point in the history
…y are visible

 Conflicts:
	gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/component/OperationalButtonsPanel.java
  • Loading branch information
KaterynaHonchar committed Jan 23, 2024
1 parent 5621b9b commit ed830a7
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ protected void showMainPopup(Popupable popupable, AjaxRequestTarget target) {
}

@Override
protected boolean isSavePreviewButtonEnabled() {
protected boolean isSaveButtonVisible() {
return !ItemStatus.NOT_CHANGED.equals(getModelObject().getStatus()) || getModelObject().canModify() ||
isAuthorizedToModify(); //this check was added due to MID-9380
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,7 @@ protected void onError(AjaxRequestTarget target) {
@Override
public boolean isVisible() {
return WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_PREVIEW_CHANGES_URL)
&& !getModelObject().isReadOnly();
}

@Override
public boolean isEnabled() {
return isSavePreviewButtonEnabled();
&& !getModelObject().isReadOnly() && isSaveButtonVisible();
}
});
preview.titleAsLabel(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,6 @@ protected void onError(AjaxRequestTarget target) {
public boolean isVisible() {
return isSaveButtonVisible();
}

@Override
public boolean isEnabled() {
return isSavePreviewButtonEnabled();
}
});
save.titleAsLabel(true);
save.setOutputMarkupId(true);
Expand All @@ -210,10 +205,6 @@ protected boolean isSaveButtonVisible() {
return !getModelObject().isReadOnly() && !isForcedPreview();
}

protected boolean isSavePreviewButtonEnabled() {
return true;
}

private boolean isForcedPreview() {
GuiObjectDetailsPageType objectDetails = getPageBase().getCompiledGuiProfile()
.findObjectDetailsConfiguration(getModelObject().getCompileTimeClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,13 @@ public UserOperationalButtonsPanel(String id, LoadableModel<PrismObjectWrapper<U
super(id, model, executeOptionsModel, isSelfProfile);
}

@Override
protected boolean isSavePreviewButtonEnabled() {
return isAuthorizedToModify() || super.isSavePreviewButtonEnabled();
}

@Override
protected boolean isAuthorizedToModify() {
try {
boolean selfModify = super.isAuthorizedToModify();
boolean thisObjectModify = super.isAuthorizedToModify();
boolean otherUserModify = getPageBase().isAuthorized(ModelAuthorizationAction.MODIFY.getUrl(),
AuthorizationPhaseType.EXECUTION, new UserType().asPrismObject(), null, null);
return selfModify || otherUserModify;
return thisObjectModify || otherUserModify;
} catch (Exception e) {
return false;
}
Expand Down

0 comments on commit ed830a7

Please sign in to comment.