Skip to content

Commit

Permalink
Fixing a few Console glitches
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgrosso committed Jun 26, 2023
1 parent 2de9269 commit 9f353bb
Show file tree
Hide file tree
Showing 31 changed files with 141 additions and 157 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@
import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
import org.apache.syncope.client.console.wicket.markup.html.form.Action;
import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink;
import org.apache.syncope.client.console.wizards.any.AnyObjectWrapper;
import org.apache.syncope.client.console.wizards.any.GroupWrapper;
import org.apache.syncope.client.console.wizards.any.MergeLinkedAccountsWizardBuilder;
import org.apache.syncope.client.ui.commons.wizards.AjaxWizard;
import org.apache.syncope.client.ui.commons.wizards.any.AnyWrapper;
import org.apache.syncope.client.ui.commons.wizards.any.UserWrapper;
import org.apache.syncope.common.lib.to.AnyObjectTO;
import org.apache.syncope.common.lib.to.GroupTO;
import org.apache.syncope.common.lib.to.UserTO;
Expand Down Expand Up @@ -81,7 +84,7 @@ public List<Action<UserTO>> get(
@Override
public void onClick(final AjaxRequestTarget target, final UserTO ignore) {
IModel<AnyWrapper<UserTO>> formModel = new CompoundPropertyModel<>(
new AnyWrapper<>(model.getObject()));
new UserWrapper(model.getObject()));
modal.setFormModel(formModel);

target.add(modal.setContent(new AnyStatusModal<>(
Expand All @@ -108,7 +111,7 @@ public void onClick(final AjaxRequestTarget target, final UserTO ignore) {
public void onClick(final AjaxRequestTarget target, final UserTO ignore) {
model.setObject(userRestClient.read(model.getObject().getKey()));
IModel<AnyWrapper<UserTO>> formModel = new CompoundPropertyModel<>(
new AnyWrapper<>(model.getObject()));
new UserWrapper(model.getObject()));
modal.setFormModel(formModel);

target.add(modal.setContent(new AnyStatusModal<>(
Expand Down Expand Up @@ -190,7 +193,7 @@ public List<Action<GroupTO>> get(
@Override
public void onClick(final AjaxRequestTarget target, final GroupTO ignore) {
IModel<AnyWrapper<GroupTO>> formModel = new CompoundPropertyModel<>(
new AnyWrapper<>(modelObject));
new GroupWrapper(modelObject));
modal.setFormModel(formModel);

target.add(modal.setContent(new AnyStatusModal<>(
Expand Down Expand Up @@ -231,8 +234,8 @@ public List<Action<AnyObjectTO>> get(

@Override
public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) {
final IModel<AnyWrapper<AnyObjectTO>> formModel = new CompoundPropertyModel<>(
new AnyWrapper<>(modelObject));
IModel<AnyWrapper<AnyObjectTO>> formModel = new CompoundPropertyModel<>(
new AnyObjectWrapper(modelObject));
modal.setFormModel(formModel);

target.add(modal.setContent(new AnyStatusModal<>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ public void updateResultTable(final String type, final AjaxRequestTarget target)
}
}

synchronized (this) {
dataProvider = dataProvider();
}

super.updateResultTable(target);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,4 @@ public String getResource() {
public ConnObject getConnObjectTO() {
return connObjectTO;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.io.Serializable;
import org.apache.syncope.common.lib.to.AnyTO;

public class AnyWrapper<T extends AnyTO> implements Serializable {
public abstract class AnyWrapper<T extends AnyTO> implements Serializable {

private static final long serialVersionUID = 8058288034211558375L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
*/
package org.apache.syncope.client.ui.commons.wizards.any;

import java.io.Serializable;
import org.apache.syncope.common.lib.to.EntityTO;

public class EntityWrapper<T extends EntityTO> {
public class EntityWrapper<T extends EntityTO> implements Serializable {

private static final long serialVersionUID = 1L;

protected final T entityTO;

Expand All @@ -31,5 +34,4 @@ public EntityWrapper(final T entityTO) {
public T getInnerObject() {
return entityTO;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.StringResourceModel;
import org.apache.wicket.spring.injection.annot.SpringBean;

Expand All @@ -80,7 +81,9 @@ public class NotificationDirectoryPanel
protected final BaseModal<String> utilityModal = new BaseModal<>(Constants.OUTER);

public NotificationDirectoryPanel(
final String id, final NotificationRestClient restClient, final PageReference pageRef) {
final String id,
final NotificationRestClient restClient,
final PageReference pageRef) {

super(id, restClient, pageRef, true);
disableCheckBoxes();
Expand Down Expand Up @@ -126,9 +129,9 @@ protected List<IColumn<NotificationTO, String>> getColumns() {

@Override
public ActionsPanel<NotificationTO> getActions(final IModel<NotificationTO> model) {
final ActionsPanel<NotificationTO> panel = super.getActions(model);
ActionsPanel<NotificationTO> actions = super.getActions(model);

panel.add(new ActionLink<>() {
actions.add(new ActionLink<>() {

private static final long serialVersionUID = -7978723352517770645L;

Expand All @@ -140,21 +143,20 @@ public void onClick(final AjaxRequestTarget target, final NotificationTO ignore)
}
}, ActionLink.ActionType.EDIT, IdRepoEntitlement.NOTIFICATION_UPDATE);

panel.add(new ActionLink<>() {
actions.add(new ActionLink<>() {

private static final long serialVersionUID = -7978723352517770645L;

@Override
public void onClick(final AjaxRequestTarget target, final NotificationTO ignore) {
target.add(utilityModal.setContent(
new NotificationTasks(model.getObject().getKey(), pageRef)));
target.add(utilityModal.setContent(new NotificationTasks(model.getObject().getKey(), pageRef)));
utilityModal.header(new StringResourceModel("notification.tasks", model));
utilityModal.show(true);
target.add(utilityModal);
}
}, ActionLink.ActionType.NOTIFICATION_TASKS, IdRepoEntitlement.TASK_LIST);

panel.add(new ActionLink<>() {
actions.add(new ActionLink<>() {

private static final long serialVersionUID = -3722207913631435501L;

Expand All @@ -172,7 +174,7 @@ public void onClick(final AjaxRequestTarget target, final NotificationTO ignore)
}
}, ActionLink.ActionType.DELETE, IdRepoEntitlement.NOTIFICATION_DELETE, true);

return panel;
return actions;
}

@Override
Expand Down Expand Up @@ -217,15 +219,7 @@ public long size() {

@Override
public IModel<NotificationTO> model(final NotificationTO notification) {
return new IModel<>() {

private static final long serialVersionUID = 774694801558497248L;

@Override
public NotificationTO getObject() {
return notification;
}
};
return Model.of(notification);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package org.apache.syncope.client.console.notifications;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -28,30 +27,29 @@
import org.apache.syncope.client.console.panels.search.SearchClause;
import org.apache.syncope.client.console.panels.search.SearchUtils;
import org.apache.syncope.client.lib.SyncopeClient;
import org.apache.syncope.client.ui.commons.wizards.any.EntityWrapper;
import org.apache.syncope.common.lib.search.AbstractFiqlSearchConditionBuilder;
import org.apache.syncope.common.lib.to.NotificationTO;

public class NotificationWrapper implements Serializable {
public class NotificationWrapper extends EntityWrapper<NotificationTO> {

private static final long serialVersionUID = 8058288034211558376L;

private final NotificationTO notificationTO;

private List<Pair<String, List<SearchClause>>> aboutClauses;

private List<SearchClause> recipientClauses;

public NotificationWrapper(final NotificationTO notificationTO) {
this.notificationTO = notificationTO;
super(notificationTO);
}

public final String getKey() {
return this.notificationTO.getKey();
return getInnerObject().getKey();
}

public List<Pair<String, List<SearchClause>>> getAboutClauses() {
if (this.aboutClauses == null) {
this.aboutClauses = SearchUtils.getSearchClauses(this.notificationTO.getAbouts()).entrySet().stream().
this.aboutClauses = SearchUtils.getSearchClauses(getInnerObject().getAbouts()).entrySet().stream().
map(entry -> Pair.of(entry.getKey(), entry.getValue())).collect(Collectors.toList());
}

Expand All @@ -64,7 +62,7 @@ public void setAboutClauses(final List<Pair<String, List<SearchClause>>> dynClau

public List<SearchClause> getRecipientClauses() {
if (this.recipientClauses == null) {
this.recipientClauses = SearchUtils.getSearchClauses(this.notificationTO.getRecipientsFIQL());
this.recipientClauses = SearchUtils.getSearchClauses(getInnerObject().getRecipientsFIQL());
}
return this.recipientClauses;
}
Expand All @@ -75,7 +73,7 @@ public void setRecipientClauses(final List<SearchClause> dynClauses) {

public Map<String, String> getAboutFIQLs() {
if (CollectionUtils.isEmpty(this.aboutClauses) || this.aboutClauses.get(0).getValue().isEmpty()) {
return this.notificationTO.getAbouts();
return getInnerObject().getAbouts();
} else {
Map<String, String> res = new HashMap<>();
for (Pair<String, List<SearchClause>> pair : this.aboutClauses) {
Expand Down Expand Up @@ -107,17 +105,13 @@ private String getRecipientsFIQL() {
}

public NotificationTO fillAboutConditions() {
this.notificationTO.getAbouts().clear();
this.notificationTO.getAbouts().putAll(this.getAboutFIQLs());
return this.notificationTO;
getInnerObject().getAbouts().clear();
getInnerObject().getAbouts().putAll(this.getAboutFIQLs());
return getInnerObject();
}

public NotificationTO fillRecipientConditions() {
this.notificationTO.setRecipientsFIQL(this.getRecipientsFIQL());
return this.notificationTO;
}

public NotificationTO getInnerObject() {
return this.notificationTO;
getInnerObject().setRecipientsFIQL(this.getRecipientsFIQL());
return getInnerObject();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public Engagements(final PageParameters parameters) {
body.add(content);
}

private List<ITab> buildTabList() {
protected List<ITab> buildTabList() {
List<ITab> tabs = new ArrayList<>();

tabs.add(new AbstractTab(new ResourceModel("schedTasks")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public Notifications(final PageParameters parameters) {
body.add(content);
}

private List<ITab> buildTabList() {
final List<ITab> tabs = new ArrayList<>();
protected List<ITab> buildTabList() {
List<ITab> tabs = new ArrayList<>();

tabs.add(new AbstractTab(new ResourceModel("notifications")) {

Expand All @@ -74,6 +74,7 @@ public Panel getPanel(final String panelId) {
return new MailTemplateDirectoryPanel(panelId, notificationRestClient, getPageReference());
}
});

return tabs;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink.ActionType;
import org.apache.syncope.client.console.wicket.markup.html.form.ActionsPanel;
import org.apache.syncope.client.console.wizards.WizardMgtPanel;
import org.apache.syncope.client.console.wizards.any.AnyObjectWrapper;
import org.apache.syncope.client.ui.commons.Constants;
import org.apache.syncope.client.ui.commons.wizards.AjaxWizard;
import org.apache.syncope.client.ui.commons.wizards.any.AnyWrapper;
Expand Down Expand Up @@ -117,7 +118,7 @@ public ActionsPanel<AnyObjectTO> getActions(final IModel<AnyObjectTO> model) {
public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) {
send(AnyObjectDirectoryPanel.this, Broadcast.EXACT,
new AjaxWizard.EditItemActionEvent<>(
new AnyWrapper<>(restClient.read(model.getObject().getKey())), target));
new AnyObjectWrapper(restClient.read(model.getObject().getKey())), target));
}
}, ActionType.EDIT,
String.format("%s,%s", AnyEntitlement.READ.getFor(type), AnyEntitlement.UPDATE.getFor(type))).
Expand All @@ -129,7 +130,7 @@ public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) {
model.getObject(),
realm,
altDefaultModal,
getString("any.edit", new Model<>(new AnyWrapper<>(model.getObject()))),
getString("any.edit", new Model<>(new AnyObjectWrapper(model.getObject()))),
this,
pageRef).forEach(panel::add);

Expand Down Expand Up @@ -214,7 +215,7 @@ public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) {
final AnyObjectTO clone = SerializationUtils.clone(model.getObject());
clone.setKey(null);
send(AnyObjectDirectoryPanel.this, Broadcast.EXACT,
new AjaxWizard.NewItemActionEvent<>(new AnyWrapper<>(clone), target));
new AjaxWizard.NewItemActionEvent<>(new AnyObjectWrapper(clone), target));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,11 @@ protected void updateResultTable(final boolean create) {
}

protected void updateResultTable(final boolean create, final int rows) {
dataProvider = dataProvider();
synchronized (this) {
if (dataProvider == null) {
dataProvider = dataProvider();
}
}

int currentPage = Optional.ofNullable(resultTable).
map(table -> (create ? (int) table.getPageCount() - 1 : (int) table.getCurrentPage())).orElse(0);
Expand Down
Loading

0 comments on commit 9f353bb

Please sign in to comment.