fix(console): apply labelpolicy if icon is provided, signout page (#4499)

* label policy as observable

* signedout policy via state

* add caching

* disable loading spinner on signedout

* cleanup

* catch error

* update deps

* move policy to localstorage

* handle labelpolicy for users without org

Co-authored-by: Livio Spring <[email protected]>
Co-authored-by: Fabi <[email protected]>
This commit is contained in:
Max Peintner
2022-10-17 14:09:34 +02:00
committed by GitHub
co-authored by Livio Spring Fabi
parent bb16852e84
commit da51b481ee
18 changed files with 355 additions and 536 deletions
@@ -64,6 +64,9 @@ export class AccountsCardComponent implements OnInit {
}
public logout(): void {
const lP = JSON.stringify(this.userService.labelpolicy.getValue());
localStorage.setItem('labelPolicyOnSignout', lP);
this.authService.signout();
this.closedCard.emit();
}
@@ -11,22 +11,24 @@
</a>
</div>
<div class="footer-socials" *ngIf="!privateLabelPolicy || privateLabelPolicy?.disableWatermark === false">
<a target="_blank" rel="noreferrer" href="https://github.com/zitadel">
<i class="text-3xl lab la-github"></i>
</a>
<a target="_blank" rel="noreferrer" href="https://twitter.com/zitadel">
<i class="text-3xl lab la-twitter"></i>
</a>
<a target="_blank" rel="noreferrer" href="https://www.linkedin.com/company/zitadel/">
<i class="text-3xl lab la-linkedin"></i>
</a>
<a target="_blank" rel="noreferrer" href="https://zitadel.com/chat">
<i class="text-3xl lab la-discord"></i>
</a>
<a target="_blank" rel="noreferrer" href="https://www.youtube.com/channel/UCUAWJUNYaRn1yIVrZxEfsuA">
<i class="text-3xl lab la-youtube"></i>
</a>
<div class="footer-socials" *ngIf="authService.labelpolicy | async as lP">
<ng-container *ngIf="lP?.disableWatermark === false">
<a target="_blank" rel="noreferrer" href="https://github.com/zitadel">
<i class="text-3xl lab la-github"></i>
</a>
<a target="_blank" rel="noreferrer" href="https://twitter.com/zitadel">
<i class="text-3xl lab la-twitter"></i>
</a>
<a target="_blank" rel="noreferrer" href="https://www.linkedin.com/company/zitadel/">
<i class="text-3xl lab la-linkedin"></i>
</a>
<a target="_blank" rel="noreferrer" href="https://zitadel.com/chat">
<i class="text-3xl lab la-discord"></i>
</a>
<a target="_blank" rel="noreferrer" href="https://www.youtube.com/channel/UCUAWJUNYaRn1yIVrZxEfsuA">
<i class="text-3xl lab la-youtube"></i>
</a>
</ng-container>
</div>
<div class="theme">
@@ -9,8 +9,7 @@ import { GrpcAuthService } from 'src/app/services/grpc-auth.service';
})
export class FooterComponent {
public policy?: PrivacyPolicy.AsObject;
@Input() public privateLabelPolicy?: LabelPolicy.AsObject;
constructor(authService: GrpcAuthService) {
constructor(public authService: GrpcAuthService) {
authService.getMyPrivacyPolicy().then((policyResp) => {
if (policyResp.policy) {
this.policy = policyResp.policy;
@@ -1,26 +1,27 @@
<mat-toolbar class="header-wrapper">
<div class="header-content">
<a
class="title custom"
[routerLink]="['/']"
*ngIf="org && labelpolicy && labelpolicy.disableWatermark; else defaultHome"
>
<img
class="logo"
alt="home logo"
*ngIf="isDarkTheme; else customlighttheme"
[src]="labelpolicy.iconUrlDark ? labelpolicy.iconUrlDark : './assets/images/zitadel-logo-solo-light.svg'"
(error)="errorHandler($event, './assets/images/zitadel-logo-solo-light.svg')"
/>
<ng-template #customlighttheme>
<div *ngIf="authService.labelPolicyLoading$ | async; else logo" class="logo-placeholder">
<mat-spinner [diameter]="20"></mat-spinner>
</div>
<ng-template #logo>
<a class="title custom" [routerLink]="['/']" *ngIf="authService.labelpolicy | async as lP; else defaultHome">
<img
alt="home logo"
class="logo"
[src]="labelpolicy.iconUrl ? labelpolicy.iconUrl : './assets/images/zitadel-logo-solo-dark.svg'"
(error)="errorHandler($event, './assets/images/zitadel-logo-solo-dark.svg')"
alt="home logo"
*ngIf="isDarkTheme; else customlighttheme"
[src]="lP.iconUrlDark ? lP.iconUrlDark : './assets/images/zitadel-logo-solo-light.svg'"
(error)="errorHandler($event, './assets/images/zitadel-logo-solo-light.svg')"
/>
</ng-template>
</a>
<ng-template #customlighttheme>
<img
alt="home logo"
class="logo"
[src]="lP.iconUrl ? lP.iconUrl : './assets/images/zitadel-logo-solo-dark.svg'"
(error)="errorHandler($event, './assets/images/zitadel-logo-solo-dark.svg')"
/>
</ng-template>
</a>
</ng-template>
<ng-template #defaultHome>
<a class="title" [routerLink]="authService.zitadelPermissions.getValue().length === 0 ? ['/users', 'me'] : ['/']">
@@ -181,6 +181,16 @@
}
}
.logo-placeholder {
height: 40px;
width: 40px;
border-radius: 50%;
background-color: if($is-dark-theme, #00000020, #00000010);
display: flex;
align-items: center;
justify-content: center;
}
.title {
text-decoration: none;
color: white;
@@ -22,7 +22,6 @@ export class HeaderComponent implements OnDestroy {
@Input() public isDarkTheme: boolean = true;
@Input() public user?: User.AsObject;
@Input() public labelpolicy?: LabelPolicy.AsObject;
public showOrgContext: boolean = false;
public orgs$: Observable<Org.AsObject[]> = of([]);
+2 -2
View File
@@ -6,10 +6,10 @@ import { UntypedFormControl } from '@angular/forms';
import { Router } from '@angular/router';
import { BehaviorSubject, map, Observable, Subject, take } from 'rxjs';
import { Org } from 'src/app/proto/generated/zitadel/org_pb';
import { LabelPolicy } from 'src/app/proto/generated/zitadel/policy_pb';
import { User } from 'src/app/proto/generated/zitadel/user_pb';
import { AuthenticationService } from 'src/app/services/authentication.service';
import { BreadcrumbService, BreadcrumbType } from 'src/app/services/breadcrumb.service';
import { GrpcAuthService } from 'src/app/services/grpc-auth.service';
import { KeyboardShortcutsService } from 'src/app/services/keyboard-shortcuts/keyboard-shortcuts.service';
import { ManagementService } from 'src/app/services/mgmt.service';
@@ -73,7 +73,6 @@ export class NavComponent implements OnDestroy {
@Input() public isDarkTheme: boolean = true;
@Input() public user!: User.AsObject;
@Input() public labelpolicy?: LabelPolicy.AsObject;
public isHandset$: Observable<boolean> = this.breakpointObserver.observe('(max-width: 599px)').pipe(
map((result) => {
return result.matches;
@@ -91,6 +90,7 @@ export class NavComponent implements OnDestroy {
public customerPortalLink: string = '';
constructor(
public authService: GrpcAuthService,
public authenticationService: AuthenticationService,
public breadcrumbService: BreadcrumbService,
public mgmtService: ManagementService,
@@ -57,7 +57,6 @@ export class OrgTableComponent {
private router: Router,
private toast: ToastService,
private _liveAnnouncer: LiveAnnouncer,
private themeService: ThemeService,
) {
this.requestOrgs$.next({ limit: this.initialLimit, offset: 0, queries: this.searchQueries });
this.authService.getActiveOrg().then((org) => (this.activeOrg = org));
@@ -137,7 +136,6 @@ export class OrgTableComponent {
public setAndNavigateToOrg(org: Org.AsObject): void {
this.authService.setActiveOrg(org);
this.themeService.loadPrivateLabelling();
this.router.navigate(['/org']);
}