import { ProjectRole } from '../../projects/models/project-role' ; export enum ProjectAction { ViewProject , EditProject , DeleteProject , ViewProjectPlan , EditProjectPlan , ViewProjectUsers , EditProjectUsers , DeleteProjectUsers , InviteProjectUser , ViewProjectInvites , EditProjectInvites , DeleteProjectInvites , AddTerm , ViewTerm , EditTerm , DeleteTerm , AddLabel , ViewLabel , EditLabel , DeleteLabel , AddTranslation , ViewTranslation , EditTranslation , DeleteTranslation , ImportTranslation , ExportTranslation , AddProjectClient , ViewProjectClients , EditProjectClients , DeleteProjectClients } export const AllowedEditorActions = new Set ( [ ProjectAction . ViewProject , ProjectAction . ViewProjectPlan , ProjectAction . ViewProjectUsers , ProjectAction . ViewProjectInvites , ProjectAction . AddTerm , ProjectAction . ViewTerm , ProjectAction . EditTerm , ProjectAction . DeleteTerm , ProjectAction . AddLabel , ProjectAction . ViewLabel , ProjectAction . EditLabel , ProjectAction . DeleteLabel , ProjectAction . AddTranslation , ProjectAction . ViewTranslation , ProjectAction . EditTranslation , ProjectAction . DeleteTranslation , ProjectAction . ImportTranslation , ProjectAction . ExportTranslation , ProjectAction . ViewProjectClients , ] ) ; export const AllowedViewerActions = new Set ( [ ProjectAction . ViewProject , ProjectAction . ViewProjectPlan , ProjectAction . ViewProjectUsers , ProjectAction . ViewProjectInvites , ProjectAction . ViewTerm , ProjectAction . ViewLabel , ProjectAction . ViewTranslation , ProjectAction . ExportTranslation , ProjectAction . ViewProjectClients , ] ) ; export function isAuthorized ( role , action ) { switch ( role ) { case ProjectRole . Admin : return true ; case ProjectRole . Editor : return AllowedEditorActions . has ( action ) ; case ProjectRole . Viewer : return AllowedViewerActions . has ( action ) ; default : return false ; } }