fix(console): Idp settings, settings reset warn dialog, Accept-Language header interceptor, i18n (#3727)

* fix idp table, settings reset warn dialog, fix i18n interceptor, i18n

* fix label policy on org change

* fallback

* fix preview button styles

* footer, login-policy null check

* org create btn alignment

* show error with toast

* error toast
This commit is contained in:
Max Peintner
2022-05-31 09:08:47 +02:00
committed by GitHub
parent 3513148cf6
commit f9e9b4b64b
45 changed files with 472 additions and 413 deletions
+4 -92
View File
@@ -216,13 +216,14 @@ export class AppComponent implements OnDestroy {
.getActiveOrg()
.then((org) => {
this.org = org;
this.loadPrivateLabelling();
this.themeService.loadPrivateLabelling();
// TODO add when console storage is implemented
// this.startIntroWorkflow();
})
.catch((error) => {
console.error(error);
this.themeService.setDefaultColors();
this.router.navigate(['/users/me']);
});
}
@@ -256,95 +257,6 @@ export class AppComponent implements OnDestroy {
this.destroy$.complete();
}
public loadPrivateLabelling(): void {
const setDefaultColors = () => {
const darkPrimary = '#bbbafa';
const lightPrimary = '#5469d4';
const darkWarn = '#ff3b5b';
const lightWarn = '#cd3d56';
const darkBackground = '#111827';
const lightBackground = '#fafafa';
const darkText = '#ffffff';
const lightText = '#000000';
this.themeService.savePrimaryColor(darkPrimary, true);
this.themeService.savePrimaryColor(lightPrimary, false);
this.themeService.saveWarnColor(darkWarn, true);
this.themeService.saveWarnColor(lightWarn, false);
this.themeService.saveBackgroundColor(darkBackground, true);
this.themeService.saveBackgroundColor(lightBackground, false);
this.themeService.saveTextColor(darkText, true);
this.themeService.saveTextColor(lightText, false);
};
setDefaultColors();
this.mgmtService.getLabelPolicy().then((labelpolicy) => {
if (labelpolicy.policy) {
this.labelpolicy = labelpolicy.policy;
const isDark = (color: string) => this.themeService.isDark(color);
const isLight = (color: string) => this.themeService.isLight(color);
const darkPrimary = this.labelpolicy?.primaryColorDark || '#bbbafa';
const lightPrimary = this.labelpolicy?.primaryColor || '#5469d4';
const darkWarn = this.labelpolicy?.warnColorDark || '#ff3b5b';
const lightWarn = this.labelpolicy?.warnColor || '#cd3d56';
let darkBackground = this.labelpolicy?.backgroundColorDark;
let lightBackground = this.labelpolicy?.backgroundColor;
let darkText = this.labelpolicy.fontColorDark;
let lightText = this.labelpolicy.fontColor;
this.themeService.savePrimaryColor(darkPrimary, true);
this.themeService.savePrimaryColor(lightPrimary, false);
this.themeService.saveWarnColor(darkWarn, true);
this.themeService.saveWarnColor(lightWarn, false);
if (darkBackground && !isDark(darkBackground)) {
console.info(
`Background (${darkBackground}) is not dark enough for a dark theme. Falling back to zitadel background`,
);
darkBackground = '#111827';
}
this.themeService.saveBackgroundColor(darkBackground || '#111827', true);
if (lightBackground && !isLight(lightBackground)) {
console.info(
`Background (${lightBackground}) is not light enough for a light theme. Falling back to zitadel background`,
);
lightBackground = '#fafafa';
}
this.themeService.saveBackgroundColor(lightBackground || '#fafafa', false);
if (darkText && !isLight(darkText)) {
console.info(
`Text color (${darkText}) is not light enough for a dark theme. Falling back to zitadel's text color`,
);
darkText = '#ffffff';
}
this.themeService.saveTextColor(darkText || '#ffffff', true);
if (lightText && !isDark(lightText)) {
console.info(
`Text color (${lightText}) is not dark enough for a light theme. Falling back to zitadel's text color`,
);
lightText = '#000000';
}
this.themeService.saveTextColor(lightText || '#000000', false);
}
});
}
public prepareRoute(outlet: RouterOutlet): boolean {
return outlet && outlet.activatedRouteData && outlet.activatedRouteData.animation;
}
@@ -357,7 +269,7 @@ export class AppComponent implements OnDestroy {
}
public changedOrg(org: Org.AsObject): void {
this.loadPrivateLabelling();
this.themeService.loadPrivateLabelling();
this.authService.zitadelPermissionsChanged.pipe(take(1)).subscribe(() => {
this.router.navigate(['/org'], { fragment: org.id });
});