mattermost-mobile/app/components/error_text/error_text.js
Saturnino Abril f05faaa949
E2E: Initial Detox setup for Mobile UI automation (#4535)
* initial Detox setup for mobile UI automation

* fix iOS allow permission on opening the app, add npm script to root folder, fix test when using longer site URL and add detox dependency to root for android build dependency

* remove detox proguardFile

* update packages and emulator

* change folder build on local and CI

* add test to post a message, ability to have test in isolation, server API commands, server config, dependency updates and update folder structure

* update snapshot

* update detox and do clean up

* update dependencies
2020-08-29 07:18:41 +08:00

58 lines
1.6 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import {Text} from 'react-native';
import CustomPropTypes from 'app/constants/custom_prop_types';
import FormattedText from 'app/components/formatted_text';
import {GlobalStyles} from 'app/styles';
import {makeStyleSheetFromTheme} from 'app/utils/theme';
export default class ErrorText extends PureComponent {
static propTypes = {
error: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
textStyle: CustomPropTypes.Style,
theme: PropTypes.object.isRequired,
};
render() {
const {error, textStyle, theme} = this.props;
if (!error) {
return null;
}
const style = getStyleSheet(theme);
const {intl} = error;
if (intl) {
return (
<FormattedText
testID='error_text'
id={intl.id}
defaultMessage={intl.defaultMessage}
values={intl.values}
style={[GlobalStyles.errorLabel, style.errorLabel, textStyle]}
/>
);
}
return (
<Text
testID='error_text'
style={[GlobalStyles.errorLabel, style.errorLabel, textStyle]}
>
{error.message || error}
</Text>
);
}
}
const getStyleSheet = makeStyleSheetFromTheme((theme) => {
return {
errorLabel: {
color: (theme.errorTextColor || '#DA4A4A'),
},
};
});