mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 07:23:03 +00:00
64503: Collection harvester settings refresh cache after submitting changes
This commit is contained in:
@@ -20,6 +20,7 @@ import { By } from '@angular/platform-browser';
|
|||||||
import { Collection } from '../../../core/shared/collection.model';
|
import { Collection } from '../../../core/shared/collection.model';
|
||||||
import { RemoteData } from '../../../core/data/remote-data';
|
import { RemoteData } from '../../../core/data/remote-data';
|
||||||
import { CollectionDataService } from '../../../core/data/collection-data.service';
|
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 infoNotification: INotification = new Notification('id', NotificationType.Info, 'info');
|
||||||
const warningNotification: INotification = new Notification('id', NotificationType.Warning, 'warning');
|
const warningNotification: INotification = new Notification('id', NotificationType.Warning, 'warning');
|
||||||
@@ -36,6 +37,7 @@ let formService: DynamicFormService;
|
|||||||
let router: any;
|
let router: any;
|
||||||
let collection: Collection;
|
let collection: Collection;
|
||||||
let collectionService: CollectionDataService;
|
let collectionService: CollectionDataService;
|
||||||
|
let requestService: RequestService;
|
||||||
|
|
||||||
describe('CollectionSourceComponent', () => {
|
describe('CollectionSourceComponent', () => {
|
||||||
let comp: CollectionSourceComponent;
|
let comp: CollectionSourceComponent;
|
||||||
@@ -111,8 +113,10 @@ describe('CollectionSourceComponent', () => {
|
|||||||
});
|
});
|
||||||
collectionService = jasmine.createSpyObj('collectionService', {
|
collectionService = jasmine.createSpyObj('collectionService', {
|
||||||
getContentSource: observableOf(contentSource),
|
getContentSource: observableOf(contentSource),
|
||||||
updateContentSource: observableOf(contentSource)
|
updateContentSource: observableOf(contentSource),
|
||||||
|
getHarvesterEndpoint: observableOf('harvester-endpoint')
|
||||||
});
|
});
|
||||||
|
requestService = jasmine.createSpyObj('requestService', ['removeByHrefSubstring']);
|
||||||
|
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [TranslateModule.forRoot(), RouterTestingModule],
|
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: ActivatedRoute, useValue: { parent: { data: observableOf({ dso: new RemoteData(false, false, true, null, collection) }) } } },
|
||||||
{ provide: Router, useValue: router },
|
{ provide: Router, useValue: router },
|
||||||
{ provide: GLOBAL_CONFIG, useValue: { collection: { edit: { undoTimeout: 10 } } } as any },
|
{ 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]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
|
@@ -31,6 +31,7 @@ import { CollectionDataService } from '../../../core/data/collection-data.servic
|
|||||||
import { getSucceededRemoteData } from '../../../core/shared/operators';
|
import { getSucceededRemoteData } from '../../../core/shared/operators';
|
||||||
import { MetadataConfig } from '../../../core/shared/metadata-config.model';
|
import { MetadataConfig } from '../../../core/shared/metadata-config.model';
|
||||||
import { INotification } from '../../../shared/notifications/models/notification.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
|
* Component for managing the content source of the collection
|
||||||
@@ -236,7 +237,8 @@ export class CollectionSourceComponent extends AbstractTrackableComponent implem
|
|||||||
protected route: ActivatedRoute,
|
protected route: ActivatedRoute,
|
||||||
protected router: Router,
|
protected router: Router,
|
||||||
@Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig,
|
@Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig,
|
||||||
protected collectionService: CollectionDataService) {
|
protected collectionService: CollectionDataService,
|
||||||
|
protected requestService: RequestService) {
|
||||||
super(objectUpdatesService, notificationsService, translate);
|
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
|
* Submit the edited Content Source to the REST API, re-initialize the field update and display a notification
|
||||||
*/
|
*/
|
||||||
onSubmit() {
|
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(
|
this.collectionRD$.pipe(
|
||||||
getSucceededRemoteData(),
|
getSucceededRemoteData(),
|
||||||
map((col) => col.payload.uuid),
|
map((col) => col.payload.uuid),
|
||||||
|
Reference in New Issue
Block a user