Skip to content

Commit 9070ad6

Browse files
committed
119602: Port disabling of cookie popup from main
# Conflicts: # src/app/footer/footer.component.spec.ts # src/app/footer/footer.component.ts # src/config/default-app-config.ts # src/config/info-config.interface.ts # src/environments/environment.test.ts
1 parent 9e39b01 commit 9070ad6

8 files changed

Lines changed: 19 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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,17 @@ describe('Footer component', () => {
6767
it('should call cookies.showSettings() if cookies is defined', () => {
6868
const cookies = jasmine.createSpyObj('cookies', ['showSettings']);
6969
comp.cookies = cookies;
70-
comp.showCookieSettings();
70+
comp.openCookieSettings();
7171
expect(cookies.showSettings).toHaveBeenCalled();
7272
});
7373

7474
it('should not call cookies.showSettings() if cookies is undefined', () => {
7575
comp.cookies = undefined;
76-
expect(() => comp.showCookieSettings()).not.toThrow();
76+
expect(() => comp.openCookieSettings()).not.toThrow();
7777
});
7878

7979
it('should return false', () => {
80-
expect(comp.showCookieSettings()).toBeFalse();
80+
expect(comp.openCookieSettings()).toBeFalse();
8181
});
8282
});
8383

src/app/footer/footer.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export class FooterComponent implements OnInit {
4040
* A boolean representing if to show or not the top footer container
4141
*/
4242
showTopFooter = false;
43+
showCookieSettings = false;
4344
showPrivacyPolicy: boolean;
4445
showEndUserAgreement: boolean;
4546
showSendFeedback$: Observable<boolean>;
@@ -54,13 +55,14 @@ export class FooterComponent implements OnInit {
5455
}
5556

5657
ngOnInit(): void {
58+
this.showCookieSettings = this.appConfig.info.enableCookieConsentPopup;
5759
this.showPrivacyPolicy = this.appConfig.info.enablePrivacyStatement;
5860
this.showEndUserAgreement = this.appConfig.info.enableEndUserAgreement;
5961
this.coarLdnEnabled$ = this.appConfig.info.enableCOARNotifySupport ? this.notifyInfoService.isCoarConfigEnabled() : observableOf(false);
6062
this.showSendFeedback$ = this.authorizationService.isAuthorized(FeatureID.CanSendFeedback);
6163
}
6264

63-
showCookieSettings() {
65+
openCookieSettings() {
6466
if (hasValue(this.cookies)) {
6567
this.cookies.showSettings();
6668
}

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

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

168-
this.klaroConfig.services = this.filterConfigServices(servicesToHide);
168+
if (!environment.info?.enableCookieConsentPopup) {
169+
this.klaroConfig.services = [];
170+
} else {
171+
this.klaroConfig.services = this.filterConfigServices(servicesToHide);
172+
}
173+
169174
this.lazyKlaro.then(({ setup }) => setup(this.klaroConfig));
170175
});
171176
}

src/config/default-app-config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ export class DefaultAppConfig implements AppConfig {
478478
enableEndUserAgreement: true,
479479
enablePrivacyStatement: true,
480480
enableCOARNotifySupport: true,
481+
enableCookieConsentPopup: true,
481482
};
482483

483484
// 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
@@ -4,4 +4,5 @@ export interface InfoConfig extends Config {
44
enableEndUserAgreement: boolean;
55
enablePrivacyStatement: boolean;
66
enableCOARNotifySupport: boolean;
7+
enableCookieConsentPopup: boolean;
78
}

src/environments/environment.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ export const environment: BuildConfig = {
338338
enableEndUserAgreement: true,
339339
enablePrivacyStatement: true,
340340
enableCOARNotifySupport: true,
341+
enableCookieConsentPopup: true,
341342
},
342343
markdown: {
343344
enabled: false,

0 commit comments

Comments
 (0)