Skip to content

Commit

Permalink
Displayed environment title in header.
Browse files Browse the repository at this point in the history
Closes #612.
  • Loading branch information
imolorhe committed Mar 9, 2019
1 parent ed17115 commit 73b44d6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/app/containers/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,16 @@
<clr-dropdown>
<button
clrDropdownTrigger
class="nav-icon"
class="nav-text"
type="button"
track-id="show_environment_menu"
[popper]="'ENVIRONMENTS_BUTTON' | translate"
>
<clr-icon shape="file-settings" [ngClass]="{ 'has-badge': (environments$ | async)?.activeSubEnvironment}"></clr-icon>
<span class="header__environemnt-link">
<clr-icon shape="file-settings" [ngClass]="{ 'has-badge': (activeEnvironment$ | async) }"></clr-icon>
<span *ngIf="(activeEnvironment$ | async)">{{ (activeEnvironment$ | async)?.title }}</span>
<span *ngIf="!(activeEnvironment$ | async)">{{ 'NO_ENVIRONMENT_TEXT' | translate }}</span>
</span>
</button>
<clr-dropdown-menu clrPosition="bottom-right" *clrIfOpen>
<ng-container *ngIf="(environments$ | async)?.subEnvironments.length">
Expand All @@ -57,7 +61,7 @@
clrDropdownItem
(click)="selectActiveEnvironment(environment.id)"
*ngFor="let environment of (environments$ | async).subEnvironments"
[ngClass]="{ 'active': environment.id === (environments$ | async).activeSubEnvironment }"
[ngClass]="{ 'active': environment.id === (activeEnvironment$ | async) }"
track-id="select_environment">{{ environment.title }}</button>
<button type="button" clrDropdownItem (click)="selectActiveEnvironment(null)" track-id="select_no_environment">{{ 'NO_ENVIRONMENT_TEXT' | translate }}</button>
<div class="dropdown-divider"></div>
Expand Down
9 changes: 9 additions & 0 deletions src/app/containers/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class AppComponent {
collection$: Observable<fromCollection.State>;
windowsMeta$: Observable<fromWindowsMeta.State>;
environments$: Observable<fromEnvironments.State>;
activeEnvironment$: Observable<fromEnvironments.EnvironmentState>;

windowIds = [];
windows = {};
Expand Down Expand Up @@ -73,6 +74,14 @@ export class AppComponent {
this.collection$ = this.store.select('collection');
this.windowsMeta$ = this.store.select('windowsMeta');
this.environments$ = this.store.select('environments');
this.activeEnvironment$ = this.environments$.pipe(
map(environments => {
if (environments.activeSubEnvironment) {
return environments.subEnvironments.find(subEnvironment => subEnvironment.id === environments.activeSubEnvironment);
}
return null;
})
);

this.setDefaultLanguage();
this.setAvailableLanguages();
Expand Down
7 changes: 7 additions & 0 deletions src/scss/components/_header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,10 @@
.header-logo {
width: 30px;
}

.header__environemnt-link {
padding: 3px 5px;
background: var(--theme-bg-color);
border-radius: 4px;
border: 1px solid var(--theme-border-color);
}

0 comments on commit 73b44d6

Please sign in to comment.