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

Feat / IA for Newsletters #3490

Merged
merged 27 commits into from
Nov 1, 2024
Merged

Feat / IA for Newsletters #3490

merged 27 commits into from
Nov 1, 2024

Conversation

ronchambers
Copy link
Collaborator

@ronchambers ronchambers commented Oct 21, 2024

All Submissions:

Changes proposed in this Pull Request:

Once the "TODOs" below are done, this PR will complete the Information Architecture Wizard for the Newsletters Plugin. This code will update the existing Newsletters Plugin header and menu.

See screenshot:

newsletters-tabs

  • The Newsletters custom blue header is deactivated.
  • A new Admin Header is added.
  • The menu is moved and compressed.
  • Some menu items are now combined into Tabs.

Additionally the new Dashboards page is updated so that if the Newsletters plugin is not installed, then the dashboard will not show Newsletters items.

See screenshot:

newsletters-dashboard-new

TODOs:

  • We may need to change the menu icon. Export the SVG from Figma or talk to Thomas/designer. See code comment: // @TODO get SVG from Figma? This one is "envelope" from: https://wordpress.github.io/gutenberg/?path=/story/icons-icon--library

  • I was having a hard time setting the Newsletters CPT parent menu item to a decimal value. It seems that CPTs only support an integer value for menu_positon. So I created a function that will loop through global $menu and then move the CPT to position 3.3 or "3.33" if something is already at 3.3. See the current code in function move_cpt_menu(). You may want to look at function registered_post_type_newsletters( $post_type ) to see how I'm changing the menu_icon but when I try to change the menu_position to 3.3 in that function it doesn't work.

  • I didn't have chance to fully test what happens if someone goes to a "bookmarked" category or tag page that was removed by this Wizard. I recommended we remove categories and tags from the Newsletters menu in this PR ( Feat: Information Architecture for Newsletters newspack-newsletters#1678 ) but still, even with the links removed, someone could have bookmarked any of the following links, so we may want to view them in the browser and see what the user would see. We'll probably want to remove the "blue" Newsletters header and apply the new Admin Header like this code does for the other screens.

    • edit-tags.php?taxonomy=category&post_type=newspack_nl_cpt
    • edit-tags.php?taxonomy=post_tag&post_type=newspack_nl_cpt
    • term.php?taxonomy=category&tag_ID=4&post_type=newspack_nl_cpt
    • term.php?taxonomy=post_tag&tag_ID=31&post_type=newspack_nl_cpt
  • There is an existing Newsletters admin screen in the current (trunk) Newspack Plugin. It can be seen in wp-admin Newspack > Engagement > Newsletters or admin.php?page=newspack-engagement-wizard#/newsletters. It looks to be a React version of the existing Newsletters Settings screen. Typically I'm not a fan of having different screens that do the same thing, so ... maybe we can just remove the React version when IA goes live since Newsletters already has a Settings screen? But I'm not in charge 😉 If it is kept, I'm not sure how to "plug it in" so that admin users that have the Newspack Plugin with IA active get "redirected/shown" the React version of the screen vs admin users that just use Newsletters stand-alone without the Newspack Plugin who will just see the normal settings page.

  • Finally, I'm not sure why ci/cirlceci:test-php is failing in github below. Maybe it was an error that got merged into this branch via trunk or epic/ia?

How to test the changes in this Pull Request:

  1. Pull branch.
  2. npm run build
  3. Activate Newspack plugin.
  4. Install/activate Newspack Newsletters Plugin.
  5. Verify screenshots and notes above.
  6. Deactivate Newsletters plugin, verify dashboard no longer shows Newsletters section.
  7. Re-activate the Newsleters plugin and do the one test related to get_settings_url() in the related PR ( Feat: Information Architecture for Newsletters newspack-newsletters#1678 )

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@ronchambers ronchambers changed the base branch from trunk to epic/ia October 21, 2024 18:23
@ronchambers
Copy link
Collaborator Author

@miguelpeixe - I assigned you in Asana. I'll reach out in slack.

@miguelpeixe
Copy link
Member

Addressing the remaining work:

We may need to change the menu icon. Export the SVG from Figma or talk to Thomas/designer. See code comment: // @todo get SVG from Figma? This one is "envelope" from: https://wordpress.github.io/gutenberg/?path=/story/icons-icon--library

I've settled on using Gutenberg's envelope with proper styles to match different states:

Selected Unselected
image image

I was having a hard time setting the Newsletters CPT parent menu item to a decimal value. It seems that CPTs only support an integer value for menu_positon. So I created a function that will loop through global $menu and then move the CPT to position 3.3 or "3.33" if something is already at 3.3. See the current code in function move_cpt_menu(). You may want to look at function registered_post_type_newsletters( $post_type ) to see how I'm changing the menu_icon but when I try to change the menu_position to 3.3 in that function it doesn't work.

The menu order handling has been refactored in #3501 and merged to this PR.

I didn't have chance to fully test what happens if someone goes to a "bookmarked" category or tag page that was removed by this Wizard.

This seems like a very edge case, which I didn't tackle here. If this becomes a problem, we can setup redirects later on.

There is an existing Newsletters admin screen in the current (trunk) Newspack Plugin. It can be seen in wp-admin Newspack > Engagement > Newsletters or admin.php?page=newspack-engagement-wizard#/newsletters. It looks to be a React version of the existing Newsletters Settings screen.

This wizard should reflect the react version, under Engagement, not the one coming from the Newsletters plugin. The Newsletters version should remain unchanged and available in case the main plugin is not installed.

I've refactored this PR to move the wizard from the Engagement tab to the root level under the Newsletters menu. This also means moving the methods from includes/wizards/class-engagement-wizard.php to includes/wizards/class-newsletters-wizard.php.

To match the proposed tabs with "Tracking", a new wizard was created for those settings:

Settings Tracking
image image

We were also missing the wizard header when creating and editing local subscription lists:

image

Testing

  1. Checkout this branch and, without the Newsletters plugin active, confirm the menu is not available
  2. Activate Newsletters and confirm the menu is now available
  3. Visit all links on the Newsletters menu and confirm the expected pages render
  4. Click "Newsletters -> Settings", configure and ESP and hit Save
  5. Refresh the page and confirm the changes persist
  6. Toggle Subscription Lists and Save
  7. Refresh the page and confirm the changes persist
  8. Click "Add New" on Subscription Lists
  9. Confirm the editor renders with the correct wizard header
  10. Save the list and click "<< Back to Subscription Lists management"
  11. Confirm you're back to the Settings wizard
  12. Navigate to the "Tracking" tab
  13. Toggle both options, refresh the page and confirm they persist

@miguelpeixe miguelpeixe marked this pull request as ready for review October 29, 2024 19:28
@miguelpeixe miguelpeixe requested a review from a team as a code owner October 29, 2024 19:28
@miguelpeixe miguelpeixe self-assigned this Oct 29, 2024
@miguelpeixe miguelpeixe added the [Status] Needs Review The issue or pull request needs to be reviewed label Oct 29, 2024
Copy link
Collaborator

@jaredrethman jaredrethman left a comment

Choose a reason for hiding this comment

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

@miguelpeixe this is great!

We were also missing the wizard header when creating and editing local subscription lists:

Nice catch - thanks for adding this.

Testing

  1. Checkout this branch and, without the Newsletters plugin active, confirm the menu is not available
  2. Activate Newsletters and confirm the menu is now available
  3. Visit all links on the Newsletters menu and confirm the expected pages render
  4. Click “Newsletters -> Settings”, configure and ESP and hit Save
  5. Refresh the page and confirm the changes persist
  6. Toggle Subscription Lists and Save
  7. Refresh the page and confirm the changes persist
  8. Click “Add New” on Subscription Lists
  9. Confirm the editor renders with the correct wizard header
  10. Save the list and click “<< Back to Subscription Lists management”
  11. Confirm you’re back to the Settings wizard
  12. Navigate to the “Tracking” tab
  13. Toggle both options, refresh the page and confirm they persist

All tests work as described. Some feedback:

  • Submenu highlighting:
    • Not highlighting /wp-admin/post-new.php?post_type=newspack_nl_cpt (template select and edit screen). Should highlight "All Newsletters"?
      Screenshot 2024-10-31 at 08 47 58
    • Not highlighting /wp-admin/post-new.php?post_type=newspack_nl_ads_cpt. Should highlight "Advertising"?
      Screenshot 2024-10-31 at 08 50 03
    • "All Newsletters" highlighted when on Add New Lists (/wp-admin/post-new.php?post_type=newspack_nl_list) - is this intentional?
    • Is Newsletters > Tracking new (not in Figma)?
  • Newsletters > Settings
    • No space between sections. This bug was introduced when refactoring general Wizard section(s) styling. This should be handled separate from this PR.
      Screenshot 2024-10-31 at 08 54 38
    • WooCommerce integration missing?
      Screenshot 2024-10-31 at 08 56 04
  • Settings tabs missing headers. Have added suggestions below.

const [ { newslettersConfig }, updateConfiguration ] = hooks.useObjectState( {} );
const [ initialProvider, setInitialProvider ] = useState( '' );
const [ lockedLists, setLockedLists ] = useState( false );
const [ authUrl, setAuthUrl ] = useState( false );

return (
<>
<NewspackNewsletters
<Settings
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
<Settings
<h1>{ __( 'Newsletter Settings', 'newspack-plugin' ) }</h1>
<Settings

Copy link
Member

Choose a reason for hiding this comment

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

It feels like we're saying the same thing 3 times:

image

It's how it's proposed in the design, but since the design screen doesn't have the wizard header, maybe it slipped by. @thomasguillot could you confirm that this is the intended result?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's ok if we repeat things and it's to have some sort of consistency with the other wizards. We could probably the heading to simply "Settings"

Copy link
Member

Choose a reason for hiding this comment

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

Which one?

Copy link
Member

Choose a reason for hiding this comment

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

Like this?

image

Copy link
Member

Choose a reason for hiding this comment

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

Added in ac26dbc

Copy link
Contributor

Choose a reason for hiding this comment

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

Like this?

Yes


return (
<>
<ActionCard
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
<ActionCard
<h1>{ __( 'Newsletter Tracking', 'newspack-plugin' ) }</h1>
<ActionCard

Copy link
Member

Choose a reason for hiding this comment

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

Same as above:

image

Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, I'd say "Tracking" is sufficient

Copy link
Member

Choose a reason for hiding this comment

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

Added in ac26dbc

@miguelpeixe
Copy link
Member

Thansk for the review, @jaredrethman!

Not highlighting /wp-admin/post-new.php?post_type=newspack_nl_cpt (template select and edit screen). Should highlight "All Newsletters"?
Not highlighting /wp-admin/post-new.php?post_type=newspack_nl_ads_cpt. Should highlight "Advertising"?
"All Newsletters" highlighted when on Add New Lists (/wp-admin/post-new.php?post_type=newspack_nl_list) - is this intentional?

Nice catch! After some investigation I finally understood how submenu_file and parent_file works. Fixed in c4df9b0.

Unfortunately, as stated in the code, I was unable to make the Settings submenu get highlighted when editing a Subscription List. The $submenu_file is empty for edit.php?post_type=newspack_nl_cpt&page=newspack-newsletters and I can't figure out how to point to that item.

Is Newsletters > Tracking new (not in Figma)?

Yes. We missed it, but it's required.

This should be handled separate from this PR.

👍

WooCommerce integration missing?

Whoops! I missed it. Added in bb131a9

@jaredrethman
Copy link
Collaborator

@miguelpeixe thank you for your changes/fixes.

Unfortunately, as stated in the code, I was unable to make the Settings submenu get highlighted when editing a Subscription List. The $submenu_file is empty for edit.php?post_type=newspack_nl_cpt&page=newspack-newsletters and I can't figure out how to point to that item.

If highlighting "Settings" when adding/editing a Subscription List is what we want it would require updating:

// Move newsletter subscription list submenu_file.
if ( ! empty( $submenu_file ) && strpos( $submenu_file, 'newspack_nl_list' ) !== false ) {
// This would ideally be under &page=newspack-newsletters to match the
// Settings submenu, but it's not reachable so we go with the second best
// possibility.
return 'edit.php?post_type=newspack_nl_cpt';
}

to:

if ( ! empty( $submenu_file ) && strpos( $submenu_file, 'newspack_nl_list' ) !== false ) {
	return $this->slug;
}

@miguelpeixe
Copy link
Member

🤯 thank you!! Updated in f9442fb

@miguelpeixe
Copy link
Member

@jaredrethman I've also just pushed b6a9f7e to address 1205919985867982-as-1208668902916641/f

There's no need to have the ESP settings ActionCard inside a div. There's no instance in which className is used. Not here and not in the onboarding wizard, which makes use of the same component.

Copy link
Collaborator

@jaredrethman jaredrethman left a comment

Choose a reason for hiding this comment

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

@miguelpeixe nice work here - appreciate the revisions! Approved!

@github-actions github-actions bot added [Status] Approved The pull request has been reviewed and is ready to merge and removed [Status] Needs Review The issue or pull request needs to be reviewed labels Nov 1, 2024
@miguelpeixe miguelpeixe merged commit 8ad5986 into epic/ia Nov 1, 2024
9 checks passed
@miguelpeixe miguelpeixe deleted the feat/ia-newsletters branch November 1, 2024 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] Approved The pull request has been reviewed and is ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants