Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/merge
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Apr 17, 2024
2 parents 8f1e1ae + 913f006 commit 29dd741
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ protected String getChangePasswordButtonStyle() {
return CHANGE_PASSWORD_BUTTON_STYLE;
}

private void updateNewPasswordValuePerformed(AjaxRequestTarget target) {
protected void updateNewPasswordValuePerformed(AjaxRequestTarget target) {
target.add(get(ID_PASSWORD_VALIDATION_PANEL));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ private List<IColumn<PasswordAccountDto, String>> initColumns() {
List<IColumn<PasswordAccountDto, String>> columns = new ArrayList<>();

columns.add(new CheckBoxHeaderColumn<PasswordAccountDto>() {
private static final long serialVersionUID = 1L;
@Override
protected IModel<Boolean> getEnabled(IModel<PasswordAccountDto> rowModel) {
return () -> {
Expand Down Expand Up @@ -367,6 +368,7 @@ protected IModel<String> getHelpModel() {

IconColumn enabled = new IconColumn<PasswordAccountDto>(createStringResource("ChangePasswordPanel.enabled")) {

private static final long serialVersionUID = 1L;
@Override
protected DisplayType getIconDisplayType(IModel<PasswordAccountDto> rowModel) {
String cssClass = "fa fa-question text-info";
Expand Down Expand Up @@ -395,21 +397,22 @@ public String getCssClass() {

@Override
public void populateItem(Item<ICellPopulator<PasswordAccountDto>> cellItem, String componentId, IModel<PasswordAccountDto> rowModel) {
IModel<List<StringLimitationResult>> limitationsModel = () -> {
if (rowModel.getObject().getPasswordValuePolicy() == null) {
return new ArrayList<>();
}
LoadableModel<List<StringLimitationResult>> limitationsModel = new LoadableModel<>() {
private static final long serialVersionUID = 1L;
@Override
protected List<StringLimitationResult> load() {
if (rowModel.getObject().getPasswordValuePolicy() == null) {
return new ArrayList<>();
}

return getLimitationsForActualPassword(rowModel.getObject().getPasswordValuePolicy(),
rowModel.getObject().getObject());
return getLimitationsForActualPassword(rowModel.getObject().getPasswordValuePolicy(),
rowModel.getObject().getObject());
}
};

PasswordPolicyValidationPanel validationPanel = new PasswordPolicyValidationPanel(componentId, limitationsModel);
validationPanel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !limitationsModel.getObject().isEmpty();
}
});
validationPanel.add(new VisibleEnableBehaviour(() -> !limitationsModel.getObject().isEmpty()));
validationPanel.setOutputMarkupId(true);
cellItem.add(validationPanel);
}

Expand All @@ -425,6 +428,7 @@ public String getCssClass() {
@Override
public void populateItem(Item<ICellPopulator<PasswordAccountDto>> cellItem, String componentId, IModel<PasswordAccountDto> rowModel) {
LoadableModel<OperationResult> resultStatusModel = new LoadableModel<OperationResult>() {
private static final long serialVersionUID = 1L;
@Override
protected OperationResult load() {
if (progress == null
Expand Down Expand Up @@ -454,6 +458,7 @@ protected OperationResult load() {
}
};
ColumnResultPanel resultPanel = new ColumnResultPanel(componentId, resultStatusModel) {
private static final long serialVersionUID = 1L;
@Override
protected boolean isProjectionResult() {
return !rowModel.getObject().isMidpoint();
Expand Down Expand Up @@ -615,7 +620,7 @@ protected boolean shouldLoadAccounts() {
|| CredentialsPropagationUserControlType.IDENTITY_MANAGER_MANDATORY.equals(getCredentialsPropagationUserControl());
}

protected void updateResultColumnOfTable(AjaxRequestTarget target) {
private void updateResultColumnOfTable(AjaxRequestTarget target) {
getTableComponent().getDataTable().visitChildren(ColumnResultPanel.class,
(IVisitor<ColumnResultPanel, ColumnResultPanel>) (panel, iVisit) -> {
if (panel.getModel() instanceof LoadableModel) {
Expand All @@ -625,6 +630,19 @@ protected void updateResultColumnOfTable(AjaxRequestTarget target) {
});
}

//fix for open project ticket 9608
private void updatePasswordValidationColumnOfTable(AjaxRequestTarget target) {
getTableComponent().getDataTable().visitChildren(PasswordPolicyValidationPanel.class,
(IVisitor<PasswordPolicyValidationPanel, PasswordPolicyValidationPanel>) (panel, iVisit) -> {
if (panel.getModel() instanceof LoadableModel) {
((LoadableModel) panel.getModel()).reset();
}
target.add(panel);
});

target.appendJavaScript(PasswordPolicyValidationPanel.JAVA_SCRIPT_CODE);
}

private CredentialsPropagationUserControlType getCredentialsPropagationUserControl() {
CredentialsPolicyType credentialsPolicy = credentialsPolicyModel.getObject();
return credentialsPolicy != null && credentialsPolicy.getPassword() != null ?
Expand Down Expand Up @@ -658,4 +676,9 @@ private boolean isMandatoryPropagation(PasswordAccountDto passwordAccountDto) {
return passwordAccountDto.isMidpoint()
&& CredentialsPropagationUserControlType.IDENTITY_MANAGER_MANDATORY.equals(propagationUserControl);
}

protected void updateNewPasswordValuePerformed(AjaxRequestTarget target) {
super.updateNewPasswordValuePerformed(target);
updatePasswordValidationColumnOfTable(target);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@

<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:head>
<script type="text/javascript" >
$(document).ready(function (){
$(".info-icon").passwordValidatorPopover(".info-icon", ".password-validator-popover");
});
</script>
</wicket:head>
<wicket:panel>
<div style="float: left; padding-right: 5px;" wicket:id="resultIcon"/>
<div style="position: relative;">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
import com.evolveum.midpoint.gui.api.GuiStyleConstants;
import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.component.password.PasswordLimitationsPanel;
import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.gui.api.util.GuiDisplayTypeUtil;
import com.evolveum.midpoint.model.api.validator.StringLimitationResult;

import com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

Expand All @@ -29,12 +32,23 @@ public class PasswordPolicyValidationPanel extends BasePanel<List<StringLimitati
private static final String ID_RESULT_ICON = "resultIcon";
private static final String ID_INFO_ICON = "infoIcon";
private static final String ID_POLICY_VALIDATION_POPOVER = "policyValidationPopover";

public static final String JAVA_SCRIPT_CODE = "$(document).ready(function (){\n"
+ " $(\".info-icon\").passwordValidatorPopover(\".info-icon\", \".password-validator-popover\");\n"
+ " });\n";
private Model<Boolean> isAfterInitialization = Model.of(false);

public PasswordPolicyValidationPanel(String id, IModel<List<StringLimitationResult>> model) {
public PasswordPolicyValidationPanel(String id, LoadableModel<List<StringLimitationResult>> model) {
super(id, model);
}

@Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);

response.render(OnDomReadyHeaderItem.forScript(JAVA_SCRIPT_CODE));
}

@Override
protected void onInitialize() {
super.onInitialize();
Expand Down Expand Up @@ -63,6 +77,7 @@ private void initLayout() {

ImagePanel infoPanel = new ImagePanel(
ID_INFO_ICON, Model.of(GuiDisplayTypeUtil.createDisplayType("fa fa-info-circle")));
infoPanel.setOutputMarkupId(true);
add(infoPanel);

PasswordLimitationsPanel validationPanel = new PasswordLimitationsPanel(ID_POLICY_VALIDATION_POPOVER, getModel());
Expand Down

0 comments on commit 29dd741

Please sign in to comment.