From 1c43c78cf471e15a694cd9c3e29c4e8575124f52 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Date: Mon, 16 Aug 2021 18:08:34 -0300 Subject: [PATCH] [FIX] Unarchive permission not honored (#3237) * [FIX] Show alert when unarchive error * Title in alert * Disable button when the user donesn't have the role permission * Use ARCHIVE/UNARCHIVE instead of their lowercase in alert and removed capitalize lodash * Check if the error eis translated before parse through i18n * Remove unnecessary code Co-authored-by: Diego Mello Co-authored-by: Levy Costa --- app/views/RoomInfoEditView/index.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/views/RoomInfoEditView/index.js b/app/views/RoomInfoEditView/index.js index 28666b2ca..8dd7e0865 100644 --- a/app/views/RoomInfoEditView/index.js +++ b/app/views/RoomInfoEditView/index.js @@ -415,11 +415,6 @@ class RoomInfoEditView extends React.Component { return permissions[PERMISSION_DELETE_C]; } - hasArchivePermission = () => { - const { permissions } = this.state; - return (permissions[PERMISSION_ARCHIVE] || permissions[PERMISSION_UNARCHIVE]); - }; - renderSystemMessages = () => { const { systemMessages, enableSysMes } = this.state; const { theme } = this.props; @@ -691,11 +686,11 @@ class RoomInfoEditView extends React.Component { style={[ styles.buttonInverted, styles.buttonContainer_inverted, - !this.hasArchivePermission() && sharedStyles.opacity5, + archived ? !permissions[PERMISSION_UNARCHIVE] && sharedStyles.opacity5 : !permissions[PERMISSION_ARCHIVE] && sharedStyles.opacity5, { flex: 1, marginLeft: 10, borderColor: dangerColor } ]} onPress={this.toggleArchive} - disabled={!this.hasArchivePermission()} + disabled={archived ? !permissions[PERMISSION_UNARCHIVE] : !permissions[PERMISSION_ARCHIVE]} testID={archived ? 'room-info-edit-view-unarchive' : 'room-info-edit-view-archive'} >