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

Setup wizard: Done screen #4954

Merged
merged 59 commits into from
Jul 2, 2020
Merged

Setup wizard: Done screen #4954

merged 59 commits into from
Jul 2, 2020

Conversation

johnwatkins0
Copy link
Contributor

@johnwatkins0 johnwatkins0 commented Jun 29, 2020

Summary

Fixes #4707

This adds the final screen for the setup wizard. Uses are presented with an iframe showing an AMP page on their site in a mobile viewport, along with links to view the site or customize (in Reader mode). The "Next" button becomes "Finish" and links back to AMP settings.

Screen Shot 2020-06-29 at 11 04 03 PM

Checklist

  • My pull request is addressing an open issue (please create one otherwise).
  • My code is tested and passes existing tests.
  • My code follows the Engineering Guidelines (updates are often made to the guidelines, check it out periodically).

@johnwatkins0 johnwatkins0 self-assigned this Jun 29, 2020
@googlebot googlebot added the cla: yes Signed the Google CLA label Jun 29, 2020
@johnwatkins0 johnwatkins0 added this to the v1.6 milestone Jun 29, 2020
<Phone>
<iframe
className="done__preview-iframe"
sandbox="allow-scripts"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
sandbox="allow-scripts"
sandbox="allow-scripts allow-forms allow-popups allow-presentation"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You got this in just ahead of my comment below. I'll try it in a little while.

@johnwatkins0
Copy link
Contributor Author

@westonruter This PR is still WIP, but I wanted to flag for you that I made an attempt to hide the admin bar in the iframe using the sandbox attribute. I expected it to work, but for some reason it didn't. I could sense that figuring this out was potentially going to take a signicant amount of time, so I went to the fallback of setting a amp-no-admin-bar URL var and turning off the admin bar when it is set.

This PR still has the iframe with the sandbox parameter. To replicate, remove the show_admin_bar filter I added in includes/amp-helper-functions.php. Then, in the wizard, select standard mode and navigate to the last screen, which has the iframe. Where we would expect the iframe to be hidden, it's still showing.

@westonruter
Copy link
Member

I may have been mistaken on the behavior of sandbox and whether it blocks cookies from being used then. Maybe it's just a matter of whether the iframed window can read cookies from the parent window or not.

@westonruter
Copy link
Member

I have another idea: provide a name to the iframe, like amp-wizard-completion-preview. Then, you could do something like this:

add_action( 'wp_print_footer_scripts', function() {
	if ( ! amp_is_dev_mode() || ! is_admin_bar_showing() ) {
		return;
	}
	?>
	<script data-ampdevmode>
        document.addEventListener( 'DOMContentLoaded', () => {
            if ( document.body.classList.contains( 'admin-bar' ) ) {
                document.body.classList.remove( 'admin-bar' );
                document.documentElement.style.cssText += '; margin-top: 0 !important';
                document.getElementById( 'wpadminbar' ).remove();
            }
        } );
	</script>
	<?php
} );

But that would still result in a flash of the admin bar appearing momentarily.

In any case, this is probably overkill. If the admin bar shows up upon navigation, that's not the end of the world 😄

@johnwatkins0
Copy link
Contributor Author

johnwatkins0 commented Jun 30, 2020

This is very similar:

/**
 * Hide admin bar if the window is inside the setup wizard iframe.
 */
add_action(
	'wp_print_footer_scripts',
	function() {
		if ( ! amp_is_dev_mode() || ! is_admin_bar_showing() ) {
			return;
		}
		?>
		<script data-ampdevmode>
			document.addEventListener( 'DOMContentLoaded', function() {
				if (!('name' in window) || 'amp-wizard-completion-preview' !== window.name) { // Detects whether the current window is in an iframe.
					return;
				}

				if ( document.body.classList.contains( 'admin-bar' ) ) {
					document.body.classList.remove( 'admin-bar' );
					document.documentElement.style.cssText += '; margin-top: 0 !important';
					document.getElementById( 'wpadminbar' ).remove();
				}
			});
		</script>
		<?php
	}
);

Apparently if a window is in an iframe, the iframe's name attribute is available as window.name. I've never come across this piece of information before (that I can recall).

I don't think this is overkill because it's no more complicated and is maybe more reliable than the query var, and works across navigations, so I'm going to add it.

@johnwatkins0 johnwatkins0 marked this pull request as ready for review June 30, 2020 04:13
@johnwatkins0
Copy link
Contributor Author

Opening this for review after making a round of CSS updates not necessarily directly related to this task. I also removed the feature flag around the setup wizard, so anyone checking out this branch or develop after this branch is merged will have access to the setup wizard. No need for the AMP_NEW_ONBOARDING constant. This can easily be reversed if I've done it too soon.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 30, 2020

Plugin builds for c73edb0 are ready 🛎️!

@johnwatkins0
Copy link
Contributor Author

@jwold The production build in the above comment should work in your local environment out of the box without having to mess with PHP constants.

@johnwatkins0 johnwatkins0 requested a review from jwold June 30, 2020 04:18
@jwold
Copy link
Collaborator

jwold commented Jun 30, 2020

  1. Can we make all the steps blue checkmarks as they get completed? https://d.pr/i/rDAmSj
  2. I'm now wondering if we should have the gray outline: https://d.pr/i/ZMfD7t. It is feeling like a button. Curious for your thoughts! cc @amedina and @westonruter

@johnwatkins0
Copy link
Contributor Author

Now being handled in #4962

@johnwatkins0
Copy link
Contributor Author

@westonruter @pierlon This is ready for review again. This PR has become a catch-all for everything we've discussed for the last couple days, and this afternoon while waiting for builds to run I refactored the e2e tests (to allow us to be able to sequence the tests -- which helps with testing persistent options). Sorry about the extra diff. Let me know if you see any issues.

@westonruter
Copy link
Member

@johnwatkins0 I went through the wizard after having saved previously with a Reader theme.

  1. The technical question is pre-selected to be non-technical. ✅
  2. The Reader mode is selected by default. ✅
  3. Clicking next (without changing the mode) then takes me immediately to the Summary screen. I should have been able to go to the theme selection. ❌
  4. The mobile theme screenshot is not populated. ❌
  5. Clicking Previous takes me to Theme selection but the screen is empty. ❌

image

image

To work around this issue I have to make a change to the mode and then switch back to Reader, and then I am taken to the theme selection and see the screenshot as expected on the summary screen.

@johnwatkins0
Copy link
Contributor Author

Thanks, @westonruter . 7ab0495 should fix that. I had to make some changes to the way options are held in the application state, so that now we have originalOptions (what's received from the endpoint), updates (changed values) and editedOptions ( { ...originalOptions, ...updates } ), and it looks I missed switching updates to editedOptions in a couple places where the latter should be used.

@westonruter
Copy link
Member

@johnwatkins0 When clicking the Finish button I'm getting a JS error:

image

@westonruter
Copy link
Member

activePageIndex is 5 so and there is no activePageIndex + 1 page:

image

@johnwatkins0
Copy link
Contributor Author

@johnwatkins0 When clicking the Finish button I'm getting a JS error:

image

a56bd97 should fix that.

className="done__preview-iframe"
src={ previewPermalink }
title={ __( 'Site preview', 'amp' ) }
name="amp-wizard-completion-preview"
Copy link
Member

Choose a reason for hiding this comment

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

Minor suggestion that I'm not totally sold on myself: since the admin bar gets hidden at DOMContentLoaded there is a flash of the admin bar. This could be avoided if we hide the iframe until the page is loaded.

Suggested change
name="amp-wizard-completion-preview"
name="amp-wizard-completion-preview"
style={ { opacity: 0 } }
onLoad={ ( event ) => { event.target.style.opacity = '1'; } }

There's probably a more elegant way to do this however. (Including showing a spinner initially.)

Not important.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 9b707af

@westonruter
Copy link
Member

westonruter commented Jul 2, 2020

@johnwatkins0 When on the Done screen, the Close button and the Finish button do the same thing:

image

Should the close button be removed on the Done screen then? There's no sense to “Exit” the wizard when on the Done screen as the icon implies.

Also, I think the Close button should intentionally do history.back() to take the user to the screen they were just on (or else pass the return URL via a return query param similar to how the Customizer implements the Close button there).

Update: Filed as #4974.

// Initialize page from URL `amp-setup-screen` parameter. If not set, current page is 0.
// This is primarily for testing.
const [ activePageIndex, setActivePageIndex ] = useState( () => {
const index = pages.findIndex( ( { slug } ) => slug === getQueryArg( global.location.href, 'amp-setup-screen' ) );
Copy link
Member

Choose a reason for hiding this comment

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

Aside: I miss this query var 😄 It was useful to be on a screen and reload after changes to avoid having to tap Next Next Next.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I put it back? I thought I was probably the only person using it.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, please do. It's nice for development, no?

@pierlon
Copy link
Contributor

pierlon commented Jul 2, 2020

Should the text within the information panel on the template mode screen be selectable?

@johnwatkins0
Copy link
Contributor Author

Should the text within the information panel on the template mode screen be selectable?

Updated in 8c320a6. I think we can just let these be button-like because they will be genuine buttons in a few weeks.

Copy link
Member

@westonruter westonruter left a comment

Choose a reason for hiding this comment

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

Functionality checks out. I'll merge once @pierlon gives his +1 on technical specifics.

Copy link
Contributor

@pierlon pierlon left a comment

Choose a reason for hiding this comment

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

Looks good, ship it!

@westonruter westonruter merged commit 37cb245 into develop Jul 2, 2020
@westonruter westonruter deleted the feature/4707-done-screen branch July 2, 2020 02:07
@schlessera
Copy link
Collaborator

@schlessera
Copy link
Collaborator

This may be because you still have "classic" set as the reader theme, which won't be accepted by the validate_callback now that we've switched that slug to legacy.

Won't other folks have this as well? We'll probably need to ensure whatever value is found is handled gracefully (by silently setting to the correct default value, for example?).

@pierlon
Copy link
Contributor

pierlon commented Jul 2, 2020

@schlessera I think he meant the reader_theme option, which is not in production as yet.

@westonruter westonruter added the Changelogged Whether the issue/PR has been added to release notes. label Jul 17, 2020
@johnwatkins0 johnwatkins0 added the WS:UX Work stream for UX/Front-end label Aug 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelogged Whether the issue/PR has been added to release notes. cla: yes Signed the Google CLA WS:UX Work stream for UX/Front-end
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wizard step: "Done" screen
7 participants