Skip to content

Commit

Permalink
Merge branch 'dev' into bugfix/1998-limit-ff-reader-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ppratikcr7 authored Oct 3, 2024
2 parents a020b69 + a6ba52a commit 6cc5382
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions frontend/projects/upgrade/src/app/core/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export class AuthService {
case UserRole.ADMIN:
this.userPermissions$.next({
experiments: { create: true, read: true, update: true, delete: true },
stratifications: { create: true, read: true, update: true, delete: true },
users: { create: true, read: true, update: true, delete: true },
logs: { create: true, read: true, update: true, delete: true },
manageRoles: { create: true, read: true, update: true, delete: true },
Expand All @@ -185,6 +186,7 @@ export class AuthService {
case UserRole.CREATOR:
this.userPermissions$.next({
experiments: { create: true, read: true, update: true, delete: true },
stratifications: { create: true, read: true, update: true, delete: true },
users: { create: true, read: true, update: true, delete: true },
logs: { create: false, read: true, update: false, delete: false },
manageRoles: { create: false, read: true, update: false, delete: false },
Expand All @@ -196,6 +198,7 @@ export class AuthService {
case UserRole.USER_MANAGER:
this.userPermissions$.next({
experiments: { create: false, read: true, update: false, delete: false },
stratifications: { create: false, read: true, update: false, delete: false },
users: { create: true, read: true, update: true, delete: true },
logs: { create: false, read: true, update: false, delete: false },
manageRoles: { create: false, read: true, update: false, delete: false },
Expand All @@ -207,6 +210,7 @@ export class AuthService {
case UserRole.READER:
this.userPermissions$.next({
experiments: { create: false, read: true, update: false, delete: false },
stratifications: { create: false, read: true, update: false, delete: false },
users: { create: false, read: true, update: false, delete: false },
logs: { create: false, read: true, update: false, delete: false },
manageRoles: { create: false, read: true, update: false, delete: false },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface CRUD {

export interface UserPermission {
experiments: CRUD;
stratifications: CRUD;
users: CRUD;
logs: CRUD;
manageRoles: CRUD;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ <h3 class="ft-22-700">{{ 'users.stratification-users-title.text' | translate }}<
</div>
<div>
<button
*ngIf="(permissions$ | async)?.stratifications.create"
(click)="openImportStratificationsDialog()"
mat-flat-button
color="primary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import { MatDialog } from '@angular/material/dialog';
import * as clonedeep from 'lodash.clonedeep';
import { DeleteStratificationComponent } from './delete-stratification/delete-stratification.component';
import { StratificationFactor } from '../../../../../core/stratification-factors/store/stratification-factors.model';
import { Subscription } from 'rxjs';
import { Observable, Subscription } from 'rxjs';
import { StratificationFactorsService } from '../../../../../core/stratification-factors/stratification-factors.service';
import { ExperimentService } from '../../../../../core/experiments/experiments.service';
import { ExperimentNameVM } from '../../../../../core/experiments/store/experiments.model';
import { MatTableDataSource } from '@angular/material/table';
import { UserPermission } from '../../../../../core/auth/store/auth.models';
import { AuthService } from '../../../../../core/auth/auth.service';

interface StratificationFactorsTableRow {
factor: string;
Expand All @@ -24,6 +26,7 @@ interface StratificationFactorsTableRow {
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class StratificationComponent implements OnInit {
permissions$: Observable<UserPermission>;
allStratificationFactors: StratificationFactor[];
allStratificationFactorsSub: Subscription;
isLoading$ = this.stratificationFactorsService.isLoading$;
Expand All @@ -36,10 +39,12 @@ export class StratificationComponent implements OnInit {
private dialog: MatDialog,
private stratificationFactorsService: StratificationFactorsService,
private experimentService: ExperimentService,
private cdr: ChangeDetectorRef
private cdr: ChangeDetectorRef,
private authService: AuthService
) {}

ngOnInit(): void {
this.permissions$ = this.authService.userPermissions$;
this.experimentService.allExperimentNames$.subscribe((allExperimentNames) => {
this.allExperimentsName = allExperimentNames;
});
Expand Down

0 comments on commit 6cc5382

Please sign in to comment.