[FIX] Option to prevent users from using Invisible status (#3186)

* [FIX] Option to prevent users from using Invisible status

* Added error to pt-BR

Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
Reinaldo Neto 2021-06-04 17:53:39 -03:00 committed by GitHub
parent fa00ef92ef
commit 2502b27564
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 3 deletions

View File

@ -193,5 +193,8 @@ export default {
},
Allow_Save_Media_to_Gallery: {
type: 'valueAsBoolean'
},
Accounts_AllowInvisibleStatusOption: {
type: 'valueAsString'
}
};

View File

@ -79,6 +79,7 @@
"error-user-registration-disabled": "User registration is disabled",
"error-user-registration-secret": "User registration is only allowed via Secret URL",
"error-you-are-last-owner": "You are the last owner. Please set new owner before leaving the room.",
"error-status-not-allowed": "Invisible status is disabled",
"Actions": "Actions",
"activity": "activity",
"Activity": "Activity",

View File

@ -75,6 +75,7 @@
"error-user-registration-disabled": "O registro do usuário está desativado",
"error-user-registration-secret": "O registro de usuário é permitido somente via URL secreta",
"error-you-are-last-owner": "Você é o último proprietário da sala. Por favor defina um novo proprietário antes de sair.",
"error-status-not-allowed": "O status invisível está desativado",
"Actions": "Ações",
"activity": "atividade",
"Activity": "Atividade",

View File

@ -8,6 +8,7 @@ import * as List from '../containers/List';
import Status from '../containers/Status/Status';
import TextInput from '../containers/TextInput';
import EventEmitter from '../utils/events';
import { showErrorAlert } from '../utils/info';
import Loading from '../containers/Loading';
import RocketChat from '../lib/rocketchat';
import log, { logEvent, events } from '../utils/log';
@ -58,7 +59,8 @@ class StatusView extends React.Component {
theme: PropTypes.string,
navigation: PropTypes.object,
isMasterDetail: PropTypes.bool,
setUser: PropTypes.func
setUser: PropTypes.func,
Accounts_AllowInvisibleStatusOption: PropTypes.bool
}
constructor(props) {
@ -168,6 +170,7 @@ class StatusView extends React.Component {
setUser({ status: item.id });
}
} catch (e) {
showErrorAlert(I18n.t(e.data.errorType));
logEvent(events.SET_STATUS_FAIL);
log(e);
}
@ -181,10 +184,14 @@ class StatusView extends React.Component {
render() {
const { loading } = this.state;
const { Accounts_AllowInvisibleStatusOption } = this.props;
const status = Accounts_AllowInvisibleStatusOption ? STATUS : STATUS.filter(s => s.id !== 'offline');
return (
<SafeAreaView testID='status-view'>
<FlatList
data={STATUS}
data={status}
keyExtractor={item => item.id}
renderItem={this.renderItem}
ListHeaderComponent={this.renderHeader}
@ -199,7 +206,8 @@ class StatusView extends React.Component {
const mapStateToProps = state => ({
user: getUserSelector(state),
isMasterDetail: state.app.isMasterDetail
isMasterDetail: state.app.isMasterDetail,
Accounts_AllowInvisibleStatusOption: state.settings.Accounts_AllowInvisibleStatusOption ?? true
});
const mapDispatchToProps = dispatch => ({