Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
* 'master' of github.com:Evolveum/midpoint:
  removed userDashboardLink from initial sys config; different small fixes for dashboard
  SubscriptionUtil: making checkstyle happy, now with truly final map
  added subscription-less footer to reports, cleanup around subs.type code
  fix new translations
  more updates for initial enduser role and dashboard
  • Loading branch information
katkav committed Aug 19, 2022
2 parents aa9c001 + 1f7cd2d commit 0733641
Show file tree
Hide file tree
Showing 31 changed files with 336 additions and 408 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ <h5 class="text-secondary mb-5" wicket:id="subText"/>
<i class="fas fa-right-from-bracket mr-2"></i>
<wicket:message key="WizardPanel.exit"/>
</a>
<a class="btn btn-success" wicket:id="finish">
<i class="fas fa-flag-checkered ml-2"/>
<wicket:message key="WizardPanel.finish"/>
<a class="btn btn-success" wicket:id="submit">
<i class="fas fa-check ml-2"/>
<span wicket:id="submitLabel"/>
</a>
<a class="btn btn-success" wicket:id="next">
<wicket:message key="WizardHeader.next"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public class BasicWizardStepPanel<T> extends WizardStepPanel<T> {
private static final String ID_BACK = "back";
private static final String ID_EXIT = "exit";

private static final String ID_FINISH = "finish";
private static final String ID_SUBMIT = "submit";
private static final String ID_SUBMIT_LABEL = "submitLabel";
private static final String ID_NEXT = "next";
private static final String ID_NEXT_LABEL = "nextLabel";

Expand Down Expand Up @@ -83,7 +84,7 @@ public void onClick(AjaxRequestTarget target) {
WebComponentUtil.addDisabledClassBehavior(exit);
add(exit);

AjaxSubmitButton finish = new AjaxSubmitButton(ID_FINISH) {
AjaxSubmitButton submit = new AjaxSubmitButton(ID_SUBMIT) {

@Override
public void onSubmit(AjaxRequestTarget target) {
Expand All @@ -95,11 +96,14 @@ protected void onError(AjaxRequestTarget target) {
updateFeedbackPanels(target);
}
};
finish.add(new VisibleBehaviour(() -> isFinishVisible()));
finish.setOutputMarkupId(true);
finish.setOutputMarkupPlaceholderTag(true);
WebComponentUtil.addDisabledClassBehavior(finish);
add(finish);
submit.add(new VisibleBehaviour(() -> isSubmitVisible()));
submit.setOutputMarkupId(true);
submit.setOutputMarkupPlaceholderTag(true);
WebComponentUtil.addDisabledClassBehavior(submit);
add(submit);

Label submitLabel = new Label(ID_SUBMIT_LABEL, getSubmitLabelModel());
submit.add(submitLabel);

AjaxSubmitButton next = new AjaxSubmitButton(ID_NEXT) {

Expand All @@ -123,12 +127,16 @@ protected void onError(AjaxRequestTarget target) {
next.add(nextLabel);
}

protected IModel<?> getSubmitLabelModel() {
return getPageBase().createStringResource("WizardPanel.submit");
}

@Override
public VisibleEnableBehaviour getNextBehaviour() {
return new VisibleEnableBehaviour(() -> !isFinishVisible());
return new VisibleEnableBehaviour(() -> !isSubmitVisible());
}

private boolean isFinishVisible() {
private boolean isSubmitVisible() {
return getWizard().getNextPanel() == null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
import com.evolveum.midpoint.schema.internals.InternalsConfig;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.MiscSchemaUtil;
import com.evolveum.midpoint.schema.util.SubscriptionUtil;
import com.evolveum.midpoint.schema.util.SubscriptionUtil.SubscriptionType;
import com.evolveum.midpoint.security.api.AuthorizationConstants;
import com.evolveum.midpoint.security.api.MidPointPrincipal;
import com.evolveum.midpoint.security.api.OwnerResolver;
Expand Down Expand Up @@ -328,13 +328,11 @@ public String getDescribe() {

@Override
public String getObject() {
String subscriptionId = getSubscriptionId();
if (!SubscriptionUtil.isSubscriptionIdCorrect(subscriptionId)) {
SubscriptionType subscriptionType = MidPointApplication.get().getSubscriptionType();
if (!subscriptionType.isCorrect()) {
return " " + createStringResource("PageBase.nonActiveSubscriptionMessage").getString();
}
assert subscriptionId != null;
if (SubscriptionUtil.SubscriptionType.DEMO_SUBSCRIPTION.getSubscriptionType()
.equals(subscriptionId.substring(0, 2))) {
if (subscriptionType == SubscriptionType.DEMO_SUBSCRIPTION) {
return " " + createStringResource("PageBase.demoSubscriptionMessage").getString();
}
return "";
Expand All @@ -357,18 +355,9 @@ public boolean isVisible() {
}

private boolean isFooterVisible() {
String subscriptionId = getSubscriptionId();
if (StringUtils.isEmpty(subscriptionId)) {
return true;
}
return !SubscriptionUtil.isSubscriptionIdCorrect(subscriptionId) ||
(SubscriptionUtil.SubscriptionType.DEMO_SUBSCRIPTION.getSubscriptionType().equals(subscriptionId.substring(0, 2))
&& SubscriptionUtil.isSubscriptionIdCorrect(subscriptionId));
}

private String getSubscriptionId() {
DeploymentInformationType info = MidPointApplication.get().getDeploymentInfo();
return info != null ? info.getSubscriptionIdentifier() : null;
SubscriptionType subscriptionType = MidPointApplication.get().getSubscriptionType();
return !subscriptionType.isCorrect()
|| subscriptionType == SubscriptionType.DEMO_SUBSCRIPTION;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@
import java.util.*;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.gui.api.component.wizard.WizardModel;
import com.evolveum.midpoint.gui.api.component.wizard.WizardPanel;
import com.evolveum.midpoint.gui.impl.page.self.PageRequestAccess;

import com.evolveum.midpoint.gui.impl.page.self.requestAccess.ShoppingCartPanel;
import com.evolveum.midpoint.web.component.util.EnableBehaviour;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
Expand Down Expand Up @@ -44,11 +37,14 @@
import com.evolveum.midpoint.common.validator.EventResult;
import com.evolveum.midpoint.common.validator.LegacyValidator;
import com.evolveum.midpoint.gui.api.GuiStyleConstants;
import com.evolveum.midpoint.gui.api.component.wizard.WizardModel;
import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.gui.impl.component.menu.LeftMenuPanel;
import com.evolveum.midpoint.gui.impl.page.self.PageRequestAccess;
import com.evolveum.midpoint.gui.impl.page.self.requestAccess.ShoppingCartPanel;
import com.evolveum.midpoint.gui.impl.prism.panel.ItemPanelSettings;
import com.evolveum.midpoint.gui.impl.prism.panel.PrismContainerValuePanel;
import com.evolveum.midpoint.model.api.authentication.CompiledGuiProfile;
Expand All @@ -67,8 +63,6 @@
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.Holder;
import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.application.AsyncWebProcessManager;
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.AjaxIconButton;
Expand All @@ -80,6 +74,7 @@
import com.evolveum.midpoint.web.component.menu.SideBarMenuItem;
import com.evolveum.midpoint.web.component.menu.top.LocalePanel;
import com.evolveum.midpoint.web.component.message.FeedbackAlerts;
import com.evolveum.midpoint.web.component.util.EnableBehaviour;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;
import com.evolveum.midpoint.web.page.error.PageError404;
import com.evolveum.midpoint.web.page.self.PageAssignmentsList;
Expand Down Expand Up @@ -130,8 +125,6 @@ public abstract class PageBase extends PageAdminLTE {
public static final String PARAMETER_DASHBOARD_WIDGET_NAME = "dashboardWidgetName";
public static final String PARAMETER_SEARCH_BY_NAME = "name";

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

private List<Breadcrumb> breadcrumbs;

private boolean initialized = false;
Expand Down Expand Up @@ -181,36 +174,6 @@ public PageBase() {
this(null);
}

// public <O extends ObjectType> boolean isAuthorized(ModelAuthorizationAction action, PrismObject<O> object) {
// try {
// return isAuthorized(AuthorizationConstants.AUTZ_ALL_URL, null, null, null, null, null)
// || isAuthorized(action.getUrl(), null, object, null, null, null);
// } catch (SchemaException | ExpressionEvaluationException | ObjectNotFoundException | CommunicationException |
// ConfigurationException | SecurityViolationException e) {
// LoggingUtils.logUnexpectedException(LOGGER, "Couldn't determine authorization for {}", e, action);
// return true; // it is only GUI thing
// }
// }
//
// public boolean isAuthorized(String operationUrl) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException {
// return isAuthorized(operationUrl, null, null, null, null, null);
// }
//
// public <O extends ObjectType, T extends ObjectType> boolean isAuthorized(String operationUrl, AuthorizationPhaseType phase,
// PrismObject<O> object, ObjectDelta<O> delta, PrismObject<T> target, OwnerResolver ownerResolver) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException {
// Task task = getPageTask();
// AuthorizationParameters<O, T> params = new AuthorizationParameters.Builder<O, T>()
// .oldObject(object)
// .delta(delta)
// .target(target)
// .build();
// boolean isAuthorized = getSecurityEnforcer().isAuthorized(operationUrl, phase, params, ownerResolver, task, task.getResult());
// if (!isAuthorized && (ModelAuthorizationAction.GET.getUrl().equals(operationUrl) || ModelAuthorizationAction.SEARCH.getUrl().equals(operationUrl))) {
// isAuthorized = getSecurityEnforcer().isAuthorized(ModelAuthorizationAction.READ.getUrl(), phase, params, ownerResolver, task, task.getResult());
// }
// return isAuthorized;
// }

public <O extends ObjectType, T extends ObjectType> void authorize(String operationUrl, AuthorizationPhaseType phase,
PrismObject<O> object, ObjectDelta<O> delta, PrismObject<T> target, OwnerResolver ownerResolver, OperationResult result)
throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -612,31 +612,6 @@ public static CompiledObjectCollectionView getDefaultGuiObjectListType(PageBase
return pageBase.getCompiledGuiProfile().getDefaultObjectCollectionView();
}

// public enum Channel {
// // TODO: move this to schema component
// LIVE_SYNC(SchemaConstants.CHANGE_CHANNEL_LIVE_SYNC_URI),
// RECONCILIATION(SchemaConstants.CHANGE_CHANNEL_RECON_URI),
// RECOMPUTATION(SchemaConstants.CHANGE_CHANNEL_RECOMPUTE_URI),
// DISCOVERY(SchemaConstants.CHANGE_CHANNEL_DISCOVERY_URI),
// WEB_SERVICE(SchemaConstants.CHANNEL_WEB_SERVICE_URI),
// IMPORT(SchemaConstants.CHANNEL_OBJECT_IMPORT_URI),
// REST(SchemaConstants.CHANNEL_REST_URI),
// INIT(SchemaConstants.CHANNEL_GUI_INIT_URI),
// USER(SchemaConstants.CHANNEL_USER_URI),
// SELF_REGISTRATION(SchemaConstants.CHANNEL_GUI_SELF_REGISTRATION_URI),
// RESET_PASSWORD(SchemaConstants.CHANNEL_GUI_RESET_PASSWORD_URI);
//
// private String channel;
//
// Channel(String channel) {
// this.channel = channel;
// }
//
// public String getChannel() {
// return channel;
// }
// }

public static DateValidator getRangeValidator(Form<?> form, ItemPath path) {
DateValidator validator = null;
List<DateValidator> validators = form.getBehaviors(DateValidator.class);
Expand Down Expand Up @@ -3910,6 +3885,10 @@ public static String getIconCssClass(DisplayType displayType) {
return displayType.getIcon().getCssClass();
}

public static PolyStringType getLabel(DisplayType displayType) {
return displayType == null ? null : displayType.getLabel();
}

public static String getIconColor(DisplayType displayType) {
if (displayType == null || displayType.getIcon() == null) {
return "";
Expand Down Expand Up @@ -4898,12 +4877,12 @@ private static SceneDto createTaskChangesDto(String titleKey, String boxClassOve
}

public static String getMidpointCustomSystemName(PageAdminLTE pageBase, String defaultSystemNameKey) {
DeploymentInformationType deploymentInfo = MidPointApplication.get().getDeploymentInfo();
String subscriptionId = deploymentInfo != null ? deploymentInfo.getSubscriptionIdentifier() : null;
if (!SubscriptionUtil.isSubscriptionIdCorrect(subscriptionId)
|| SubscriptionType.DEMO_SUBSCRIPTION.getSubscriptionType().equals(subscriptionId.substring(0, 2))) {
SubscriptionType subscriptionType = MidPointApplication.get().getSubscriptionType();
if (!subscriptionType.isCorrect() || subscriptionType == SubscriptionType.DEMO_SUBSCRIPTION) {
return pageBase.createStringResource(defaultSystemNameKey).getString();
}

DeploymentInformationType deploymentInfo = MidPointApplication.get().getDeploymentInfo();
return deploymentInfo != null && StringUtils.isNotEmpty(deploymentInfo.getSystemName()) ?
deploymentInfo.getSystemName() : pageBase.createStringResource(defaultSystemNameKey).getString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,11 @@ protected boolean isHeaderVisible() {
}

protected boolean isDashboard() {
return dashboard || (config != null && BooleanUtils.isTrue(config.isPreview()));
return dashboard || isPreview();
}

private boolean isPreview() {
return config != null && BooleanUtils.isTrue(config.isPreview());
}

protected PageStorage getPageStorage(String storageKey) {
Expand Down Expand Up @@ -965,7 +969,7 @@ public void onClick(AjaxRequestTarget target) {
viewAllActionPerformed(target);
}
};
viewAll.add(new VisibleBehaviour(() -> isDashboard()));
viewAll.add(new VisibleBehaviour(this::isPreview));
viewAll.add(AttributeAppender.append("class", "btn btn-default btn-sm"));
viewAll.showTitleAsLabel(true);
return viewAll;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected void onInitialize() {
}

private void initLayout() {
Label label = new Label(ID_TITLE, Model.of(WebComponentUtil.getTranslatedPolyString(getModelObject().getLabel())));
Label label = new Label(ID_TITLE, Model.of(WebComponentUtil.getTranslatedPolyString(WebComponentUtil.getLabel(getModelObject()))));
label.setRenderBodyOnly(true);
add(label);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ protected void initLayout() {
@Override
protected List<IColumn<SelectableBean<AuditEventRecordType>, String>> createColumns() {
List<IColumn<SelectableBean<AuditEventRecordType>, String>> columns = super.createColumns();

if (isDashboard()) {
return columns;
}
IColumn<SelectableBean<AuditEventRecordType>, String> column
= new AbstractColumn<SelectableBean<AuditEventRecordType>, String>(new Model<>()) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ protected void onFinishPerformed(AjaxRequestTarget target) {
public String appendCssToWizard() {
return "mt-5 mx-auto col-8";
}

protected IModel<String> getFormTitle() {
return getTitle();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ protected IModel<String> getBreadcrumbLabel() {
}

@Override
protected IModel<String> getSubTextModel() {
protected IModel<String> getTextModel() {
return getPageBase().createStringResource("PreviewResourceDataWizardPanel.text");
}

@Override
protected IModel<String> getTextModel() {
protected IModel<String> getSubTextModel() {
return getPageBase().createStringResource("PreviewResourceDataWizardPanel.subText");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected String getIcon() {

@Override
protected IModel<?> getTitleModel() {
return getTitle();
return getFormTitle();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@
/**
* @author lskublik
*/
@PanelType(name = "basicSettingsWizard")
@PanelInstance(identifier = "basicSettingsWizard",
@PanelType(name = "basicInformationWizard")
@PanelInstance(identifier = "basicInformationWizard",
applicableForType = ResourceType.class,
applicableForOperation = OperationTypeType.ADD,
display = @PanelDisplay(label = "PageResource.wizard.step.basicSettings", icon = "fa fa-wrench"),
display = @PanelDisplay(label = "PageResource.wizard.step.basicInformation", icon = "fa fa-wrench"),
containerPath = "empty")
public class BasicSettingStepPanel extends AbstractFormResourceWizardStepPanel {
public class BasicInformationStepPanel extends AbstractFormResourceWizardStepPanel {

private static final String PANEL_TYPE = "basicSettingsWizard";
private static final String PANEL_TYPE = "basicInformationWizard";

public BasicSettingStepPanel(ResourceDetailsModel model) {
public BasicInformationStepPanel(ResourceDetailsModel model) {
super(model);
}

Expand All @@ -54,17 +54,17 @@ protected String getIcon() {

@Override
public IModel<String> getTitle() {
return createStringResource("PageResource.wizard.step.basicSettings");
return createStringResource("PageResource.wizard.step.basicInformation");
}

@Override
protected IModel<?> getTextModel() {
return createStringResource("PageResource.wizard.step.basicSettings.text");
return createStringResource("PageResource.wizard.step.basicInformation.text");
}

@Override
protected IModel<?> getSubTextModel() {
return createStringResource("PageResource.wizard.step.basicSettings.subText");
return createStringResource("PageResource.wizard.step.basicInformation.subText");
}

protected boolean checkMandatory(ItemWrapper itemWrapper) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public ResourceDetailsModel getResourceModel() {

private List<WizardStep> createBasicSteps() {
List<WizardStep> steps = new ArrayList<>();
steps.add(new BasicSettingStepPanel(getResourceModel()) {
steps.add(new BasicInformationStepPanel(getResourceModel()) {

@Override
public boolean onBackPerformed(AjaxRequestTarget target) {
Expand Down

0 comments on commit 0733641

Please sign in to comment.