diff --git a/src/components/BlockingViews/BlockingView.js b/src/components/BlockingViews/BlockingView.js new file mode 100644 index 000000000000..279e4c86cf54 --- /dev/null +++ b/src/components/BlockingViews/BlockingView.js @@ -0,0 +1,47 @@ +import React from 'react'; +import {View} from 'react-native'; +import PropTypes from 'prop-types'; +import styles from '../../styles/styles'; +import variables from '../../styles/variables'; +import Icon from '../Icon'; +import Text from '../Text'; +import themeColors from '../../styles/themes/default'; + +const propTypes = { + /** Expensicon for the page */ + icon: PropTypes.func.isRequired, + + /** Color for the icon (should be from theme) */ + iconColor: PropTypes.string, + + /** Title message below the icon */ + title: PropTypes.string.isRequired, + + /** Subtitle message below the title */ + subtitle: PropTypes.string.isRequired, +}; + +const defaultProps = { + iconColor: themeColors.offline, +}; + +const BlockingView = props => ( + + + {props.title} + {props.subtitle} + +); + +BlockingView.propTypes = propTypes; +BlockingView.defaultProps = defaultProps; +BlockingView.displayName = 'BlockingView'; + +export default BlockingView; diff --git a/src/components/BlockingViews/FullPageNotFoundView.js b/src/components/BlockingViews/FullPageNotFoundView.js new file mode 100644 index 000000000000..9b9afdcd8b83 --- /dev/null +++ b/src/components/BlockingViews/FullPageNotFoundView.js @@ -0,0 +1,42 @@ + +import React from 'react'; +import PropTypes from 'prop-types'; +import BlockingView from './BlockingView'; +import * as Expensicons from '../Icon/Expensicons'; +import withLocalize, {withLocalizePropTypes} from '../withLocalize'; + +const propTypes = { + /** Props to fetch translation features */ + ...withLocalizePropTypes, + + /** Child elements */ + children: PropTypes.node.isRequired, + + /** If true, child components are replaced with a blocking "not found" view */ + shouldShow: PropTypes.bool, +}; + +const defaultProps = { + shouldShow: false, +}; + +// eslint-disable-next-line rulesdir/no-negated-variables +const FullPageNotFoundView = (props) => { + if (props.shouldShow) { + return ( + + ); + } + + return props.children; +}; + +FullPageNotFoundView.propTypes = propTypes; +FullPageNotFoundView.defaultProps = defaultProps; +FullPageNotFoundView.displayName = 'FullPageNotFoundView'; + +export default withLocalize(FullPageNotFoundView); diff --git a/src/components/BlockingViews/FullPageOfflineBlockingView.js b/src/components/BlockingViews/FullPageOfflineBlockingView.js new file mode 100644 index 000000000000..44eb3426a400 --- /dev/null +++ b/src/components/BlockingViews/FullPageOfflineBlockingView.js @@ -0,0 +1,41 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import networkPropTypes from '../networkPropTypes'; +import {withNetwork} from '../OnyxProvider'; +import withLocalize, {withLocalizePropTypes} from '../withLocalize'; +import * as Expensicons from '../Icon/Expensicons'; +import compose from '../../libs/compose'; +import BlockingView from './BlockingView'; + +const propTypes = { + /** Child elements */ + children: PropTypes.node.isRequired, + + /** Props to fetch translation features */ + ...withLocalizePropTypes, + + /** Props to detect online status */ + network: networkPropTypes.isRequired, +}; + +const FullPageOfflineBlockingView = (props) => { + if (props.network.isOffline) { + return ( + + ); + } + + return props.children; +}; + +FullPageOfflineBlockingView.propTypes = propTypes; +FullPageOfflineBlockingView.displayName = 'FullPageOfflineBlockingView'; + +export default compose( + withLocalize, + withNetwork(), +)(FullPageOfflineBlockingView); diff --git a/src/components/FullPageOfflineBlockingView.js b/src/components/FullPageOfflineBlockingView.js deleted file mode 100644 index 46af2cc4cfde..000000000000 --- a/src/components/FullPageOfflineBlockingView.js +++ /dev/null @@ -1,53 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import {View} from 'react-native'; -import Icon from './Icon'; -import networkPropTypes from './networkPropTypes'; -import {withNetwork} from './OnyxProvider'; -import Text from './Text'; -import withLocalize, {withLocalizePropTypes} from './withLocalize'; -import * as Expensicons from './Icon/Expensicons'; -import themeColors from '../styles/themes/default'; -import styles from '../styles/styles'; -import compose from '../libs/compose'; -import variables from '../styles/variables'; - -const propTypes = { - /** Child elements */ - children: PropTypes.node.isRequired, - - /** Props to fetch translation features */ - ...withLocalizePropTypes, - - /** Props to detect online status */ - network: networkPropTypes.isRequired, -}; - -const FullPageOfflineBlockingView = (props) => { - if (props.network.isOffline) { - return ( - - - {props.translate('common.youAppearToBeOffline')} - {props.translate('common.thisFeatureRequiresInternet')} - - ); - } - - return props.children; -}; - -FullPageOfflineBlockingView.propTypes = propTypes; -FullPageOfflineBlockingView.displayName = 'FullPageOfflineBlockingView'; - -export default compose( - withLocalize, - withNetwork(), -)(FullPageOfflineBlockingView); diff --git a/src/languages/en.js b/src/languages/en.js index 02bf873c3a9d..1e5724e28fb2 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -507,6 +507,8 @@ export default { chatYouLookingForCannotBeFound: 'The chat you are looking for cannot be found.', getMeOutOfHere: 'Get me out of here', iouReportNotFound: 'The payment details you are looking for cannot be found.', + notHere: "Hmm... it's not here", + pageNotFound: 'That page is nowhere to be found.', }, setPasswordPage: { enterPassword: 'Enter a password', diff --git a/src/languages/es.js b/src/languages/es.js index d7751c630de9..360844a48841 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -507,6 +507,8 @@ export default { chatYouLookingForCannotBeFound: 'El chat que estás buscando no se ha podido encontrar.', getMeOutOfHere: 'Sácame de aquí', iouReportNotFound: 'Los detalles del pago que estás buscando no se han podido encontrar.', + notHere: 'Hmm… no está aquí', + pageNotFound: 'La página que buscas no existe.', }, setPasswordPage: { enterPassword: 'Escribe una contraseña', diff --git a/src/pages/NotFound.js b/src/pages/NotFound.js deleted file mode 100755 index e69de29bb2d1..000000000000