Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow Importing Stratification Factors for Users with the 'Reader' Role #2010

Merged
merged 2 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading