Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Kateryna Honchar committed Sep 5, 2022
2 parents 567f9cb + b04530e commit fe8dc17
Show file tree
Hide file tree
Showing 47 changed files with 890 additions and 331 deletions.
12 changes: 6 additions & 6 deletions gui/admin-gui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.web.page.self.PageSelfProfile;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -2670,18 +2672,17 @@ public static void redirectFromDashboardWidget(ContainerPanelConfigurationType w

Constructor<?> constructor = clazz.getConstructor();
Object pageInstance = constructor.newInstance();
if (pageInstance instanceof AbstractPageObjectDetails && StringUtils.isNotEmpty(panelType)) {
if (pageInstance instanceof PageSelfProfile && StringUtils.isNotEmpty(panelType)) {
String storageKey = "details" + ((AbstractPageObjectDetails<?, ?>) pageInstance).getType().getSimpleName();
FocusType principal = pageBase.getPrincipalFocus();
ObjectDetailsStorage pageStorage = pageBase.getSessionStorage().getObjectDetailsStorage(storageKey);
if (pageStorage == null) {
pageBase.getSessionStorage().setObjectDetailsStorage(storageKey, config);
} else {
pageStorage.setDefaultConfiguration(config);
}
WebComponentUtil.dispatchToObjectDetailsPage(principal.asPrismObject(), component);
pageBase.navigateToNext(WebComponentUtil.resolveSelfPage());
} else if (pageInstance instanceof WebPage) {
pageBase.navigateToNext((WebPage) pageInstance);
pageBase.navigateToNext((Class<? extends WebPage>) clazz);
}
} catch (Throwable e) {
e.printStackTrace();
Expand Down Expand Up @@ -5482,10 +5483,6 @@ public static IModel<String> createMappingDescription(IModel<PrismContainerValue

//TODO
public static <T extends ObjectType> Component createPanel(Class<? extends Panel> panelClass, String markupId, ObjectDetailsModels<T> objectDetailsModels, ContainerPanelConfigurationType panelConfig) {
if (panelClass == null) {
return new WebMarkupContainer(markupId);
}

if (AbstractAssignmentTypePanel.class.isAssignableFrom(panelClass)) {
try {
Panel panel = ConstructorUtils.invokeConstructor(panelClass, markupId, objectDetailsModels.getObjectWrapperModel(), panelConfig);
Expand All @@ -5497,18 +5494,6 @@ public static <T extends ObjectType> Component createPanel(Class<? extends Panel
}
}

if (ContainerableListPanel.class.isAssignableFrom(panelClass)) {
try {
ContainerableListPanel panel = (ContainerableListPanel) ConstructorUtils.invokeConstructor(panelClass, markupId, new ArrayList<>(), panelConfig);
panel.setDashboard(true);
panel.setOutputMarkupId(true);
return panel;
} catch (Throwable e) {
LOGGER.trace("No constructor found for (String, LoadableModel, ContainerPanelConfigurationType). Continue with lookup.", e);
return null;
}
}

try {
Panel panel = ConstructorUtils.invokeConstructor(panelClass, markupId, objectDetailsModels, panelConfig);
panel.setOutputMarkupId(true);
Expand All @@ -5517,7 +5502,7 @@ public static <T extends ObjectType> Component createPanel(Class<? extends Panel
e.printStackTrace();
LOGGER.trace("No constructor found for (String, LoadableModel, ContainerPanelConfigurationType). Continue with lookup.", e);
}
return new WebMarkupContainer(markupId);
return null;
}

public static PrismObject<ResourceType> findResource(PrismPropertyWrapper itemWrapper, PrismPropertyPanelContext panelCtx) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<div wicket:id="basic" />
<div wicket:id="attributes" />
</wicket:panel>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ protected ItemVisibility getVisibility(ItemWrapper itemWrapper) {
}
};
add(baseConstructionPanel);

ResourceAttributePanel attrsPanel = new ResourceAttributePanel(ID_ATTRIBUTES, PrismContainerWrapperModel.fromContainerWrapper(getModel(), ConstructionType.F_ATTRIBUTE), null);
add(attrsPanel);

}

public ContainerPanelConfigurationType getConfig() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
*/
package com.evolveum.midpoint.gui.impl.component;

import java.util.ArrayList;
import java.util.List;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.gui.impl.prism.panel.ResourceAssociationPanel;
import com.evolveum.midpoint.gui.impl.prism.panel.ResourceAttributePanel;

import org.apache.wicket.extensions.markup.html.tabs.ITab;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.model.IModel;
Expand Down Expand Up @@ -65,7 +69,7 @@ protected List<ITab> createTabs() {
AssignmentsUtil.AssignmentTypeType assignmentTypeType = AssignmentsUtil.getAssignmentType(getModelObject());
switch (assignmentTypeType) {
case CONSTRUCTION:
tabs.add(createConstructionTabs());
tabs.addAll(createConstructionTabs());
break;
case POLICY_RULE:
tabs.add(createTabs("AssignmentType.policyRule", AssignmentType.F_POLICY_RULE, PolicyRuleType.COMPLEX_TYPE));
Expand Down Expand Up @@ -235,17 +239,42 @@ public WebMarkupContainer createPanel(String panelId) {
};

}
private PanelTab createConstructionTabs() {
return new PanelTab(createStringResource("AssignmentType.construction")) {
private List<PanelTab> createConstructionTabs() {
List<PanelTab> constructionTabs = new ArrayList<>();

constructionTabs.add(new PanelTab(createStringResource("AssignmentType.construction")) {

@Override
public WebMarkupContainer createPanel(String panelId) {
return new AssignmentConstructionPanel(panelId, PrismContainerWrapperModel.fromContainerValueWrapper(getModel(), AssignmentType.F_CONSTRUCTION), getConfig());
}
};
});

if (isInducement()) {
constructionTabs.add(new PanelTab(createStringResource("AssignmentDetailsPanel.construction.attribute")) {

@Override
public WebMarkupContainer createPanel(String panelId) {
return new ResourceAttributePanel(panelId, PrismContainerWrapperModel.fromContainerValueWrapper(getModel(), ItemPath.create(AssignmentType.F_CONSTRUCTION, ConstructionType.F_ATTRIBUTE)), null);
}
});

constructionTabs.add(new PanelTab(createStringResource("AssignmentDetailsPanel.construction.association")) {

@Override
public WebMarkupContainer createPanel(String panelId) {
return new ResourceAssociationPanel(panelId, PrismContainerWrapperModel.fromContainerValueWrapper(getModel(), ItemPath.create(AssignmentType.F_CONSTRUCTION, ConstructionType.F_ASSOCIATION)), null);
}
});
}
return constructionTabs;
// return createTabs("AssignmentType.construction", AssignmentType.F_CONSTRUCTION, ConstructionType.COMPLEX_TYPE);
}

private boolean isInducement() {
return AbstractRoleType.F_INDUCEMENT.equivalent(getModelObject().getPath().lastName());
}

private PanelTab createActivationTab() {
return new PanelTab(createStringResource("AssignmentType.activation")) {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package com.evolveum.midpoint.gui.impl.model;

import java.util.Collection;
import java.util.stream.Collectors;

import org.apache.commons.lang3.Validate;
import org.apache.wicket.RestartResponseException;
Expand Down Expand Up @@ -104,14 +105,23 @@ private String getDefaultValue() {
throw new RestartResponseException(PageError.class);
}

if (property == null || property.getRealValue() == null) {
return "";
if (property.isSingleValue()) {
if (property == null || property.getRealValue() == null) {
return "";
}
return getTranslatedRealValue(property.getRealValue());
}
if (property.getRealValue() instanceof PolyString) {
return serviceLocator.getLocalizationService().translate((PolyString) property.getRealValue(),
return property.getRealValues().stream()
.map(realValue -> getTranslatedRealValue(realValue))
.collect(Collectors.joining(", "));
}

private String getTranslatedRealValue(Object realValue) {
if (realValue instanceof PolyString) {
return serviceLocator.getLocalizationService().translate((PolyString) realValue,
serviceLocator.getLocale(), true);
}
return property.getRealValue().toString();
return realValue.toString();
}

private String getExpressionValue(ExpressionType expressionType, String contextDesc, Task task, OperationResult result) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,6 @@ public Collection<ObjectDeltaOperation<? extends ObjectType>> saveOrPreviewPerfo
PrismObjectWrapper<O> objectWrapper = getModelWrapperObject();
LOGGER.debug("Saving object {}", objectWrapper);

// todo: improve, delta variable is quickfix for MID-1006
// redirecting to user list page everytime user is created in repository
// during user add in gui,
// and we're not taking care about account/assignment create errors
// (error message is still displayed)
// delta = null;

if (task == null) {
task = createSimpleTask(OPERATION_SEND_TO_SUBMIT);
}
Expand Down Expand Up @@ -310,7 +303,6 @@ protected ExecuteChangeOptionsDto getExecuteChangesOptionsDto() {

protected void reviveModels() throws SchemaException {
WebComponentUtil.revive(getModel(), getPrismContext());
// WebComponentUtil.revive(parentOrgModel, getPrismContext());
}

protected ObjectChangeExecutor getChangeExecutor() {
Expand Down Expand Up @@ -349,28 +341,17 @@ public void refresh(AjaxRequestTarget target, boolean soft) {
target.add(getFeedbackPanel());
target.add(get(ID_DETAILS_VIEW));
refreshTitle(target);

// if (soft) {
// for (Component component : getMainPanel().getTabbedPanel()) {
// if (component instanceof RefreshableTabPanel) {
// for (Component c : ((RefreshableTabPanel) component).getComponentsToUpdate()) {
// target.add(c);
// }
// }
// }
// } else {
// target.add(getMainPanel().getTabbedPanel());
// }
}

private ContainerPanelConfigurationType findDefaultConfiguration() {
ObjectDetailsStorage storage = getSessionStorage().getObjectDetailsStorage("details" + getType().getSimpleName());
if (storage != null) {
ContainerPanelConfigurationType config = storage.getDefaultConfiguration();
if (config != null) {
return config;
}
}
//TODO how to do the redirection to concrete panel?
// ObjectDetailsStorage storage = getSessionStorage().getObjectDetailsStorage("details" + getType().getSimpleName());
// if (storage != null) {
// ContainerPanelConfigurationType config = storage.getDefaultConfiguration();
// if (config != null) {
// return config;
// }
// }
ContainerPanelConfigurationType defaultConfiguration = findDefaultConfiguration(getPanelConfigurations().getObject());

if (defaultConfiguration != null) {
Expand Down Expand Up @@ -424,22 +405,31 @@ private void initMainPanel(ContainerPanelConfigurationType panelConfig, Midpoint

getSessionStorage().setObjectDetailsStorage("details" + getType().getSimpleName(), panelConfig);
String panelType = panelConfig.getPanelType();

if (panelType == null && LOGGER.isDebugEnabled()) {
//No panel defined, just grouping element, e.g. top "Assignments" in details navigation menu
LOGGER.debug("AbstractPageObjectDetails.panelTypeUndefined {}", panelConfig.getIdentifier());
form.addOrReplace(new WebMarkupContainer(ID_MAIN_PANEL));
return;
}

Class<? extends Panel> panelClass = findObjectPanel(panelType);
if (panelClass == null) {
//panel type defined, but no class found. Something strange happened.
addErrorPanel(false, form, MessagePanel.MessagePanelType.ERROR,"AbstractPageObjectDetails.panelTypeUndefined", panelConfig.getIdentifier());
return;
}

Component panel = WebComponentUtil.createPanel(panelClass, ID_MAIN_PANEL, objectDetailsModels, panelConfig);
panel.add(AttributeAppender.append("class", () -> {
if (panel != null) {
panel.add(AttributeAppender.append("class", () -> {
List panels = getPanelConfigurations().getObject();
if (panels == null || panels.size() <= 1) {
return "flex-grow-1";
}

return null;
}));

if (panel != null) {
}));
form.addOrReplace(panel);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

package com.evolveum.midpoint.gui.impl.page.admin.component;

import com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder;
import com.evolveum.midpoint.gui.impl.component.icon.LayeredIconCssStyle;
import com.evolveum.midpoint.web.component.AjaxCompositedIconSubmitButton;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.html.basic.Label;
Expand Down Expand Up @@ -76,11 +80,18 @@ protected void addButtons(RepeatingView repeatingView) {
}

private void createPreviewButton(RepeatingView repeatingView) {
AjaxIconButton preview = new AjaxIconButton(repeatingView.newChildId(), Model.of(GuiStyleConstants.CLASS_ICON_PREVIEW),
CompositedIconBuilder iconBuilder = new CompositedIconBuilder().setBasicIcon(GuiStyleConstants.CLASS_ICON_PREVIEW, LayeredIconCssStyle.IN_ROW_STYLE);
AjaxCompositedIconSubmitButton preview = new AjaxCompositedIconSubmitButton(repeatingView.newChildId(), iconBuilder.build(),
getPageBase().createStringResource("pageAdminFocus.button.previewChanges")) {

@Override
protected void onSubmit(AjaxRequestTarget target) {
previewPerformed(target);
}

@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
previewPerformed(ajaxRequestTarget);
protected void onError(AjaxRequestTarget target) {
target.add(getPageBase().getFeedbackPanel());
}
};
preview.add(new VisibleEnableBehaviour() {
Expand All @@ -97,7 +108,7 @@ public boolean isEnabled() {
return isSavePreviewButtonEnabled();
}
});
preview.showTitleAsLabel(true);
preview.titleAsLabel(true);
preview.add(AttributeAppender.append("class", "btn btn-info btn-sm"));
repeatingView.add(preview);
}
Expand Down

0 comments on commit fe8dc17

Please sign in to comment.