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

Adding snackbar notices support to the new widgets page #16020

Merged
merged 2 commits into from Jun 17, 2019

Conversation

youknowriad
Copy link
Contributor

This PR adds a "save success" snackbar notice to the new widgets page. It's also the first PR adding support for the notices to the widgets screen which raises a bunch of interesting questions :)

Testing instructions

  • Click the "update" button in the widgets screen
  • A success notice should show up

@youknowriad youknowriad self-assigned this Jun 6, 2019
import { SnackbarList } from '@wordpress/components';
import { useSelect, useDispatch } from '@wordpress/data';

function Notices() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This made me wonder if we want to move the EditorNotices component from the editor package to the notices package as we'd have to rewrite such component for each consumer.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I guess it would be good to avoid this code repetition and just expose the component as part of the notices package.

__( 'Block areas saved succesfully.' ),
{
id: WIDGET_AREAS_SAVE_NOTICE_ID,
type: 'snackbar',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wondered whether the "context" argument should be used here to differentiate between the "post editor" notices and the "widget screen" notices. Imagine a world where the WP-Admin is a full SPA, do we want to use this context to differentiate between these notices?

Also depending on the answer, this raises the question of whether we should set a default context to "post editor" for existing plugins creating notices in the editor.

Copy link
Member

Choose a reason for hiding this comment

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

Hi @youknowriad, you mean the context for translation right? If yes even if we a are in a full SPA I don't think we need context to differentiate between screens. WordPress did not used different contexts if two strings were on different screens so I think we can follow the same logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, I meant the "context" property of the notices (we never used it but the API supports it). cc @aduth as we discussed some of this recently.

@youknowriad youknowriad added the [Feature] Widgets Screen The block-based screen that replaced widgets.php. label Jun 6, 2019
@jorgefilipecosta jorgefilipecosta added this to Widget screen UI issues in Block-based Widgets Editor Jun 12, 2019
Copy link
Member

@jorgefilipecosta jorgefilipecosta left a comment

Choose a reason for hiding this comment

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

Things worked great in my tests, thank you for this important UX improvement 👍 I guess the would be good to a avoid the need to implement the notices component as part of this package (packages/edit-widgets/src/components/notices/index.js), but I'm ok with that refactored being performed in a different PR.

import { SnackbarList } from '@wordpress/components';
import { useSelect, useDispatch } from '@wordpress/data';

function Notices() {
Copy link
Member

Choose a reason for hiding this comment

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

Yes, I guess it would be good to avoid this code repetition and just expose the component as part of the notices package.

args: [
'Block areas saved succesfully.',
{
id: 'WIDGET_AREAS_SAVE_NOTICE_ID',
Copy link
Member

Choose a reason for hiding this comment

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

Nit pick: Maybe the test can import WIDGET_AREAS_SAVE_NOTICE_ID as a constant from the actions file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not exported at the moment. I mean I could export it but for a test, maybe it's not that important.

@mapk
Copy link
Contributor

mapk commented Jun 14, 2019

I tested, and from a design perspective, it looked great. :shipit: I may have missed it, but wanted to verify there was agreement on the time the snackbar remained visible before dismissing itself. I love these little notifications animating into view!

@youknowriad youknowriad merged commit 1d653d1 into master Jun 17, 2019
@youknowriad youknowriad deleted the add/widgets-notices branch June 17, 2019 08:34
@jorgefilipecosta jorgefilipecosta moved this from Widget screen UI issues to Core/Extensibility/API tasks in Block-based Widgets Editor Jun 17, 2019
@jorgefilipecosta jorgefilipecosta moved this from Core/Extensibility/API tasks to Done in Block-based Widgets Editor Jun 17, 2019
@youknowriad youknowriad added this to the Gutenberg 6.0 milestone Jun 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Widgets Screen The block-based screen that replaced widgets.php.
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants