Skip to content

Commit

Permalink
Merge pull request #26754 from adamgrzybowski/@swm/move-demo-pages
Browse files Browse the repository at this point in the history
Move demo pages to the AuthScreens

(cherry picked from commit b47ed8d)
  • Loading branch information
mountiny authored and OSBotify committed Sep 5, 2023
1 parent a76e4c8 commit 7e89ab5
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 29 deletions.
11 changes: 11 additions & 0 deletions src/libs/Navigation/AppNavigator/AuthScreens.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import styles from '../../../styles/styles';
import * as SessionUtils from '../../SessionUtils';
import NotFoundPage from '../../../pages/ErrorPage/NotFoundPage';
import getRootNavigatorScreenOptions from './getRootNavigatorScreenOptions';
import DemoSetupPage from '../../../pages/DemoSetupPage';

let timezone;
let currentAccountID;
Expand Down Expand Up @@ -282,6 +283,16 @@ class AuthScreens extends React.Component {
return ConciergePage;
}}
/>
<RootStack.Screen
name={CONST.DEMO_PAGES.SAASTR}
options={defaultScreenOptions}
component={DemoSetupPage}
/>
<RootStack.Screen
name={CONST.DEMO_PAGES.SBE}
options={defaultScreenOptions}
component={DemoSetupPage}
/>
<RootStack.Screen
name={SCREENS.REPORT_ATTACHMENTS}
options={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ import React from 'react';
import {createStackNavigator} from '@react-navigation/stack';
import SCREENS from '../../../../SCREENS';
import ReportScreenWrapper from '../ReportScreenWrapper';
import DemoSetupPage from '../../../../pages/DemoSetupPage';
import getCurrentUrl from '../../currentUrl';
import styles from '../../../../styles/styles';
import FreezeWrapper from '../../FreezeWrapper';
import CONST from '../../../../CONST';

const Stack = createStackNavigator();

Expand All @@ -30,22 +28,6 @@ function CentralPaneNavigator() {
}}
component={ReportScreenWrapper}
/>
<Stack.Screen
name={CONST.DEMO_PAGES.SAASTR}
options={{
headerShown: false,
title: 'New Expensify',
}}
component={DemoSetupPage}
/>
<Stack.Screen
name={CONST.DEMO_PAGES.SBE}
options={{
headerShown: false,
title: 'New Expensify',
}}
component={DemoSetupPage}
/>
</Stack.Navigator>
</FreezeWrapper>
);
Expand Down
6 changes: 4 additions & 2 deletions src/libs/Navigation/linkingConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export default {
[SCREENS.DESKTOP_SIGN_IN_REDIRECT]: ROUTES.DESKTOP_SIGN_IN_REDIRECT,
[SCREENS.REPORT_ATTACHMENTS]: ROUTES.REPORT_ATTACHMENTS,

// Demo routes
[CONST.DEMO_PAGES.SAASTR]: ROUTES.SAASTR,
[CONST.DEMO_PAGES.SBE]: ROUTES.SBE,

// Sidebar
[SCREENS.HOME]: {
path: ROUTES.HOME,
Expand All @@ -26,8 +30,6 @@ export default {
[NAVIGATORS.CENTRAL_PANE_NAVIGATOR]: {
screens: {
[SCREENS.REPORT]: ROUTES.REPORT_WITH_ID,
[CONST.DEMO_PAGES.SAASTR]: ROUTES.SAASTR,
[CONST.DEMO_PAGES.SBE]: ROUTES.SBE,
},
},
[SCREENS.NOT_FOUND]: '*',
Expand Down
18 changes: 10 additions & 8 deletions src/pages/DemoSetupPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ const propTypes = {
*/
function DemoSetupPage(props) {
useFocusEffect(() => {
// Depending on the route that the user hit to get here, run a specific demo flow
if (props.route.name === CONST.DEMO_PAGES.SAASTR) {
DemoActions.runSaastrDemo();
} else if (props.route.name === CONST.DEMO_PAGES.SBE) {
DemoActions.runSbeDemo();
} else {
Navigation.goBack();
}
Navigation.isNavigationReady().then(() => {
// Depending on the route that the user hit to get here, run a specific demo flow
if (props.route.name === CONST.DEMO_PAGES.SAASTR) {
DemoActions.runSaastrDemo();
} else if (props.route.name === CONST.DEMO_PAGES.SBE) {
DemoActions.runSbeDemo();
} else {
Navigation.goBack();
}
});
});

return <FullScreenLoadingIndicator />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ const propTypes = {

/** Forwarded ref to FloatingActionButtonAndPopover */
innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),

/** Information about any currently running demos */
demoInfo: PropTypes.shape({
saastr: PropTypes.shape({
isBeginningDemo: PropTypes.bool,
}),
sbe: PropTypes.shape({
isBeginningDemo: PropTypes.bool,
}),
}),
};
const defaultProps = {
onHideCreateMenu: () => {},
Expand All @@ -76,6 +86,7 @@ const defaultProps = {
isLoading: false,
innerRef: null,
shouldShowDownloadAppBanner: true,
demoInfo: {},
};

/**
Expand Down Expand Up @@ -162,8 +173,11 @@ function FloatingActionButtonAndPopover(props) {
if (props.shouldShowDownloadAppBanner && Browser.isMobile()) {
return;
}
if (lodashGet(props.demoInfo, 'saastr.isBeginningDemo', false) || lodashGet(props.demoInfo, 'sbe.isBeginningDemo', false)) {
return;
}
Welcome.show({routes, showCreateMenu});
}, [props.shouldShowDownloadAppBanner, props.navigation, showCreateMenu]);
}, [props.shouldShowDownloadAppBanner, props.navigation, showCreateMenu, props.demoInfo]);

useEffect(() => {
if (!didScreenBecomeInactive()) {
Expand Down Expand Up @@ -299,6 +313,9 @@ export default compose(
shouldShowDownloadAppBanner: {
key: ONYXKEYS.SHOW_DOWNLOAD_APP_BANNER,
},
demoInfo: {
key: ONYXKEYS.DEMO_INFO,
},
}),
)(
forwardRef((props, ref) => (
Expand Down

0 comments on commit 7e89ab5

Please sign in to comment.