Skip to content

Commit b44f74a

Browse files
committed
119602: Port disabling of cookie popup from main
1 parent 5075724 commit b44f74a

8 files changed

Lines changed: 27 additions & 7 deletions

File tree

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929
DSPACE_CACHE_SERVERSIDE_ANONYMOUSCACHE_MAX: 0
3030
# Tell Cypress to run e2e tests using the same UI URL
3131
CYPRESS_BASE_URL: http://127.0.0.1:4000
32+
# Disable the cookie consent banner in e2e tests to avoid errors because of elements hidden by it
33+
DSPACE_INFO_ENABLECOOKIECONSENTPOPUP: false
3234
# When Chrome version is specified, we pin to a specific version of Chrome
3335
# Comment this out to use the latest release
3436
#CHROME_VERSION: "90.0.4430.212-1"

src/app/footer/footer.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ <h5 class="text-uppercase">Footer Content</h5>
6363
href="https://www.lyrasis.org/" role="link" tabindex="0">{{ 'footer.link.lyrasis' | translate}}</a>
6464
</p>
6565
<ul class="footer-info list-unstyled d-flex justify-content-center mb-0">
66-
<li>
67-
<button class="btn btn-link text-white" type="button" (click)="showCookieSettings()" role="button" tabindex="0">
66+
<li *ngIf="showCookieSettings">
67+
<button class="btn btn-link text-white" type="button" (click)="openCookieSettings()" role="button" tabindex="0">
6868
{{ 'footer.link.cookies' | translate}}
6969
</button>
7070
</li>

src/app/footer/footer.component.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import { TranslateLoaderMock } from '../shared/mocks/translate-loader.mock';
1717
import { storeModuleConfig } from '../app.reducer';
1818
import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service';
1919
import { AuthorizationDataServiceStub } from '../shared/testing/authorization-service.stub';
20+
import { APP_CONFIG } from '../../config/app-config.interface';
21+
import { environment } from '../../environments/environment.test';
2022

2123
let comp: FooterComponent;
2224
let fixture: ComponentFixture<FooterComponent>;
@@ -38,6 +40,7 @@ describe('Footer component', () => {
3840
providers: [
3941
FooterComponent,
4042
{ provide: AuthorizationDataService, useClass: AuthorizationDataServiceStub },
43+
{ provide: APP_CONFIG, useValue: environment },
4144
],
4245
schemas: [CUSTOM_ELEMENTS_SCHEMA]
4346
});

src/app/footer/footer.component.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,42 @@
1-
import { Component, Optional } from '@angular/core';
1+
import { Component, Optional, Inject, OnInit } from '@angular/core';
22
import { hasValue } from '../shared/empty.util';
33
import { KlaroService } from '../shared/cookies/klaro.service';
44
import { environment } from '../../environments/environment';
55
import { Observable } from 'rxjs';
66
import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service';
77
import { FeatureID } from '../core/data/feature-authorization/feature-id';
8+
import { AppConfig, APP_CONFIG } from '../../config/app-config.interface';
89

910
@Component({
1011
selector: 'ds-footer',
1112
styleUrls: ['footer.component.scss'],
1213
templateUrl: 'footer.component.html'
1314
})
14-
export class FooterComponent {
15+
export class FooterComponent implements OnInit {
1516
dateObj: number = Date.now();
1617

1718
/**
1819
* A boolean representing if to show or not the top footer container
1920
*/
2021
showTopFooter = false;
22+
showCookieSettings = false;
2123
showPrivacyPolicy = environment.info.enablePrivacyStatement;
2224
showEndUserAgreement = environment.info.enableEndUserAgreement;
2325
showSendFeedback$: Observable<boolean>;
2426

2527
constructor(
2628
@Optional() private cookies: KlaroService,
2729
private authorizationService: AuthorizationDataService,
30+
@Inject(APP_CONFIG) protected appConfig: AppConfig,
2831
) {
2932
this.showSendFeedback$ = this.authorizationService.isAuthorized(FeatureID.CanSendFeedback);
3033
}
3134

32-
showCookieSettings() {
35+
ngOnInit() {
36+
this.showCookieSettings = this.appConfig.info.enableCookieConsentPopup;
37+
}
38+
39+
openCookieSettings() {
3340
if (hasValue(this.cookies)) {
3441
this.cookies.showSettings();
3542
}

src/app/shared/cookies/browser-klaro.service.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,12 @@ export class BrowserKlaroService extends KlaroService {
145145
*/
146146
this.translateConfiguration();
147147

148-
this.klaroConfig.services = this.filterConfigServices(servicesToHide);
148+
if (!environment.info?.enableCookieConsentPopup) {
149+
this.klaroConfig.services = [];
150+
} else {
151+
this.klaroConfig.services = this.filterConfigServices(servicesToHide);
152+
}
153+
149154
this.lazyKlaro.then(({ setup }) => setup(this.klaroConfig));
150155
});
151156
}

src/config/default-app-config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,8 @@ export class DefaultAppConfig implements AppConfig {
412412
// - All mentions of the privacy policy being removed from the UI (e.g. in the footer)
413413
info: InfoConfig = {
414414
enableEndUserAgreement: true,
415-
enablePrivacyStatement: true
415+
enablePrivacyStatement: true,
416+
enableCookieConsentPopup: true,
416417
};
417418

418419
// Whether to enable Markdown (https://commonmark.org/) and MathJax (https://www.mathjax.org/)

src/config/info-config.interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ import { Config } from './config.interface';
33
export interface InfoConfig extends Config {
44
enableEndUserAgreement: boolean;
55
enablePrivacyStatement: boolean;
6+
enableCookieConsentPopup: boolean;
67
}

src/environments/environment.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ export const environment: BuildConfig = {
321321
info: {
322322
enableEndUserAgreement: true,
323323
enablePrivacyStatement: true,
324+
enableCookieConsentPopup: true,
324325
},
325326
markdown: {
326327
enabled: false,

0 commit comments

Comments
 (0)