Skip to content

Commit

Permalink
hide save button on preview changes page when development configurati…
Browse files Browse the repository at this point in the history
…on is used
  • Loading branch information
skublik committed Mar 25, 2024
1 parent 475f4a7 commit 6d164dd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public abstract class AbstractPageObjectDetails<O extends ObjectType, ODM extend
private static final String OPERATION_LOAD_OBJECT = DOT_CLASS + "loadObject";
protected static final String OPERATION_SAVE = DOT_CLASS + "save";
protected static final String OPERATION_PREVIEW_CHANGES = DOT_CLASS + "previewChanges";
protected static final String OPERATION_PREVIEW_CHANGES_WITH_DEV_CONFIG = DOT_CLASS + "previewChangesWithDevConfig";
protected static final String OPERATION_SEND_TO_SUBMIT = DOT_CLASS + "sendToSubmit";
protected static final String OPERATION_EXECUTE_ARCHETYPE_CHANGES = DOT_CLASS + "executeArchetypeChanges";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import java.time.Duration;
import java.util.*;

import com.evolveum.midpoint.schema.TaskExecutionMode;

import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.MarkupContainer;
import org.apache.wicket.Session;
Expand Down Expand Up @@ -139,7 +141,13 @@ public void savePerformed(AjaxRequestTarget target) {

public void previewPerformed(AjaxRequestTarget target) {
previewRequested = true;
OperationResult result = new OperationResult(OPERATION_PREVIEW_CHANGES);
OperationResult result;
if (getExecuteChangesOptionsDto() != null
&& TaskExecutionMode.SIMULATED_DEVELOPMENT.equals(getExecuteChangesOptionsDto().getTaskMode())) {
result = new OperationResult(OPERATION_PREVIEW_CHANGES_WITH_DEV_CONFIG);
} else {
result = new OperationResult(OPERATION_PREVIEW_CHANGES);
}
saveOrPreviewPerformed(target, result, true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import java.util.List;
import java.util.Map;

import com.evolveum.midpoint.schema.TaskExecutionMode;

import org.apache.wicket.Component;
import org.apache.wicket.RestartResponseException;
import org.apache.wicket.ajax.AjaxRequestTarget;
Expand Down Expand Up @@ -122,10 +124,19 @@ public void onClick(AjaxRequestTarget target) {
};
//save.add(new EnableBehaviour(() -> violationsEmpty())); // does not work as expected (MID-4252)

save.add(new VisibleBehaviour(() -> violationsEmpty())); // so hiding the button altogether
save.add(new VisibleBehaviour(() -> violationsEmpty() && isWithProductionConfiguration())); // so hiding the button altogether
mainForm.add(save);
}

private boolean isWithProductionConfiguration() {
for (ModelContext<O> modelContext : modelContextMap.values()) {
if (modelContext != null && TaskExecutionMode.SIMULATED_PRODUCTION.equals(modelContext.getTaskExecutionMode())) {
return true;
}
}
return false;
}

//TODO relocate the logic from the loop to some util method, code repeats in PreviewChangesTabPanel
private boolean violationsEmpty() {
for (ModelContext<O> modelContext : modelContextMap.values()) {
Expand Down

0 comments on commit 6d164dd

Please sign in to comment.