Skip to content

Commit f919f1d

Browse files
[DURACOM-317] add description, adapt table header, fix menu visibility
1 parent 48f4662 commit f919f1d

File tree

3 files changed

+39
-20
lines changed

3 files changed

+39
-20
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ import { PaginationComponent } from '../../shared/pagination/pagination.componen
2929
import { StringReplacePipe } from '../../shared/utils/string-replace.pipe';
3030
import { VarDirective } from '../../shared/utils/var.directive';
3131

32+
/**
33+
* Renders a paginated table of audit records, either in overview mode for all the environemnt or tied to a specific DSpaceObject.
34+
* Supports row expansion to show details.
35+
*/
36+
3237
@Component({
3338
selector: 'ds-audit-table',
3439
templateUrl: './audit-table.component.html',

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

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ import {
1919
combineLatest,
2020
map,
2121
Observable,
22+
of,
2223
} from 'rxjs';
24+
import { switchMap } from 'rxjs/operators';
2325

2426
import { LinkMenuItemModel } from '../menu-item/models/link.model';
2527
import { MenuItemType } from '../menu-item-type.model';
@@ -39,26 +41,38 @@ export class AuditLogsMenuProvider extends DSpaceObjectPageMenuProvider {
3941
}
4042

4143
public getSectionsForContext(dso: DSpaceObject): Observable<PartialMenuSection[]> {
42-
return combineLatest([
43-
this.authorizationDataService.isAuthorized(FeatureID.AdministratorOf),
44-
this.configurationDataService.findByPropertyName('audit.context-menu-entry.enabled').pipe(
45-
getFirstCompletedRemoteData(),
46-
map((response: RemoteData<ConfigurationProperty>) => {
47-
return response.hasSucceeded ? (response.payload.values.length > 0 && response.payload.values[0] === 'true') : false;
48-
}),
49-
),
50-
]).pipe(
51-
map(([isAdmin, isAuditEnabled]: [boolean, boolean]) => {
52-
return [{
53-
model: {
54-
type: MenuItemType.LINK,
55-
text: 'context-menu.actions.audit-item.btn',
56-
link: new URLCombiner(getDSORoute(dso), 'auditlogs').toString(),
57-
} as LinkMenuItemModel,
58-
icon: 'clipboard-check',
59-
visible: true,
60-
}] as PartialMenuSection[];
44+
return this.configurationDataService.findByPropertyName('audit.enabled').pipe(
45+
getFirstCompletedRemoteData(),
46+
map((response: RemoteData<ConfigurationProperty>) => this.isPropertyEnabled(response)),
47+
switchMap((isAuditEnabled: boolean) => {
48+
if (isAuditEnabled) {
49+
return combineLatest([
50+
this.authorizationDataService.isAuthorized(FeatureID.AdministratorOf),
51+
this.configurationDataService.findByPropertyName('audit.context-menu-entry.enabled').pipe(
52+
getFirstCompletedRemoteData(),
53+
map((response: RemoteData<ConfigurationProperty>) => this.isPropertyEnabled(response)),
54+
),
55+
]).pipe(
56+
map(([isAdmin, isAuditMenuEnabled]: [boolean, boolean]) => {
57+
return [{
58+
model: {
59+
type: MenuItemType.LINK,
60+
text: 'context-menu.actions.audit-item.btn',
61+
link: new URLCombiner(getDSORoute(dso), 'auditlogs').toString(),
62+
} as LinkMenuItemModel,
63+
icon: 'clipboard-check',
64+
visible: isAdmin && isAuditMenuEnabled,
65+
}] as PartialMenuSection[];
66+
}),
67+
);
68+
} else {
69+
return of([]);
70+
}
6171
}),
6272
);
6373
}
74+
75+
private isPropertyEnabled(property: RemoteData<ConfigurationProperty>): boolean {
76+
return property.hasSucceeded ? (property.payload.values.length > 0 && property.payload.values[0] === 'true') : false;
77+
}
6478
}

src/assets/i18n/en.json5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@
933933

934934
"audit.overview.table.other": "Other Object",
935935

936-
"audit.overview.table.timestamp": "Time",
936+
"audit.overview.table.timestamp": "Time (UTC)",
937937

938938
"audit.overview.breadcrumbs": "Audit Logs",
939939

0 commit comments

Comments
 (0)