[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 <diegolmello@gmail.com> Co-authored-by: Levy Costa <levycosta471@gmail.com>
This commit is contained in:
parent
49f936bf1c
commit
1c43c78cf4
|
@ -415,11 +415,6 @@ class RoomInfoEditView extends React.Component {
|
||||||
return permissions[PERMISSION_DELETE_C];
|
return permissions[PERMISSION_DELETE_C];
|
||||||
}
|
}
|
||||||
|
|
||||||
hasArchivePermission = () => {
|
|
||||||
const { permissions } = this.state;
|
|
||||||
return (permissions[PERMISSION_ARCHIVE] || permissions[PERMISSION_UNARCHIVE]);
|
|
||||||
};
|
|
||||||
|
|
||||||
renderSystemMessages = () => {
|
renderSystemMessages = () => {
|
||||||
const { systemMessages, enableSysMes } = this.state;
|
const { systemMessages, enableSysMes } = this.state;
|
||||||
const { theme } = this.props;
|
const { theme } = this.props;
|
||||||
|
@ -691,11 +686,11 @@ class RoomInfoEditView extends React.Component {
|
||||||
style={[
|
style={[
|
||||||
styles.buttonInverted,
|
styles.buttonInverted,
|
||||||
styles.buttonContainer_inverted,
|
styles.buttonContainer_inverted,
|
||||||
!this.hasArchivePermission() && sharedStyles.opacity5,
|
archived ? !permissions[PERMISSION_UNARCHIVE] && sharedStyles.opacity5 : !permissions[PERMISSION_ARCHIVE] && sharedStyles.opacity5,
|
||||||
{ flex: 1, marginLeft: 10, borderColor: dangerColor }
|
{ flex: 1, marginLeft: 10, borderColor: dangerColor }
|
||||||
]}
|
]}
|
||||||
onPress={this.toggleArchive}
|
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'}
|
testID={archived ? 'room-info-edit-view-unarchive' : 'room-info-edit-view-archive'}
|
||||||
>
|
>
|
||||||
<Text
|
<Text
|
||||||
|
|
Loading…
Reference in New Issue