Skip to content

Commit c2cbb5c

Browse files
FrancescoMolinarosteph-ieffam
authored andcommitted
Merged in DSC-1632-version-history-box-porting (pull request DSpace#1551)
DSC-1632 version history box porting Approved-by: Stefano Maffei
2 parents 63acc9b + 70c0c87 commit c2cbb5c

3 files changed

Lines changed: 46 additions & 5 deletions

File tree

src/app/cris-layout/enums/layout-box.enum.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ export enum LayoutBox {
1313
ORCID_SYNC_QUEUE = 'ORCID_SYNC_QUEUE',
1414
IIIFVIEWER = 'IIIFVIEWER',
1515
COLLECTIONS = 'COLLECTIONS',
16+
VERSIONING = 'VERSIONING',
1617
}

src/app/item-page/versions/item-versions.component.spec.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Version } from '../../core/shared/version.model';
1010
import { VersionHistory } from '../../core/shared/version-history.model';
1111
import { VersionHistoryDataService } from '../../core/data/version-history-data.service';
1212
import { BrowserModule, By } from '@angular/platform-browser';
13-
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
13+
import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
1414
import { createPaginatedList } from '../../shared/testing/utils.test';
1515
import { EMPTY, of, of as observableOf } from 'rxjs';
1616
import { PaginationService } from '../../core/pagination/pagination.service';
@@ -26,7 +26,7 @@ import { FeatureID } from '../../core/data/feature-authorization/feature-id';
2626
import { WorkspaceitemDataService } from '../../core/submission/workspaceitem-data.service';
2727
import { WorkflowItemDataService } from '../../core/submission/workflowitem-data.service';
2828
import { ConfigurationDataService } from '../../core/data/configuration-data.service';
29-
import { Router } from '@angular/router';
29+
import { ActivatedRoute, Router } from '@angular/router';
3030
import { CommonModule } from '@angular/common';
3131
import { ItemSharedModule } from '../item-shared.module';
3232
import { UUIDService } from '../../core/shared/uuid.service';
@@ -135,6 +135,25 @@ describe('ItemVersionsComponent', () => {
135135
navigateByUrl: null,
136136
});
137137

138+
const mockItem = Object.assign(new Item(), {
139+
id: 'fake-id',
140+
uuid: 'fake-id',
141+
handle: 'fake/handle',
142+
lastModified: '2018',
143+
_links: {
144+
self: {
145+
href: 'https://localhost:8000/items/fake-id'
146+
}
147+
}
148+
});
149+
150+
const routeStub = {
151+
data: observableOf({
152+
dso: createSuccessfulRemoteDataObject(mockItem)
153+
}),
154+
children: []
155+
};
156+
138157
beforeEach(waitForAsync(() => {
139158

140159
TestBed.configureTestingModule({
@@ -153,7 +172,8 @@ describe('ItemVersionsComponent', () => {
153172
{provide: WorkflowItemDataService, useValue: workflowItemDataServiceSpy},
154173
{provide: ConfigurationDataService, useValue: configurationServiceSpy},
155174
{ provide: Router, useValue: routerSpy },
156-
{ provide: UUIDService, useValue: getMockUUIDService() }
175+
{ provide: UUIDService, useValue: getMockUUIDService() },
176+
{ provide: ActivatedRoute, useValue: routeStub },
157177
],
158178
schemas: [NO_ERRORS_SCHEMA]
159179
}).compileComponents();

src/app/item-page/versions/item-versions.component.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import { TranslateService } from '@ngx-translate/core';
4040
import { ItemVersionsDeleteModalComponent } from './item-versions-delete-modal/item-versions-delete-modal.component';
4141
import { VersionDataService } from '../../core/data/version-data.service';
4242
import { ItemDataService } from '../../core/data/item-data.service';
43-
import { Router } from '@angular/router';
43+
import { ActivatedRoute, Router } from '@angular/router';
4444
import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service';
4545
import { FeatureID } from '../../core/data/feature-authorization/feature-id';
4646
import { ItemVersionsSharedService } from './item-versions-shared.service';
@@ -49,7 +49,11 @@ import { WorkspaceitemDataService } from '../../core/submission/workspaceitem-da
4949
import { WorkflowItemDataService } from '../../core/submission/workflowitem-data.service';
5050
import { ConfigurationDataService } from '../../core/data/configuration-data.service';
5151
import { UUIDService } from '../../core/shared/uuid.service';
52+
import { RenderCrisLayoutBoxFor } from '../../cris-layout/decorators/cris-layout-box.decorator';
53+
import { LayoutBox } from '../../cris-layout/enums/layout-box.enum';
5254

55+
56+
@RenderCrisLayoutBoxFor(LayoutBox.VERSIONING)
5357
@Component({
5458
selector: 'ds-item-versions',
5559
templateUrl: './item-versions.component.html',
@@ -182,7 +186,8 @@ export class ItemVersionsComponent implements OnDestroy, OnInit {
182186
private workspaceItemDataService: WorkspaceitemDataService,
183187
private workflowItemDataService: WorkflowItemDataService,
184188
private configurationService: ConfigurationDataService,
185-
private uuidService: UUIDService
189+
private uuidService: UUIDService,
190+
private route: ActivatedRoute,
186191
) {
187192
}
188193

@@ -488,6 +493,21 @@ export class ItemVersionsComponent implements OnDestroy, OnInit {
488493
* Initialize all observables
489494
*/
490495
ngOnInit(): void {
496+
if (!hasValue(this.item)) {
497+
this.subs.push(this.route.data.pipe(
498+
map((data) => {
499+
return data.dso as RemoteData<Item>;
500+
}),
501+
getFirstCompletedRemoteData(),
502+
map(data => data.payload)
503+
).subscribe((item) => {
504+
this.item = item;
505+
this.ngOnInit();
506+
}));
507+
508+
return;
509+
}
510+
491511
if (hasValue(this.item.version)) {
492512
this.versionRD$ = this.item.version;
493513
this.versionHistoryRD$ = this.versionRD$.pipe(

0 commit comments

Comments
 (0)