You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2022/06/21 11:06:04 UTC
[syncope] branch 2_1_X updated: [SYNCOPE-1683] Show properties override during resource create in tabular topology (#353)
This is an automated email from the ASF dual-hosted git repository.
ilgrosso pushed a commit to branch 2_1_X
in repository https://gitbox.apache.org/repos/asf/syncope.git
The following commit(s) were added to refs/heads/2_1_X by this push:
new 92c61e7660 [SYNCOPE-1683] Show properties override during resource create in tabular topology (#353)
92c61e7660 is described below
commit 92c61e766099d4fdc0566f02558be5babc0b8148
Author: SamuelGaro <72...@users.noreply.github.com>
AuthorDate: Tue Jun 21 13:05:58 2022 +0200
[SYNCOPE-1683] Show properties override during resource create in tabular topology (#353)
---
.../wizards/resources/AbstractConnConfPanel.java | 2 +-
.../wizards/resources/ResourceConnConfPanel.java | 9 +++
.../wizards/resources/ResourceDetailsPanel.java | 8 ++-
.../wizards/resources/ResourceWizardBuilder.java | 66 +++++++++++++++++++++-
4 files changed, 80 insertions(+), 5 deletions(-)
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/resources/AbstractConnConfPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/resources/AbstractConnConfPanel.java
index f96a02ae2d..635d96aa62 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/resources/AbstractConnConfPanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/resources/AbstractConnConfPanel.java
@@ -76,7 +76,7 @@ public abstract class AbstractConnConfPanel<T extends EntityTO> extends WizardSt
}
protected void setConfPropertyListView(final IModel<List<ConnConfProperty>> model, final boolean withOverridable) {
- propertiesContainer.add(new ConnConfPropertyListView(
+ propertiesContainer.addOrReplace(new ConnConfPropertyListView(
"connectorProperties", model, withOverridable).setOutputMarkupId(true));
}
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/resources/ResourceConnConfPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/resources/ResourceConnConfPanel.java
index 13ed54d718..0506d2df82 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/resources/ResourceConnConfPanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/resources/ResourceConnConfPanel.java
@@ -26,6 +26,7 @@ import java.util.Map;
import org.apache.syncope.client.console.rest.ConnectorRestClient;
import org.apache.syncope.common.lib.to.ResourceTO;
import org.apache.syncope.common.lib.types.ConnConfProperty;
+import org.apache.wicket.ajax.markup.html.form.AjaxButton;
import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.model.PropertyModel;
@@ -114,4 +115,12 @@ public abstract class ResourceConnConfPanel extends AbstractConnConfPanel<Resour
return props;
}
+
+ public LoadableDetachableModel<List<ConnConfProperty>> getModel() {
+ return model;
+ }
+
+ public AjaxButton getCheck() {
+ return check;
+ }
}
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/resources/ResourceDetailsPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/resources/ResourceDetailsPanel.java
index 76658951fe..eb6e5dfa21 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/resources/ResourceDetailsPanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/resources/ResourceDetailsPanel.java
@@ -50,6 +50,8 @@ public class ResourceDetailsPanel extends WizardStep {
private static final long serialVersionUID = -7982691107029848579L;
+ private AjaxDropDownChoicePanel<String> connector;
+
private final ImplementationRestClient implRestClient = new ImplementationRestClient();
private final IModel<List<String>> propagationActions = new LoadableDetachableModel<List<String>>() {
@@ -154,7 +156,7 @@ public class ResourceDetailsPanel extends WizardStep {
false).addRequiredLabel().setEnabled(false));
} else {
ConnectorRestClient connectorRestClient = new ConnectorRestClient();
- final AjaxDropDownChoicePanel<String> connector = new AjaxDropDownChoicePanel<>(
+ connector = new AjaxDropDownChoicePanel<>(
"connector",
new ResourceModel("connector", "connector").getObject(),
new PropertyModel<>(resourceTO, "connector"), false);
@@ -189,4 +191,8 @@ public class ResourceDetailsPanel extends WizardStep {
container.add(connector);
}
}
+
+ public AjaxDropDownChoicePanel<String> getConnector() {
+ return connector;
+ }
}
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/resources/ResourceWizardBuilder.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/resources/ResourceWizardBuilder.java
index bea83ca397..1ba7c2088c 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/resources/ResourceWizardBuilder.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/resources/ResourceWizardBuilder.java
@@ -19,17 +19,24 @@
package org.apache.syncope.client.console.wizards.resources;
import java.io.Serializable;
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.List;
import org.apache.commons.lang3.tuple.Pair;
+import org.apache.syncope.client.console.commons.Constants;
import org.apache.syncope.client.console.rest.ConnectorRestClient;
import org.apache.syncope.client.console.rest.ResourceRestClient;
import org.apache.syncope.client.console.topology.TopologyNode;
+import org.apache.syncope.client.console.wicket.ajax.form.IndicatorAjaxFormComponentUpdatingBehavior;
import org.apache.syncope.client.console.wizards.AjaxWizard;
import org.apache.syncope.common.lib.to.ResourceTO;
+import org.apache.syncope.common.lib.types.ConnConfProperty;
import org.apache.wicket.PageReference;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.wizard.WizardModel;
import org.apache.wicket.markup.ComponentTag;
+import org.apache.wicket.model.LoadableDetachableModel;
+import org.apache.wicket.model.PropertyModel;
/**
* Resource wizard builder.
@@ -57,8 +64,9 @@ public class ResourceWizardBuilder extends AbstractResourceWizardBuilder<Resourc
@Override
protected WizardModel buildModelSteps(final Serializable modelObject, final WizardModel wizardModel) {
ResourceTO resourceTO = ResourceTO.class.cast(modelObject);
- wizardModel.add(new ResourceDetailsPanel(resourceTO, createFlag));
- wizardModel.add(new ResourceConnConfPanel(resourceTO, createFlag) {
+ ResourceDetailsPanel resourceDetailsPanel = new ResourceDetailsPanel(resourceTO, createFlag);
+
+ ResourceConnConfPanel resourceConnConfPanel = new ResourceConnConfPanel(resourceTO, createFlag) {
private static final long serialVersionUID = -1128269449868933504L;
@@ -72,7 +80,59 @@ public class ResourceWizardBuilder extends AbstractResourceWizardBuilder<Resourc
tag.append("class", "scrollable-tab-content", " ");
}
- });
+ };
+
+ if (createFlag && resourceDetailsPanel.getConnector() != null) {
+ resourceDetailsPanel.getConnector().getField().add(
+ new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
+
+ private static final long serialVersionUID = 4600298808455564695L;
+
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+ resourceTO.setConnector(resourceDetailsPanel.getConnector().getModelObject());
+
+ LoadableDetachableModel<List<ConnConfProperty>> model =
+ new LoadableDetachableModel<List<ConnConfProperty>>() {
+
+ private static final long serialVersionUID = -2965284931860212687L;
+
+ @Override
+ protected List<ConnConfProperty> load() {
+ List<ConnConfProperty> confOverride =
+ resourceConnConfPanel.getConnProperties(resourceTO);
+ resourceTO.getConfOverride().clear();
+ resourceTO.getConfOverride().addAll(confOverride);
+
+ return new PropertyModel<List<ConnConfProperty>>(modelObject, "confOverride") {
+
+ private static final long serialVersionUID = -7809699384012595307L;
+
+ @Override
+ public List<ConnConfProperty> getObject() {
+ List<ConnConfProperty> res = new ArrayList<>(super.getObject());
+
+ // re-order properties
+ Collections.sort(res, (left, right) -> {
+ if (left == null) {
+ return -1;
+ } else {
+ return left.compareTo(right);
+ }
+ });
+
+ return res;
+ }
+ }.getObject();
+ }
+ };
+ resourceConnConfPanel.setConfPropertyListView(model, true);
+ target.add(resourceConnConfPanel.getCheck().setVisible(true).setEnabled(true));
+ }
+ });
+ }
+ wizardModel.add(resourceDetailsPanel);
+ wizardModel.add(resourceConnConfPanel);
if (resourceTO.getConnector() != null) {
wizardModel.add(new ResourceConnCapabilitiesPanel(
resourceTO, connectorRestClient.read(resourceTO.getConnector()).getCapabilities()));