Merge pull request #1476 from 4Science/CST-5064

Show submitter in version history table
This commit is contained in:
Tim Donohue
2022-01-10 10:03:25 -06:00
committed by GitHub
4 changed files with 51 additions and 8 deletions

View File

@@ -47,6 +47,12 @@ export class Version extends DSpaceObject {
@autoserialize
summary: string;
/**
* The name of the submitter of this version
*/
@autoserialize
submitterName: string;
/**
* The Date this version was created
*/

View File

@@ -17,7 +17,7 @@
<thead>
<tr>
<th scope="col">{{"item.version.history.table.version" | translate}}</th>
<th scope="col" *ngIf="(hasEpersons$ | async)">{{"item.version.history.table.editor" | translate}}</th>
<th scope="col" *ngIf="(showSubmitter() | async)">{{"item.version.history.table.editor" | translate}}</th>
<th scope="col">{{"item.version.history.table.date" | translate}}</th>
<th scope="col">{{"item.version.history.table.summary" | translate}}</th>
</tr>
@@ -87,10 +87,8 @@
</ng-container>
</ng-container>
</td>
<td *ngIf="(hasEpersons$ | async)" class="version-row-element-editor">
<span *ngVar="(version?.eperson | async)?.payload as eperson">
<a *ngIf="eperson" [href]="'mailto:' + eperson?.email">{{eperson?.name}}</a>
</span>
<td class="version-row-element-editor" *ngIf="(showSubmitter() | async)">
{{version?.submitterName}}
</td>
<td class="version-row-element-date">
{{version?.created | date : 'yyyy-MM-dd HH:mm:ss'}}

View File

@@ -24,6 +24,7 @@ import { AuthorizationDataService } from '../../../core/data/feature-authorizati
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
import { WorkspaceitemDataService } from '../../../core/submission/workspaceitem-data.service';
import { WorkflowItemDataService } from '../../../core/submission/workflowitem-data.service';
import { ConfigurationDataService } from '../../../core/data/configuration-data.service';
describe('ItemVersionsComponent', () => {
let component: ItemVersionsComponent;
@@ -34,6 +35,7 @@ describe('ItemVersionsComponent', () => {
let workspaceItemDataService: WorkspaceitemDataService;
let workflowItemDataService: WorkflowItemDataService;
let versionService: VersionDataService;
let configurationService: ConfigurationDataService;
const versionHistory = Object.assign(new VersionHistory(), {
id: '1',
@@ -109,6 +111,10 @@ describe('ItemVersionsComponent', () => {
findById: EMPTY,
});
const configurationServiceSpy = jasmine.createSpyObj('configurationService', {
findByPropertyName: of(true),
});
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
@@ -125,6 +131,7 @@ describe('ItemVersionsComponent', () => {
{provide: VersionDataService, useValue: versionServiceSpy},
{provide: WorkspaceitemDataService, useValue: workspaceItemDataServiceSpy},
{provide: WorkflowItemDataService, useValue: workflowItemDataServiceSpy},
{provide: ConfigurationDataService, useValue: configurationServiceSpy},
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();
@@ -135,6 +142,7 @@ describe('ItemVersionsComponent', () => {
workspaceItemDataService = TestBed.inject(WorkspaceitemDataService);
workflowItemDataService = TestBed.inject(WorkflowItemDataService);
versionService = TestBed.inject(VersionDataService);
configurationService = TestBed.inject(ConfigurationDataService);
}));

View File

@@ -5,7 +5,6 @@ import { RemoteData } from '../../../core/data/remote-data';
import {
BehaviorSubject,
combineLatest,
combineLatest as observableCombineLatest,
Observable,
of,
Subscription,
@@ -48,6 +47,7 @@ import { ItemVersionsSharedService } from './item-versions-shared.service';
import { WorkspaceItem } from '../../../core/submission/models/workspaceitem.model';
import { WorkspaceitemDataService } from '../../../core/submission/workspaceitem-data.service';
import { WorkflowItemDataService } from '../../../core/submission/workflowitem-data.service';
import { ConfigurationDataService } from '../../../core/data/configuration-data.service';
@Component({
selector: 'ds-item-versions',
@@ -180,6 +180,7 @@ export class ItemVersionsComponent implements OnInit {
private authorizationService: AuthorizationDataService,
private workspaceItemDataService: WorkspaceitemDataService,
private workflowItemDataService: WorkflowItemDataService,
private configurationService: ConfigurationDataService,
) {
}
@@ -375,6 +376,36 @@ export class ItemVersionsComponent implements OnInit {
return this.authorizationService.isAuthorized(FeatureID.CanEditVersion, version.self);
}
/**
* Show submitter in version history table
*/
showSubmitter() {
const includeSubmitter$ = this.configurationService.findByPropertyName('versioning.item.history.include.submitter').pipe(
getFirstSucceededRemoteDataPayload(),
map((configurationProperty) => configurationProperty.values[0]),
startWith(false),
);
const isAdmin$ = combineLatest([
this.authorizationService.isAuthorized(FeatureID.IsCollectionAdmin),
this.authorizationService.isAuthorized(FeatureID.IsCommunityAdmin),
this.authorizationService.isAuthorized(FeatureID.AdministratorOf),
]).pipe(
map(([isCollectionAdmin, isCommunityAdmin, isSiteAdmin]) => {
return isCollectionAdmin || isCommunityAdmin || isSiteAdmin;
}),
take(1),
);
return combineLatest([includeSubmitter$, isAdmin$]).pipe(
map(([includeSubmitter, isAdmin]) => {
return includeSubmitter && isAdmin;
})
);
}
/**
* Check if the current user can delete the version
* @param version
@@ -389,7 +420,7 @@ export class ItemVersionsComponent implements OnInit {
*/
getAllVersions(versionHistory$: Observable<VersionHistory>): void {
const currentPagination = this.paginationService.getCurrentPagination(this.options.id, this.options);
observableCombineLatest([versionHistory$, currentPagination]).pipe(
combineLatest([versionHistory$, currentPagination]).pipe(
switchMap(([versionHistory, options]: [VersionHistory, PaginationComponentOptions]) => {
return this.versionHistoryService.getVersions(versionHistory.id,
new PaginatedSearchOptions({pagination: Object.assign({}, options, {currentPage: options.currentPage})}),
@@ -486,7 +517,7 @@ export class ItemVersionsComponent implements OnInit {
);
this.itemPageRoutes$ = this.versionsRD$.pipe(
getAllSucceededRemoteDataPayload(),
switchMap((versions) => observableCombineLatest(...versions.page.map((version) => version.item.pipe(getAllSucceededRemoteDataPayload())))),
switchMap((versions) => combineLatest(versions.page.map((version) => version.item.pipe(getAllSucceededRemoteDataPayload())))),
map((versions) => {
const itemPageRoutes = {};
versions.forEach((item) => itemPageRoutes[item.uuid] = getItemPageRoute(item));