Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/710 url to supportsite #1175

Merged
merged 13 commits into from
Nov 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -3,5 +3,5 @@
import java.util.Map;

public record ClientConfigDto(String activeProfile, String issuer, String clientId, String favicon, String logo,
String triangles, String backgroundLogo, String title, Map<String, String> customStyles) {
String triangles, String backgroundLogo, String title, String helpSiteUrl, Map<String, String> customStyles) {
}
Original file line number Diff line number Diff line change
@@ -3,5 +3,5 @@
import java.util.Map;

public record TenantClientCustomization(String favicon, String logo, String triangles, String backgroundLogo,
String title, Map<String, String> customStyles) {
String title, String helpSiteUrl, Map<String, String> customStyles) {
}
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@ private TenantClientCustomization readClientCustomizationConfig(String tenantId)
env.getProperty(MessageFormat.format("okr.tenants.{0}.clientcustomization.triangles", tenantId)),
env.getProperty(MessageFormat.format("okr.tenants.{0}.clientcustomization.background-logo", tenantId)),
env.getProperty(MessageFormat.format("okr.tenants.{0}.clientcustomization.title", tenantId)),
env.getProperty(MessageFormat.format("okr.tenants.{0}.clientcustomization.helpSiteUrl", tenantId)),
getCustomCssStyles(tenantId) //
);
}
Original file line number Diff line number Diff line change
@@ -57,6 +57,7 @@ public ClientConfigDto getConfigBasedOnActiveEnv(String hostName) {
tenantClientCustomization.get().triangles(), //
tenantClientCustomization.get().backgroundLogo(), //
tenantClientCustomization.get().title(), //
tenantClientCustomization.get().helpSiteUrl(), //
tenantClientCustomization.get().customStyles()); //
}

2 changes: 2 additions & 0 deletions backend/src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
@@ -48,6 +48,7 @@ okr.tenants.pitc.clientcustomization.triangles=assets/images/triangles-okr-heade
okr.tenants.pitc.clientcustomization.background-logo=assets/images/puzzle-p.svg
okr.tenants.pitc.clientcustomization.favicon=assets/favicon.png
okr.tenants.pitc.clientcustomization.title=Puzzle OKR
okr.tenants.pitc.clientcustomization.helpSiteUrl=https://wiki.puzzle.ch/Puzzle/OKRs
okr.tenants.pitc.clientcustomization.customstyles.okr-topbar-background-color=#1e5a96
okr.tenants.pitc.clientcustomization.customstyles.okr-banner-background-color=#dcedf9

@@ -57,5 +58,6 @@ okr.tenants.acme.clientcustomization.triangles=assets/images/triangles-okr-acme-
okr.tenants.acme.clientcustomization.background-logo=assets/images/acme.svg
okr.tenants.acme.clientcustomization.favicon=assets/favicon-acme.png
okr.tenants.acme.clientcustomization.title=ACME OKR
okr.tenants.acme.clientcustomization.helpSiteUrl=https://en.wikipedia.org/wiki/Objectives_and_key_results
okr.tenants.acme.clientcustomization.customstyles.okr-topbar-background-color=#738290
okr.tenants.acme.clientcustomization.customstyles.okr-banner-background-color=#F2F2F2
Original file line number Diff line number Diff line change
@@ -51,6 +51,7 @@ okr.tenants.pitc.clientcustomization.triangles=assets/images/triangles-okr-heade
okr.tenants.pitc.clientcustomization.background-logo=assets/images/puzzle-p.svg
okr.tenants.pitc.clientcustomization.favicon=assets/favicon.png
okr.tenants.pitc.clientcustomization.title=Puzzle OKR
okr.tenants.pitc.clientcustomization.helpSiteUrl=https://wiki.puzzle.ch/Puzzle/OKRs
okr.tenants.pitc.clientcustomization.customstyles.okr-topbar-background-color=#1e5a96

# acme client customization
@@ -59,4 +60,5 @@ okr.tenants.acme.clientcustomization.triangles=assets/images/triangles-okr-acme-
okr.tenants.acme.clientcustomization.background-logo=assets/images/acme.svg
okr.tenants.acme.clientcustomization.favicon=assets/favicon-acme.png
okr.tenants.acme.clientcustomization.title=ACME OKR
okr.tenants.acme.clientcustomization.helpSiteUrl=https://en.wikipedia.org/wiki/Objectives_and_key_results
okr.tenants.acme.clientcustomization.customstyles.okr-topbar-background-color=#738290
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ void shouldGetClientConfig() throws Exception {

mvc.perform(get("/config").contentType(MediaType.APPLICATION_JSON))
.andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(jsonPath(JSON_PATH_ROOT, Matchers.aMapWithSize(9)))
.andExpect(jsonPath(JSON_PATH_ROOT, Matchers.aMapWithSize(10)))
.andExpect(jsonPath("$.activeProfile", Matchers.is("Active_Profile")))
.andExpect(jsonPath("$.issuer", Matchers.is("Issuer")))
.andExpect(jsonPath("$.clientId", Matchers.is("Client_Id")))
@@ -47,14 +47,15 @@ void shouldGetClientConfig() throws Exception {
.andExpect(jsonPath("$.triangles", Matchers.is("Triangles")))
.andExpect(jsonPath("$.backgroundLogo", Matchers.is("Background_Logo")))
.andExpect(jsonPath("$.title", Matchers.is("Title")))
.andExpect(jsonPath("$.helpSiteUrl", Matchers.is("helpSiteUrl")))
.andExpect(jsonPath("$.customStyles.font-family", Matchers.is("verdana")))
.andExpect(jsonPath("$.customStyles.font-size", Matchers.is("20px")));
}

private ClientConfigDto createClientConfigDto() {
Map<String, String> customStyles = Map.of("font-family", "verdana", "font-size", "20px");
return new ClientConfigDto("Active_Profile", "Issuer", "Client_Id", "Favicon", "Logo", "Triangles",
"Background_Logo", "Title", customStyles);
"Background_Logo", "Title", "helpSiteUrl", customStyles);
}

}
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ public class TenantClientCustomizationProviderTestIT {
private static final String BACKGROUND_LOGO = "background-logo";
private static final String FAVICON = "favicon";
private static final String TITLE = "title";
private static final String HELP_SITE_URL = "helpSiteUrl";

private static final String CUSTOM_STYLE_NAME = "okr-topbar-background-color";
private static final String CUSTOM_STYLE_VALUE = "css-custom-value";
@@ -43,6 +44,7 @@ private void setupPropertiesForTenantWithId(String id) {
mockProperty("okr.tenants.{0}.clientcustomization.background-logo", BACKGROUND_LOGO, id);
mockProperty("okr.tenants.{0}.clientcustomization.favicon", FAVICON, id);
mockProperty("okr.tenants.{0}.clientcustomization.title", TITLE, id);
mockProperty("okr.tenants.{0}.clientcustomization.helpSiteUrl", HELP_SITE_URL, id);
mockProperty("okr.tenants.{0}.clientcustomization.customstyles.okr-topbar-background-color", CUSTOM_STYLE_VALUE,
id);
}
@@ -77,6 +79,7 @@ private void assertTenantClientCustomization(TenantClientCustomization customiza
assertEquals(prefix(tenantId) + TRIANGLES, customization.triangles());
assertEquals(prefix(tenantId) + BACKGROUND_LOGO, customization.backgroundLogo());
assertEquals(prefix(tenantId) + TITLE, customization.title());
assertEquals(prefix(tenantId) + HELP_SITE_URL, customization.helpSiteUrl());
assertCustomStyles(customization, tenantId);
}

Original file line number Diff line number Diff line change
@@ -112,6 +112,7 @@ private TenantClientCustomization getTenantClientCustomization(String tenantId)
prefix(tenantId) + "triangles", //
prefix(tenantId) + "backgroundLogo", //
prefix(tenantId) + "title", //
prefix(tenantId) + "helpSiteUrl", //
new HashMap<>());
}

Original file line number Diff line number Diff line change
@@ -22,9 +22,10 @@
</button>

<button
*ngIf="this.helpSiteUrl | async as helpSiteUrl"
id="hilfeButton"
class="topBarEntry btn"
onclick="window.open('https://wiki.puzzle.ch/Puzzle/OKRs', '_blank')"
(click)="window.open(helpSiteUrl, '_blank')"
>
<mat-icon aria-hidden="false" aria-label="Help icon" fontIcon="help_outline"></mat-icon>
<span class="d-none d-md-flex"> Hilfe </span>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
import { OAuthService } from 'angular-oauth2-oidc';
import { BehaviorSubject, filter, Observable, of, Subscription, switchMap } from 'rxjs';
import { BehaviorSubject, Subscription } from 'rxjs';
import { ConfigService } from '../../services/config.service';
import { NavigationEnd, Router } from '@angular/router';
import { UserService } from '../../services/user.service';
@@ -16,6 +16,7 @@ export class ApplicationTopBarComponent implements OnInit, OnDestroy {
userFullName: string = '';
menuIsOpen = false;
logoSrc$ = new BehaviorSubject<String>('assets/images/empty.svg');
helpSiteUrl = new BehaviorSubject<string>('https://en.wikipedia.org/wiki/Objectives_and_key_results');
private subscription?: Subscription;

constructor(
@@ -32,6 +33,9 @@ export class ApplicationTopBarComponent implements OnInit, OnDestroy {
if (config.logo) {
this.logoSrc$.next(config.logo);
}
if (config.helpSiteUrl) {
this.helpSiteUrl.next(config.helpSiteUrl);
}
},
});
this.initUserFullName();
@@ -57,4 +61,6 @@ export class ApplicationTopBarComponent implements OnInit, OnDestroy {
}
});
}

protected readonly window = window;
MasterEvarior marked this conversation as resolved.
Show resolved Hide resolved
}
4 changes: 4 additions & 0 deletions frontend/src/app/services/customization.service.spec.ts
Original file line number Diff line number Diff line change
@@ -36,6 +36,7 @@ describe('CustomizationService', () => {
logo: 'logo',
triangles: 'triangles',
backgroundLogo: 'backgroundLogo',
helpSiteUrl: 'https://wiki.puzzle.ch/Puzzle/OKRs',
customStyles: { cssVar1: 'foo' },
};

@@ -86,6 +87,7 @@ describe('CustomizationService', () => {
expect(currentConfig?.favicon).toBe(body.favicon);
expect(currentConfig?.triangles).toBe(body.triangles);
expect(currentConfig?.backgroundLogo).toBe(body.backgroundLogo);
expect(currentConfig?.helpSiteUrl).toBe(body.helpSiteUrl);
expect(currentConfig?.customStyles['cssVar1']).toBe(body.customStyles['cssVar1']);

expect(callRecorder.getCallCount('title.innerHTML')).toBe(1);
@@ -110,6 +112,7 @@ describe('CustomizationService', () => {
logo: 'logo-second',
triangles: 'triangles-second',
backgroundLogo: 'backgroundLogo-second',
helpSiteUrl: 'https://wiki.puzzle.ch/Puzzle/OKRs',
customStyles: { cssVarNew: 'bar' },
};
configSubject.next(bodySecond);
@@ -120,6 +123,7 @@ describe('CustomizationService', () => {
expect(currentConfig?.favicon).toBe(bodySecond.favicon);
expect(currentConfig?.triangles).toBe(bodySecond.triangles);
expect(currentConfig?.backgroundLogo).toBe(bodySecond.backgroundLogo);
expect(currentConfig?.helpSiteUrl).toBe(bodySecond.helpSiteUrl);
expect(currentConfig?.customStyles['cssVarNew']).toBe(bodySecond.customStyles['cssVarNew']);
expect(currentConfig?.customStyles['cssVar1']).toBe(undefined);

1 change: 1 addition & 0 deletions frontend/src/app/shared/types/model/ClientConfig.ts
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ export interface CustomizationConfig {
logo: string;
triangles: string;
backgroundLogo: string;
helpSiteUrl: string;
customStyles: CustomStyles;
}
export interface ClientConfig extends AuthConfig, CustomizationConfig {}
Loading