Add history permission into client

Requires the permission "core.can_see_history" to see the history in the navigation.
Disables navigating in the timeline and clearing the history for everyone than than the super admin
This commit is contained in:
Sean Engelhardt 2019-02-21 11:40:56 +01:00
parent d06a4a5c6d
commit a86af342eb
3 changed files with 25 additions and 14 deletions

View File

@ -4,7 +4,10 @@
<!-- Menu -->
<div class="menu-slot">
<button type="button" mat-icon-button [matMenuTriggerFor]="historyMenu"><mat-icon>more_vert</mat-icon></button>
<!-- Hidden for everyone but the superadmin -->
<button *osPerms="'superadmin'" type="button" mat-icon-button [matMenuTriggerFor]="historyMenu">
<mat-icon>more_vert</mat-icon>
</button>
</div>
</os-head-bar>

View File

@ -10,6 +10,7 @@ import { History } from 'app/shared/models/core/history';
import { HistoryRepositoryService } from 'app/core/repositories/history/history-repository.service';
import { isDetailNavigable } from 'app/shared/models/base/detail-navigable';
import { ListViewBaseComponent } from 'app/site/base/list-view-base';
import { OperatorService } from 'app/core/core-services/operator.service';
import { ViewHistory } from '../../models/view-history';
import { ViewModelStoreService } from 'app/core/core-services/view-model-store.service';
@ -36,6 +37,9 @@ export class HistoryListComponent extends ListViewBaseComponent<ViewHistory, His
* @param translate Handle translations
* @param matSnackBar Showing errors and messages
* @param repo The history repository
* @param viewModelStore Access view models
* @param router route to pages
* @param operator checks if the user is a super admin
*/
public constructor(
titleService: Title,
@ -43,7 +47,8 @@ export class HistoryListComponent extends ListViewBaseComponent<ViewHistory, His
matSnackBar: MatSnackBar,
private repo: HistoryRepositoryService,
private viewModelStore: ViewModelStoreService,
private router: Router
private router: Router,
private operator: OperatorService
) {
super(titleService, translate, matSnackBar);
}
@ -105,10 +110,10 @@ export class HistoryListComponent extends ListViewBaseComponent<ViewHistory, His
* @param history Represents the selected element
*/
public async onClickRow(history: ViewHistory): Promise<void> {
if (this.operator.isInGroupIds(2)) {
await this.repo.browseHistory(history);
const element = this.viewModelStore.get(history.getCollectionString(), history.getModelId());
let message = this.translate.instant('OpenSlides is temporarily reset to following timestamp:');
console.log(message);
message += ' ' + history.getLocaleString('DE-de');
if (isDetailNavigable(element)) {
@ -118,13 +123,16 @@ export class HistoryListComponent extends ListViewBaseComponent<ViewHistory, His
this.raiseError(message);
}
}
}
/**
* Handler for the delete all button
*/
public onDeleteAllButton(): void {
if (this.operator.isInGroupIds(2)) {
this.repo.delete();
}
}
/**
* Returns a translated history information string which contains optional (translated) arguments.

View File

@ -23,7 +23,7 @@ export const HistoryAppConfig: AppConfig = {
displayName: 'History',
icon: 'history',
weight: 1200,
permission: 'core.view_history'
permission: 'core.can_see_history'
}
]
};