Skip to content

Commit

Permalink
Adding in activation flow for money2020
Browse files Browse the repository at this point in the history
  • Loading branch information
Beamanator committed Oct 10, 2023
1 parent 0ef24c0 commit 833cc72
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2704,6 +2704,7 @@ const CONST = {
DEMO_PAGES: {
SAASTR: 'SaaStrDemoSetup',
SBE: 'SbeDemoSetup',
MONEY2020: 'Money2020DemoSetup',
},

MAPBOX: {
Expand Down
3 changes: 3 additions & 0 deletions src/Expensify.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import KeyboardShortcutsModal from './components/KeyboardShortcutsModal';
import AppleAuthWrapper from './components/SignInButtons/AppleAuthWrapper';
import EmojiPicker from './components/EmojiPicker/EmojiPicker';
import * as EmojiPickerAction from './libs/actions/EmojiPickerAction';
import * as DemoActions from './libs/actions/DemoActions';
import DeeplinkWrapper from './components/DeeplinkWrapper';

// This lib needs to be imported, but it has nothing to export since all it contains is an Onyx connection
Expand Down Expand Up @@ -168,11 +169,13 @@ function Expensify(props) {

// If the app is opened from a deep link, get the reportID (if exists) from the deep link and navigate to the chat report
Linking.getInitialURL().then((url) => {
DemoActions.runDemoByURL(url);
Report.openReportFromDeepLink(url, isAuthenticated);
});

// Open chat report from a deep link (only mobile native)
Linking.addEventListener('url', (state) => {
DemoActions.runDemoByURL(state.url);
Report.openReportFromDeepLink(state.url, isAuthenticated);
});

Expand Down
3 changes: 2 additions & 1 deletion src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,10 @@ export default {
getRoute: (policyID: string) => `workspace/${policyID}/members`,
},

// These are some on-off routes that will be removed once they're no longer needed (see GH issues for details)
// These are some one-off routes that will be removed once they're no longer needed (see GH issues for details)
SAASTR: 'saastr',
SBE: 'sbe',
MONEY2020: 'money2020',

// Iframe screens from olddot
HOME_OLDDOT: 'home',
Expand Down
20 changes: 20 additions & 0 deletions src/libs/Navigation/AppNavigator/AuthScreens.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ const propTypes = {
/** The last Onyx update ID was applied to the client */
lastUpdateIDAppliedToClient: PropTypes.number,

/** Information about any currently running demos */
demoInfo: PropTypes.shape({
money2020: PropTypes.shape({
isBeginningDemo: PropTypes.bool,
}),
}),

...windowDimensionsPropTypes,
};

Expand All @@ -127,6 +134,7 @@ const defaultProps = {
},
lastOpenedPublicRoomID: null,
lastUpdateIDAppliedToClient: null,
demoInfo: {},
};

class AuthScreens extends React.Component {
Expand Down Expand Up @@ -169,6 +177,10 @@ class AuthScreens extends React.Component {
App.setUpPoliciesAndNavigate(this.props.session, !this.props.isSmallScreenWidth);
App.redirectThirdPartyDesktopSignIn();

// Check if we should be running any demos immediately after signing in.
if (lodashGet(this.props.demoInfo, 'money2020.isBeginningDemo', false)) {
Navigation.navigate(ROUTES.MONEY2020, CONST.NAVIGATION.TYPE.FORCED_UP);
}
if (this.props.lastOpenedPublicRoomID) {
// Re-open the last opened public room if the user logged in from a public room link
Report.openLastOpenedPublicRoom(this.props.lastOpenedPublicRoomID);
Expand Down Expand Up @@ -293,6 +305,11 @@ class AuthScreens extends React.Component {
options={defaultScreenOptions}
component={DemoSetupPage}
/>
<RootStack.Screen
name={CONST.DEMO_PAGES.MONEY2020}
options={defaultScreenOptions}
component={DemoSetupPage}
/>
<RootStack.Screen
name={SCREENS.REPORT_ATTACHMENTS}
options={{
Expand Down Expand Up @@ -344,5 +361,8 @@ export default compose(
lastUpdateIDAppliedToClient: {
key: ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT,
},
demoInfo: {
key: ONYXKEYS.DEMO_INFO,
},
}),
)(AuthScreens);
3 changes: 3 additions & 0 deletions src/libs/Navigation/linkingConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export default {
[SCREENS.DESKTOP_SIGN_IN_REDIRECT]: ROUTES.DESKTOP_SIGN_IN_REDIRECT,
[SCREENS.REPORT_ATTACHMENTS]: ROUTES.REPORT_ATTACHMENTS.route,

// Demo routes
[CONST.DEMO_PAGES.MONEY2020]: ROUTES.MONEY2020,

// Sidebar
[SCREENS.HOME]: {
path: ROUTES.HOME,
Expand Down
36 changes: 36 additions & 0 deletions src/libs/actions/DemoActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import Onyx from 'react-native-onyx';
import _ from 'underscore';
import lodashGet from 'lodash/get';
import CONST from '../../CONST';
import * as API from '../API';
import * as ReportUtils from '../ReportUtils';
import Navigation from '../Navigation/Navigation';
import ROUTES from '../../ROUTES';
import ONYXKEYS from '../../ONYXKEYS';

function runMoney2020Demo() {
// createDemoWorkspaceAndNavigate(CONST.EMAIL.MONEY2020, 'CreateChatReport');
}

/**
* Runs code for specific demos, based on the provided URL
*
* @param {String} url - URL user is navigating to via deep link (or regular link in web)
*/
function runDemoByURL(url = '') {
const cleanUrl = (url || '').toLowerCase();

if (cleanUrl.endsWith(ROUTES.MONEY2020)) {
Onyx.set(ONYXKEYS.DEMO_INFO, {
money2020: {
isBeginningDemo: true,
},
});
} else {
// No demo is being run, so clear out demo info
Onyx.set(ONYXKEYS.DEMO_INFO, null);
}
}

export {runMoney2020Demo, runDemoByURL};

8 changes: 6 additions & 2 deletions src/pages/DemoSetupPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ const propTypes = {
* route that led the user here. Now, it's just used to route the user home so we
* don't show them a "Hmm... It's not here" message (which looks broken).
*/
function DemoSetupPage() {
function DemoSetupPage(props) {
useFocusEffect(() => {
Navigation.isNavigationReady().then(() => {
Navigation.goBack(ROUTES.HOME);
if (props.route.name === CONST.DEMO_PAGES.MONEY2020) {
DemoActions.runMoney2020Demo();
} else {
Navigation.goBack(ROUTES.HOME);
}
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ const propTypes = {

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

/** Information about any currently running demos */
demoInfo: PropTypes.shape({
money2020: PropTypes.shape({
isBeginningDemo: PropTypes.bool,
}),
}),
};
const defaultProps = {
onHideCreateMenu: () => {},
Expand All @@ -70,6 +77,7 @@ const defaultProps = {
betas: [],
isLoading: false,
innerRef: null,
demoInfo: {},
};

/**
Expand Down Expand Up @@ -152,6 +160,12 @@ function FloatingActionButtonAndPopover(props) {
if (currentRoute && ![NAVIGATORS.CENTRAL_PANE_NAVIGATOR, SCREENS.HOME].includes(currentRoute.name)) {
return;
}
if (lodashGet(props.demoInfo, 'saastr.isBeginningDemo', false) || lodashGet(props.demoInfo, 'sbe.isBeginningDemo', false)) {
return;
}
if (lodashGet(props.demoInfo, 'money2020.isBeginningDemo', false)) {
return;
}
Welcome.show({routes, showCreateMenu});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
Expand Down Expand Up @@ -261,6 +275,9 @@ export default compose(
isLoading: {
key: ONYXKEYS.IS_LOADING_REPORT_DATA,
},
demoInfo: {
key: ONYXKEYS.DEMO_INFO,
},
}),
)(
forwardRef((props, ref) => (
Expand Down

0 comments on commit 833cc72

Please sign in to comment.