mattermost-mobile/app/components/error_text.js
Harrison Healey 3ac7b48adc RN-289 Sentry integration (#873)
* Added JS code for Sentry

* Removed leftover initializeSentry call

* Added SentryOptions config setting

* Added native components for react-native-exception-handler

* Removed default props from ErrorText

* Moved where Sentry is initialized

* Added ios/sentry.properties to .gitignore

* Added linking react-native-sentry to Fastlane

* Fixed fastlane to include newlines in sentry.properties

* Moved to manually link react-native-sentry

* Captured redux errors with Sentry

* Redid how Sentry is optionally compiled to be simpler

* Added Sentry middleware to create redux breadcrumbs

* Added Sentry tags for server version

* Initialize Sentry when testing

* Fixed string replacement for SentryEnabled in fastlane

* Added react-native-sentry to NOTICE.txt
2017-09-01 14:50:17 -03:00

63 lines
1.7 KiB
JavaScript

// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import {connect} from 'react-redux';
import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import {Text} from 'react-native';
import FormattedText from 'app/components/formatted_text';
import {getTheme} from 'app/selectors/preferences';
import {GlobalStyles} from 'app/styles';
import {makeStyleSheetFromTheme} from 'app/utils/theme';
class ErrorText extends PureComponent {
static propTypes = {
error: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
theme: PropTypes.object.isRequired
};
render() {
const {error, theme} = this.props;
if (!error) {
return null;
}
const style = getStyleSheet(theme);
if (error.hasOwnProperty('intl')) {
const {intl} = error;
return (
<FormattedText
id={intl.id}
defaultMessage={intl.defaultMessage}
values={intl.values}
style={[GlobalStyles.errorLabel, style.errorLabel]}
/>
);
}
return (
<Text style={[GlobalStyles.errorLabel, style.errorLabel]}>
{error.message || error}
</Text>
);
}
}
const getStyleSheet = makeStyleSheetFromTheme((theme) => {
return {
errorLabel: {
color: (theme.errorTextColor || '#DA4A4A')
}
};
});
function mapStateToProps(state, ownProps) {
return {
...ownProps,
theme: getTheme(state)
};
}
export default connect(mapStateToProps)(ErrorText);