|
|
@ -1,4 +1,3 @@ |
|
|
import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service'; |
|
|
|
|
|
import { UserService } from '@ghostfolio/client/services/user/user.service'; |
|
|
import { UserService } from '@ghostfolio/client/services/user/user.service'; |
|
|
import { CreateOrderDto, UpdateOrderDto } from '@ghostfolio/common/dtos'; |
|
|
import { CreateOrderDto, UpdateOrderDto } from '@ghostfolio/common/dtos'; |
|
|
import { Activity, User } from '@ghostfolio/common/interfaces'; |
|
|
import { Activity, User } from '@ghostfolio/common/interfaces'; |
|
|
@ -47,9 +46,6 @@ export class GfActivityDialogHostComponent implements OnDestroy, OnInit { |
|
|
private readonly destroyRef = inject(DestroyRef); |
|
|
private readonly destroyRef = inject(DestroyRef); |
|
|
private readonly deviceDetectorService = inject(DeviceDetectorService); |
|
|
private readonly deviceDetectorService = inject(DeviceDetectorService); |
|
|
private readonly dialog = inject(MatDialog); |
|
|
private readonly dialog = inject(MatDialog); |
|
|
private readonly impersonationStorageService = inject( |
|
|
|
|
|
ImpersonationStorageService |
|
|
|
|
|
); |
|
|
|
|
|
private readonly route = inject(ActivatedRoute); |
|
|
private readonly route = inject(ActivatedRoute); |
|
|
private readonly router = inject(Router); |
|
|
private readonly router = inject(Router); |
|
|
private readonly userService = inject(UserService); |
|
|
private readonly userService = inject(UserService); |
|
|
@ -95,7 +91,7 @@ export class GfActivityDialogHostComponent implements OnDestroy, OnInit { |
|
|
if ( |
|
|
if ( |
|
|
!activity || |
|
|
!activity || |
|
|
!hasPermission(user?.permissions, permissions.updateActivity) || |
|
|
!hasPermission(user?.permissions, permissions.updateActivity) || |
|
|
this.isReadOnlyMode(user, scopes.activityUpdate) |
|
|
this.isWriteRestricted(user, scopes.activityUpdate) |
|
|
) { |
|
|
) { |
|
|
this.navigateBack(); |
|
|
this.navigateBack(); |
|
|
|
|
|
|
|
|
@ -116,7 +112,7 @@ export class GfActivityDialogHostComponent implements OnDestroy, OnInit { |
|
|
// Cloning creates a new activity as well
|
|
|
// Cloning creates a new activity as well
|
|
|
if ( |
|
|
if ( |
|
|
!hasPermission(user?.permissions, permissions.createActivity) || |
|
|
!hasPermission(user?.permissions, permissions.createActivity) || |
|
|
this.isReadOnlyMode(user, scopes.activityCreate) |
|
|
this.isWriteRestricted(user, scopes.activityCreate) |
|
|
) { |
|
|
) { |
|
|
this.navigateBack(); |
|
|
this.navigateBack(); |
|
|
|
|
|
|
|
|
@ -157,10 +153,9 @@ export class GfActivityDialogHostComponent implements OnDestroy, OnInit { |
|
|
this.dialogRef?.close(); |
|
|
this.dialogRef?.close(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private isReadOnlyMode(user: User, requiredScope: Scope) { |
|
|
private isWriteRestricted(user: User, requiredScope: Scope) { |
|
|
return ( |
|
|
return ( |
|
|
(!!this.impersonationStorageService.getId() && |
|
|
!hasScope(user?.scopes, requiredScope) || |
|
|
!hasScope(user?.scopes, requiredScope)) || |
|
|
|
|
|
!!user?.settings?.isRestrictedView |
|
|
!!user?.settings?.isRestrictedView |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|