64503: Collection harvester settings refresh cache after submitting changes

This commit is contained in:
Kristof De Langhe
2020-01-06 12:57:00 +01:00
parent d2c2431c6c
commit dee06c69a6
2 changed files with 19 additions and 3 deletions

View File

@@ -20,6 +20,7 @@ import { By } from '@angular/platform-browser';
import { Collection } from '../../../core/shared/collection.model';
import { RemoteData } from '../../../core/data/remote-data';
import { CollectionDataService } from '../../../core/data/collection-data.service';
import { RequestService } from '../../../core/data/request.service';
const infoNotification: INotification = new Notification('id', NotificationType.Info, 'info');
const warningNotification: INotification = new Notification('id', NotificationType.Warning, 'warning');
@@ -36,6 +37,7 @@ let formService: DynamicFormService;
let router: any;
let collection: Collection;
let collectionService: CollectionDataService;
let requestService: RequestService;
describe('CollectionSourceComponent', () => {
let comp: CollectionSourceComponent;
@@ -111,8 +113,10 @@ describe('CollectionSourceComponent', () => {
});
collectionService = jasmine.createSpyObj('collectionService', {
getContentSource: observableOf(contentSource),
updateContentSource: observableOf(contentSource)
updateContentSource: observableOf(contentSource),
getHarvesterEndpoint: observableOf('harvester-endpoint')
});
requestService = jasmine.createSpyObj('requestService', ['removeByHrefSubstring']);
TestBed.configureTestingModule({
imports: [TranslateModule.forRoot(), RouterTestingModule],
@@ -125,7 +129,8 @@ describe('CollectionSourceComponent', () => {
{ provide: ActivatedRoute, useValue: { parent: { data: observableOf({ dso: new RemoteData(false, false, true, null, collection) }) } } },
{ provide: Router, useValue: router },
{ provide: GLOBAL_CONFIG, useValue: { collection: { edit: { undoTimeout: 10 } } } as any },
{ provide: CollectionDataService, useValue: collectionService }
{ provide: CollectionDataService, useValue: collectionService },
{ provide: RequestService, useValue: requestService }
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();

View File

@@ -31,6 +31,7 @@ import { CollectionDataService } from '../../../core/data/collection-data.servic
import { getSucceededRemoteData } from '../../../core/shared/operators';
import { MetadataConfig } from '../../../core/shared/metadata-config.model';
import { INotification } from '../../../shared/notifications/models/notification.model';
import { RequestService } from '../../../core/data/request.service';
/**
* Component for managing the content source of the collection
@@ -236,7 +237,8 @@ export class CollectionSourceComponent extends AbstractTrackableComponent implem
protected route: ActivatedRoute,
protected router: Router,
@Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig,
protected collectionService: CollectionDataService) {
protected collectionService: CollectionDataService,
protected requestService: RequestService) {
super(objectUpdatesService, notificationsService, translate);
}
@@ -373,6 +375,15 @@ export class CollectionSourceComponent extends AbstractTrackableComponent implem
* Submit the edited Content Source to the REST API, re-initialize the field update and display a notification
*/
onSubmit() {
// Remove cached harvester request to allow for latest harvester to be displayed when switching tabs
this.collectionRD$.pipe(
getSucceededRemoteData(),
map((col) => col.payload.uuid),
switchMap((uuid) => this.collectionService.getHarvesterEndpoint(uuid)),
take(1)
).subscribe((endpoint) => this.requestService.removeByHrefSubstring(endpoint));
// Update harvester
this.collectionRD$.pipe(
getSucceededRemoteData(),
map((col) => col.payload.uuid),