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

Add a new page/post button on publish panel #33276

Merged

Conversation

thisissandip
Copy link
Contributor

Fixes #32099

Description

Adds a create "New Page/Post" button at the end of the publish check panel.

How has this been tested?

  1. Create a New Post
  2. Publish the post
  3. Check the post publish panel

Screenshots

post_publish_button.mov

Types of changes

New nonbreaking feature

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.

@thisissandip thisissandip mentioned this pull request Jul 8, 2021
7 tasks
@paaljoachim
Copy link
Contributor

paaljoachim commented Jul 8, 2021

Hi @thisissandip Sandip

It looks great! Let's just remove the "Back to Dashboard" text link and it is done.
Similar to what I have done here: #32910 (comment)

We can then get a code review perhaps from @Mamaduka

@thisissandip
Copy link
Contributor Author

Hey @paaljoachim!

I removed the Back to dashboard link. I guess it is ready for the code review! 😄

@paaljoachim paaljoachim added the Good First Review A PR that's suitable for someone looking to contribute for the first time by reviewing code label Jul 8, 2021
@thisissandip thisissandip requested a review from ellatrix July 10, 2021 14:54
@paaljoachim paaljoachim mentioned this pull request Jul 14, 2021
@mtias mtias added the Needs Design Feedback Needs general design feedback. label Jul 14, 2021
@javierarce
Copy link
Contributor

javierarce commented Jul 14, 2021

Just a tiny detail: since the input field and the button are next to each other, could we set the border-radius of the adjacent sides to 0px?

image

@javierarce
Copy link
Contributor

On second thought, I think it would be better to have some space between those two elements instead, because if they are together we'll end up having a state like this (and it doesn't look nice):

image

@paaljoachim
Copy link
Contributor

We can go with what Joen suggested here: #32910 (comment) (Joen also suggested removing the "Back to dashboard" text link.)

Prepublish-panel

As in giving space between the page address field and the Copy button.

@thisissandip
Copy link
Contributor Author

thisissandip commented Jul 14, 2021

Added the margin-left to the copy button. This is how the post publish panel looks now:

image

@paaljoachim
Copy link
Contributor

paaljoachim commented Jul 14, 2021

Are we done? Any more design comments?
If not then we can remove the Needs Design feedback label @mtias added, and get a code review.
Thanks!

Copy link
Contributor

@gwwar gwwar left a comment

Choose a reason for hiding this comment

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

Thanks for looking into this @thisissandip !

Some UX feedback here, moving the copy button up looks like it crowds the post address field. So in some cases we'll normally only see our site domain.

The width of the copy button can also change when the text label is updated from copy to copied!, which might be worse in other languages. This is more pronounced when we put this next to the post address field (there's less button padding).

Custom post types can have long names, so we might need to add a more generic label like "add item".

Before:

before.mp4

After:

after.mp4

Custom Post Type:

custom.post.type.mp4

To help move this forward, lets:

  • Drop sentence case changes in this PR (We can still pursue this in a more general follow up discussion). If possible it'd be great if we could avoid magic numbers in CSS styling too.
  • Get additional design feedback, cc maybe @kellychoffman or @jasmussen ?

@@ -91,9 +96,17 @@ class PostPublishPanelPostpublish extends Component {
render() {
const { children, isScheduled, post, postType } = this.props;
const postLabel = get( postType, [ 'labels', 'singular_name' ] );
const viewPostLabel = get( postType, [ 'labels', 'view_item' ] );
const viewPostLabel = ConvertToSentenceCase(
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's drop the sentence case changes here for now.

This is part of a larger discussion, but instead of doing this in JS, I'm thinking we should converge on a standard for sentence case or title case, and update the i18n labels instead.

https://core.trac.wordpress.org/ticket/49616

cc @sixhours @swissspidy or anyone else interested in this.

Copy link
Member

@swissspidy swissspidy Jul 15, 2021

Choose a reason for hiding this comment

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

Agreed. This function should be removed.

This only really works well in English but not necessarily in other languages.

@javierarce
Copy link
Contributor

javierarce commented Jul 16, 2021

+1 to label the button "add item" for custom post types.

The width of the copy button can also change when the text label is updated from copy to copied!, which might be worse in other languages. This is more pronounced when we put this next to the post address field (there's less button padding).

That's a good point, @gwwar… could we solve this problem using a clipboard icon instead of the text? Or maybe just the tick icon when the action is done, like GitHub does when you grab the URL of a repo to clone it.

Kapture 2021-07-16 at 13 15 54

Another idea could be adding a message below the input field, like in the Pattern Directory.

image

@thisissandip
Copy link
Contributor Author

@gwwar I have made the required changes let me know if this looks good! 😄

@gwwar
Copy link
Contributor

gwwar commented Jul 20, 2021

This looks really close!

It's good to use "Add item" for custom post types, but it may be better to stick with named types like "post"/"page" for the built-ins. We'll end up with mixed label usage otherwise with: "View post/Add item"

known cpt
Screen Shot 2021-07-20 at 2 48 46 PM Screen Shot 2021-07-20 at 2 46 36 PM

Besides that, technically this looks fine to me. What's left is a +1 for Design approval ✅

That's a good point, @gwwar… could we solve this problem using a clipboard icon instead of the text?

@javierarce I think something like that could work ✨ Do you think we should leave that exploration for a follow up issue?

: __( 'Copy Link' ) }
</CopyButton>
<Button variant="secondary" href={ addLink }>
{ __( 'Add Item' ) }
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 be coming from the post type labels.

@swissspidy
Copy link
Member

It's good to use "Add item" for custom post types, but it may be better to stick with named types like "post"/"page" for the built-ins.

Why should this be good? Using the correct post type label like was done before da70034 makes more sense.

If you need a new post type label you should just patch it / add it.

@gwwar
Copy link
Contributor

gwwar commented Jul 20, 2021

Using the correct post type label like was done before da70034 makes more sense.

@swissspidy What I mean is the final output text. Eg existing behavior for known post types (using the post type label like before), "View post/Add post" and "View item/Add item" for cpts. I can of course defer to folks if y'all feel strongly, but what can happen is that labels are mismatched in the CPT case with "View item/Add new cpt name"

Screen Shot 2021-07-20 at 3 08 42 PM

@gwwar
Copy link
Contributor

gwwar commented Jul 20, 2021

Oh sorry, @swissspidy is right here with the label usage 👍. I must have some mixed label definitions with the plugin I was testing with.

Beside changing that back, this still needs a design +1

@thisissandip
Copy link
Contributor Author

I have updated the code to use the correct post type label for the Add New button

@javierarce
Copy link
Contributor

Ok, I think this is fine from a design perspective, but I have one final observation: I think we should make the view button the primary action to make the hierarchy of the actions more clear.

image

@javierarce I think something like that could work ✨ Do you think we should leave that exploration for a follow up issue?

@gwwar Yes, I'll create a new issue for that.

@gwwar
Copy link
Contributor

gwwar commented Jul 22, 2021

@javierarce so to confirm the two screens: add an is-primary class when two buttons are present (publishing immediately). Should we also add a primary style when scheduling?

publish immediately scheduled
Screen Shot 2021-07-22 at 9 54 22 AM Screen Shot 2021-07-22 at 9 53 24 AM

@javierarce
Copy link
Contributor

Should we also add a primary style when scheduling?

@gwwar oh, yes, sorry… in that case the "add new" button will be the primary action, so we need to add the class there too.

@thisissandip
Copy link
Contributor Author

I have made the required changes for the primary action buttons.

This is how the post publish panel looks now -

When a post is published:

image

When a post is scheduled:

image

Copy link
Contributor

@gwwar gwwar left a comment

Choose a reason for hiding this comment

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

Tests well for me @thisissandip! I'll leave this open for a day in case others had any other feedback. Will merge next week.

Thanks for the reviews @javierarce @swissspidy

@paaljoachim
Copy link
Contributor

paaljoachim commented Jul 24, 2021

Nice work @thisissandip Sandip! Thank you very much for testing @gwwar Kerry!
I look forward to getting this feature into the Gutenberg plugin!

I am testing on a local dev site of a client site that uses a CPT named Nettmagasin.
If not using a regular WP post or page but a CPT will it show up with "View Item" and "Add New Item" ?

One thing I noticed while reading Joen's comment here:
#32910 (comment)

"While this was titlecase before, we should actually be using sentence case everywhere, so since this PR touches those parts it might be nice to go in and fix that. So "View Post" → "View post", "Add New Post" → "Add new post"
(Go through Joen's comment and see if there is anything else that we missed or changed along the way.)

I noticed the title case is correct here:
#33276 (comment)

That's what I noticed.
Thanks!

@swissspidy
Copy link
Member

If not using a regular WP post or page but a CPT will it show up with "View Item" and "Add New Item" ?

It will show up with whatever label the post types has been registered with.

@gwwar
Copy link
Contributor

gwwar commented Jul 26, 2021

While this was titlecase before, we should actually be using sentence case everywhere, so since this PR touches those parts it might be nice to go in and fix that

If we'd like sentence case for English, this needs to be updated in the post labels themselves and also tested for other UI areas that also use them. Note that sentence case doesn't make sense for some i18n locales. See also: https://core.trac.wordpress.org/ticket/49616

@gwwar
Copy link
Contributor

gwwar commented Jul 26, 2021

Since it looks like there's no major feedback, let's try to land. We can see if there's any additional feedback during the RC and address it in follow up PRs/issues.

@gwwar gwwar merged commit 59530f3 into WordPress:trunk Jul 26, 2021
@github-actions github-actions bot added this to the Gutenberg 11.2 milestone Jul 26, 2021
@simison
Copy link
Member

simison commented Jul 27, 2021

Neat change! I was looking at this and thought same as @gwwar:

Some UX feedback here, moving the copy button up looks like it crowds the post address field. So in some cases we'll normally only see our site domain.

It was the case already previously without copy button — in screenshot below showing the URL isn't helpful at all:

image

As a follow-up, have you considered some other format than input? Few ideas:

  • Omit domain (although it's helpful at re-assuring you posted at the right site)
  • Omit "https" part
  • Don't use input and use link instead, which basically doubles as "view" action and allows removing one button.

Super rough mock, doesn't look great but conveys the idea:

Screenshot 2021-07-27 at 10 00 26

Also worth considering "Post name is now live" text kinda doubles as preview link already?

@talldan talldan added [Feature] Saving Related to saving functionality [Package] Editor /packages/editor [Type] Enhancement A suggestion for improvement. labels Jul 28, 2021
@talldan
Copy link
Contributor

talldan commented Jul 28, 2021

@gwwar @thisissandip Would be greatly appreciated if you could add [Type] and either [Feature] or [Package] labels to PRs—these are used for compiling the changelog and without them it results in a lot of manual work for the individual doing the release. Thanks.

@gwwar
Copy link
Contributor

gwwar commented Jul 28, 2021

Would be greatly appreciated if you could add [Type] and either [Feature] or [Package] labels to PRs

Will do in the future! I forgot to check the labels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Saving Related to saving functionality Good First Review A PR that's suitable for someone looking to contribute for the first time by reviewing code Needs Design Feedback Needs general design feedback. [Package] Editor /packages/editor [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Publish panel: Add a Create "New Page/Post" button at the end of Pre-Publish check panel.
8 participants