Skip to content

Commit

Permalink
Feature/710 url to supportsite (#1175)
Browse files Browse the repository at this point in the history
* change config and Tenant enitity to have new attribute supportSiteURL

* implement new config attr in frontend and rename attr

* change onclick to click because onclick doesnt work

* remove window import and use normal window instead

* update customization service spec to test new config

* update backend config tests to test new attr

* change e2e properties to work with new config and remove unused testId

* rename supportSiteUrl to helpSiteUrl and change helpSiteUrl of acme

* delete compiled js files
  • Loading branch information
nevio18324 authored Nov 21, 2024
1 parent 4b6382c commit ce699f6
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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
Expand Up @@ -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) //
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public ClientConfigDto getConfigBasedOnActiveEnv(String hostName) {
tenantClientCustomization.get().triangles(), //
tenantClientCustomization.get().backgroundLogo(), //
tenantClientCustomization.get().title(), //
tenantClientCustomization.get().helpSiteUrl(), //
tenantClientCustomization.get().customStyles()); //
}

Expand Down
2 changes: 2 additions & 0 deletions backend/src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Up @@ -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
Expand All @@ -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
Expand Up @@ -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")))
Expand All @@ -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
Expand Up @@ -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";
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
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';
Expand All @@ -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(
Expand All @@ -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();
Expand All @@ -57,4 +61,6 @@ export class ApplicationTopBarComponent implements OnInit, OnDestroy {
}
});
}

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

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);

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

0 comments on commit ce699f6

Please sign in to comment.