119602: Port disabling of cookie popup from main

This commit is contained in:
Andreas Awouters
2025-06-30 10:47:37 +02:00
parent 50757247ab
commit b44f74a20a
8 changed files with 27 additions and 7 deletions

View File

@@ -29,6 +29,8 @@ jobs:
DSPACE_CACHE_SERVERSIDE_ANONYMOUSCACHE_MAX: 0 DSPACE_CACHE_SERVERSIDE_ANONYMOUSCACHE_MAX: 0
# Tell Cypress to run e2e tests using the same UI URL # Tell Cypress to run e2e tests using the same UI URL
CYPRESS_BASE_URL: http://127.0.0.1:4000 CYPRESS_BASE_URL: http://127.0.0.1:4000
# Disable the cookie consent banner in e2e tests to avoid errors because of elements hidden by it
DSPACE_INFO_ENABLECOOKIECONSENTPOPUP: false
# When Chrome version is specified, we pin to a specific version of Chrome # When Chrome version is specified, we pin to a specific version of Chrome
# Comment this out to use the latest release # Comment this out to use the latest release
#CHROME_VERSION: "90.0.4430.212-1" #CHROME_VERSION: "90.0.4430.212-1"

View File

@@ -63,8 +63,8 @@
href="https://www.lyrasis.org/" role="link" tabindex="0">{{ 'footer.link.lyrasis' | translate}}</a> href="https://www.lyrasis.org/" role="link" tabindex="0">{{ 'footer.link.lyrasis' | translate}}</a>
</p> </p>
<ul class="footer-info list-unstyled d-flex justify-content-center mb-0"> <ul class="footer-info list-unstyled d-flex justify-content-center mb-0">
<li> <li *ngIf="showCookieSettings">
<button class="btn btn-link text-white" type="button" (click)="showCookieSettings()" role="button" tabindex="0"> <button class="btn btn-link text-white" type="button" (click)="openCookieSettings()" role="button" tabindex="0">
{{ 'footer.link.cookies' | translate}} {{ 'footer.link.cookies' | translate}}
</button> </button>
</li> </li>

View File

@@ -17,6 +17,8 @@ import { TranslateLoaderMock } from '../shared/mocks/translate-loader.mock';
import { storeModuleConfig } from '../app.reducer'; import { storeModuleConfig } from '../app.reducer';
import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service'; import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service';
import { AuthorizationDataServiceStub } from '../shared/testing/authorization-service.stub'; import { AuthorizationDataServiceStub } from '../shared/testing/authorization-service.stub';
import { APP_CONFIG } from '../../config/app-config.interface';
import { environment } from '../../environments/environment.test';
let comp: FooterComponent; let comp: FooterComponent;
let fixture: ComponentFixture<FooterComponent>; let fixture: ComponentFixture<FooterComponent>;
@@ -38,6 +40,7 @@ describe('Footer component', () => {
providers: [ providers: [
FooterComponent, FooterComponent,
{ provide: AuthorizationDataService, useClass: AuthorizationDataServiceStub }, { provide: AuthorizationDataService, useClass: AuthorizationDataServiceStub },
{ provide: APP_CONFIG, useValue: environment },
], ],
schemas: [CUSTOM_ELEMENTS_SCHEMA] schemas: [CUSTOM_ELEMENTS_SCHEMA]
}); });

View File

@@ -1,23 +1,25 @@
import { Component, Optional } from '@angular/core'; import { Component, Optional, Inject, OnInit } from '@angular/core';
import { hasValue } from '../shared/empty.util'; import { hasValue } from '../shared/empty.util';
import { KlaroService } from '../shared/cookies/klaro.service'; import { KlaroService } from '../shared/cookies/klaro.service';
import { environment } from '../../environments/environment'; import { environment } from '../../environments/environment';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service'; import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service';
import { FeatureID } from '../core/data/feature-authorization/feature-id'; import { FeatureID } from '../core/data/feature-authorization/feature-id';
import { AppConfig, APP_CONFIG } from '../../config/app-config.interface';
@Component({ @Component({
selector: 'ds-footer', selector: 'ds-footer',
styleUrls: ['footer.component.scss'], styleUrls: ['footer.component.scss'],
templateUrl: 'footer.component.html' templateUrl: 'footer.component.html'
}) })
export class FooterComponent { export class FooterComponent implements OnInit {
dateObj: number = Date.now(); dateObj: number = Date.now();
/** /**
* A boolean representing if to show or not the top footer container * A boolean representing if to show or not the top footer container
*/ */
showTopFooter = false; showTopFooter = false;
showCookieSettings = false;
showPrivacyPolicy = environment.info.enablePrivacyStatement; showPrivacyPolicy = environment.info.enablePrivacyStatement;
showEndUserAgreement = environment.info.enableEndUserAgreement; showEndUserAgreement = environment.info.enableEndUserAgreement;
showSendFeedback$: Observable<boolean>; showSendFeedback$: Observable<boolean>;
@@ -25,11 +27,16 @@ export class FooterComponent {
constructor( constructor(
@Optional() private cookies: KlaroService, @Optional() private cookies: KlaroService,
private authorizationService: AuthorizationDataService, private authorizationService: AuthorizationDataService,
@Inject(APP_CONFIG) protected appConfig: AppConfig,
) { ) {
this.showSendFeedback$ = this.authorizationService.isAuthorized(FeatureID.CanSendFeedback); this.showSendFeedback$ = this.authorizationService.isAuthorized(FeatureID.CanSendFeedback);
} }
showCookieSettings() { ngOnInit() {
this.showCookieSettings = this.appConfig.info.enableCookieConsentPopup;
}
openCookieSettings() {
if (hasValue(this.cookies)) { if (hasValue(this.cookies)) {
this.cookies.showSettings(); this.cookies.showSettings();
} }

View File

@@ -145,7 +145,12 @@ export class BrowserKlaroService extends KlaroService {
*/ */
this.translateConfiguration(); this.translateConfiguration();
if (!environment.info?.enableCookieConsentPopup) {
this.klaroConfig.services = [];
} else {
this.klaroConfig.services = this.filterConfigServices(servicesToHide); this.klaroConfig.services = this.filterConfigServices(servicesToHide);
}
this.lazyKlaro.then(({ setup }) => setup(this.klaroConfig)); this.lazyKlaro.then(({ setup }) => setup(this.klaroConfig));
}); });
} }

View File

@@ -412,7 +412,8 @@ export class DefaultAppConfig implements AppConfig {
// - All mentions of the privacy policy being removed from the UI (e.g. in the footer) // - All mentions of the privacy policy being removed from the UI (e.g. in the footer)
info: InfoConfig = { info: InfoConfig = {
enableEndUserAgreement: true, enableEndUserAgreement: true,
enablePrivacyStatement: true enablePrivacyStatement: true,
enableCookieConsentPopup: true,
}; };
// Whether to enable Markdown (https://commonmark.org/) and MathJax (https://www.mathjax.org/) // Whether to enable Markdown (https://commonmark.org/) and MathJax (https://www.mathjax.org/)

View File

@@ -3,4 +3,5 @@ import { Config } from './config.interface';
export interface InfoConfig extends Config { export interface InfoConfig extends Config {
enableEndUserAgreement: boolean; enableEndUserAgreement: boolean;
enablePrivacyStatement: boolean; enablePrivacyStatement: boolean;
enableCookieConsentPopup: boolean;
} }

View File

@@ -321,6 +321,7 @@ export const environment: BuildConfig = {
info: { info: {
enableEndUserAgreement: true, enableEndUserAgreement: true,
enablePrivacyStatement: true, enablePrivacyStatement: true,
enableCookieConsentPopup: true,
}, },
markdown: { markdown: {
enabled: false, enabled: false,