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

Enhance/display important dates on search #41301

Merged

Conversation

millerf
Copy link
Contributor

@millerf millerf commented Apr 20, 2020

Changes proposed in this Pull Request

Before After Comment
Screenshot 2020-04-18 at 19 21 32 Screenshot 2020-04-18 at 19 21 17 On listing, scheduled posts/pages now display the right date (scheduled ate)
Screenshot 2020-04-18 at 19 23 56 Screenshot 2020-04-18 at 19 25 06 Published now display "sticky" if needed
Screenshot 2020-04-18 at 19 29 19 Screenshot 2020-04-18 at 19 26 25 Post Search now displays the right status and appropriate date. The "sticky" status has been added. Maybe need some feedback from design?
Screenshot 2020-04-18 at 19 29 05 Screenshot 2020-04-18 at 19 31 03 Pages search now displays only one date and the right status

Based on @sixhours remarks (#41242 (review)), some minor fixes need to be added.

Fixes #41075

@sixhours sixhours added Posts [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Apr 20, 2020
@sixhours sixhours requested a review from a team April 20, 2020 19:16
@millerf
Copy link
Contributor Author

millerf commented Apr 20, 2020

@sixhours

When searching for a scheduled post, the line "Scheduled for Tomorrow at [time]" reads oddly because "tomorrow" is capitalized:
screenshot

That cannot be reproduced on this branch... It shows:
Screenshot 2020-04-20 at 22 44 11
But I think the latter format was better, as it showed the hour.

@sixhours
Copy link
Contributor

I can't reproduce this behavior with this branch, either, but I can on production:

Screen Shot 2020-04-20 at 4 53 20 PM

So maybe we add the post time back, ie. "Scheduled in a day at [time]"?

@millerf
Copy link
Contributor Author

millerf commented Apr 20, 2020

@sixhours I just pushed a fix.

@millerf
Copy link
Contributor Author

millerf commented Apr 21, 2020

I'm not a native English speaker

Me neither... I'll change "on" to "for" right away...

@mmtr
Copy link
Member

mmtr commented Apr 21, 2020

Thanks @millerf for taking this one!

Some quick notes after testing the posts search.

Before (prod) After (this branch)
Screen Shot 2020-04-21 at 11 42 35 Screen Shot 2020-04-21 at 11 42 28
  • Not sure if the comma after "Draft" or "Published" is intended but I think we can drop it.

Screen Shot 2020-04-21 at 11 48 23

Screen Shot 2020-04-21 at 11 48 11

  • Published posts should display the published date rather than the last modified date

Screen Shot 2020-04-21 at 11 49 07

  • Scheduled posts for tomorrow should include the "for" preposition as well.

Screen Shot 2020-04-21 at 11 49 57

  • Posts pending review should display the last modified date, along with the Pending review flag. I think we can consider them as drafts, since they have not been published yet.

Screen Shot 2020-04-21 at 11 52 45

@millerf
Copy link
Contributor Author

millerf commented Apr 21, 2020

Not sure if the comma after "Draft" or "Published" is intended but I think we can drop it.

It is intended, we discussed this here. @sixhours thought it was misleading.

Scheduled posts for tomorrow should include the "for" preposition as well.

Will do

Posts pending review

How do you create those ones? 😅
I remember we talked about it. I should be able blind-fix it anyway...

@mmtr
Copy link
Member

mmtr commented Apr 21, 2020

It is intended, we discussed this here. @sixhours thought it was misleading.

Uhm, I think she was referring specifically to the published post status combined with the last modified date. If we change that to read "Published on [published_date]" as I suggested above, I don't think we need the comma.

How do you create those ones?

By toggling the "Pending review" checkbox on the sidebar panel and saving it as pending:

Screen Shot 2020-04-21 at 12 17 16

client/my-sites/post-relative-time-status/index.jsx Outdated Show resolved Hide resolved
extraStatusClassName = 'is-trash';
statusIcon = 'trash';
const displayedTime = this.getDisplayedTimeForLabel();
statusText = this.props.translate( 'trashed %(displayedTime)s', {
Copy link
Member

Choose a reason for hiding this comment

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

Cannot add more comments to the previous discussion, so I'm copying the comments over here to continue it.

@mmtr #41301 (comment):

@Automattic/i18n or @akirk can confirm, but I think we need to handle both status and date on the same translation. For instance, here displayScheduleTime contains on [date] for posts trashed more than a week ago, so trashed %(displayScheduleTime)s finally reads as trashed on [date]. Some languages might need to move the translated "on" part before "trashed" (while leaving the date after). To support those languages, the translatable string should be trashed on [date] rather than trashed [datePrefixedWithOn].

The same applies for the rest of statuses (scheduled for [date], published on [date], draft last modified on [date], ...).

@millerf #41301 (comment):

This is quite complex to tackle, as the "on" is not always present (for example : "Published yesterday" vs "Published on Mar, 23 march 2020")
And as translation texts cannot have variables to pass on the status, I would have to have to list all cases that could happen.

Also waiting to translators to confirm, but I think the "on" is the beginning of the proposition of time, so it correlates more with the date than the adjective. As in "On 23rd of March, I published, etc,..." But I might be mistaken...

Copy link
Member

Choose a reason for hiding this comment

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

Also waiting to translators to confirm, but I think the "on" is the beginning of the proposition of time, so it correlates more with the date than the adjective

Yeah, let's see if @Automattic/i18n or @akirk can jump in. I might be wrong as well, but languages are so different that I wouldn't assume that prepositions are always part of the date in all of them.

@millerf millerf force-pushed the enhance/display_important_dates_on_search branch from 4d9b98e to 6157493 Compare April 28, 2020 09:03
@akirk
Copy link
Member

akirk commented Apr 28, 2020

I took a look at the screenshots and the code and it seems to me we still have a lot of string concats here which should be avoided. In some languages maybe the date needs to be put at the start of the phrase, this makes it impossible. Also it's hard to know if in a translation the date might depend on the rest of the phrase. Since there are not that many possible states, I'd recommend to just write them out:

  • Trashed on %(specificDate)s (comment: Example: Trashed on March 3)
  • Trashed %(relativeTimeAgo)s (comment: Example: Scheduled 3 days ago)
  • Published on %(specificDate)s (comment: Example: Published on March 3)
  • Published %(relativeTimeAgo)s (comment: Example: Published 3 days ago)
  • Last modified on %(specificDate)s (comment: Example: Last modified on March 3)
  • Last modified %(relativeTimeAgo)s (comment: Example: Last modified 3 days ago)
  • Scheduled %(futureRelativeDateAndTime)s (comment: Example: Scheduled in 3 hours)
  • Scheduled for %(futureSpecificDateAndTime)s (comment: Example: Scheduled for March 3)

Where possible, we should go for a label, like with Pending Review, we should do the same for Private and Draft. So for example:

  • Scheduled in 2 minutes <icon> Pending Review
  • Scheduled for August 3 10:00 <icon> Private <icon> Sticky
  • Last modified 3 days ago <icon> Draft <icon> Private
  • Last modified on January 1 <icon> Draft <icon> Private
  • Last modified on January 1 <icon> Pending Review
  • Published 3 days ago <icon> Private <icon> Sticky
  • Published on January 1 <icon> Private <icon> Sticky
  • Trashed 3 days ago <icon> Private <icon> Sticky
  • Trashed on January 1 <icon> Private <icon> Sticky

Using a clock instead of "Last modified" and then the plain specific date or relative date is also an option. But it should only be used for "Last modified" and that date should only be displayed when the post is in the draft stage (resp. pending review).

@mmtr
Copy link
Member

mmtr commented Apr 28, 2020

Where possible, we should go for a label, like with Pending Review, we should do the same for Private and Draft.

Not sure we need a Draft label. It is a status like trashed, published or scheduled. In fact, the last modified date will be only displayed on drafts, which is why we suggested to display posts in this state as Draft last modified on [date]/Draft last modified [relativeTimeAgo].

@millerf
Copy link
Contributor Author

millerf commented Apr 28, 2020

Also it's hard to know if in a translation the date might depend on the rest of the phrase

Following our discussion about the right place of the [on], please consider those examples:

Scheduled in 2 minutes
Scheduled for August 3 10:00
Published on January 1

[in], [for] and [on] have the exact same syntaxic/grammatical function. So if we had to move [on] to the "published" translation block following your logic, we should also move [for] and [in] (although the last one is directly translated from the moment library, so it might be difficult).

I'll prepare the code for that anyway, but I think we really need some translator to help out here before doing anything 😄

@akirk
Copy link
Member

akirk commented Apr 28, 2020

[in], [for] and [on] have the exact same syntaxic/grammatical function.

In English. You cannot make this assumption for other languages, some languages don't have prepositions. I only know a few but I can well see cases where a relative time needs to come at the beginning of a sentence, while an absolute time needs to be at the end. This is why we should not split sentences and join them through concat.

Copy link
Member

@mmtr mmtr left a comment

Choose a reason for hiding this comment

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

Thanks again for the latest update, @millerf! I tried to test all the different combinations and it works great overall. I've found two issues, but only one of them is blocking. Please, see below.

⚠️ Published
Private posts are flagged twice now: with a prefix in the title and with a status label. Fine to address this in a follow-up.

Posts Pages
Screen Shot 2020-04-29 at 11 31 00 Screen Shot 2020-04-29 at 11 23 13

✅Drafts

Posts Pages
Screen Shot 2020-04-29 at 11 31 08 Screen Shot 2020-04-29 at 11 23 23

✅Scheduled

Posts Pages
Screen Shot 2020-04-29 at 11 31 14 Screen Shot 2020-04-29 at 11 23 30

✅Trashed

Posts Pages
Screen Shot 2020-04-29 at 11 31 19 Screen Shot 2020-04-29 at 11 23 36

❌Search
Published date is not displayed for private posts. We'd need to fix this before merging.

Posts Pages
Screen Shot 2020-04-29 at 11 31 32 Screen Shot 2020-04-29 at 11 23 49

} );
}
return this.props.translate( 'trashed %(displayedTime)s', {
comment: '%(displayedTime)s is when a post or page was trashed',
Copy link
Member

Choose a reason for hiding this comment

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

Given absolute/relative dates need to be at a different place for some languages, translators will need to know if this date is relative or absolute. Could you add some extra info in the comments so they can know that we use an absolute date in trashed on/published on/scheduled for/last modified on [date] and a relative date in trashed/published/last modified [date]?

@millerf
Copy link
Contributor Author

millerf commented Apr 29, 2020

@mmtr Thanks a lot for the deep testing. Yesterday I didn't quite finish what I wanted to do, to it is still work-in-progress. Sorry I forgot to mention it!

But anyway, I found something interesting:

Private posts are flagged twice now: with a prefix in the title and with a status label. Fine to address this in a follow-up.

I didn't have any private post (I was testing with pages), so I didn't see it.
It turns out it is coming from the back-end. They prefix the post title with "private: " when searching.

Request URL: https://public-api.wordpress.com/rest/v1.1/sites/174604573/posts?http_envelope=1&author=&number=20&order=DESC&search=&status=publish%2Cprivate&type=post&page=1

Screenshot 2020-04-29 at 18 03 44

@millerf
Copy link
Contributor Author

millerf commented Apr 29, 2020

Published date is not displayed for private posts. We'd need to fix this before merging.

Fixed

@millerf
Copy link
Contributor Author

millerf commented Apr 29, 2020

I found another bug on wordpress.com that I will fix now:
You can click on a trashed page, and it sends you to a 404... Posts cannot be clicked when trashed.

Or is it because my site hasn't been launched yet? I am a bit confused...

Screenshot 2020-04-29 at 18 33 00

@kwight
Copy link
Contributor

kwight commented Apr 29, 2020

You can click on a trashed page, and it sends you to a 404... Posts cannot be clicked when trashed.

Well spotted @millerf , definitely a bug: #41640

Copy link
Member

@mmtr mmtr 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 working on this, @millerf! Experience is much more consistent now ❤️. Didn't find any regression so let's merge this after addressing the couple of very minor comments below.

client/my-sites/post-relative-time-status/index.jsx Outdated Show resolved Hide resolved
client/my-sites/post-relative-time-status/index.jsx Outdated Show resolved Hide resolved
@mmtr
Copy link
Member

mmtr commented Apr 30, 2020

It turns out it is coming from the back-end. They prefix the post title with "private: " when searching.

Nice catch! I'll file an issue so we can fix that server-side once this lands.

millerf and others added 2 commits April 30, 2020 12:03
Co-Authored-By: Miguel Torres <miguelmariatorresrojas@gmail.com>
Co-Authored-By: Miguel Torres <miguelmariatorresrojas@gmail.com>
@millerf
Copy link
Contributor Author

millerf commented Apr 30, 2020

@mmtr I commited your suggestions, I think this can be landed safely now

@mmtr mmtr merged commit ace3c71 into Automattic:master Apr 30, 2020
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Apr 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display only most important date when listing posts or pages
8 participants