[CST-12109] porting of box thatallows undo of QAEvent request

This commit is contained in:
Mykhaylo Boychuk
2023-11-07 16:17:49 +01:00
parent ef1bd9fa3d
commit 5589c76f54
15 changed files with 210 additions and 2 deletions

View File

@@ -0,0 +1,48 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { Item } from '../../../core/shared/item.model';
import { getFirstCompletedRemoteData, getPaginatedListPayload, getRemoteDataPayload } from '../../../core/shared/operators';
import { Observable } from 'rxjs';
import { AlertType } from '../../../shared/alert/aletr-type';
import { FindListOptions } from '../../../core/data/find-list-options.model';
import { RequestParam } from '../../../core/cache/models/request-param.model';
import { QualityAssuranceSourceDataService } from '../../../core/suggestion-notifications/qa/source/quality-assurance-source-data.service';
import { QualityAssuranceSourceObject } from '../../../core/suggestion-notifications/qa/models/quality-assurance-source.model';
@Component({
selector: 'ds-qa-event-notification',
templateUrl: './qa-event-notification.component.html',
styleUrls: ['./qa-event-notification.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [QualityAssuranceSourceDataService]
})
/**
* Component for displaying quality assurance event notifications for an item.
*/
export class QaEventNotificationComponent {
/**
* The item to display quality assurance event notifications for.
*/
@Input() item: Item;
/**
* The type of alert to display for the notification.
*/
AlertTypeInfo = AlertType.Info;
constructor(
private qualityAssuranceSourceDataService: QualityAssuranceSourceDataService,
) { }
/**
* Returns an Observable of QualityAssuranceSourceObject[] for the current item.
* @returns An Observable of QualityAssuranceSourceObject[] for the current item.
* Note: sourceId is composed as: id: "sourceName:<target>"
*/
getQualityAssuranceSources$(): Observable<QualityAssuranceSourceObject[]> {
const findListTopicOptions: FindListOptions = {
searchParams: [new RequestParam('target', this.item.uuid)]
};
return this.qualityAssuranceSourceDataService.getSourcesByTarget(findListTopicOptions)
.pipe(
getFirstCompletedRemoteData(),
getRemoteDataPayload(),
getPaginatedListPayload(),
);
}
}