Skip to content

Commit

Permalink
one more attempt for link container visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Aug 31, 2023
1 parent aca2980 commit 07c8799
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,30 @@
<hr class="w-100" style="border-color: #818d98;">
</div>

<div wicket:id="flowLinkContainer">
<wicket:enclosure child="identityRecovery">
<div class="d-flex justify-content-end mt-2">
<a wicket:id="identityRecovery" class="btn btn-default text-center login-panel-control">
<div wicket:id="identityRecoveryLabel"/>
</a>
<div wicket:id="flowLinkContainer">
<wicket:enclosure child="identityRecovery">
<div class="d-flex justify-content-end mt-2">
<a wicket:id="identityRecovery" class="btn btn-default text-center login-panel-control">
<div wicket:id="identityRecoveryLabel"/>
</a>
</div>
</wicket:enclosure>
<wicket:enclosure child="resetPassword">
<div class="d-flex justify-content-end mt-2">
<a wicket:id="resetPassword" class="btn btn-default text-center login-panel-control">
<div wicket:id="resetPasswordLabel"/>
</a>
</div>
</wicket:enclosure>
<wicket:enclosure child="selfRegistration">
<div class="d-flex justify-content-end mt-2">
<a wicket:id="selfRegistration" class="btn btn-default text-center login-panel-control">
<div wicket:id="selfRegistrationLabel"/>
</a>
</div>
</wicket:enclosure>
</div>
</wicket:enclosure>
<wicket:enclosure child="resetPassword">
<div class="d-flex justify-content-end mt-2">
<a wicket:id="resetPassword" class="btn btn-default text-center login-panel-control">
<div wicket:id="resetPasswordLabel"/>
</a>
</div>
</wicket:enclosure>
<wicket:enclosure child="selfRegistration">
<div class="d-flex justify-content-end mt-2">
<a wicket:id="selfRegistration" class="btn btn-default text-center login-panel-control">
<div wicket:id="selfRegistrationLabel"/>
</a>
</div>
</wicket:enclosure>
</div>
</wicket:enclosure>

</wicket:extend>
</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ protected final void initCustomLayout() {
addForgotPasswordLink(flowLinkContainer, securityPolicy);
addRegistrationLink(flowLinkContainer, securityPolicy);

flowLinkContainer.add(new VisibleBehaviour(() -> !flowLinkContainer.streamChildren().findAny().isEmpty()));
flowLinkContainer.add(new VisibleBehaviour(() -> isFlowLinkContainerVisible(flowLinkContainer)));

WebMarkupContainer csrfField = SecurityUtils.createHiddenInputForCsrf(ID_CSRF_FIELD);
form.add(csrfField);
Expand Down Expand Up @@ -223,6 +223,17 @@ private void addRegistrationLink(WebMarkupContainer flowLinkContainer, SecurityP
StringUtils.isEmpty(label) ? "PageLogin.registerNewAccount" : label);
}

private boolean isFlowLinkContainerVisible(WebMarkupContainer flowLinkContainer) {
return flowLinkContainer
.streamChildren()
.anyMatch(c -> c instanceof ExternalLink externalLink && isLinkVisible(externalLink));
}

private boolean isLinkVisible(ExternalLink externalLink) {
return externalLink.getBehaviors()
.stream()
.anyMatch(b -> b instanceof VisibleBehaviour vb && vb.isVisible());
}

private SecurityPolicyType loadSecurityPolicyType() {
return securityPolicyModel.getObject();
Expand Down

0 comments on commit 07c8799

Please sign in to comment.