Skip to content

Commit

Permalink
Merge pull request #2844 from alexandrevryghem/fix-home-page-issues
Browse files Browse the repository at this point in the history
Fixed home page issues
  • Loading branch information
tdonohue authored Apr 12, 2024
2 parents 4d59c13 + e10630f commit c13d23d
Show file tree
Hide file tree
Showing 37 changed files with 332 additions and 213 deletions.
3 changes: 2 additions & 1 deletion config/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,11 @@ mediaViewer:

# Whether the end user agreement is required before users use the repository.
# If enabled, the user will be required to accept the agreement before they can use the repository.
# And whether the privacy statement should exist or not.
# And whether the privacy statement/COAR notify support page should exist or not.
info:
enableEndUserAgreement: true
enablePrivacyStatement: true
enableCOARNotifySupport: true

# Whether to enable Markdown (https://commonmark.org/) and MathJax (https://www.mathjax.org/)
# display in supported metadata fields. By default, only dc.description.abstract is supported.
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<ds-configuration-search-page configuration="administrativeView" [context]="context"></ds-configuration-search-page>
<ds-themed-configuration-search-page configuration="administrativeView" [context]="context"></ds-themed-configuration-search-page>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '@angular/core/testing';
import { ActivatedRoute } from '@angular/router';

import { ConfigurationSearchPageComponent } from '../../search-page/configuration-search-page.component';
import { ThemedConfigurationSearchPageComponent } from '../../search-page/themed-configuration-search-page.component';
import { ActivatedRouteStub } from '../../shared/testing/active-router.stub';
import { AdminSearchPageComponent } from './admin-search-page.component';

Expand All @@ -23,7 +23,7 @@ describe('AdminSearchPageComponent', () => {
schemas: [NO_ERRORS_SCHEMA],
}).overrideComponent(AdminSearchPageComponent, {
remove: {
imports: [ConfigurationSearchPageComponent],
imports: [ThemedConfigurationSearchPageComponent],
},
})
.compileComponents();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Component } from '@angular/core';

import { Context } from '../../core/shared/context.model';
import { ConfigurationSearchPageComponent } from '../../search-page/configuration-search-page.component';
import { ThemedConfigurationSearchPageComponent } from '../../search-page/themed-configuration-search-page.component';

@Component({
selector: 'ds-admin-search-page',
templateUrl: './admin-search-page.component.html',
styleUrls: ['./admin-search-page.component.scss'],
standalone: true,
imports: [ConfigurationSearchPageComponent],
imports: [ThemedConfigurationSearchPageComponent],
})

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<ds-configuration-search-page configuration="supervision" [context]="context"></ds-configuration-search-page>
<ds-themed-configuration-search-page configuration="supervision" [context]="context"></ds-themed-configuration-search-page>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
waitForAsync,
} from '@angular/core/testing';

import { ConfigurationSearchPageComponent } from '../../search-page/configuration-search-page.component';
import { ThemedConfigurationSearchPageComponent } from '../../search-page/themed-configuration-search-page.component';
import { AdminWorkflowPageComponent } from './admin-workflow-page.component';

describe('AdminSearchPageComponent', () => {
Expand All @@ -20,7 +20,7 @@ describe('AdminSearchPageComponent', () => {
.overrideComponent(AdminWorkflowPageComponent, {
remove: {
imports: [
ConfigurationSearchPageComponent,
ThemedConfigurationSearchPageComponent,
],
},
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Component } from '@angular/core';

import { Context } from '../../core/shared/context.model';
import { ConfigurationSearchPageComponent } from '../../search-page/configuration-search-page.component';
import { ThemedConfigurationSearchPageComponent } from '../../search-page/themed-configuration-search-page.component';

@Component({
selector: 'ds-admin-workflow-page',
templateUrl: './admin-workflow-page.component.html',
styleUrls: ['./admin-workflow-page.component.scss'],
standalone: true,
imports: [ConfigurationSearchPageComponent],
imports: [ThemedConfigurationSearchPageComponent],
})

/**
Expand Down
1 change: 0 additions & 1 deletion src/app/app-routing-paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export function getBitstreamRequestACopyRoute(item, bitstream): { routerLink: st
},
};
}
export const COAR_NOTIFY_SUPPORT = 'coar-notify-support';

export const HOME_PAGE_PATH = 'home';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<span aria-hidden="true" class="btn btn-default invisible" cdkTreeNodeToggle>
<span class="fa fa-chevron-right"></span>
</span>
<div class="align-middle pt-2">
<div class="align-middle my-auto">
<button *ngIf="(dataSource.loading$ | async) !== true" (click)="getNextPage(node)"
class="btn btn-outline-primary btn-sm" role="button">
<i class="fas fa-angle-down"></i> {{ 'communityList.showMore' | translate }}
Expand Down Expand Up @@ -37,10 +37,10 @@
<span class="fa fa-chevron-right"></span>
</span>
<div class="d-flex flex-row">
<span class="align-middle pt-2 lead">
<span class="d-flex align-middle my-auto">
<a [routerLink]="node.route" class="lead">{{ dsoNameService.getName(node.payload) }}</a>
<span class="pr-2">&nbsp;</span>
<span *ngIf="node.payload.archivedItemsCount >= 0" class="badge badge-pill badge-secondary align-top archived-items-lead">{{node.payload.archivedItemsCount}}</span>
<span *ngIf="node.payload.archivedItemsCount >= 0" class="badge badge-pill badge-secondary align-top archived-items-lead my-auto">{{node.payload.archivedItemsCount}}</span>
</span>
</div>
</div>
Expand Down Expand Up @@ -71,7 +71,7 @@
<span aria-hidden="true" class="btn btn-default invisible" cdkTreeNodeToggle>
<span class="fa fa-chevron-right"></span>
</span>
<h6 class="align-middle pt-2">
<h6 class="align-middle my-auto">
<a [routerLink]="node.route" class="lead">{{ dsoNameService.getName(node.payload) }}</a>
</h6>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/app/footer/footer.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ <h5 class="text-uppercase">Footer Content</h5>
</li>
</ul>
</div>
<div class="notify-enabled text-white" [hidden]="!coarLdnEnabled">
<div *ngIf="coarLdnEnabled$ | async" class="notify-enabled text-white">
<a class="coar-notify-support-route" routerLink="info/coar-notify-support">
<img class="n-coar" src="assets/images/n-coar.png" [attr.alt]="'menu.header.image.logo' | translate" />
COAR Notify
{{ 'footer.link.coar-notify-support' | translate }}
</a>
</div>
</div>
Expand Down
46 changes: 12 additions & 34 deletions src/app/footer/footer.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
// ... test imports
import { CommonModule } from '@angular/common';
import {
CUSTOM_ELEMENTS_SCHEMA,
DebugElement,
} from '@angular/core';
import {
ComponentFixture,
fakeAsync,
Expand All @@ -13,28 +7,19 @@ import {
} from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { ActivatedRoute } from '@angular/router';
import { StoreModule } from '@ngrx/store';
import {
TranslateLoader,
TranslateModule,
} from '@ngx-translate/core';
import { TranslateModule } from '@ngx-translate/core';
import { of } from 'rxjs';
import { environment } from 'src/environments/environment';

import { storeModuleConfig } from '../app.reducer';
import { APP_CONFIG } from '../../config/app-config.interface';
import { environment } from '../../environments/environment.test';
import { NotifyInfoService } from '../core/coar-notify/notify-info/notify-info.service';
import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service';
import { TranslateLoaderMock } from '../shared/mocks/translate-loader.mock';
import { ActivatedRouteStub } from '../shared/testing/active-router.stub';
import { AuthorizationDataServiceStub } from '../shared/testing/authorization-service.stub';
// Load the implementations that should be tested
import { FooterComponent } from './footer.component';

let comp: FooterComponent;
let compAny: any;
let fixture: ComponentFixture<FooterComponent>;
let de: DebugElement;
let el: HTMLElement;

let notifyInfoService = {
isCoarConfigEnabled: () => of(true),
Expand All @@ -43,30 +28,23 @@ let notifyInfoService = {
describe('Footer component', () => {
beforeEach(waitForAsync(() => {
return TestBed.configureTestingModule({
imports: [CommonModule, StoreModule.forRoot({}, storeModuleConfig), TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useClass: TranslateLoaderMock,
},
}), FooterComponent],
imports: [
TranslateModule.forRoot(),
],
providers: [
FooterComponent,
{ provide: AuthorizationDataService, useClass: AuthorizationDataServiceStub },
{ provide: NotifyInfoService, useValue: notifyInfoService },
{ provide: ActivatedRoute, useValue: new ActivatedRouteStub() },
{ provide: APP_CONFIG, useValue: environment },
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
});
}));

// synchronous beforeEach
beforeEach(() => {
fixture = TestBed.createComponent(FooterComponent);
comp = fixture.componentInstance;
compAny = comp as any;
// query for the title <p> by CSS element selector
de = fixture.debugElement.query(By.css('p'));
el = de.nativeElement;
});

it('should create footer', inject([FooterComponent], (app: FooterComponent) => {
Expand All @@ -76,23 +54,25 @@ describe('Footer component', () => {


it('should set showPrivacyPolicy to the value of environment.info.enablePrivacyStatement', () => {
comp.ngOnInit();
expect(comp.showPrivacyPolicy).toBe(environment.info.enablePrivacyStatement);
});

it('should set showEndUserAgreement to the value of environment.info.enableEndUserAgreement', () => {
comp.ngOnInit();
expect(comp.showEndUserAgreement).toBe(environment.info.enableEndUserAgreement);
});

describe('showCookieSettings', () => {
it('should call cookies.showSettings() if cookies is defined', () => {
const cookies = jasmine.createSpyObj('cookies', ['showSettings']);
compAny.cookies = cookies;
comp.cookies = cookies;
comp.showCookieSettings();
expect(cookies.showSettings).toHaveBeenCalled();
});

it('should not call cookies.showSettings() if cookies is undefined', () => {
compAny.cookies = undefined;
comp.cookies = undefined;
expect(() => comp.showCookieSettings()).not.toThrow();
});

Expand All @@ -107,9 +87,7 @@ describe('Footer component', () => {
fixture.detectChanges();
});

it('should set coarLdnEnabled based on notifyInfoService', () => {
expect(comp.coarLdnEnabled).toBeTruthy();
// Check if COAR Notify section is rendered
it('should render COAR notify support link', () => {
const notifySection = fixture.debugElement.query(By.css('.notify-enabled'));
expect(notifySection).toBeTruthy();
});
Expand Down
36 changes: 24 additions & 12 deletions src/app/footer/footer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@ import {
} from '@angular/common';
import {
Component,
Inject,
OnInit,
Optional,
} from '@angular/core';
import { RouterLink } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import {
Observable,
of as observableOf,
} from 'rxjs';

import { environment } from '../../environments/environment';
import {
APP_CONFIG,
AppConfig,
} from '../../config/app-config.interface';
import { NotifyInfoService } from '../core/coar-notify/notify-info/notify-info.service';
import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service';
import { FeatureID } from '../core/data/feature-authorization/feature-id';
Expand All @@ -25,27 +33,31 @@ import { hasValue } from '../shared/empty.util';
standalone: true,
imports: [NgIf, RouterLink, AsyncPipe, DatePipe, TranslateModule],
})
export class FooterComponent {
export class FooterComponent implements OnInit {
dateObj: number = Date.now();

/**
* A boolean representing if to show or not the top footer container
*/
showTopFooter = false;
showPrivacyPolicy = environment.info.enablePrivacyStatement;
showEndUserAgreement = environment.info.enableEndUserAgreement;
showPrivacyPolicy: boolean;
showEndUserAgreement: boolean;
showSendFeedback$: Observable<boolean>;
coarLdnEnabled: boolean;
coarLdnEnabled$: Observable<boolean>;

constructor(
@Optional() private cookies: KlaroService,
private authorizationService: AuthorizationDataService,
private notifyInfoService: NotifyInfoService,
@Optional() public cookies: KlaroService,
protected authorizationService: AuthorizationDataService,
protected notifyInfoService: NotifyInfoService,
@Inject(APP_CONFIG) protected appConfig: AppConfig,
) {
}

ngOnInit(): void {
this.showPrivacyPolicy = this.appConfig.info.enablePrivacyStatement;
this.showEndUserAgreement = this.appConfig.info.enableEndUserAgreement;
this.coarLdnEnabled$ = this.appConfig.info.enableCOARNotifySupport ? this.notifyInfoService.isCoarConfigEnabled() : observableOf(false);
this.showSendFeedback$ = this.authorizationService.isAuthorized(FeatureID.CanSendFeedback);
this.notifyInfoService.isCoarConfigEnabled().subscribe(coarLdnEnabled => {
this.coarLdnEnabled = coarLdnEnabled;
});
}

showCookieSettings() {
Expand Down
Loading

0 comments on commit c13d23d

Please sign in to comment.