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

Launch: cleaner way of redirecting the Calypso window from within the block editor #47762

Open
3 tasks
ciampo opened this issue Nov 25, 2020 · 2 comments
Open
3 tasks

Comments

@ciampo
Copy link
Contributor

ciampo commented Nov 25, 2020

The Focused Launch flow, included in the @automattic/launch package, needs to be imported both directly into Calypso and in the iframed block editor.

The LaunchContext is used to abstract some of the differences that those different environments have. One of the properties available on the LaunchContext is the redirectTo function.

When invoked from within the context of the iframe, at the moment the redirectTo function specified by Editing Toolkit is a bit hacky, as it uses window.top.location and hardcodes the https://wordpress.com origin.

We should rewrite this functionality in a cleaner way, which would also allow us to avoid hardcoding the origin.

This is one way of implementing these changes:

  • we should define a hook (from the @wordpress/hooks library) in apps/wpcom-block-editor/src/calypso/features/iframe-bridge-server.js. The hook callback would use the MessageChannel APIs to communicate to the iframe's parent window
  • In client/gutenberg/editor/calypsoify-iframe.tsx, we should listen for this newly defined MessageChannel action. In the callback, we should be able to window.location.href = path (no need to access window.top or to specify the origin)
  • in the redirectTo function defined in apps/editing-toolkit/editing-toolkit-plugin/editor-site-launch/src/attach-focused-launch.tsx, instead of imperatively changing the window.top.location, we should invoke the newly defined hook, if available (in wp-admin context, there is no iframe; see Focused launch: try enabling the flow in wp-admin #47803 and Focused Launch: more robust redirection when rendered within Editing Toolkit #47542 (comment))
@tjcafferkey
Copy link
Contributor

This issue is blocking #47372 because we need to get Calypso URL to pass it to the source param of the "Use a domain I own" flow in the component.

@github-actions
Copy link

This issue is stale because it has been 180 days with no activity. You can keep the issue open by adding a comment. If you do, please provide additional context and explain why you’d like it to remain open. You can also close the issue yourself — if you do, please add a brief explanation and apply one of relevant issue close labels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Focused Launch (inactive)
  
🗃 Later (backlog)
Development

No branches or pull requests

4 participants