Skip to content

Commit 48f4662

Browse files
[DURACOM-317] fix table links, fix tests
1 parent b20a4d6 commit 48f4662

File tree

4 files changed

+39
-9
lines changed

4 files changed

+39
-9
lines changed

src/app/audit-page/audit-table/audit-table.component.html

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,33 @@
5151
@if (isOverviewPage) {
5252
<td>
5353
@if (audit.objectUUID) {
54-
<a [routerLink]="[getObjectRoute$(audit.object) | async]">{{audit.objectUUID}}</a>
54+
<ng-container *ngVar="(getObjectRoute$(audit.objectUUID) | async) as objectRoute">
55+
@if (objectRoute !== ('/' + auditPath)) {
56+
<a [routerLink]="[objectRoute]">{{audit.objectUUID}}</a>
57+
} @else {
58+
<span>{{audit.objectUUID}}</span>
59+
}
60+
</ng-container>
5561
}
5662
</td>
5763
<td>{{ audit.objectType }}</td>
5864
<td>
5965
@if (audit.subjectUUID) {
60-
<a [routerLink]="[getObjectRoute$(audit.subject) | async]">{{audit.subjectUUID}}</a>
66+
<ng-container *ngVar="(getObjectRoute$(audit.subjectUUID) | async) as subjectRoute">
67+
@if (subjectRoute !== ('/' + auditPath)) {
68+
<a [routerLink]="[subjectRoute]">{{audit.subjectUUID}}</a>
69+
} @else {
70+
<span>{{audit.subjectUUID}}</span>
71+
}
72+
</ng-container>
6173
}
6274
</td>
6375
<td>{{ audit.subjectType }}</td>
6476
} @else {
6577
<td>
6678
<span>
6779
@if (audit.otherAuditObject; as dso) {
68-
{{ dsoNameService.getName(dso) }} <em>({{ dso.type }})</em>
80+
{{ getDsoName(dso) }} <em>({{ dso.type }})</em>
6981
} @else {
7082
{{ dataNotAvailable }}
7183
}

src/app/audit-page/audit-table/audit-table.component.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ import { By } from '@angular/platform-browser';
88
import { RouterTestingModule } from '@angular/router/testing';
99
import { Audit } from '@dspace/core/audit/model/audit.model';
1010
import { DSONameService } from '@dspace/core/breadcrumbs/dso-name.service';
11+
import { DSpaceObjectDataService } from '@dspace/core/data/dspace-object-data.service';
1112
import { PaginatedList } from '@dspace/core/data/paginated-list.model';
13+
import { DSpaceObject } from '@dspace/core/shared/dspace-object.model';
1214
import { AuditMock } from '@dspace/core/testing/audit.mock';
1315
import { DSONameServiceMock } from '@dspace/core/testing/dso-name.service.mock';
16+
import { createSuccessfulRemoteDataObject$ } from '@dspace/core/utilities/remote-data.utils';
1417
import { TranslateModule } from '@ngx-translate/core';
1518
import { PaginationComponent } from 'src/app/shared/pagination/pagination.component';
1619

@@ -21,6 +24,8 @@ describe('AuditTableComponent', () => {
2124
let fixture: ComponentFixture<AuditTableComponent>;
2225

2326
let audits = new PaginatedList() as PaginatedList<Audit>;
27+
const dSpaceObjectDataService = jasmine.createSpyObj('DSpaceObjectDataService', { findById: createSuccessfulRemoteDataObject$(new DSpaceObject()) });
28+
2429

2530
beforeEach(waitForAsync(() => {
2631
audits.page = [ AuditMock ];
@@ -33,6 +38,7 @@ describe('AuditTableComponent', () => {
3338
],
3439
providers: [
3540
{ provide: DSONameService, useValue: new DSONameServiceMock() },
41+
{ provide: DSpaceObjectDataService, useValue: dSpaceObjectDataService },
3642
],
3743
schemas: [NO_ERRORS_SCHEMA],
3844
})

src/app/audit-page/audit-table/audit-table.component.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ import {
1111
} from '@angular/core';
1212
import { RouterLink } from '@angular/router';
1313
import { AUDIT_PERSON_NOT_AVAILABLE } from '@dspace/core/data/audit-data.service';
14-
import { RemoteData } from '@dspace/core/data/remote-data';
14+
import { DSpaceObjectDataService } from '@dspace/core/data/dspace-object-data.service';
1515
import { PaginationComponentOptions } from '@dspace/core/pagination/pagination-component-options.model';
1616
import { getDSORoute } from '@dspace/core/router/utils/dso-route.utils';
17+
import { getFirstSucceededRemoteDataPayload } from '@dspace/core/shared/operators';
1718
import { URLCombiner } from '@dspace/core/url-combiner/url-combiner';
1819
import { NgbCollapseModule } from '@ng-bootstrap/ng-bootstrap';
1920
import { TranslateModule } from '@ngx-translate/core';
@@ -66,6 +67,11 @@ export class AuditTableComponent {
6667
*/
6768
@Input() object: DSpaceObject;
6869

70+
/**
71+
* Path for audit logs
72+
*/
73+
readonly auditPath = 'auditlogs';
74+
6975
protected readonly dataNotAvailable = AUDIT_PERSON_NOT_AVAILABLE;
7076

7177
/**
@@ -74,8 +80,9 @@ export class AuditTableComponent {
7480
protected readonly dateFormat = 'yyyy-MM-dd HH:mm:ss';
7581

7682
constructor(
77-
public dsoNameService: DSONameService,
83+
private dsoNameService: DSONameService,
7884
private changeDetectorRef: ChangeDetectorRef,
85+
private dsoDataService: DSpaceObjectDataService,
7986
) {}
8087

8188

@@ -84,9 +91,14 @@ export class AuditTableComponent {
8491
this.changeDetectorRef.detectChanges();
8592
}
8693

87-
getObjectRoute$(dso: Observable<RemoteData<DSpaceObject>>): Observable<string> {
88-
return dso.pipe(
89-
map(resolvedDso => new URLCombiner(getDSORoute(resolvedDso.payload), 'auditlogs').toString()),
94+
getObjectRoute$(id: string): Observable<string> {
95+
return this.dsoDataService.findById(id).pipe(
96+
getFirstSucceededRemoteDataPayload(),
97+
map(resolvedDso => new URLCombiner(getDSORoute(resolvedDso), this.auditPath).toString()),
9098
);
9199
}
100+
101+
getDsoName(dso: DSpaceObject): string {
102+
return this.dsoNameService.getName(dso);
103+
}
92104
}

src/app/shared/menu/providers/audit-item.menu.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe('AuditLogsMenuProvider', () => {
3838

3939
const configurationDataService = jasmine.createSpyObj('configurationDataService', {
4040
findByPropertyName: createSuccessfulRemoteDataObject$(Object.assign(new ConfigurationProperty(), {
41-
name: 'context-menu-entry.audit.enabled',
41+
name: 'audit.context-menu-entry.enabled',
4242
values: [
4343
'true',
4444
],

0 commit comments

Comments
 (0)