Skip to content

Commit

Permalink
KEYCLOAK-7244: Lang dropdowns should sometimes be hidden (keycloak#5175)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssilvert authored May 7, 2018
1 parent 3ced81a commit 344286e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
22 changes: 12 additions & 10 deletions themes/src/main/resources/theme/keycloak-preview/account/index.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,18 @@
-->
<ul class="nav navbar-nav navbar-right navbar-iconic">
<li><button id="signInButton" style="visibility:hidden" onclick="keycloak.login();" class="btn btn-primary btn-lg btn-sign" type="button">${msg("doLogIn")}</button></li>
<li class="dropdown">
<a href="#0" class="dropdown-toggle nav-item-iconic" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
${msg("locale_" + locale)} <span class="caret"></span>
</a>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<#list supportedLocales as locale, label>
<li><a href="${baseUrl}/?kc_locale=${locale}">${label}</a></li>
</#list>
</ul>
</li>
<#if realm.internationalizationEnabled && supportedLocales?size gt 1>
<li class="dropdown">
<a href="#0" class="dropdown-toggle nav-item-iconic" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
${msg("locale_" + locale)} <span class="caret"></span>
</a>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<#list supportedLocales as locale, label>
<li><a href="${baseUrl}/?kc_locale=${locale}">${label}</a></li>
</#list>
</ul>
</li>
</#if>
</ul>
</nav>
</nav>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</a>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu2">
<li><a href="#" (click)="logout()">{{'doSignOut' | translate}}</a></li>
<li class="dropdown-submenu pull-left">
<li *ngIf="showLocales()" class="dropdown-submenu pull-left">
<a class="test" tabindex="-1" href="#">Change language</a>
<ul class="dropdown-menu">
<li *ngFor="let locale of availableLocales" (click)="changeLocale(locale.locale)"><a tabindex="-1" href="#">{{ locale.label }}</a></li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ declare const resourceUrl: string;
declare const baseUrl: string;
declare const referrer: string;
declare const referrer_uri: string;
declare const isInternationalizationEnabled: boolean;
declare const availableLocales: Array<Object>;

@Component({
Expand Down Expand Up @@ -56,6 +57,10 @@ export class TopNavComponent implements OnInit {
this.keycloakService.logout(baseUrl);
}

private showLocales(): boolean {
return isInternationalizationEnabled && (this.availableLocales.length > 1);
}

private changeLocale(newLocale: string) {
this.keycloakService.login({kcLocale: newLocale });
}
Expand Down

0 comments on commit 344286e

Please sign in to comment.