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

Move components in wp.blocks.InspectorControls.* to wp.components.*. #4817

Merged

Conversation

jorgefilipecosta
Copy link
Member

@jorgefilipecosta jorgefilipecosta commented Feb 1, 2018

The components were not inspector controls specific, they were just generic input elements. This move will allow other parts of the Gutenberg besides blocks, e.g: document sidebar to take advantage of this reusable components.
This PR comes after some discussions in #4175 (review).
This move will also allow the move of TermTreeSelect, as TreeSelect component. Making possible to use it in the HierarchicalTermSelector removing existing duplicate code.
The inputs in Document sidebar could also be updated to use the components e.g: toggles (Stick to the Front Page) and selects (Author, Template) could make use ToggleControl and SelectControl, instead of repeating the same logic.

We expose a select control so Fixes: #3931;

Deprecation warnings are shown when importing the components from wp.blocks.InspectorControls.*, but for now, the import continues to work as before.

How Has This Been Tested?

This refactor affects the whole application so besides executing automatic tests, do general smoke testing around the app and verify things are working as before. Give special relevance to inspector controls.

@jorgefilipecosta jorgefilipecosta added the [Type] Enhancement A suggestion for improvement. label Feb 1, 2018
@jorgefilipecosta jorgefilipecosta self-assigned this Feb 1, 2018
@jorgefilipecosta jorgefilipecosta added the [Status] In Progress Tracking issues with work in progress label Feb 1, 2018
class WrappedComponent extends Component {
componentDidMount() {
// eslint-disable-next-line no-console
console.warn( `wp.blocks.InspectorControls.${ componentName } is deprecated use wp.components.${ componentName }` );
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe wp.blocks.InspectorControls.${ componentName } is deprecated, use wp.components.${ componentName }.

Added punctuation.

};

forEach(
{ BaseControl,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we move BaseControl to a new line aswell?

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.

It might be a good idea to add a small README per component (like other generic components :))

@jorgefilipecosta jorgefilipecosta force-pushed the update/moved-ic-inputs-to-wordpress-components branch from 9196c84 to db81465 Compare February 2, 2018 12:21
@jorgefilipecosta jorgefilipecosta removed the [Status] In Progress Tracking issues with work in progress label Feb 2, 2018
@jorgefilipecosta
Copy link
Member Author

Thank you for your review @youknowriad, this PR was rebased and the feedback was addressed.

@youknowriad youknowriad requested review from mtias and aduth February 2, 2018 12:48
@youknowriad
Copy link
Contributor

While I agree with this change, I added some reviewers to have other opinions here.

Copy link
Member

@aduth aduth left a comment

Choose a reason for hiding this comment

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

Not sure we need the nesting of input-controls within components.

I don't recall the specific reason why it was implemented the way it was originally; if we thought that the inputs were specific to usage within blocks/editor? As noted, they seem generic enough, so I don't have much of a problem with this.

import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import BaseControl from './../base-control';
import Button from '../../button';
Copy link
Member

Choose a reason for hiding this comment

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

It's a shame this doesn't work, but it's frustrated me in the past in my attempts to do so:

import { Dashicon, withInstanceId, Button } from '../../';

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this syntax would be better :(

@jorgefilipecosta jorgefilipecosta force-pushed the update/moved-ic-inputs-to-wordpress-components branch 4 times, most recently from 2a7ad80 to ddebc1c Compare February 8, 2018 23:13
@jorgefilipecosta
Copy link
Member Author

Maybe at the time, these controls were created the idea was for them to be InspectorControls specific maybe even render them automatically inside inspector controls, but that ended up not being the case and the components ended up being generic.

I rebased this PR adding some required changes meanwhile. All the feedback was addressed namely, removed the input-controls nesting and added a readme.md file for each component documenting them.

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.

I like the READMEs 👍

The components were not inspector controls specific, they were just generic input elements. This move will allow other parts of the Gutenberg besides blocks, e.g: document sidebar to take advantage of this reusable components.
@jorgefilipecosta jorgefilipecosta force-pushed the update/moved-ic-inputs-to-wordpress-components branch from ddebc1c to 8f0c832 Compare February 9, 2018 11:48
@jorgefilipecosta jorgefilipecosta merged commit 4cf8135 into master Feb 9, 2018
@jorgefilipecosta jorgefilipecosta deleted the update/moved-ic-inputs-to-wordpress-components branch February 9, 2018 12:02
@phpbits
Copy link
Contributor

phpbits commented Feb 12, 2018

@jorgefilipecosta @aduth seems like the Custom CSS Class is now missing. I've run build package and install the zip file. I'm not seeing the field now. Thanks!

@jorgefilipecosta
Copy link
Member Author

jorgefilipecosta commented Feb 12, 2018

Thank you for reporting this problem @phpbits. I'm also able to replicate it, and I'm investigating its cause.

@phpbits
Copy link
Contributor

phpbits commented Feb 12, 2018

@jorgefilipecosta you're very welcome. Let me know how it goes. I'm also using Inspector Control on my plugin integration and also not showing. Hope you can share the fixes. Thanks!

@jorgefilipecosta
Copy link
Member Author

The root cause was that focus prop was been used to check condition while it was removed.
A fix was submitted in PR #5004.
@phpbits I hope this fixes the issue you are having applying a similar change to your plugin.

@phpbits
Copy link
Contributor

phpbits commented Feb 12, 2018

@jorgefilipecosta I'll wait for the pull request to be merged and will try it on my end. I hope this will fix my issues too. Thanks!

@phpbits
Copy link
Contributor

phpbits commented Feb 12, 2018

@jorgefilipecosta Yes fields are now showing but it's not saving. Have you tried adding values to custom CSS Class field and save the changes? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants