Skip to content

Commit

Permalink
Merge pull request DSpace#3113 from 4Science/task/main/DURACOM-271_co…
Browse files Browse the repository at this point in the history
…ar-fixes-fixed

COAR Notify impossible to send/receive message from another DSpace
  • Loading branch information
tdonohue authored Jun 14, 2024
2 parents f7a14a1 + fe09cb6 commit d71964d
Show file tree
Hide file tree
Showing 49 changed files with 699 additions and 475 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ <h1 class="flex-grow-1">{{ isNewService ? ('ldn-create-service.title' | translat
<span> {{'ldn-service.control-constaint-select-none' | translate}} </span>
</button>
<button (click)="selectInboundItemFilter(constraint.id, i); $event.stopPropagation()"
*ngFor="let constraint of (itemfiltersRD$ | async)?.payload?.page; let internalIndex = index"
*ngFor="let constraint of (itemFiltersRD$ | async)?.payload?.page; let internalIndex = index"
class="dropdown-item collection-item text-truncate w-100"
ngbDropdownItem
type="button">
Expand Down Expand Up @@ -263,14 +263,18 @@ <h1 class="flex-grow-1">{{ isNewService ? ('ldn-create-service.title' | translat

<span (click)="addInboundPattern()"
class="add-pattern-link mb-2">{{ 'ldn-new-service.form.label.addPattern' | translate }}</span>
<hr>
<div class="form-group row">
<div class="col text-right space-children-mr">
<ng-content select="[before]"></ng-content>
<button (click)="resetFormAndLeave()" class="btn btn-outline-secondary" type="button">
<span>&nbsp;{{ 'submission.general.back.submit' | translate }}</span>
</button>
<button class="btn btn-primary" type="submit">
<span><i class="fas fa-save"></i>&nbsp;{{ 'ldn-new-service.form.label.submit' | translate }}</span>
</button>

<div class="submission-form-footer my-1 position-sticky d-flex justify-content-between" role="group">
<button (click)="resetFormAndLeave()" class="btn btn-primary" type="button">
<span>&nbsp;{{ 'submission.general.back.submit' | translate }}</span>
</button>
<button class="btn btn-primary" type="submit">
<span><i class="fas fa-save"></i>&nbsp;{{ 'ldn-new-service.form.label.submit' | translate }}</span>
</button>
</div>
</div>
</form>
</div>
Expand All @@ -294,15 +298,15 @@ <h4 *ngIf="isNewService">{{'service.overview.create.modal' | translate }}</h4>
</div>
<div class="modal-footer">
<div *ngIf="!isNewService">
<button (click)="closeModal()" class="btn btn-danger mr-2"
<button (click)="closeModal()" class="btn btn-outline-secondary mr-2"
id="delete-confirm-edit">{{ 'service.detail.return' | translate }}
</button>
<button *ngIf="!isNewService" (click)="patchService()"
class="btn btn-primary">{{ 'service.detail.update' | translate }}
</button>
</div>
<div *ngIf="isNewService">
<button (click)="closeModal()" class="btn btn-danger mr-2 "
<button (click)="closeModal()" class="btn btn-outline-secondary mr-2 "
id="delete-confirm-new">{{ 'service.refuse.create' | translate }}
</button>
<button (click)="createService()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ describe('LdnServiceFormEditComponent', () => {

it('should init properties correctly', fakeAsync(() => {
spyOn(component, 'fetchServiceData');
spyOn(component, 'setItemfilters');
spyOn(component, 'setItemFilters');
component.ngOnInit();
tick(100);
expect((component as any).serviceId).toEqual(testId);
expect(component.isNewService).toBeFalsy();
expect(component.areControlsInitialized).toBeTruthy();
expect(component.formModel.controls.notifyServiceInboundPatterns).toBeDefined();
expect(component.fetchServiceData).toHaveBeenCalledWith(testId);
expect(component.setItemfilters).toHaveBeenCalled();
expect(component.setItemFilters).toHaveBeenCalled();
}));

it('should unsubscribe on destroy', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
public inboundPatterns: string[] = notifyPatterns;
public isNewService: boolean;
public areControlsInitialized: boolean;
public itemfiltersRD$: Observable<RemoteData<PaginatedList<Itemfilter>>>;
public itemFiltersRD$: Observable<RemoteData<PaginatedList<Itemfilter>>>;
public config: FindListOptions = Object.assign(new FindListOptions(), {
elementsPerPage: 20,
});
Expand All @@ -104,12 +104,12 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
private deletedInboundPatterns: number[] = [];
private modalRef: any;
private ldnService: LdnService;
private selectPatternDefaultLabeli18Key = 'ldn-service.form.label.placeholder.default-select';
private selectPatternDefaultLabelI18Key = 'ldn-service.form.label.placeholder.default-select';
private routeSubscription: Subscription;

constructor(
protected ldnServicesService: LdnServicesService,
private ldnItemfiltersService: LdnItemfiltersService,
private ldnItemFiltersService: LdnItemfiltersService,
private formBuilder: FormBuilder,
private router: Router,
private route: ActivatedRoute,
Expand Down Expand Up @@ -147,7 +147,7 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
this.fetchServiceData(this.serviceId);
}
});
this.setItemfilters();
this.setItemFilters();
}

ngOnDestroy(): void {
Expand All @@ -157,8 +157,8 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
/**
* Sets item filters using LDN item filters service
*/
setItemfilters() {
this.itemfiltersRD$ = this.ldnItemfiltersService.findAll().pipe(
setItemFilters() {
this.itemFiltersRD$ = this.ldnItemFiltersService.findAll().pipe(
getFirstCompletedRemoteData());
}

Expand All @@ -168,21 +168,12 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
*/
createService() {
this.formModel.markAllAsTouched();
const notifyServiceInboundPatterns = this.formModel.get('notifyServiceInboundPatterns') as FormArray;
const hasInboundPattern = notifyServiceInboundPatterns?.length > 0 ? this.checkPatterns(notifyServiceInboundPatterns) : false;

if (this.formModel.invalid) {
this.closeModal();
return;
}

if (!hasInboundPattern) {
this.notificationService.warning(this.translateService.get('ldn-service-notification.created.warning.title'));
this.closeModal();
return;
}


this.formModel.value.notifyServiceInboundPatterns = this.formModel.value.notifyServiceInboundPatterns.map((pattern: {
pattern: string;
patternLabel: string,
Expand Down Expand Up @@ -272,20 +263,24 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
}

/**
* Filters pattern objects, initializes form groups, assigns labels, and adds them to the specified form array so the correct string is shown in the dropdown..
* Filters pattern objects, initializes form groups, assigns labels, and adds them to the specified form array so the correct string is shown in the dropdown.
* @param formArrayName - The name of the form array to be populated
*/
filterPatternObjectsAndAssignLabel(formArrayName: string) {
const PatternsArray = this.formModel.get(formArrayName) as FormArray;
PatternsArray.clear();

const servicesToUse = this.ldnService.notifyServiceInboundPatterns;
const servicesToUse = [...this.ldnService.notifyServiceInboundPatterns];
if (servicesToUse.length === 0) {
servicesToUse.push({ pattern: '', constraint: '', automatic: 'false' });
}

servicesToUse.forEach((patternObj: NotifyServicePattern) => {
const patternFormGroup = this.initializeInboundPatternFormGroup();
const patternLabel = patternObj?.pattern ? 'ldn-service.form.pattern.' + patternObj?.pattern + '.label' : 'ldn-service.form.label.placeholder.default-select';
const newPatternObjWithLabel = Object.assign(new NotifyServicePattern(), {
...patternObj,
patternLabel: this.translateService.instant('ldn-service.form.pattern.' + patternObj?.pattern + '.label'),
patternLabel: this.translateService.instant(patternLabel),
});
patternFormGroup.patchValue(newPatternObjWithLabel);

Expand Down Expand Up @@ -412,7 +407,7 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
}

/**
* Patches the LDN service by retrieving and sending patch operations geenrated in generatePatchOperations()
* Patches the LDN service by retrieving and sending patch operations generated in generatePatchOperations()
*/
patchService() {
this.deleteMarkedInboundPatterns();
Expand All @@ -425,17 +420,6 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
return;
}

const notifyServiceInboundPatterns = this.formModel.get('notifyServiceInboundPatterns') as FormArray;
const deletedInboundPatternsLength = this.deletedInboundPatterns.length;
// If no inbound patterns are specified, close the modal and return
// notify the user that no patterns are specified
if (notifyServiceInboundPatterns.length === deletedInboundPatternsLength) {
this.notificationService.warning(this.translateService.get('ldn-service-notification.created.warning.title'));
this.deletedInboundPatterns = [];
this.closeModal();
return;
}

this.ldnServicesService.patch(this.ldnService, patchOperations).pipe(
getFirstCompletedRemoteData(),
).subscribe(
Expand Down Expand Up @@ -571,7 +555,7 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
private createInboundPatternFormGroup(): FormGroup {
const inBoundFormGroup = {
pattern: '',
patternLabel: this.translateService.instant(this.selectPatternDefaultLabeli18Key),
patternLabel: this.translateService.instant(this.selectPatternDefaultLabelI18Key),
constraint: '',
constraintFormatted: '',
automatic: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ <h4>{{'service.overview.delete.header' | translate }}</h4>
<div>
{{ 'service.overview.delete.body' | translate }}
</div>
<div class="mt-4">
<div class="mt-4 text-right">
<button (click)="closeModal()"
[attr.aria-label]="'ldn-service-overview-close-modal' | translate"
class="btn btn-primary mr-2">{{ 'service.detail.delete.cancel' | translate }}</button>
class="btn btn-outline-secondary mr-2">{{ 'service.detail.delete.cancel' | translate }}</button>
<button (click)="deleteSelected(this.selectedServiceId.toString(), ldnServicesService)"
class="btn btn-danger"
[attr.aria-label]="'ldn-service-overview-select-delete' | translate"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export const notifyPatterns = [

'request-review',

'announce-relationship',

];


Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { ActivatedRoute } from '@angular/router';
import { NgbNavModule } from '@ng-bootstrap/ng-bootstrap';
import { TranslateModule } from '@ngx-translate/core';

import { APP_CONFIG } from '../../../config/app-config.interface';
import { environment } from '../../../environments/environment.test';
import { buildPaginatedList } from '../../core/data/paginated-list.model';
import { SearchService } from '../../core/shared/search/search.service';
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
Expand All @@ -28,9 +30,89 @@ describe('AdminNotifyDashboardComponent', () => {
let searchResult3;
let results;

const mockBoxes = [
{ title: 'admin-notify-dashboard.received-ldn', boxes: [ undefined, undefined, undefined, undefined, undefined ] },
{ title: 'admin-notify-dashboard.generated-ldn', boxes: [ undefined, undefined, undefined, undefined, undefined ] },
const mockBoxes = [
{
title: 'admin-notify-dashboard.received-ldn',
boxes: [
{
color: '#B8DAFF',
title: 'admin-notify-dashboard.NOTIFY.incoming.accepted',
config: 'NOTIFY.incoming.accepted',
description: 'admin-notify-dashboard.NOTIFY.incoming.accepted.description',
count: undefined,
},
{
color: '#D4EDDA',
title: 'admin-notify-dashboard.NOTIFY.incoming.processed',
config: 'NOTIFY.incoming.processed',
description: 'admin-notify-dashboard.NOTIFY.incoming.processed.description',
count: undefined,
},
{
color: '#FDBBC7',
title: 'admin-notify-dashboard.NOTIFY.incoming.failure',
config: 'NOTIFY.incoming.failure',
description: 'admin-notify-dashboard.NOTIFY.incoming.failure.description',
count: undefined,
},
{
color: '#FDBBC7',
title: 'admin-notify-dashboard.NOTIFY.incoming.untrusted',
config: 'NOTIFY.incoming.untrusted',
description: 'admin-notify-dashboard.NOTIFY.incoming.untrusted.description',
count: undefined,
},
{
color: '#43515F',
title: 'admin-notify-dashboard.NOTIFY.incoming.involvedItems',
textColor: '#fff',
config: 'NOTIFY.incoming.involvedItems',
description: 'admin-notify-dashboard.NOTIFY.incoming.involvedItems.description',
count: undefined,
},
],
},
{
title: 'admin-notify-dashboard.generated-ldn',
boxes: [
{
color: '#D4EDDA',
title: 'admin-notify-dashboard.NOTIFY.outgoing.delivered',
config: 'NOTIFY.outgoing.delivered',
description: 'admin-notify-dashboard.NOTIFY.outgoing.delivered.description',
count: undefined,
},
{
color: '#B8DAFF',
title: 'admin-notify-dashboard.NOTIFY.outgoing.queued',
config: 'NOTIFY.outgoing.queued',
description: 'admin-notify-dashboard.NOTIFY.outgoing.queued.description',
count: undefined,
},
{
color: '#FDEEBB',
title: 'admin-notify-dashboard.NOTIFY.outgoing.queued_for_retry',
config: 'NOTIFY.outgoing.queued_for_retry',
description: 'admin-notify-dashboard.NOTIFY.outgoing.queued_for_retry.description',
count: undefined,
},
{
color: '#FDBBC7',
title: 'admin-notify-dashboard.NOTIFY.outgoing.failure',
config: 'NOTIFY.outgoing.failure',
description: 'admin-notify-dashboard.NOTIFY.outgoing.failure.description',
count: undefined,
},
{
color: '#43515F',
title: 'admin-notify-dashboard.NOTIFY.outgoing.involvedItems',
textColor: '#fff',
config: 'NOTIFY.outgoing.involvedItems',
description: 'admin-notify-dashboard.NOTIFY.outgoing.involvedItems.description',
count: undefined,
},
],
},
];

beforeEach(async () => {
Expand All @@ -45,6 +127,7 @@ describe('AdminNotifyDashboardComponent', () => {
await TestBed.configureTestingModule({
imports: [TranslateModule.forRoot(), NgbNavModule, AdminNotifyDashboardComponent],
providers: [
{ provide: APP_CONFIG, useValue: environment },
{ provide: SearchService, useValue: { search: () => createSuccessfulRemoteDataObject$(results) } },
{ provide: ActivatedRoute, useValue: new ActivatedRouteStub() },
],
Expand Down
Loading

0 comments on commit d71964d

Please sign in to comment.