From 2502b27564926f3a15bfa0ed04ef9c9ede292c21 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Date: Fri, 4 Jun 2021 17:53:39 -0300 Subject: [PATCH] [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 --- app/constants/settings.js | 3 +++ app/i18n/locales/en.json | 1 + app/i18n/locales/pt-BR.json | 1 + app/views/StatusView.js | 14 +++++++++++--- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/constants/settings.js b/app/constants/settings.js index 9f0df8865..d684a11c1 100644 --- a/app/constants/settings.js +++ b/app/constants/settings.js @@ -193,5 +193,8 @@ export default { }, Allow_Save_Media_to_Gallery: { type: 'valueAsBoolean' + }, + Accounts_AllowInvisibleStatusOption: { + type: 'valueAsString' } }; diff --git a/app/i18n/locales/en.json b/app/i18n/locales/en.json index e23bb33b7..1f37628d6 100644 --- a/app/i18n/locales/en.json +++ b/app/i18n/locales/en.json @@ -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", diff --git a/app/i18n/locales/pt-BR.json b/app/i18n/locales/pt-BR.json index 7eca8b049..293959613 100644 --- a/app/i18n/locales/pt-BR.json +++ b/app/i18n/locales/pt-BR.json @@ -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", diff --git a/app/views/StatusView.js b/app/views/StatusView.js index 3f5a48c12..2ac358343 100644 --- a/app/views/StatusView.js +++ b/app/views/StatusView.js @@ -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 ( 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 => ({