Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Jun 14, 2022
2 parents d99efda + 979ecca commit 8f365e3
Show file tree
Hide file tree
Showing 45 changed files with 1,156 additions and 388 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public void postProcess(CompiledGuiProfile compiledGuiProfile) {
compileDefaultDetailsPages(compiledGuiProfile);
mergeCollectionViewsWithDefault(compiledGuiProfile);
processShadowPanels(compiledGuiProfile);
processResourcePanels(compiledGuiProfile);
}

private void compileDefaultDetailsPages(CompiledGuiProfile compiledGuiProfile) {
Expand Down Expand Up @@ -273,6 +274,41 @@ private void processShadowPanels(CompiledGuiProfile compiledGuiProfile) {
}
}

private void processResourcePanels(CompiledGuiProfile compiledGuiProfile) {
List<ContainerPanelConfigurationType> resourcePanels = new ArrayList<>();
for (Class<?> clazz : getPanelInstanceClasses()) {
for (PanelInstance instance : getPanelInstancesAnnotations(clazz)) {
if (instance == null) {
continue;
}
if (!instance.applicableForType().equals(ResourceType.class)) {
continue;
}

if (compiledGuiProfile.getObjectDetails() == null) {
compiledGuiProfile.setObjectDetails(new GuiObjectDetailsSetType());
}
ContainerPanelConfigurationType resourcePanel = compileContainerPanelConfiguration(clazz, ResourceType.class, instance);
resourcePanels.add(resourcePanel);
}
}

if (compiledGuiProfile.getObjectDetails() == null) {
compiledGuiProfile.setObjectDetails(new GuiObjectDetailsSetType());
}

if (compiledGuiProfile.getObjectDetails().getResourceDetailsPage().isEmpty()) {
compiledGuiProfile.getObjectDetails().getResourceDetailsPage().add(new GuiResourceDetailsPageType());
}

for (GuiResourceDetailsPageType resourceDetailsPage : compiledGuiProfile.getObjectDetails().getResourceDetailsPage()) {
List<ContainerPanelConfigurationType> mergedPanels =
adminGuiConfigurationMergeManager.mergeContainerPanelConfigurationType(resourcePanels, resourceDetailsPage.getPanel());
resourceDetailsPage.getPanel().clear();
resourceDetailsPage.getPanel().addAll(mergedPanels);
}
}

private synchronized void fillInPanelsMap() {
if (!PANELS_MAP.isEmpty()) {
return;
Expand Down Expand Up @@ -367,7 +403,8 @@ private void addDetails(GuiObjectDetailsSetType detailsSet, Class<? extends Cont
return;
}

if (QNameUtil.match(details.getType(), ShadowType.COMPLEX_TYPE)) {
if (QNameUtil.match(details.getType(), ShadowType.COMPLEX_TYPE)
|| QNameUtil.match(details.getType(), ResourceType.COMPLEX_TYPE)) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ <h2 class="mb-3" wicket:id="text"/>
<h5 class="text-secondary mb-5" wicket:id="subText"/>

<wicket:child/>
<!-- todo remove -->
<div wicket:id="content"/>

<div class="d-flex gap-3 justify-content-center mt-5">
<a class="btn btn-outline-primary" wicket:id="back">
<i class="fas fa-arrow-left mr-2"></i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@

package com.evolveum.midpoint.gui.api.component.wizard;

import com.evolveum.midpoint.web.component.AjaxSubmitButton;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;

import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.behavior.AttributeAppender;
Expand All @@ -18,7 +19,6 @@
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;

/**
* @author lskublik
Expand All @@ -29,7 +29,6 @@ public class BasicWizardPanel<T> extends WizardStepPanel<T> {

private static final String ID_TEXT = "text";
private static final String ID_SUBTEXT = "subText";
private static final String ID_CONTENT = "content";
private static final String ID_BACK = "back";
private static final String ID_NEXT = "next";
private static final String ID_NEXT_LABEL = "nextLabel";
Expand Down Expand Up @@ -57,8 +56,6 @@ private void initLayout() {
secondaryText.add(new VisibleBehaviour(() -> getSubTextModel().getObject() != null));
add(secondaryText);

add(createContentPanel(ID_CONTENT));

AjaxLink back = new AjaxLink<>(ID_BACK) {

@Override
Expand All @@ -72,12 +69,17 @@ public void onClick(AjaxRequestTarget target) {
back.add(AttributeAppender.append("class", () -> !back.isEnabledInHierarchy() ? "disabled" : null));
add(back);

AjaxLink next = new AjaxLink<>(ID_NEXT) {
AjaxSubmitButton next = new AjaxSubmitButton(ID_NEXT) {

@Override
public void onClick(AjaxRequestTarget target) {
public void onSubmit(AjaxRequestTarget target) {
onNextPerformed(target);
}

@Override
protected void onError(AjaxRequestTarget target) {
updateFeedbackPanels(target);
}
};
next.add(getNextBehaviour());
next.setOutputMarkupId(true);
Expand All @@ -92,7 +94,10 @@ public void onClick(AjaxRequestTarget target) {
next.add(nextLabel);
}

protected Component createContentPanel(String id) {
protected void updateFeedbackPanels(AjaxRequestTarget target) {
}

protected WebMarkupContainer createContentPanel(String id) {
return new WebMarkupContainer(id);
}

Expand Down Expand Up @@ -124,7 +129,10 @@ protected void onBackPerformed(AjaxRequestTarget target) {
target.add(getWizard().getPanel());
return;
}
onBackAfterWizardPerformed(target);
}

protected void onBackAfterWizardPerformed(AjaxRequestTarget target) {
getPageBase().redirectBack();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ private void initLayout() {

WebMarkupContainer header = new WebMarkupContainer(ID_HEADER);
header.setOutputMarkupId(true);
header.add(getVisibilityOfStepsHeader());
add(header);

ListView<IModel<String>> steps = new ListView<>(ID_STEPS, () -> wizardModel.getSteps().stream().map(s -> s.getTitle()).collect(Collectors.toList())) {
Expand Down Expand Up @@ -149,11 +148,6 @@ public boolean isEnabled() {
addOrReplace(new WebMarkupContainer(ID_CONTENT_BODY));
}

@NotNull
protected VisibleEnableBehaviour getVisibilityOfStepsHeader() {
return VisibleEnableBehaviour.ALWAYS_VISIBLE_ENABLED;
}

public WizardStep getCurrentPanel() {
return wizardModel.getActiveStep();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5509,6 +5509,15 @@ private static PrismReferenceValue findResourceReference(PrismPropertyWrapper<QN
}
}

public static ContainerPanelConfigurationType getContainerConfiguration(GuiObjectDetailsPageType pageConfig, String panelType) {
Optional<ContainerPanelConfigurationType> config = pageConfig
.getPanel()
.stream()
.filter(containerConfig -> panelType.equals(containerConfig.getPanelType()))
.findFirst();
return config.isEmpty() ? null : config.get();
}

/**
* only for 'old' object details pages. Should be removed after only new design will be present.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!--
~ Copyright (c) 2010-2014 Evolveum
~
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
-->
<html xmlns:wicket="http://wicket.apache.org">
<body>
<wicket:panel>
<wicket:container wicket:id="list">
<span class="invalid-feedback d-block" wicket:id="message"/>
</wicket:container>
</wicket:panel>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright (c) 2010-2014 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.gui.impl.component.message;

import com.evolveum.midpoint.web.component.message.FeedbackAlerts;
import com.evolveum.midpoint.web.component.message.FeedbackListView;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import org.apache.wicket.feedback.FeedbackMessage;
import org.apache.wicket.feedback.FeedbackMessagesModel;
import org.apache.wicket.feedback.IFeedback;
import org.apache.wicket.feedback.IFeedbackMessageFilter;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.PropertyModel;

import java.util.List;

/**
* @author lazyman
*/
public class FeedbackLabels extends FeedbackAlerts {

private static final String ID_LIST = "list";
private static final String ID_MESSAGE = "message";

public FeedbackLabels(String id) {
super(id);
}

protected void initLayout() {
ListView<FeedbackMessage> list = new ListView<>(ID_LIST, new FeedbackMessagesModel(this)) {
@Override
protected void populateItem(ListItem<FeedbackMessage> item) {
item.add(
new Label(ID_MESSAGE, new PropertyModel<>(item.getModel(), "message")));
}
};
list.add(new VisibleEnableBehaviour() {

@Override
public boolean isVisible() {
return hasMessages();
}
});
add(list);
}

protected ListView<FeedbackMessage> getFeedbackListView() {
return (ListView<FeedbackMessage>) get(ID_LIST);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public void register() {

@Override
public org.apache.wicket.Component createPanel(PrismContainerPanelContext<C> panelCtx) {
if (FormPanelType.VERTICAL.equals(panelCtx.getFormType())) {

}
return new DefaultContainerablePanel<>(panelCtx.getComponentId(), panelCtx.getValueWrapper(), panelCtx.getSettings());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright (c) 2010-2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/
package com.evolveum.midpoint.gui.impl.factory.panel;

/**
* @author lskublik
*/
public enum FormPanelType {
VERTICAL,
HORIZONTAL;

public static FormPanelType getDefault() {
return HORIZONTAL;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public abstract class ItemPanelContext<T, IW extends ItemWrapper<?, ?>> implemen
private ExpressionValidator<T> expressionValidator;
private FeedbackAlerts feedback;

private FormPanelType formType = FormPanelType.getDefault();

public ItemPanelContext(IModel<IW> itemWrapper) {
this.itemWrapper = itemWrapper;
}
Expand Down Expand Up @@ -159,4 +161,11 @@ public void setForm(Form<?> form) {
this.form = form;
}

public FormPanelType getFormType() {
return formType;
}

public void setFormType(FormPanelType formType) {
this.formType = formType;
}
}

0 comments on commit 8f365e3

Please sign in to comment.