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

Documentation: Document page attributes components and a way to have drafts as parent posts #12395

Conversation

jorgefilipecosta
Copy link
Member

Fixes: #9089

In the classic editor, it has possible to change the parent attributes UI to allow drafts to be selected as a parent of a page/post.
@youknowriad suggested a reasonable way to do that in the new editor would be to implement Page Attributes as a sidebar and remove the existing panel.

This PR documents the set of page attributes components that help having a page attributes sidebar (they were undocumented).
It changes the PageAttributesParent component to allow it to receive the possible parent items as a prop if not passed it queries the items as before. This simple change allows plugin developers to use all the logic of the component but just pass a different prop with the items they want e.g.: draft posts and the subset resulting of some specific filter.
And in the end, we provide a code sample that does precisely what @youknowriad suggested implements page attributes in a sidebar, with the possibility of allowing draft posts to be selected as a parent and removes the existing Page attributes panel.

How has this been tested?

I pasted the code sample in the browser console, and I checked it works correctly.

Copy link
Member

@chrisvanpatten chrisvanpatten left a comment

Choose a reason for hiding this comment

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

I don't want to let perfect be the enemy of good so I'm not approving/denying, but there are some small docs things it'd be nice to fix. Cool to see this though!

PageAttributesCheck
===================

This component is used to check if the page attributes section should be rendered or not.
Copy link
Member

Choose a reason for hiding this comment

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

I think generally if these lines are intended to be separate paragraphs there should be a newline between each line. Otherwise, they can all be one line (we don't do line-wrapping in markdown).

Using these components, one can add a UI that allows changing page attributes in different scenarios/needs.

PageAttributesCheck
===================
Copy link
Member

Choose a reason for hiding this comment

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

I believe these should be H2s — we should only have a single H1 per page.

Copy link
Member

Choose a reason for hiding this comment

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

We should also standardise on a single type of heading syntax: # or =. I prefer # but this isn't a blocker, just an observation. (I might look for markdown linters today and write a proposal for including one.)

@@ -0,0 +1,160 @@
Here components that provide the functionality available in `Page Attributes` panel of the document sidebar are documented.
Copy link
Member

Choose a reason for hiding this comment

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

This should have an H1 page title :)

@jorgefilipecosta jorgefilipecosta force-pushed the add/document-approach-to-have-drafts-as-parent-page branch from 156e4df to a8edd99 Compare November 29, 2018 23:58
@jorgefilipecosta
Copy link
Member Author

Thank you for your review @chrisvanpatten all your feedback was applied!

@jorgefilipecosta jorgefilipecosta force-pushed the add/document-approach-to-have-drafts-as-parent-page branch from a8edd99 to 7675468 Compare January 11, 2019 18:23
@jorgefilipecosta jorgefilipecosta force-pushed the add/document-approach-to-have-drafts-as-parent-page branch from 7675468 to b7ad77d Compare January 24, 2019 11:23
@gziolo gziolo added [Type] Developer Documentation Documentation for developers Backwards Compatibility Issues or PRs that impact backwards compatability labels Feb 7, 2019
@gziolo gziolo added this to the Documentation & Handbook milestone Feb 7, 2019
Copy link
Member

@oandregal oandregal left a comment

Choose a reason for hiding this comment

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

Documentation seems fine. Tested that the example works as expected. This would be the result (no page attributes component will be shown in the document sidebar and a new sidebar will be added for this):

page-sidebar-page-atts

I'm a bit confused by this behavior, though. I'd think that we either want to:

  1. fix the current component and allow for drafts (if it is a backward compatibility issue).
  2. allow plugins to customize the parent checkbox contents (if what we want is to allow extensibility).

I'd want a second opinion on this before approving @youknowriad @jasmussen @mapk

@jorgefilipecosta
Copy link
Member Author

jorgefilipecosta commented Feb 8, 2019

Hi @nosolosw thank you for your review.
In issue #9089 it is possible to see the discussion that happened before arriving at this solution.
The base idea is that we don't want a very granular filter to allow this extensibility mechanism while we already have some possible alternatives.
This PR documents the solution referred by @youknowriad in #9089 (comment):

Developers can remove the panel and register a custom sidebar, This is a workaround.

@youknowriad youknowriad removed this from the Documentation & Handbook milestone Mar 18, 2019
…proach that allow drafts as parent posts; Update: Allow PageAttributesParent to receive the items as a property;
@youknowriad
Copy link
Contributor

Is this still needed? Maybe not with the new Document Slot?

@jorgefilipecosta
Copy link
Member Author

Hi @youknowriad, the fact that "In the classic editor, it has possible to change the parent attributes UI to allow drafts to be selected as a parent of a page/post." and in Gutenberg, we don't have an easy way to do that still persists.
Maybe this PR should be updated to document how to do this using the Document Slot?

@youknowriad
Copy link
Contributor

Maybe this PR should be updated to document how to do this using the Document Slot?

Works for me 👍

@cr0ybot
Copy link
Contributor

cr0ybot commented Nov 1, 2020

After a recent change, PageAttributesParent no longer accepts props, which breaks the proposed code... seems like either replace the dropdown entirely or provide a filter for the query.

Base automatically changed from master to trunk March 1, 2021 15:42
@tomdevisser
Copy link
Member

@jorgefilipecosta @youknowriad Is this still relevant? What needs to be done in order for this PR to be moved forward/closed? :)

@jorgefilipecosta
Copy link
Member Author

I think we can close this PR.

@sirreal sirreal deleted the add/document-approach-to-have-drafts-as-parent-page branch June 18, 2024 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backwards Compatibility Issues or PRs that impact backwards compatability [Type] Developer Documentation Documentation for developers
Projects
None yet
7 participants