]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/models/users/user-role.ts
rename blacklist to block/blocklist, merge block and auto-block views
[github/Chocobozzz/PeerTube.git] / shared / models / users / user-role.ts
index 0b6554e5160cf4d470473d6b8ec3121c95e83ef3..30ec5edce2440812e92dd2e151aae32eac2b432d 100644 (file)
@@ -7,21 +7,19 @@ export enum UserRole {
   USER = 2
 }
 
-// TODO: use UserRole for key once https://github.com/Microsoft/TypeScript/issues/13042 is fixed
-export const USER_ROLE_LABELS: { [ id: number ]: string } = {
+export const USER_ROLE_LABELS: { [ id in UserRole ]: string } = {
   [UserRole.USER]: 'User',
   [UserRole.MODERATOR]: 'Moderator',
   [UserRole.ADMINISTRATOR]: 'Administrator'
 }
 
-// TODO: use UserRole for key once https://github.com/Microsoft/TypeScript/issues/13042 is fixed
-const userRoleRights: { [ id: number ]: UserRight[] } = {
+const userRoleRights: { [ id in UserRole ]: UserRight[] } = {
   [UserRole.ADMINISTRATOR]: [
     UserRight.ALL
   ],
 
   [UserRole.MODERATOR]: [
-    UserRight.MANAGE_VIDEO_BLACKLIST,
+    UserRight.MANAGE_VIDEO_BLOCKS,
     UserRight.MANAGE_VIDEO_ABUSES,
     UserRight.REMOVE_ANY_VIDEO,
     UserRight.REMOVE_ANY_VIDEO_CHANNEL,
@@ -40,5 +38,5 @@ const userRoleRights: { [ id: number ]: UserRight[] } = {
 export function hasUserRight (userRole: UserRole, userRight: UserRight) {
   const userRights = userRoleRights[userRole]
 
-  return userRights.indexOf(UserRight.ALL) !== -1 || userRights.indexOf(userRight) !== -1
+  return userRights.includes(UserRight.ALL) || userRights.includes(userRight)
 }