From 83da090ba1a3a552dba321a0ca8a2553b58e8e6c Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Mon, 7 Jun 2021 02:27:31 -0400 Subject: [PATCH] fix permissions from last refactor --- vocodes/src/common/ApiConfig.ts | 4 ++++ vocodes/src/session/SessionState.ts | 10 ++++++++-- vocodes/src/session/SessionWrapper.ts | 8 ++++---- vocodes/src/v2/profile/ProfileFc.tsx | 2 +- vocodes/src/v2/profile_edit/ProfileEditFc.tsx | 6 +++--- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/vocodes/src/common/ApiConfig.ts b/vocodes/src/common/ApiConfig.ts index 226bd61d24..636f869dff 100644 --- a/vocodes/src/common/ApiConfig.ts +++ b/vocodes/src/common/ApiConfig.ts @@ -84,6 +84,10 @@ class ApiConfig { return `${this.getScheme()}://${this.getNewApiHost()}/w2l/template/${templateSlug}/moderate`; } + deleteW2l(templateSlug: string) : string { + return `${this.getScheme()}://${this.getNewApiHost()}/w2l/template/${templateSlug}/delete`; + } + viewW2lInferenceResult(token: string) : string { return `${this.getScheme()}://${this.getNewApiHost()}/w2l/result/${token}`; } diff --git a/vocodes/src/session/SessionState.ts b/vocodes/src/session/SessionState.ts index 76774d622c..e35d613713 100644 --- a/vocodes/src/session/SessionState.ts +++ b/vocodes/src/session/SessionState.ts @@ -23,8 +23,14 @@ export interface UserInfo { // Contribution can_upload_tts_models: boolean, can_upload_w2l_templates: boolean, + can_delete_own_tts_models: boolean, + can_delete_own_w2l_templates: boolean, // Moderation - can_ban_users: boolean, - can_edit_other_users_data: boolean, can_approve_w2l_templates: boolean, + can_edit_other_users_profiles: boolean, + can_edit_other_users_tts_models: boolean, + can_edit_other_users_w2l_templates: boolean, + can_delete_other_users_tts_models: boolean, + can_delete_other_users_w2l_templates: boolean, + can_ban_users: boolean, } diff --git a/vocodes/src/session/SessionWrapper.ts b/vocodes/src/session/SessionWrapper.ts index effcbb7ac0..46f783e432 100644 --- a/vocodes/src/session/SessionWrapper.ts +++ b/vocodes/src/session/SessionWrapper.ts @@ -40,11 +40,11 @@ export class SessionWrapper { return this.sessionStateResponse?.user?.email_gravatar_hash; } - public canEditUser(username: string) : boolean { + public canEditUserProfile(username: string) : boolean { if (this.getUsername() === username) { return true; } - return this.canEditOtherUsersData(); + return this.canEditOtherUsersProfiles(); } public canUseTts() : boolean { @@ -67,8 +67,8 @@ export class SessionWrapper { return this.sessionStateResponse?.user?.can_ban_users || false; } - public canEditOtherUsersData() : boolean { - return this.sessionStateResponse?.user?.can_edit_other_users_data || false; + public canEditOtherUsersProfiles() : boolean { + return this.sessionStateResponse?.user?.can_edit_other_users_profiles || false; } public canApproveW2lTemplates() : boolean { diff --git a/vocodes/src/v2/profile/ProfileFc.tsx b/vocodes/src/v2/profile/ProfileFc.tsx index f87145a78c..aae55fda22 100644 --- a/vocodes/src/v2/profile/ProfileFc.tsx +++ b/vocodes/src/v2/profile/ProfileFc.tsx @@ -84,7 +84,7 @@ function ProfileFc(props: Props) { let editProfileButton = - if (props.sessionWrapper.canEditUser(username)) { + if (props.sessionWrapper.canEditUserProfile(username)) { let editLinkUrl = `/profile/${username}/edit`; editProfileButton = ( { - //}); + .catch(e => { + }); return false; }