Skip to content

Commit

Permalink
Merge pull request #15776 from narefyev91/go-back-link-not-found-page
Browse files Browse the repository at this point in the history
Add go back link to initial route on Not Found Page
  • Loading branch information
mountiny authored Mar 10, 2023
2 parents bcdcfe5 + be57fe9 commit eeeaff3
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/components/BlockingViews/BlockingView.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import variables from '../../styles/variables';
import Icon from '../Icon';
import Text from '../Text';
import themeColors from '../../styles/themes/default';
import TextLink from '../TextLink';
import Navigation from '../../libs/Navigation/Navigation';
import ROUTES from '../../ROUTES';

const propTypes = {
/** Expensicon for the page */
Expand All @@ -19,10 +22,18 @@ const propTypes = {

/** Subtitle message below the title */
subtitle: PropTypes.string.isRequired,

/** Link message below the subtitle */
link: PropTypes.string,

/** Whether we should show a go back home link */
shouldShowBackHomeLink: PropTypes.bool,
};

const defaultProps = {
iconColor: themeColors.offline,
shouldShowBackHomeLink: false,
link: 'notFound.goBackHome',
};

const BlockingView = props => (
Expand All @@ -37,6 +48,15 @@ const BlockingView = props => (
/>
<Text style={[styles.notFoundTextHeader]}>{props.title}</Text>
<Text style={[styles.textAlignCenter]}>{props.subtitle}</Text>
{props.shouldShowBackHomeLink
? (
<TextLink
onPress={() => Navigation.navigate(ROUTES.REPORT)}
style={[styles.link, styles.mt2]}
>
{props.link}
</TextLink>
) : null}
</View>
);

Expand Down
10 changes: 10 additions & 0 deletions src/components/BlockingViews/FullPageNotFoundView.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ const propTypes = {
/** Whether we should show a close button */
shouldShowCloseButton: PropTypes.bool,

/** Whether we should show a go back home link */
shouldShowBackHomeLink: PropTypes.bool,

/** The key in the translations file to use for the go back link */
linkKey: PropTypes.string,

/** Method to trigger when pressing the back button of the header */
onBackButtonPress: PropTypes.func,
};
Expand All @@ -40,7 +46,9 @@ const defaultProps = {
shouldShow: false,
titleKey: 'notFound.notHere',
subtitleKey: 'notFound.pageNotFound',
linkKey: 'notFound.goBackHome',
shouldShowBackButton: true,
shouldShowBackHomeLink: false,
shouldShowCloseButton: true,
onBackButtonPress: () => Navigation.dismissModal(),
};
Expand All @@ -61,6 +69,8 @@ const FullPageNotFoundView = (props) => {
icon={Expensicons.QuestionMark}
title={props.translate(props.titleKey)}
subtitle={props.translate(props.subtitleKey)}
link={props.translate(props.linkKey)}
shouldShowBackHomeLink={props.shouldShowBackHomeLink}
/>
</View>
</>
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ export default {
notHere: "Hmm... it's not here",
pageNotFound: 'That page is nowhere to be found.',
noAccess: 'You don\'t have access to this chat',
goBackHome: 'Go back to Home page',
},
setPasswordPage: {
enterPassword: 'Enter a password',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ export default {
notHere: 'Hmm… no está aquí',
pageNotFound: 'La página que buscas no existe.',
noAccess: 'No tienes acceso a este chat',
goBackHome: 'Volver a la página principal',
},
setPasswordPage: {
enterPassword: 'Escribe una contraseña',
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ErrorPage/NotFoundPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import FullPageNotFoundView from '../../components/BlockingViews/FullPageNotFoun
// eslint-disable-next-line rulesdir/no-negated-variables
const NotFoundPage = () => (
<ScreenWrapper>
<FullPageNotFoundView shouldShow />
<FullPageNotFoundView shouldShow shouldShowBackHomeLink />
</ScreenWrapper>
);

Expand Down

0 comments on commit eeeaff3

Please sign in to comment.