Removal of email option for the curation script -> See https://github.com/DSpace/DSpace/pull/2926#pullrequestreview-477868288 for full explanation

This commit is contained in:
jonas-atmire
2020-09-02 14:59:44 +02:00
parent f4946003e2
commit be79663df9
2 changed files with 3 additions and 24 deletions

View File

@@ -4,13 +4,11 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { CurationFormComponent } from './curation-form.component'; import { CurationFormComponent } from './curation-form.component';
import { ScriptDataService } from '../core/data/processes/script-data.service'; import { ScriptDataService } from '../core/data/processes/script-data.service';
import { ProcessDataService } from '../core/data/processes/process-data.service'; import { ProcessDataService } from '../core/data/processes/process-data.service';
import { AuthService } from '../core/auth/auth.service';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { RequestEntry } from '../core/data/request.reducer'; import { RequestEntry } from '../core/data/request.reducer';
import { DSOSuccessResponse, RestResponse } from '../core/cache/response.models'; import { DSOSuccessResponse, RestResponse } from '../core/cache/response.models';
import { Process } from '../process-page/processes/process.model'; import { Process } from '../process-page/processes/process.model';
import { createSuccessfulRemoteDataObject$ } from '../shared/remote-data.utils'; import { createSuccessfulRemoteDataObject$ } from '../shared/remote-data.utils';
import { EPerson } from '../core/eperson/models/eperson.model';
import { NotificationsServiceStub } from '../shared/testing/notifications-service.stub'; import { NotificationsServiceStub } from '../shared/testing/notifications-service.stub';
import { RouterStub } from '../shared/testing/router.stub'; import { RouterStub } from '../shared/testing/router.stub';
import { NotificationsService } from '../shared/notifications/notifications.service'; import { NotificationsService } from '../shared/notifications/notifications.service';
@@ -27,7 +25,6 @@ describe('CurationFormComponent', () => {
let scriptDataService: ScriptDataService; let scriptDataService: ScriptDataService;
let processDataService: ProcessDataService; let processDataService: ProcessDataService;
let configurationDataService: ConfigurationDataService; let configurationDataService: ConfigurationDataService;
let authService: AuthService;
let notificationsService; let notificationsService;
let router; let router;
@@ -48,10 +45,6 @@ describe('CurationFormComponent', () => {
findByHref: createSuccessfulRemoteDataObject$(process) findByHref: createSuccessfulRemoteDataObject$(process)
}); });
authService = jasmine.createSpyObj('authService', {
getAuthenticatedUserFromStore: observableOf(Object.assign(new EPerson(), {email: 'test@mail'}))
});
configurationDataService = jasmine.createSpyObj('configurationDataService', { configurationDataService = jasmine.createSpyObj('configurationDataService', {
findByPropertyName: createSuccessfulRemoteDataObject$(Object.assign(new ConfigurationProperty(), { findByPropertyName: createSuccessfulRemoteDataObject$(Object.assign(new ConfigurationProperty(), {
name: 'plugin.named.org.dspace.curate.CurationTask', name: 'plugin.named.org.dspace.curate.CurationTask',
@@ -74,7 +67,6 @@ describe('CurationFormComponent', () => {
providers: [ providers: [
{provide: ScriptDataService, useValue: scriptDataService}, {provide: ScriptDataService, useValue: scriptDataService},
{provide: ProcessDataService, useValue: processDataService}, {provide: ProcessDataService, useValue: processDataService},
{provide: AuthService, useValue: authService},
{provide: NotificationsService, useValue: notificationsService}, {provide: NotificationsService, useValue: notificationsService},
{provide: Router, useValue: router}, {provide: Router, useValue: router},
{provide: ConfigurationDataService, useValue: configurationDataService}, {provide: ConfigurationDataService, useValue: configurationDataService},
@@ -119,7 +111,6 @@ describe('CurationFormComponent', () => {
expect(scriptDataService.invoke).toHaveBeenCalledWith('curate', [ expect(scriptDataService.invoke).toHaveBeenCalledWith('curate', [
{name: '-t', value: 'profileformats'}, {name: '-t', value: 'profileformats'},
{name: '-i', value: 'test-handle'}, {name: '-i', value: 'test-handle'},
{name: '-e', value: 'test@mail'},
], []); ], []);
expect(notificationsService.success).toHaveBeenCalled(); expect(notificationsService.success).toHaveBeenCalled();
expect(processDataService.findByHref).toHaveBeenCalledWith('process-link'); expect(processDataService.findByHref).toHaveBeenCalledWith('process-link');
@@ -134,7 +125,6 @@ describe('CurationFormComponent', () => {
expect(scriptDataService.invoke).toHaveBeenCalledWith('curate', [ expect(scriptDataService.invoke).toHaveBeenCalledWith('curate', [
{name: '-t', value: 'profileformats'}, {name: '-t', value: 'profileformats'},
{name: '-i', value: 'test-handle'}, {name: '-i', value: 'test-handle'},
{name: '-e', value: 'test@mail'},
], []); ], []);
expect(notificationsService.error).toHaveBeenCalled(); expect(notificationsService.error).toHaveBeenCalled();
expect(processDataService.findByHref).not.toHaveBeenCalled(); expect(processDataService.findByHref).not.toHaveBeenCalled();
@@ -149,7 +139,6 @@ describe('CurationFormComponent', () => {
expect(scriptDataService.invoke).toHaveBeenCalledWith('curate', [ expect(scriptDataService.invoke).toHaveBeenCalledWith('curate', [
{name: '-t', value: 'profileformats'}, {name: '-t', value: 'profileformats'},
{name: '-i', value: 'form-handle'}, {name: '-i', value: 'form-handle'},
{name: '-e', value: 'test@mail'},
], []); ], []);
}); });
it('should use "all" when the handle provided by the form is empty and when no dsoHandle is provided', () => { it('should use "all" when the handle provided by the form is empty and when no dsoHandle is provided', () => {
@@ -159,7 +148,6 @@ describe('CurationFormComponent', () => {
expect(scriptDataService.invoke).toHaveBeenCalledWith('curate', [ expect(scriptDataService.invoke).toHaveBeenCalledWith('curate', [
{name: '-t', value: 'profileformats'}, {name: '-t', value: 'profileformats'},
{name: '-i', value: 'all'}, {name: '-i', value: 'all'},
{name: '-e', value: 'test@mail'},
], []); ], []);
}); });
}); });

View File

@@ -3,9 +3,7 @@ import { ScriptDataService } from '../core/data/processes/script-data.service';
import { FormControl, FormGroup } from '@angular/forms'; import { FormControl, FormGroup } from '@angular/forms';
import { getResponseFromEntry } from '../core/shared/operators'; import { getResponseFromEntry } from '../core/shared/operators';
import { DSOSuccessResponse } from '../core/cache/response.models'; import { DSOSuccessResponse } from '../core/cache/response.models';
import { AuthService } from '../core/auth/auth.service'; import { filter, map, take } from 'rxjs/operators';
import { filter, map, switchMap, take } from 'rxjs/operators';
import { EPerson } from '../core/eperson/models/eperson.model';
import { NotificationsService } from '../shared/notifications/notifications.service'; import { NotificationsService } from '../shared/notifications/notifications.service';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { hasValue, isEmpty, isNotEmpty } from '../shared/empty.util'; import { hasValue, isEmpty, isNotEmpty } from '../shared/empty.util';
@@ -40,7 +38,6 @@ export class CurationFormComponent implements OnInit {
private scriptDataService: ScriptDataService, private scriptDataService: ScriptDataService,
private configurationDataService: ConfigurationDataService, private configurationDataService: ConfigurationDataService,
private processDataService: ProcessDataService, private processDataService: ProcessDataService,
private authService: AuthService,
private notificationsService: NotificationsService, private notificationsService: NotificationsService,
private translateService: TranslateService, private translateService: TranslateService,
private router: Router private router: Router
@@ -90,16 +87,10 @@ export class CurationFormComponent implements OnInit {
handle = 'all'; handle = 'all';
} }
} }
this.authService.getAuthenticatedUserFromStore().pipe( this.scriptDataService.invoke('curate', [
take(1),
switchMap((eperson: EPerson) => {
return this.scriptDataService.invoke('curate', [
{name: '-t', value: taskName}, {name: '-t', value: taskName},
{name: '-i', value: handle}, {name: '-i', value: handle},
{name: '-e', value: eperson.email}, ], []).pipe(getResponseFromEntry()).subscribe((response: DSOSuccessResponse) => {
], []).pipe(getResponseFromEntry());
})
).subscribe((response: DSOSuccessResponse) => {
if (response.isSuccessful) { if (response.isSuccessful) {
this.notificationsService.success(this.translateService.get('curation.form.submit.success.head'), this.notificationsService.success(this.translateService.get('curation.form.submit.success.head'),
this.translateService.get('curation.form.submit.success.content')); this.translateService.get('curation.form.submit.success.content'));