Skip to content

Conversation

@retrofox
Copy link
Contributor

@retrofox retrofox commented Jan 7, 2022

Changes proposed in this Pull Request

  • This PR adds the store email field to the store address step, collect its value to finally save it in the server-side

Custom hook API changes

In order to deal with options that support multiple values (object shape), the custom hook exposes the new multipleOptionHadler function. It allows handling the option data kinda easily:

```es6
import useSiteSettings from './use-site-settings';

function StoreOnboardingData() {
  const { multipleOptionHandler, save } = useSiteSettings( 'site-id' );
  const { get, update } = multipleOptionHandler( 'woocommerce_onboarding_profile' );

  return (
    <div>
      <TextControl
        label={ __( 'Email address', 'woocommerce-admin' ) }
        value={ get( 'store_email' ) }
        onChange={ ( value ) => update( 'store_email', value ) }
      />

      <Button onClick={ save }>Save</Button>
    </div>
  );
}

In the example above, the store_email stores into the woocommerce_onboarding_profile option, which has an object shape. Once the save function calls, it performs a POST request passing the woocommerce_onboarding_profile field properly:

Payload:

Response

Checking the data

Testing instructions

  • Test with a simple site
  • Apply testing patch D72639-code
  • Set store email value. Confirm it's properly saved. Confirm it's persistent (hard-refresh)
Screen.Recording.2022-01-07.at.12.04.12.PM.mov

Related to #

@retrofox retrofox added [Size] M Medium sized issue Woop WooCommerce on Plans Pod labels Jan 7, 2022
@retrofox retrofox requested review from a team and lsl January 7, 2022 15:08
@retrofox retrofox self-assigned this Jan 7, 2022
@matticbot matticbot added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Jan 7, 2022
@github-actions
Copy link

github-actions bot commented Jan 7, 2022

@matticbot
Copy link
Contributor

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

App Entrypoints (~100 bytes added 📈 [gzipped])

Details
name                   parsed_size           gzip_size
entry-main                 +1430 B  (+0.1%)     +100 B  (+0.0%)
entry-login                 +164 B  (+0.0%)      +54 B  (+0.0%)
entry-gutenboarding         +164 B  (+0.0%)      +54 B  (+0.0%)
entry-domains-landing       +164 B  (+0.0%)      +54 B  (+0.0%)
entry-browsehappy           +164 B  (+0.2%)      +54 B  (+0.2%)

Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used.

Sections (~9741 bytes added 📈 [gzipped])

Details
name                      parsed_size           gzip_size
media                          +717 B  (+0.0%)    +1057 B  (+0.2%)
comments                       -368 B  (-0.1%)      -16 B  (-0.0%)
themes                         +292 B  (+0.1%)     +774 B  (+0.5%)
jetpack-search                 +212 B  (+0.1%)     +631 B  (+0.7%)
settings                       +199 B  (+0.0%)      +60 B  (+0.0%)
settings-security              +184 B  (+0.0%)       +9 B  (+0.0%)
checkout                       +173 B  (+0.0%)     +612 B  (+0.2%)
theme                          +120 B  (+0.0%)     +113 B  (+0.1%)
settings-discussion            +120 B  (+0.0%)     -417 B  (-0.5%)
preview                        +120 B  (+0.1%)      +70 B  (+0.1%)
settings-performance           +119 B  (+0.0%)      +40 B  (+0.0%)
marketing                      +119 B  (+0.0%)      +40 B  (+0.0%)
gutenberg-editor               -116 B  (-0.0%)     -725 B  (-0.6%)
pages                          -100 B  (-0.0%)    -1374 B  (-1.3%)
home                            +80 B  (+0.0%)     +191 B  (+0.1%)
people                          -77 B  (-0.0%)     -904 B  (-0.7%)
customize                       -75 B  (-0.0%)     -894 B  (-1.6%)
scan                            +66 B  (+0.0%)       +2 B  (+0.0%)
reader                          +44 B  (+0.0%)     +166 B  (+0.1%)
woocommerce-installation        +40 B  (+0.0%)      +15 B  (+0.0%)
woocommerce                     +40 B  (+0.0%)      +15 B  (+0.0%)
sites                           +40 B  (+0.0%)      +15 B  (+0.0%)
site-purchases                  +40 B  (+0.0%)      +10 B  (+0.0%)
settings-jetpack                +40 B  (+0.0%)     +229 B  (+0.3%)
purchases                       +40 B  (+0.0%)      +10 B  (+0.0%)
plugins                         +40 B  (+0.0%)      +15 B  (+0.0%)
plans                           +40 B  (+0.0%)      +15 B  (+0.0%)
migrate                         +40 B  (+0.0%)      +15 B  (+0.0%)
marketplace                     +40 B  (+0.0%)      +15 B  (+0.0%)
jetpack-connect                 +40 B  (+0.0%)      +15 B  (+0.0%)
jetpack-cloud-settings          +40 B  (+0.0%)      -15 B  (-0.0%)
jetpack-cloud-pricing           +40 B  (+0.0%)      +15 B  (+0.0%)
jetpack-cloud                   +40 B  (+0.0%)      +15 B  (+0.0%)
hosting                         +40 B  (+0.0%)      +15 B  (+0.0%)
google-my-business              +40 B  (+0.0%)      +15 B  (+0.0%)
email                           +40 B  (+0.0%)      +15 B  (+0.0%)
earn                            +40 B  (+0.0%)      +15 B  (+0.0%)
domains                         +40 B  (+0.0%)      +10 B  (+0.0%)
concierge                       +40 B  (+0.0%)      +15 B  (+0.0%)
backup                          +40 B  (+0.0%)      +15 B  (+0.0%)
activity                        +40 B  (+0.0%)      +15 B  (+0.0%)
stats                           +36 B  (+0.0%)    +1303 B  (+0.8%)
settings-writing                -19 B  (-0.0%)     -984 B  (-0.6%)
posts-custom                    +17 B  (+0.0%)     -479 B  (-0.3%)
posts                           +17 B  (+0.0%)     -479 B  (-0.3%)
import                          +16 B  (+0.0%)     -515 B  (-0.6%)
export                          +16 B  (+0.0%)     -438 B  (-0.7%)
devdocs                         -11 B  (-0.0%)       +8 B  (+0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Async-loaded Components (~2652 bytes removed 📉 [gzipped])

Details
name                                                                 parsed_size           gzip_size
async-load-signup-steps-woocommerce-install-step-store-address            +428 B  (+0.3%)     +148 B  (+0.3%)
async-load-signup-steps-woocommerce-install-hooks-use-site-settings       +236 B  (+3.7%)      +94 B  (+4.4%)
async-load-design-blocks                                                  -163 B  (-0.0%)      -17 B  (-0.0%)
async-load-calypso-my-sites-resume-editing                                 -90 B  (-0.1%)      -23 B  (-0.1%)
async-load-calypso-post-editor-editor-media-modal                          +79 B  (+0.0%)      +32 B  (+0.0%)
async-load-calypso-blocks-support-article-dialog-dialog                    +44 B  (+0.0%)     +172 B  (+0.5%)
async-load-calypso-blocks-support-article-dialog                           +44 B  (+2.5%)       +4 B  (+0.5%)
async-load-signup-steps-design-picker                                      +40 B  (+0.0%)      +16 B  (+0.1%)
async-load-publish                                                         +40 B  (+0.1%)      -51 B  (-0.3%)
async-load-calypso-post-editor-media-modal                                 +40 B  (+0.0%)     -206 B  (-0.0%)
async-load-calypso-my-sites-site-settings-seo-settings-form                +40 B  (+0.0%)       +7 B  (+0.0%)
async-load-calypso-my-sites-sidebar                                        +40 B  (+0.0%)     +183 B  (+0.2%)
async-load-calypso-components-web-preview-component                        +40 B  (+0.0%)      +55 B  (+0.0%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@retrofox retrofox mentioned this pull request Jan 7, 2022
2 tasks
@retrofox retrofox changed the title Woop: Collect and sabe store email in site settings Woop: Collect and save store email in site settings Jan 7, 2022
@obenland
Copy link
Member

Closing in favor of #59970.

@obenland obenland closed this Jan 11, 2022
@sirreal sirreal deleted the update/woop-collect-onboarding-profile branch January 14, 2025 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Size] M Medium sized issue [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. Woop WooCommerce on Plans Pod

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants