question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Display Idea Hub notice above WP posts list table if there are new or saved ideas

See original GitHub issue

If there are any new or saved ideas in the Idea Hub module, a corresponding notice that links to the respective area of the Idea Hub widget should be displayed above the WordPress posts list admin table, following the Figma design.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • If the ideaHubModule feature flag is enabled and the Idea Hub module is active, a WordPress admin notice should be potentially displayed above the WordPress posts list table:
    • If there are saved ideas available, the notice should look like in this Figma file except not to include G Site Kit logo.
    • If there are no saved but new ideas available, the notice should look like in this Figma file except not to include G Site Kit logo.
    • In both cases, the link should lead to the respective tab of the Idea Hub widget in the Site Kit dashboard.
    • The results for whether there are new ideas or saved ideas should be cached server-side (e.g. in a transient cached for a day).
  • The notice dismissals for the two scenarios should be separately stored, both on the server-side:
    • The dismissal for the “New ideas” notice should be stored for 1 week. In other words, if the user after one week still has no saved ideas, the notice should re-appear.
    • The dismissal for the “Saved ideas” notice should be permanent, in general. However, there is one particular circumstance when it should be cleared: If the user makes a change that results in them to no longer have any saved ideas (for example unsaving the only saved idea or creating a draft post from the only saved idea), the dismissal should be cleared. In other words, once the user later saves something again, the notice should re-appear.
    • To summarize: As long as the user continuously has something in “Saved”, they will not see any notice again once they dismiss it.
    • Technically, this requires a new REST data point, e.g. POST:core/user/data/dismiss-notification, expecting a notification slug.

Implementation Brief

  • Once #3272 and #3360 have been merged.
  • Create assets/js/googlesitekit-idea-hub-post-list-notice.js.
  • Update webpack.config.js to add a new entry for the above file similar to analytics-advanced-tracking.
  • Edit includes/Modules/Idea_Hub.php
    • Edit setup_assets method to define a new Script for dist/js/googlesitekit-idea-hub-post-list-notice.js with CONTEXT_ADMIN_POSTS as context and googlesitekit-datastore-user as a dependency.
    • Define 2 slugs which will be unique identifiers saved idea notice and new ideas notice.
    • The admin_notices hook will be used to display the notifications which should be as per the designs in Figma. The callback function for the hook should do the following:
      • Ensure it runs only on the posts list screen. This can be done by using the get_current_screen function and then checking whether the id its result is equal to edit-post.
      • Get a list of dismissed items via the get_dismissed_items method of the Dismissed_Items class.
      • Check if there are saved ideas by using the get_data method of the class with saved-ideas as parameter and whether the notice has not been dismissed by checking if the slug for the saved idea notice does not exist in the list of get_dismissed_items. If this is the case, then display the notice as per the documentation: and as per the designs in Figma. If there are no saved ideas, clear any dismissed notification using the delete method of the Dismissed_Items class.
      • If there are no saved ideas, check if there are new ideas using the same method as for saved-ideas but using new-ideas as parameter for the get_data method. If there are news ideas and the notice has not been dismissed using the same logic as for the saved idea notice, then display the notice as per the documentation and as per the designs in Figma.
      • Both type of notices should be dismissible by adding the is-dismissable class name to the notice as well as the goooglesitekit-notice class name and goooglesitekit-notice__saved or goooglesitekit-notice__new depending whether it’s a saved ideas notice or new ideas notice.
      • The results of the saved ideas and new ideas count should be stored server side for 24 hours using the Transients API via the Google\Site_Kit\Core\Storage\Transients class.
      • In both above cases, the link should lead to the respective tab of the Idea Hub widget in the Site Kit dashboard using the plugins_url function together with the following hash:
        • #new-ideas for the new ideas tab
        • #saved-ideas for the saved ideas tab.
  • Update assets/js/googlesitekit-idea-hub-post-list-notice.js,
    • to include the dismissNotice function with the following details:
      • It has the following parameters:
        • slug: string, unique identifier for the notice
        • expiration_time: integer, having default value 0.
      • It then dispatches the dismissItem action of the core/user data store passing the slug and optional expiration_time. Dispatching the action is done like in other modules, for e.g Data.dispatch( CORE_USER ).dismissItem.
    • Check if there are any elements having goooglesitekit-notice class name. If this is the case, add a click event listener on the dismiss button (which has been added automatically by WordPress) which calls the dismissNotice function.
      • If it’s a saved idea notice, then the expiry is set to 0, which means it’s permanently dismissed.
      • If it’s a new idea notice, then the expiry is set to 1 week.

Test Coverage

  • No tests to be added.

Visual Regression Changes

  • N/A

QA Brief

  • Ensure you have new ideas.
  • Open your posts list page. http://sitekit.10uplabs.com/wp-admin/edit.php
  • Note the presence of a dismissible notice for new ideas.
  • Dismiss the notice and refresh the page, note the absence of the notice.
  • Reset the dismissed items by running wp user meta delete 1 wp_googlesitekitpersistent_dismissed_items command.
  • Refresh the page again and verify that the dismissible notice is shown again.

===

  • Save an idea
  • Go back to your posts list page
  • Note the presence of a dismissible notice for saved ideas
  • Dismiss the notice and refresh the page, verify that neither notice for saved ideas nor notice for new ideas is shown.
  • Unsave all saved ideas
  • Go back to your posts list page and verify that there is a notice for new ideas

Changelog entry

  • Add the Idea Hub notice to the posts list table.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:22 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
eugene-manuilovcommented, Jul 29, 2021

Unfortunately, not yet, @wpdarren

1reaction
wpdarrencommented, Jul 23, 2021

@eugene-manuilov thank you for updating the QAB and 🤦‍♂️ on the AC! I’ll put this on hold until 3747 is in QA.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Show Idea Hub context for posts based on Idea Hub ... - GitHub
The WordPress posts list table should indicate which posts are drafts created on an Idea Hub idea. Do not alter or remove anything...
Read more >
How to Display Recent Posts in WordPress - WPBeginner
In your WordPress dashboard, go to Appearance » Widgets and add the 'Latest Posts' widget block to your sidebar. Add latest post widget...
Read more >
29 Creative Office Bulletin Board Ideas In 2023 {Buzzworthy}
The Buzz Board is one of the fun office notice board ideas. It's a chalkboard where you can post something new and buzzworthy...
Read more >
How to Display Recent Posts on Any WordPress Page
The Smart Recent Posts Widget allows you to display a list of your latest posts with thumbnails, excerpts, and publish dates included. You...
Read more >
admin_notices | Hook - WordPress Developer Resources
In order to display a notice, echo a div with the class notice and one of the following classes: * notice-error – will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found