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

Introduces PluginSettingsSidebar slotfill to the Document sidebar. #13361

Merged
merged 62 commits into from
Jul 3, 2019

Conversation

ryanwelcher
Copy link
Contributor

@ryanwelcher ryanwelcher commented Jan 17, 2019

Description

Introduce a new slotFill below Status & Availability panel in the Document sidebar.
Closes #13357

How has this been tested?

This has been testing locally and there are tests on the PR.

Screenshots

slotfill

Types of changes

New feature that only affects the settings-sidebar component.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.

Basic Usage Example:

const { registerPlugin } = wp.plugins;
const { PluginDocumentSetting } = wp.editPost;

const MyDocumentSettingTest = () => (
	<PluginDocumentSetting className="my-document-setting-plugin">
		<p>My Document Setting Panel</p>
	</PluginDocumentSetting>
);

registerPlugin( 'document-setting-test', { render: MyDocumentSettingTest } );

@ryanwelcher ryanwelcher changed the title Feature/settings panel slot Introduce PluginSettingsSidebar slotfill to the Document sidebar. Jan 17, 2019
@ryanwelcher ryanwelcher changed the title Introduce PluginSettingsSidebar slotfill to the Document sidebar. Introduces PluginSettingsSidebar slotfill to the Document sidebar. Jan 17, 2019
Copy link
Member

@adamsilverstein adamsilverstein left a comment

Choose a reason for hiding this comment

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

LGTM! This is an elegant solution to a useful extension point.

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

Referring to the related slack discussion. https://wordpress.slack.com/archives/C02QB2JS7/p1545318632348900

Let's wait a bit before introducing this as Phase 2 work could have an impact on backward compatibilty here.

@gziolo
Copy link
Member

gziolo commented Jan 21, 2019

Noting, that there is also a tutorial which explains how to create a sidebar for your plugin - - it would be an alternative supported as of today:
https://github.com/WordPress/gutenberg/blob/master/docs/designers-developers/developers/tutorials/sidebar-tutorial/plugin-sidebar-0.md

There was also a related discussion on Twitter on that topic during the weekend:

https://twitter.com/AlexStandiford/status/1086313778625593344

There was mention of the article by @ocean90:
https://dominikschilling.de/how-to-edit-post-meta-outside-of-a-gutenberg-block/

@gziolo gziolo added [Feature] Extensibility The ability to extend blocks or the editing experience [Status] Blocked Used to indicate that a current effort isn't able to move forward labels Jan 22, 2019
@gziolo
Copy link
Member

gziolo commented Apr 24, 2019

@youknowriad any new thoughts on this proposal? Code wise it looks solid. There is only the question related to the UI considerations and how does it fit in the wider picture of the block editor on other screens like the widget one.

@gziolo gziolo added the Needs Decision Needs a decision to be actionable or relevant label Apr 24, 2019
@youknowriad
Copy link
Contributor

I think we can explore this a bit further now. The original reasons for delaying this are still valid (could become an inspector control in phase 2 if we ever introduce a "Document" or "Post" block) but it feels a bit too seen and this use-case is legit.

Can we expaned the description of the PR with a plugin example to test it?

I think we should rename this to DocumentSetting as it's a more semantic name that sets the expectation that this is about adding new document settings. They are now displayed in the document panel but the framework (editor) can display them in a different way if needed.

Also, is there a way to display the plugin icon in the panel header (to clarify the origin of the panel).

@youknowriad youknowriad removed Needs Decision Needs a decision to be actionable or relevant [Status] Blocked Used to indicate that a current effort isn't able to move forward labels May 6, 2019
@youknowriad
Copy link
Contributor

We might also want to include those custom panels in the Options dialog so users could disable them the same way they can do it for all other panels.

Yeah, this seems like something that is needed. I'm fine if it's a separate PR though. Whatever works best for you all.

@youknowriad
Copy link
Contributor

Tested this, it works great. A few questions:

  • Will we need an id to "enable/disable" the panel or is the plugin's identifier sufficient?
  • It does feel like we may need a way to define the position (or at least a priority or something like that) for the panel. (Also something that we can explore separately).

@ryanwelcher
Copy link
Contributor Author

@youknowriad I was able to remove the custom panels using removePanel and looking up the id in the markup.

I have been thinking about the priority aspect as well, I was thinking that adding it to registerPlugin() may make sense. This will give us the flexibility to add it to other SlotFills in the future and also for the existing ones such as PluginPrePublishPanel and PluginPostPublishPanel - both of which could benefit from it.

@ryanwelcher
Copy link
Contributor Author

@gziolo @youknowriad I've updated the e2e test and everything is passing. Is there anything else that needs to be addressed on this?

@ryanwelcher
Copy link
Contributor Author

@youknowriad I have created #16384 as an approach to manage priority. Any feedback is apprectiated!

@@ -88,6 +88,7 @@ export function initializeEditor( id, postType, postId, settings, initialEdits )
}

export { default as PluginBlockSettingsMenuItem } from './components/block-settings-menu/plugin-block-settings-menu-item';
export { default as PluginDocumentSettingPanel } from './components/sidebar/plugin-document-setting-panel';
Copy link
Contributor

Choose a reason for hiding this comment

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

@aduth any thougs on the naming?

Copy link
Member

Choose a reason for hiding this comment

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

Seems fine to me as proposed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Extensibility The ability to extend blocks or the editing experience Needs Design Feedback Needs general design feedback. [Type] Task Issues or PRs that have been broken down into an individual action to take
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add SlotFills to Document Sidebar
6 participants