Skip to content

Commit c411cf1

Browse files
committed
Split the WAYF remember-my-choice template per mode
# If applied, this commit will... Render the global and the per-SP remember-my-choice checkbox from two separate templates, selected by a thin if/elseif in rememberChoice.html.twig. # Why is this change needed? Prior to this change, one template held both variants and nested the per-SP checkbox inside the rememberChoiceFeature flag. The two modes are mutually exclusive, so the per-SP variant should not depend on the flag of the global variant, and the nesting hid that either/or relationship. # How does it address the issue? This change moves each variant into its own partial (rememberChoiceGlobal and rememberChoicePerIdp). The per-SP variant is rendered whenever rememberChoicePerIdp is set, the global variant only otherwise. The markup of both variants is unchanged. The render test now also covers the per-SP variant without the global flag and the case where both are disabled. # Provide links to any relevant tickets, articles or other resources Review feedback on the remember-my-choice checkbox pull request.
1 parent 059e6ca commit c411cf1

4 files changed

Lines changed: 29 additions & 14 deletions

File tree

‎tests/unit/OpenConext/EngineBlockBundle/Twig/WayfRememberChoiceRenderTest.php‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,17 @@ public function testPerIdpVariantRendersDurationAwareTextAndATooltip(): void
5353
$this->assertStringContainsString('remember_choice_per_idp_tooltip:90 days', $html);
5454
}
5555

56-
public function testFeatureDisabledRendersNothing(): void
56+
public function testPerIdpVariantRendersWithoutTheGlobalFeatureFlag(): void
5757
{
5858
$html = $this->render(rememberChoiceFeature: false, rememberChoicePerIdp: true, rememberChoiceDuration: '90 days');
5959

60+
$this->assertStringContainsString('remember_choice_per_idp:90 days', $html);
61+
}
62+
63+
public function testBothVariantsDisabledRendersNothing(): void
64+
{
65+
$html = $this->render(rememberChoiceFeature: false, rememberChoicePerIdp: false, rememberChoiceDuration: '');
66+
6067
$this->assertSame('', trim($html));
6168
}
6269

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
{% if rememberChoiceFeature %}
2-
<form method="post" action="{{ action }}" class="wayf__rememberChoice{% if rememberChoicePerIdp %} wayf__rememberChoice--perIdp{% endif %}">
3-
<input type="checkbox" name="rememberChoice" id="rememberChoice">
4-
{% if rememberChoicePerIdp %}
5-
<label for="rememberChoice">{{ 'remember_choice_per_idp'|trans({ '%duration%': rememberChoiceDuration }) }}</label>
6-
<input type="checkbox" tabindex="-1" class="tooltip visually-hidden" aria-expanded="false" role="button" aria-pressed="false" id="rememberChoiceTooltip" name="rememberChoiceTooltip">
7-
{% include '@theme/Authentication/View/Proxy/Partials/WAYF/rememberChoiceTooltip.html.twig' with {
8-
rememberChoiceDuration: rememberChoiceDuration,
9-
} only %}
10-
{% else %}
11-
<label for="rememberChoice">{{ 'remember_choice'|trans }}</label>
12-
{% endif %}
13-
</form>
1+
{% if rememberChoicePerIdp %}
2+
{% include '@theme/Authentication/View/Proxy/Partials/WAYF/rememberChoicePerIdp.html.twig' with {
3+
action: action,
4+
rememberChoiceDuration: rememberChoiceDuration,
5+
} only %}
6+
{% elseif rememberChoiceFeature %}
7+
{% include '@theme/Authentication/View/Proxy/Partials/WAYF/rememberChoiceGlobal.html.twig' with {
8+
action: action,
9+
} only %}
1410
{% endif %}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<form method="post" action="{{ action }}" class="wayf__rememberChoice">
2+
<input type="checkbox" name="rememberChoice" id="rememberChoice">
3+
<label for="rememberChoice">{{ 'remember_choice'|trans }}</label>
4+
</form>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<form method="post" action="{{ action }}" class="wayf__rememberChoice wayf__rememberChoice--perIdp">
2+
<input type="checkbox" name="rememberChoice" id="rememberChoice">
3+
<label for="rememberChoice">{{ 'remember_choice_per_idp'|trans({ '%duration%': rememberChoiceDuration }) }}</label>
4+
<input type="checkbox" tabindex="-1" class="tooltip visually-hidden" aria-expanded="false" role="button" aria-pressed="false" id="rememberChoiceTooltip" name="rememberChoiceTooltip">
5+
{% include '@theme/Authentication/View/Proxy/Partials/WAYF/rememberChoiceTooltip.html.twig' with {
6+
rememberChoiceDuration: rememberChoiceDuration,
7+
} only %}
8+
</form>

0 commit comments

Comments
 (0)