From 965122028ab83ad60f9a4bcd366424cc09da0a9c Mon Sep 17 00:00:00 2001 From: Abdelhafidh Belalia <16493223+s77rt@users.noreply.github.com> Date: Fri, 24 Feb 2023 23:47:51 +0100 Subject: [PATCH 1/2] Show NotFoundPage if report does not exist in sub report views --- src/pages/home/report/withReportOrNavigateHome.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/pages/home/report/withReportOrNavigateHome.js b/src/pages/home/report/withReportOrNavigateHome.js index 5e74f65a0cb8..8306e8f5d45b 100644 --- a/src/pages/home/report/withReportOrNavigateHome.js +++ b/src/pages/home/report/withReportOrNavigateHome.js @@ -3,7 +3,7 @@ import React, {Component} from 'react'; import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; import getComponentDisplayName from '../../../libs/getComponentDisplayName'; -import Navigation from '../../../libs/Navigation/Navigation'; +import NotFoundPage from '../../ErrorPage/NotFoundPage'; import ONYXKEYS from '../../../ONYXKEYS'; import reportPropTypes from '../../reportPropTypes'; @@ -23,14 +23,11 @@ export default function (WrappedComponent) { }; class WithReportOrNavigateHome extends Component { - componentDidMount() { - if (!_.isEmpty(this.props.report)) { - return; + render() { + if (_.isEmpty(this.props.report) || !this.props.report.reportID) { + return ; } - Navigation.dismissModal(); - } - render() { const rest = _.omit(this.props, ['forwardedRef']); return ( From 15bcf156714e59398c88786496c0a372719be7ee Mon Sep 17 00:00:00 2001 From: Abdelhafidh Belalia <16493223+s77rt@users.noreply.github.com> Date: Sat, 25 Feb 2023 00:08:50 +0100 Subject: [PATCH 2/2] Renamed withReportOrNavigateHome to withReportOrNotFound --- src/pages/ReportDetailsPage.js | 4 ++-- src/pages/ReportParticipantsPage.js | 4 ++-- src/pages/ReportSettingsPage.js | 4 ++-- ...tOrNavigateHome.js => withReportOrNotFound.js} | 15 ++++++++------- 4 files changed, 14 insertions(+), 13 deletions(-) rename src/pages/home/report/{withReportOrNavigateHome.js => withReportOrNotFound.js} (76%) diff --git a/src/pages/ReportDetailsPage.js b/src/pages/ReportDetailsPage.js index 688b691fb62c..02bd202c1d2c 100644 --- a/src/pages/ReportDetailsPage.js +++ b/src/pages/ReportDetailsPage.js @@ -22,7 +22,7 @@ import MenuItem from '../components/MenuItem'; import Text from '../components/Text'; import CONST from '../CONST'; import reportPropTypes from './reportPropTypes'; -import withReportOrNavigateHome from './home/report/withReportOrNavigateHome'; +import withReportOrNotFound from './home/report/withReportOrNotFound'; import FullPageNotFoundView from '../components/BlockingViews/FullPageNotFoundView'; const propTypes = { @@ -181,7 +181,7 @@ ReportDetailsPage.propTypes = propTypes; export default compose( withLocalize, - withReportOrNavigateHome, + withReportOrNotFound, withOnyx({ personalDetails: { key: ONYXKEYS.PERSONAL_DETAILS, diff --git a/src/pages/ReportParticipantsPage.js b/src/pages/ReportParticipantsPage.js index 07c4d62b448a..eb682d5026be 100755 --- a/src/pages/ReportParticipantsPage.js +++ b/src/pages/ReportParticipantsPage.js @@ -19,7 +19,7 @@ import withLocalize, {withLocalizePropTypes} from '../components/withLocalize'; import compose from '../libs/compose'; import * as ReportUtils from '../libs/ReportUtils'; import reportPropTypes from './reportPropTypes'; -import withReportOrNavigateHome from './home/report/withReportOrNavigateHome'; +import withReportOrNotFound from './home/report/withReportOrNotFound'; import FullPageNotFoundView from '../components/BlockingViews/FullPageNotFoundView'; const propTypes = { @@ -118,7 +118,7 @@ ReportParticipantsPage.displayName = 'ReportParticipantsPage'; export default compose( withLocalize, - withReportOrNavigateHome, + withReportOrNotFound, withOnyx({ personalDetails: { key: ONYXKEYS.PERSONAL_DETAILS, diff --git a/src/pages/ReportSettingsPage.js b/src/pages/ReportSettingsPage.js index 86fa8b6cec16..fca21166d0f6 100644 --- a/src/pages/ReportSettingsPage.js +++ b/src/pages/ReportSettingsPage.js @@ -20,7 +20,7 @@ import Picker from '../components/Picker'; import * as ValidationUtils from '../libs/ValidationUtils'; import OfflineWithFeedback from '../components/OfflineWithFeedback'; import reportPropTypes from './reportPropTypes'; -import withReportOrNavigateHome from './home/report/withReportOrNavigateHome'; +import withReportOrNotFound from './home/report/withReportOrNotFound'; import Form from '../components/Form'; import FullPageNotFoundView from '../components/BlockingViews/FullPageNotFoundView'; @@ -220,7 +220,7 @@ ReportSettingsPage.propTypes = propTypes; export default compose( withLocalize, - withReportOrNavigateHome, + withReportOrNotFound, withOnyx({ policies: { key: ONYXKEYS.COLLECTION.POLICY, diff --git a/src/pages/home/report/withReportOrNavigateHome.js b/src/pages/home/report/withReportOrNotFound.js similarity index 76% rename from src/pages/home/report/withReportOrNavigateHome.js rename to src/pages/home/report/withReportOrNotFound.js index 8306e8f5d45b..e1e3b0f64ef0 100644 --- a/src/pages/home/report/withReportOrNavigateHome.js +++ b/src/pages/home/report/withReportOrNotFound.js @@ -22,7 +22,7 @@ export default function (WrappedComponent) { report: {}, }; - class WithReportOrNavigateHome extends Component { + class WithReportOrNotFound extends Component { render() { if (_.isEmpty(this.props.report) || !this.props.report.reportID) { return ; @@ -40,17 +40,18 @@ export default function (WrappedComponent) { } } - WithReportOrNavigateHome.propTypes = propTypes; - WithReportOrNavigateHome.defaultProps = defaultProps; - WithReportOrNavigateHome.displayName = `withReportOrNavigateHome(${getComponentDisplayName(WrappedComponent)})`; - const withReportOrNavigateHome = React.forwardRef((props, ref) => ( + WithReportOrNotFound.propTypes = propTypes; + WithReportOrNotFound.defaultProps = defaultProps; + WithReportOrNotFound.displayName = `withReportOrNotFound(${getComponentDisplayName(WrappedComponent)})`; + // eslint-disable-next-line rulesdir/no-negated-variables + const withReportOrNotFound = React.forwardRef((props, ref) => ( // eslint-disable-next-line react/jsx-props-no-spreading - + )); return withOnyx({ report: { key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${route.params.reportID}`, }, - })(withReportOrNavigateHome); + })(withReportOrNotFound); }