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
  • Loading branch information
KaterynaHonchar committed Jan 23, 2024
1 parent 815178c commit c1ac6c6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,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 @@ -90,12 +90,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 @@ -213,7 +213,7 @@ protected void onError(AjaxRequestTarget target) {
}
};

save.add(new VisibleEnableBehaviour(this::isSaveButtonVisible, this::isSavePreviewButtonEnabled));
save.add(new VisibleBehaviour(this::isSaveButtonVisible));
save.titleAsLabel(true);
save.setOutputMarkupId(true);
save.add(AttributeAppender.append("class", "btn btn-success btn-sm"));
Expand All @@ -233,10 +233,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 c1ac6c6

Please sign in to comment.