diff --git a/src/ONYXKEYS.js b/src/ONYXKEYS.js index 947d0aaf0c31..3f4dc215eb16 100755 --- a/src/ONYXKEYS.js +++ b/src/ONYXKEYS.js @@ -22,6 +22,9 @@ export default { // Boolean flag set whenever the sidebar has loaded IS_SIDEBAR_LOADED: 'isSidebarLoaded', + // Boolean flag set when workspace is being created + IS_CREATING_WORKSPACE: 'isCreatingWorkspace', + NETWORK_REQUEST_QUEUE: 'networkRequestQueue', // What the active route is for our navigator. Global route that determines what views to display. diff --git a/src/libs/actions/Policy.js b/src/libs/actions/Policy.js index 23da7c531ab2..e08b5edee9fe 100644 --- a/src/libs/actions/Policy.js +++ b/src/libs/actions/Policy.js @@ -94,9 +94,11 @@ function updateAllPolicies(policyCollection) { * @returns {Promise} */ function create(name = '') { + Onyx.set(ONYXKEYS.IS_CREATING_WORKSPACE, true); let res = null; return API.Policy_Create({type: CONST.POLICY.TYPE.FREE, policyName: name}) .then((response) => { + Onyx.set(ONYXKEYS.IS_CREATING_WORKSPACE, false); if (response.jsonCode !== 200) { // Show the user feedback const errorMessage = translateLocal('workspace.new.genericFailureMessage'); diff --git a/src/pages/home/sidebar/SidebarScreen.js b/src/pages/home/sidebar/SidebarScreen.js index d89624980029..5a8be3b78039 100755 --- a/src/pages/home/sidebar/SidebarScreen.js +++ b/src/pages/home/sidebar/SidebarScreen.js @@ -38,12 +38,16 @@ const propTypes = { /* Flag for new users used to open the Global Create menu on first load */ isFirstTimeNewExpensifyUser: PropTypes.bool, + /* Is workspace is being created by the user? */ + isCreatingWorkspace: PropTypes.bool, + ...windowDimensionsPropTypes, ...withLocalizePropTypes, }; const defaultProps = { isFirstTimeNewExpensifyUser: false, + isCreatingWorkspace: false, }; class SidebarScreen extends Component { @@ -185,7 +189,7 @@ class SidebarScreen extends Component { onSelected: () => Navigation.navigate(ROUTES.IOU_BILL), }, ] : []), - ...(Permissions.canUseFreePlan(this.props.betas) && !Policy.isAdminOfFreePolicy(this.props.allPolicies) ? [ + ...(!this.props.isCreatingWorkspace && Permissions.canUseFreePlan(this.props.betas) && !Policy.isAdminOfFreePolicy(this.props.allPolicies) ? [ { icon: NewWorkspace, iconWidth: 46, @@ -221,5 +225,8 @@ export default compose( isFirstTimeNewExpensifyUser: { key: ONYXKEYS.NVP_IS_FIRST_TIME_NEW_EXPENSIFY_USER, }, + isCreatingWorkspace: { + key: ONYXKEYS.IS_CREATING_WORKSPACE, + }, }), )(SidebarScreen);