From 7c56fb7a3d273306792e90f8cfb6f5d41e8e36fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henry=20T=C3=A4schner?= <129834483+HenryT-CG@users.noreply.github.com> Date: Wed, 24 Jan 2024 15:08:17 +0100 Subject: [PATCH] feat: configure theme product (#39) * feat: configure theme product * fix: app description * fix: code issues detected by sonar --- Dockerfile | 2 +- helm/values.yaml | 12 ++++++------ src/app/app.component.spec.ts | 4 ++-- src/app/app.component.ts | 2 +- src/app/app.module.ts | 2 +- ...emote.module.ts => onecx-theme-remote.module.ts} | 4 ++-- src/app/shared/can-active-guard.service.ts | 2 +- .../image-container/image-container.component.ts | 2 +- src/app/shared/label.resolver.ts | 2 +- src/app/shared/shared.module.ts | 8 +++----- src/app/test/mocks/auth-mock.service.ts | 4 +++- .../theme-designer/theme-designer.component.html | 8 -------- .../theme/theme-detail/theme-detail.component.html | 13 ------------- .../theme/theme-detail/theme-detail.component.ts | 2 +- src/assets/silent-check-sso.html | 6 +++++- src/environments/environment.ts | 9 --------- src/index.html | 2 +- tsconfig.app.json | 2 +- webpack.config.js | 2 +- 19 files changed, 31 insertions(+), 57 deletions(-) rename src/app/{theme-mgmt-remote.module.ts => onecx-theme-remote.module.ts} (85%) diff --git a/Dockerfile b/Dockerfile index d1d8506..f4451ae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ COPY dist/onecx-theme-ui/ $DIR_HTML # Application environments default values ENV BFF_URL http://onecx-theme-bff:8080/ -ENV APP_BASE_HREF /theme/ +ENV APP_BASE_HREF / RUN chmod 775 -R $DIR_HTML/assets USER 1001 diff --git a/helm/values.yaml b/helm/values.yaml index 73879bf..209c484 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -4,16 +4,16 @@ app: repository: 'onecx/onecx-theme-ui' routing: enabled: true - path: /ui/mfe/theme/ + path: /mfe/theme/ operator: # Microfrontend microfrontend: enabled: true spec: - exposedModule: "./ThemeMgmtModule" - description: "Theme Mgmt module" - note: "Theme Mgmt UI module auto import via MF operator" + exposedModule: "./OneCXThemeModule" + description: "OneCX Theme Module" + note: "OneCX Theme UI module auto import via MF operator" # Permission permission: enabled: true @@ -33,9 +33,9 @@ app: enabled: true client: |- { - "clientId": "theme-mgmt-ui", + "clientId": "onecx-theme-ui", "enabled": true, - "description": "Keycloak client for theme-mgmt-ui", + "description": "Keycloak client for onecx-theme-ui", "redirectUris": ["*"], "webOrigins": ["*"], "publicClient": true, diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index c2fe1a5..406a5e2 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -18,9 +18,9 @@ describe('AppComponent', () => { expect(app).toBeTruthy() }) - it(`should have as title 'theme-mgmt'`, () => { + it(`should have as title 'onecx-theme-ui'`, () => { const fixture = TestBed.createComponent(AppComponent) const app = fixture.componentInstance - expect(app.title).toEqual('theme-mgmt') + expect(app.title).toEqual('onecx-theme-ui') }) }) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 92b1342..34caa4c 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -4,5 +4,5 @@ import { Component } from '@angular/core' templateUrl: './app.component.html' }) export class AppComponent { - title = 'theme-mgmt' + title = 'onecx-theme-ui' } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 35a66a8..214fb59 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -24,7 +24,7 @@ function initializer(translate: TranslateService): () => Observable { @NgModule({ bootstrap: [AppComponent], declarations: [AppComponent], - imports: [BrowserModule, KeycloakAuthModule, BrowserAnimationsModule, PortalCoreModule.forRoot('theme-mgmt-ui')], + imports: [BrowserModule, KeycloakAuthModule, BrowserAnimationsModule, PortalCoreModule.forRoot('onecx-theme-ui')], providers: [ DialogService, { provide: APP_CONFIG, useValue: environment }, diff --git a/src/app/theme-mgmt-remote.module.ts b/src/app/onecx-theme-remote.module.ts similarity index 85% rename from src/app/theme-mgmt-remote.module.ts rename to src/app/onecx-theme-remote.module.ts index ec377f7..67a75b9 100644 --- a/src/app/theme-mgmt-remote.module.ts +++ b/src/app/onecx-theme-remote.module.ts @@ -15,8 +15,8 @@ const routes: Routes = [ providers: [], schemas: [] }) -export class ThemeMgmtModule { +export class OneCXThemeModule { constructor(@Inject(MFE_INFO) mfeInfo?: MfeInfo) { - console.info('Theme Mgmt Module constructor', mfeInfo) + console.info('OneCX Theme Module constructor', mfeInfo) } } diff --git a/src/app/shared/can-active-guard.service.ts b/src/app/shared/can-active-guard.service.ts index 69df9f7..201a143 100644 --- a/src/app/shared/can-active-guard.service.ts +++ b/src/app/shared/can-active-guard.service.ts @@ -12,7 +12,7 @@ const DEFAULT_LANG = 'en' export class CanActivateGuard implements CanActivate { constructor(private txService: TranslateService, private config: ConfigurationService) {} - /* eslint-disable @typescript-eslint/no-unused-vars */ /* TODO: is route and state needed */ + /* eslint-disable @typescript-eslint/no-unused-vars */ canActivate( route: ActivatedRouteSnapshot, state: RouterStateSnapshot diff --git a/src/app/shared/image-container/image-container.component.ts b/src/app/shared/image-container/image-container.component.ts index 7636ba9..b189a7c 100644 --- a/src/app/shared/image-container/image-container.component.ts +++ b/src/app/shared/image-container/image-container.component.ts @@ -24,7 +24,7 @@ export class ImageContainerComponent implements OnChanges { // if image Url does not start with a http the api-prefix ... // ...then it stored in the backend. So we need to put prefix in front - if (this.imageUrl && !this.imageUrl.match(/^(http|https)/g) && this.imageUrl.indexOf(this.apiPrefix) !== 0) { + if (this.imageUrl && !this.imageUrl.match(/^(http|https)/g) && !this.imageUrl.startsWith(this.apiPrefix)) { this.imageUrl = this.apiPrefix + this.imageUrl } } diff --git a/src/app/shared/label.resolver.ts b/src/app/shared/label.resolver.ts index 538e552..cc6206f 100644 --- a/src/app/shared/label.resolver.ts +++ b/src/app/shared/label.resolver.ts @@ -7,7 +7,7 @@ import { Observable } from 'rxjs' @Injectable() export class LabelResolver implements Resolve { constructor(private translate: TranslateService) {} - /* eslint-disable @typescript-eslint/no-unused-vars */ /* TODO: is state needed */ + /* eslint-disable @typescript-eslint/no-unused-vars */ resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): string | Observable | Promise { return route.data['breadcrumb'] ? this.translate.instant(route.data['breadcrumb']) : route.routeConfig?.path } diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index 96e818c..42e965a 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -45,10 +45,8 @@ import { ImageContainerComponent } from './image-container/image-container.compo import { ThemeColorBoxComponent } from './theme-color-box/theme-color-box.component' export const basePathProvider = (mfeInfo: MfeInfo) => { - console.log( - 'Base path provider: ' + (mfeInfo ? mfeInfo.remoteBaseUrl + '' + environment.apiPrefix : '' + environment.apiPrefix) - ) - return mfeInfo ? mfeInfo.remoteBaseUrl + '' + environment.apiPrefix : '' + environment.apiPrefix + console.log('Base path provider: ' + (mfeInfo ? mfeInfo?.remoteBaseUrl : '') + environment.apiPrefix) + return (mfeInfo ? mfeInfo?.remoteBaseUrl : '') + environment.apiPrefix } export function HttpLoaderFactory(http: HttpClient, mfeInfo: MfeInfo) { @@ -56,7 +54,7 @@ export function HttpLoaderFactory(http: HttpClient, mfeInfo: MfeInfo) { console.log(`Configuring translation loader ${mfeInfo?.remoteBaseUrl}`) } // if running standalone then load the app assets directly from remote base URL - const appAssetPrefix = mfeInfo && mfeInfo.remoteBaseUrl ? mfeInfo.remoteBaseUrl : './' + const appAssetPrefix = mfeInfo?.remoteBaseUrl ? mfeInfo.remoteBaseUrl : './' return new TranslateCombinedLoader( new TranslateHttpLoader(http, appAssetPrefix + 'assets/i18n/', '.json'), new TranslateHttpLoader(http, appAssetPrefix + 'onecx-portal-lib/assets/i18n/', '.json') diff --git a/src/app/test/mocks/auth-mock.service.ts b/src/app/test/mocks/auth-mock.service.ts index ed76935..424c944 100644 --- a/src/app/test/mocks/auth-mock.service.ts +++ b/src/app/test/mocks/auth-mock.service.ts @@ -6,7 +6,9 @@ export class IAuthMockService implements IAuthService { getCurrentUser(): UserProfile | null { return null } - logout(): void {} + logout(): void { + // logout + } hasPermission(permissionKey: string): boolean { return false } diff --git a/src/app/theme/theme-designer/theme-designer.component.html b/src/app/theme/theme-designer/theme-designer.component.html index 8d19bd0..55edeca 100644 --- a/src/app/theme/theme-designer/theme-designer.component.html +++ b/src/app/theme/theme-designer/theme-designer.component.html @@ -62,14 +62,6 @@ - -
workspace.workspaceName) - return arr?.sort(sortByLocale).join(', ') || '' + return arr?.sort(sortByLocale).join(', ') ?? '' } } diff --git a/src/assets/silent-check-sso.html b/src/assets/silent-check-sso.html index ffe492c..9476448 100644 --- a/src/assets/silent-check-sso.html +++ b/src/assets/silent-check-sso.html @@ -1,4 +1,8 @@ - + + + + Some relevant title +