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

fix(ia): hide notifications #3563

Merged
merged 9 commits into from
Nov 26, 2024
Merged

fix(ia): hide notifications #3563

merged 9 commits into from
Nov 26, 2024

Conversation

ronchambers
Copy link
Collaborator

@ronchambers ronchambers commented Nov 21, 2024

All Submissions:

Changes proposed in this Pull Request:

The current "hide notifications" code needed some fixes to work for the current wizards and new wizards too.

This new solution moves remove_notifications() from the newspack class to the wizard abstract class.

To get an idea of what notifications are being removed, please see this PR that was leaving the notices in place, but just adding margin. We've now since decided/fixed that we'll actually remove the notices instead.

Another fix/change that was made was to move the rendering hook for the "admin-header-only" wizards to in_admin_header instead of all_admin_notices because we were removing the action that was also being used for rendering. Because of this hook change, the location in the HTML where the admin-header was being rendered changed, so we needed to adjust the CSS based on this new HTML location. Mainly this was needed to fix the mobile layout.

image

Finally, the CSS that originally added margins to the notifications (instead of removing notifications) was allowed to stay in the CSS (with some refactoring). This is kind of a "fall-back" in case the PHP doesn't hide a notice for some reason it will still look OK on the page.

Testing:

When testing, no notices should appear on any wizards (except WordPress core notices like "1 post moved to trash" and "saved").

For Wizards that are "admin-header-only" on CPT pages, notices such as "post moved to trash" and other "bulk/edit" actions will still show. These are internal to WordPress and provide helpful feedback to users/admins.

image

Settings pages such as Network > Site Role (admin.php?page=newspack-network) will show a "saved" notice like the attached since these are rendered by core and are not removed.

image

How to test the changes in this Pull Request:

  1. Pull this branch.
  2. npm run build
  3. Click on a variety of Wizards pages in wp-admin and verify no notices are shows.

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 November 21, 2024 06:30
@ronchambers ronchambers marked this pull request as ready for review November 24, 2024 17:18
@ronchambers ronchambers requested a review from a team as a code owner November 24, 2024 17:18
@jaredrethman jaredrethman changed the title Fix/ia hide notifications fix(ia): hide notifications Nov 25, 2024
@ronchambers
Copy link
Collaborator Author

I'm going to look into this today:

We could move this PR's php code to the abstract Wizards class so that each wizard could control it's own ability to hide notifications or not. We could set the default to "hide" but wizards could unhide on a per-screen basis. Just an idea if we ever need more granularity for hiding.

@ronchambers ronchambers mentioned this pull request Nov 25, 2024
6 tasks
@ronchambers
Copy link
Collaborator Author

ronchambers commented Nov 25, 2024

PR write-up above has been updated for moving code into the wizard class. Ready for review again.

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.

Appreciate the refactor @ronchambers , this is looking great! One thing I noticed is this change isn't affecting Network Wizards. Looks like the constructor in Network_Wizard is missing parent::__construct();

@ronchambers
Copy link
Collaborator Author

thanks @jaredrethman - the parent construct issue was just fixed in this PR: #3479 (comment)

Once both PRs are merged, the issue will solve itself; the Network Wizard will hide notices.

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.

@ronchambers thanks for addressing my feedback. Code is approved!

@github-actions github-actions bot added the [Status] Approved The pull request has been reviewed and is ready to merge label Nov 26, 2024
@ronchambers ronchambers merged commit 613a2e6 into epic/ia Nov 26, 2024
9 checks passed
@ronchambers ronchambers deleted the fix/ia-hide-notifications branch November 26, 2024 17:29
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.

2 participants