Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exporter: WP.com API integration #1359

Closed
wants to merge 7 commits into from
Closed

Conversation

jordwest
Copy link
Contributor

@jordwest jordwest commented Dec 8, 2015

This PR is being split into smaller PRs:


Awaiting #500 => #1126

This change completes the exporter, adding the API calls to communicate with wp.com

export

How to test

Export All

  1. Go to http://calypso.localhost:3000/settings/export and select a site.
  2. Click the Export All button.
  3. A notice should appear with a link to download the export file. You should also receive an email with a link.

Export Specific Content

  1. Go to http://calypso.localhost:3000/settings/export and select a site.
  2. Click the gear icon.
  3. Select Posts, Pages, or Feedback and change some of the settings under that section.
  4. Click the Export Selected Content button.
  5. A notice should appear with a link to download the export file. You should also receive an email with a link.

Jetpack sites
Jetpack sites still display the export interface, but should instead show a message with a button link to wp-admin. Since export is still behind a feature flag, this will be covered in #77 under a separate PR.

Mobile
If you are set up with a local dev proxy, please try it out on mobile. It would be good to get an idea of the flow on Android. I've tested on iOS 9:
export_mobile_flow

Todo

  • Rebase (various changes to Redux and prior PRs)
  • Use the site ID from the Redux store instead of passing the site prop to the Exporter component
  • Now that we only allow a single post type to be selected (Post, Page, or Feedback), the API calls need to be constructed from the state differently (modify prepareExportRequest( ... ) in state/site-settings/exporter/selectors.js)
  • Be more specific with the start and end dates passed to the API. Instead of sending '2011-05' for the end date, send '2011-05-31'
  • Display loading placeholders instead of the dropdowns while the available advanced settings are being fetched:
    screen shot 2015-12-17 at 11 13 00 am

@jordwest jordwest self-assigned this Dec 8, 2015
@jordwest jordwest added this to the Export: First Release milestone Dec 8, 2015
@jordwest jordwest force-pushed the add/exporter-api-calls branch 2 times, most recently from 739e97f to bece6f9 Compare December 9, 2015 09:54
@jordwest jordwest force-pushed the add/exporter-api-calls branch 3 times, most recently from b73c88d to 802b7d4 Compare December 10, 2015 11:20
@jordwest jordwest force-pushed the add/exporter-api-calls branch 3 times, most recently from 5fef3da to 2b09f01 Compare December 18, 2015 10:49
@jordwest jordwest force-pushed the add/exporter-api-calls branch 3 times, most recently from 6a6b3ac to 1e6d842 Compare January 8, 2016 00:37
@jordwest jordwest force-pushed the add/exporter-api-calls branch from 1e6d842 to e3add36 Compare January 12, 2016 05:27
@@ -34,25 +34,41 @@ export default React.createClass( {
pages: this.translate( 'Pages' ),
feedback: this.translate( 'Feedback' )
};
const defaultLabels = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be translated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I missed that in a past refactor. Fixed

@jordwest jordwest force-pushed the add/exporter-api-calls branch from 07e616c to 17badb2 Compare January 13, 2016 02:15
@jordwest jordwest added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] In Progress labels Jan 13, 2016
@jordwest
Copy link
Contributor Author

Thanks for the review @dllh - I've fixed up those issues and rebased to fix the merge conflict

@dllh
Copy link
Member

dllh commented Jan 13, 2016

It's possible to navigate to /settings/export/:site and see the export form for Jetpack sites, when really we should probably do something more like what's done for import. Might want to just open an issue for that to handle once this lands to prevent bloating this PR.

Update: To clarify re Jetpack, it's possible to manually specify a url and get a form that doesn't work. For import, if you do that, you get a slightly different view that directs you over to wp-admin for the site to do the export.

This change completes the exporter, adding the API calls to communicate
with wp.com
This refactors the Exporter so that the `site` prop is no longer needed.
Instead the current site is retrieved from the Redux store using the
`getSelectedSite` selector in state/lib/ui.js.
The site was the only remaining external prop (excluding the Redux store)
that was depended upon by the Exporter prior to this change.
@jordwest jordwest force-pushed the add/exporter-api-calls branch from d2b87e2 to 4c985d0 Compare January 14, 2016 04:11
this.wpcom.req.get( {
apiVersion: '1.1',
path: `/sites/${ siteId }/exports/settings`
}, fn );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you return these calls, then your code can take advantage of that by inspecting the request object.

additionally, if you return them and don't use a callback, the wpcom.js library will return a Promise that resolves on the successful response from the API and rejects on error

Undocumented.prototype.getExportSettings = function( siteId ) {
    return this.wpcom.req.get( {
        apiVersion: '1.1',
        path: `/sites/${ siteId }/exports/settings`
    } );
}

//~~~ another file ~~~~
wpcom.getExportSettings( siteId )
    .then( receiveExportSettings )
    .catch( apiFailure );

@dmsnell
Copy link
Member

dmsnell commented Jan 19, 2016

@jordwest this is a pretty big PR. Since this isn't public yet, I suppose it's not too bad, but it would be really cool if it were split up into smaller functional blocks for testing purposes.

In general, there's a lot of use of passing the entire global state around. I'm not sure this is really needed or beneficial. That exposes many of the smaller functions to a wider range of possible issues. If instead of sending the state object around, we only passed the data that they need, it would be more clear what they are doing. When thinking about testing too, it involves less setup for the test since we can mock up some related object without having to know the entire state structure to make sure we build the appropriate container for that mock object.

I left many comments and would be happy to review this again after you respond!

@dmsnell dmsnell added [Status] Needs Author Reply and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Jan 19, 2016
@jordwest
Copy link
Contributor Author

Thanks for the in-depth (as always!) review @dmsnell. I've made some changes based on your feedback, but I'm now working on splitting this up into smaller PRs so the modifications will all be incorporated in those

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants