KEYCLOAK-7244: Lang dropdowns should sometimes be hidden (#5175)
This commit is contained in:
parent
3ced81a2c2
commit
344286e037
3 changed files with 18 additions and 11 deletions
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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({
|
||||
|
@ -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 });
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue