Skip to content

Commit

Permalink
Merge pull request #4533 from Expensify/timszot_autoCreateWorkspace
Browse files Browse the repository at this point in the history
Always auto name and create new workspaces from oldDot
  • Loading branch information
Tim Szot authored Aug 11, 2021
2 parents 69df821 + 1e672f4 commit 4ec7474
Show file tree
Hide file tree
Showing 12 changed files with 10 additions and 135 deletions.
5 changes: 2 additions & 3 deletions src/Expensify.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ import UpdateAppModal from './components/UpdateAppModal';
import Visibility from './libs/Visibility';
import GrowlNotification from './components/GrowlNotification';
import {growlRef} from './libs/Growl';
import Navigation from './libs/Navigation/Navigation';
import ROUTES from './ROUTES';
import StartupTimer from './libs/StartupTimer';
import {setRedirectToWorkspaceNewAfterSignIn} from './libs/actions/Session';
import {create} from './libs/actions/Policy';

const propTypes = {
/* Onyx Props */
Expand Down Expand Up @@ -116,7 +115,7 @@ class Expensify extends PureComponent {
&& !_.isEmpty(this.props.betas)
&& lodashGet(this.props, 'session.redirectToWorkspaceNewAfterSignIn', false)) {
setRedirectToWorkspaceNewAfterSignIn(false);
Navigation.navigate(ROUTES.WORKSPACE_NEW);
create();
}

if (this.getAuthToken() && this.props.initialReportDataLoaded && this.props.isSidebarLoaded) {
Expand Down
1 change: 0 additions & 1 deletion src/ROUTES.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export default {
VALIDATE_LOGIN_WITH_VALIDATE_CODE_NEW_WORKSPACE: 'v/:accountID/:validateCode/new-workspace',
VALIDATE_LOGIN_WITH_VALIDATE_CODE_2FA_NEW_WORKSPACE: 'v/:accountID/:validateCode/2fa/new-workspace',
ENABLE_PAYMENTS: 'enable-payments',
WORKSPACE_NEW: 'workspace/new',
WORKSPACE: 'workspace',
WORKSPACE_CARD: ':policyID/card',
WORKSPACE_PEOPLE: ':policyID/people',
Expand Down
7 changes: 1 addition & 6 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -563,12 +563,7 @@ export default {
new: {
newWorkspace: 'New Workspace',
getTheExpensifyCardAndMore: 'Get the Expensify Card and more',
welcome: 'Welcome',
chooseAName: 'Choose a name',
helpText: 'Name your Workspace before enabling your Expensify Cards!',
getStarted: 'Get started!',
genericFailureMessage: 'An error occurred creating the workspace, please try again.',
successMessage: 'Workspace created',
},
people: {
assignee: 'Assignee',
Expand Down Expand Up @@ -605,7 +600,7 @@ export default {
avatarUploadFailureMessage: 'An error occurred uploading the avatar, please try again.',
},
error: {
growlMessageInvalidPolicy: 'Invalid workspace! You can create a new workspace!',
growlMessageInvalidPolicy: 'Invalid workspace! A new workspace has been created.',
},
},
requestCallPage: {
Expand Down
7 changes: 1 addition & 6 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -565,12 +565,7 @@ export default {
new: {
newWorkspace: 'Nuevo Espacio de trabajo',
getTheExpensifyCardAndMore: 'Consigue la Expensify Card y más',
welcome: 'Bienvenido/a',
chooseAName: 'Elige un nombre',
helpText: 'Elige un nombre para el espacio de trabajo antes de activar las tarjetas Expensify',
getStarted: '¡Empezar!',
genericFailureMessage: 'Se ha producido un error al intentar crear el Workspace. Por favor, inténtalo de nuevo.',
successMessage: 'Espacio de trabajo creado',
},
people: {
assignee: 'Persona asignada',
Expand Down Expand Up @@ -607,7 +602,7 @@ export default {
avatarUploadFailureMessage: 'No se pudo subir el avatar. Por favor, inténtalo de nuevo.',
},
error: {
growlMessageInvalidPolicy: '¡Espacio de trabajo no válido! ¡Puedes crear un nuevo espacio de trabajo!',
growlMessageInvalidPolicy: '¡Espacio de trabajo no válido! Un nuevo espacio de trabajo ha sido creado.',
},
},
requestCallPage: {
Expand Down
7 changes: 0 additions & 7 deletions src/libs/Navigation/AppNavigator/AuthScreens.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ import {
EnablePaymentsStackNavigator,
AddPersonalBankAccountModalStackNavigator,
ReimbursementAccountModalStackNavigator,
NewWorkspaceStackNavigator,
WorkspaceInviteModalStackNavigator,
RequestCallModalStackNavigator,
ReportDetailsModalStackNavigator,
Expand Down Expand Up @@ -390,12 +389,6 @@ class AuthScreens extends React.Component {
component={AddPersonalBankAccountModalStackNavigator}
listeners={modalScreenListeners}
/>
<RootStack.Screen
name="NewWorkspace"
options={modalScreenOptions}
component={NewWorkspaceStackNavigator}
listeners={modalScreenListeners}
/>
<RootStack.Screen
name="ReimbursementAccount"
options={modalScreenOptions}
Expand Down
7 changes: 0 additions & 7 deletions src/libs/Navigation/AppNavigator/ModalStackNavigators.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import EnablePaymentsPage from '../../../pages/EnablePayments';
import AddPersonalBankAccountPage from '../../../pages/AddPersonalBankAccountPage';
import WorkspaceInvitePage from '../../../pages/workspace/WorkspaceInvitePage';
import ReimbursementAccountPage from '../../../pages/ReimbursementAccount/ReimbursementAccountPage';
import NewWorkspacePage from '../../../pages/workspace/NewWorkspacePage';
import RequestCallPage from '../../../pages/RequestCallPage';
import ReportDetailsPage from '../../../pages/ReportDetailsPage';
import WorkspaceEditorPage from '../../../pages/workspace/WorkspaceEditorPage';
Expand Down Expand Up @@ -183,11 +182,6 @@ const ReimbursementAccountModalStackNavigator = createModalStackNavigator([{
name: 'ReimbursementAccount_Root',
}]);

const NewWorkspaceStackNavigator = createModalStackNavigator([{
Component: NewWorkspacePage,
name: 'NewWorkspace_Root',
}]);

const WorkspaceInviteModalStackNavigator = createModalStackNavigator([{
Component: WorkspaceInvitePage,
name: 'WorkspaceInvite_Root',
Expand Down Expand Up @@ -218,7 +212,6 @@ export {
EnablePaymentsStackNavigator,
AddPersonalBankAccountModalStackNavigator,
ReimbursementAccountModalStackNavigator,
NewWorkspaceStackNavigator,
WorkspaceInviteModalStackNavigator,
RequestCallModalStackNavigator,
WorkspaceEditorNavigator,
Expand Down
5 changes: 0 additions & 5 deletions src/libs/Navigation/linkingConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,6 @@ export default {
WorkspaceInvite_Root: ROUTES.WORKSPACE_INVITE,
},
},
NewWorkspace: {
screens: {
NewWorkspace_Root: ROUTES.WORKSPACE_NEW,
},
},

WorkspaceSettings: {
path: ROUTES.WORKSPACE,
Expand Down
1 change: 0 additions & 1 deletion src/libs/actions/Policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ function create(name = '') {
}).then(() => {
Navigation.dismissModal();
Navigation.navigate(ROUTES.getWorkspaceCardRoute(res.policyID));
Growl.success(translateLocal('workspace.new.successMessage'));
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/pages/ValidateLogin2FANewWorkspacePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Text from '../components/Text';
import compose from '../libs/compose';
import ONYXKEYS from '../ONYXKEYS';
import Navigation from '../libs/Navigation/Navigation';
import ROUTES from '../ROUTES';
import {create} from '../libs/actions/Policy';

const propTypes = {
/* Onyx Props */
Expand Down Expand Up @@ -71,7 +71,7 @@ class ValidateLogin2FANewWorkspacePage extends Component {
if (_.isEmpty(this.props.betas)) {
setRedirectToWorkspaceNewAfterSignIn(true);
} else {
Navigation.navigate(ROUTES.WORKSPACE_NEW);
create();
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/ValidateLoginNewWorkspacePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import validateLinkPropTypes from './validateLinkPropTypes';
import compose from '../libs/compose';
import ONYXKEYS from '../ONYXKEYS';
import Navigation from '../libs/Navigation/Navigation';
import ROUTES from '../ROUTES';
import {continueSessionFromECom, setRedirectToWorkspaceNewAfterSignIn} from '../libs/actions/Session';
import {create} from '../libs/actions/Policy';

const propTypes = {
/* Onyx Props */
Expand Down Expand Up @@ -47,7 +47,7 @@ class ValidateLoginNewWorkspacePage extends Component {
if (_.isEmpty(this.props.betas)) {
setRedirectToWorkspaceNewAfterSignIn(true);
} else {
Navigation.navigate(ROUTES.WORKSPACE_NEW);
create();
}
return;
}
Expand Down
94 changes: 0 additions & 94 deletions src/pages/workspace/NewWorkspacePage.js

This file was deleted.

3 changes: 2 additions & 1 deletion src/pages/workspace/WorkspaceSidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import Growl from '../../libs/Growl';
import ONYXKEYS from '../../ONYXKEYS';
import Avatar from '../../components/Avatar';
import CONST from '../../CONST';
import {create} from '../../libs/actions/Policy';

const propTypes = {
/** Policy for the current route */
Expand Down Expand Up @@ -68,7 +69,7 @@ const WorkspaceSidebar = ({translate, isSmallScreenWidth, policy}) => {
if (_.isEmpty(policy)) {
Growl.error(translate('workspace.error.growlMessageInvalidPolicy'), CONST.GROWL.DURATION_LONG);
Navigation.dismissModal();
Navigation.navigate(ROUTES.WORKSPACE_NEW);
create();
return null;
}
}, [policy]);
Expand Down

0 comments on commit 4ec7474

Please sign in to comment.