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

Site Settings: add date time format sub-page #11259

Merged
merged 28 commits into from
Mar 14, 2017

Conversation

Copons
Copy link
Contributor

@Copons Copons commented Feb 8, 2017

See relevant discussion at #10441 (specifically this comment and the following).

Add a General Settings sub-page for Date Format, Time Format, Week Starts On, and possibly even Timezone.
The actual code handling the settings is being developed in #10400, and will be ported over here after its merge.

Screenshots

https://cldup.com/tTOywjzlEJ-2000x2000.png
https://cldup.com/MkK2NnUToR-3000x3000.png

GIF

https://cldup.com/RGKE4SdU-0.gif

@Copons Copons added [Feature] Site Settings All other general site settings. [Status] In Progress labels Feb 8, 2017
@Copons Copons added this to the Feature Parity Audit: wp-admin milestone Feb 8, 2017
@matticbot
Copy link
Contributor


return (
<div className="main main-column date-time-format" role="main">
<DocumentHead title={ translate( 'Manage Date and Time Format Configurations' ) } />
Copy link

@a8ci18n a8ci18n Feb 8, 2017

Choose a reason for hiding this comment

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

Hi! I've found a possible matching string that has already been translated 52 times:
translate( 'Date and time format:' ) ES Score: 13.14
See 1 additional suggestion in the PR translation status page

Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).

Copy link
Contributor

Choose a reason for hiding this comment

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

Hrm, this comment should have been for the string below, line 26. (different case)

Copy link
Contributor Author

@Copons Copons Feb 8, 2017

Choose a reason for hiding this comment

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

@yoavf I guess you're here for the wrong comment, but please don't waste your time on this PR already, since it's still very WIP.
I'll likely move things around a bit in the next commits, and I'm sure when I'll get some design feedback the translation strings will change too.

Maybe it could make sense to limit the i18n bot to needs review PRs only?
(I'd say to "needs i18n review" only, but I know us devs, we always forget about that label 🙂 )

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense, but I still find it useful to audit every pr for now, to make sure everything works as expected. Once we're more confident we'll probably activate on "needs review".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yup, I meant that, not "ready to merge". :)

href={ `/settings/date-time-format/${ site.slug }` }
>
<h2 className="site-settings__date-time-format-title">
{ translate( 'Date and time format configuration' ) }
Copy link

Choose a reason for hiding this comment

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

Hi! I've found a possible matching string that has already been translated 52 times:
translate( 'Date and time format:' ) ES Score: 6.74
See 1 additional suggestion in the PR translation status page

Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).

@Copons Copons force-pushed the add/site-settings/date-format-sub-page branch 2 times, most recently from 6d3b1e6 to 817c2b8 Compare February 14, 2017 14:08
@Copons Copons added [Status] Needs Copy Review Add this when you'd like to get a review / feedback from the Editorial team on your PR [Status] Needs Design Review Add this when you'd like to get a review / feedback from the Design team on your PR [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Type] Enhancement and removed [Status] In Progress labels Feb 14, 2017
@kristastevens
Copy link

Hello! Here are a few items that need love, based on copy review -- thanks for the ping!

  • Timezone should be two words. It appears twice -- Once in the subtitle, "Site Timezone" again in the microcopy, "Choose a city in your timezone." S/b time zone.
  • Date and Time Format Configuration > Both format and configuration aren't needed here. Suggest: "Date and Time Format"
  • Week Starts On Monday" > The caps can be removed: "Week starts on Monday"
  • "You can also modify the interface language in your profile." A little more personal to say, "You can also modify your interface's language in your profile."
  • "Documentation on date and time formatting" > I'd make it more friendly by saying, "Learn more about date and time formatting."

@Copons
Copy link
Contributor Author

Copons commented Feb 14, 2017

Thanks @kristastevens!
I'll see to update the copy on the date/time/week format parts and pass along the suggestion regarding the time zone to the team working on it! :)

(Then cue to i18n wrath for so many new translation strings 😄 )

Copons added a commit that referenced this pull request Feb 16, 2017
<div className="site-settings__date-time-format-info">
{ date_format ? today.format( phpToMomentDatetimeFormat( date_format ) ) : '' } &bull;&nbsp;
{ time_format ? today.format( phpToMomentDatetimeFormat( time_format ) ) : '' } &bull;&nbsp;
{ translate( 'Week starts on' ) } { start_of_week ? daysOfWeek[ start_of_week ] : daysOfWeek[ 0 ] }
Copy link

@a8ci18n a8ci18n Feb 16, 2017

Choose a reason for hiding this comment

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

Hi! I've found a possible matching string that has already been translated 88 times:
translate( 'Week Starts On' ) ES Score: 13.93

Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).

</span>
<FormSettingExplanation>
<ExternalLink href="https://codex.wordpress.org/Formatting_Date_and_Time" icon>
{ translate( 'Learn more about date and time formatting.' ) }
Copy link

Choose a reason for hiding this comment

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

Hi! I've found a possible matching string that has already been translated 5 times:
translate( 'Documentation on date and time formatting.' ) ES Score: 6.55

Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).

@Copons
Copy link
Contributor Author

Copons commented Feb 16, 2017

@yoavf about the latest commit, please refer to #11259 (comment) for the reason.
I have no strong opinions regarding capitalization, so it's pretty much a fight between better copy vs. less translation strings. :)

@yoavf
Copy link
Contributor

yoavf commented Feb 16, 2017

@Copons sure, better copy is obviously important. I have some ideas about processes we could set up to copy all existing translations when a string with a different case is added (we already do this right now when we change a string - but it doesn't happen if the changed string also exists elsewhere).

I'll take a look at some of the changes here: when possible (=not a core string), I'll apply the changes to the other instances too, so we don't have duplication.

Edit: see (internal) r151058-wpcom for an example.

export class DateTimeFormatOptions extends Component {
dateFormatOption() {
const {
fields: { date_format, timezone_string },
Copy link
Contributor

Choose a reason for hiding this comment

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

What if you destructured these to camelCase names?

{ date_format: dateFormat, timezone_string: timezoneString }

</span>
</span>
<FormSettingExplanation>
<ExternalLink href="https://codex.wordpress.org/Formatting_Date_and_Time" icon>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can ExternalLink open in a new tab/window? I think that'd be good for this link.

/>
<FormSettingExplanation>
{ isCustomFormat && dateFormat
? translate( 'Preview: %s', {
Copy link

@a8ci18n a8ci18n Feb 17, 2017

Choose a reason for hiding this comment

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

Hi! I've found a possible matching string that has already been translated 67 times:
translate( 'Preview %s' ) ES Score: 18

Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).

.site-settings__date-time-format-custom-preview {
white-space: nowrap;
.site-settings__date-time-format-info {
color: $gray;
Copy link
Contributor

Choose a reason for hiding this comment

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

Change this to $gray-text-min so that it's dark enough!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!
I've also replaced $gray-dark with $gray-text as, while they are the same color, it makes more sense to me to use -text for a text color.

@davewhitley
Copy link
Contributor

Other than my one comment, I think the design is good to go.

@davewhitley davewhitley removed the [Status] Needs Design Review Add this when you'd like to get a review / feedback from the Design team on your PR label Feb 17, 2017
@Copons Copons force-pushed the add/site-settings/date-format-sub-page branch from ab9e54f to a9c601b Compare February 20, 2017 13:59
<div className="site-settings__date-time-format-info">
{ dateFormat ? now.format( phpToMomentDatetimeFormat( dateFormat ) ) : '' } &bull;&nbsp;
{ timeFormat ? now.format( phpToMomentDatetimeFormat( timeFormat ) ) : '' } &bull;&nbsp;
{ translate( 'Week starts on' ) } { startOfWeek
Copy link

Choose a reason for hiding this comment

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

Hi! I've found a possible matching string that has already been translated 88 times:
translate( 'Week Starts On' ) ES Score: 14

Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).

@Copons
Copy link
Contributor Author

Copons commented Mar 7, 2017

@dmsnell I've renamed all those nows with localizedDate for consistency with an already established naming convention (see:

const getLocalizedDate = ( date, tz, gmt ) => {
).

Just FYI, I didn't reuse that function because I would have needed an even more complicated function to handle timezone strings and UTC offset hours-minutes conversions.

/>
<FormSettingExplanation>
{ isCustom && timeFormat
? translate( 'Preview: %s', {
Copy link

Choose a reason for hiding this comment

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

Hi! I've found a possible matching string that has already been translated 67 times:
translate( 'Preview %s' ) ES Score: 18

Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).

? localizedDate.format( phpToMomentDatetimeFormat( timeFormat ) )
: ''
} &bull;&nbsp;
{ translate( 'Week starts on' ) } { startOfWeek
Copy link

Choose a reason for hiding this comment

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

Hi! I've found a possible matching string that has already been translated 88 times:
translate( 'Week Starts On' ) ES Score: 14

Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).

{ translate( 'Date Format' ) }
</FormLabel>
{ defaultDateFormats.map( ( format, index ) =>
<FormLabel key={ index }>
Copy link
Member

Choose a reason for hiding this comment

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

danger, React key as loop index!

args: localizedDate.format( phpToMomentDatetimeFormat( dateFormat ) ),
comment: 'Date/time format preview',
} )
: ''
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused at the ternary here. Is the goal only to output a string when isCustom && dateFormat? If so, we can just just another &&

{ isCustom && dateFormat && translate(
	'Preview: %s',
	{
		args: ,
		comment: ,
	}
) }

primary={ true }
type="submit"
disabled={ isRequestingSettings || isSavingSettings }>
{ isSavingSettings
Copy link
Member

Choose a reason for hiding this comment

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

small nitpick: this confused me here (also a big reason I prefer to keep the > on the next line) because of the indentation. could we move that closing > into alignment with <Button?

<Button
	compact={ true }
	
>
	{ isSavingSettings
		? 
		: 
	}
</Button>

start_of_week: settings.start_of_week,
time_format: settings.time_format,
timezone_string: settings.timezone_string,
};
Copy link
Member

Choose a reason for hiding this comment

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

fun fact! we can use object assignment to provide defaults. I'm not sure if you want the default switch to be "either use all of the defaults or use none of them" but if you want to instead say "use any of the defaults if their corresponding value isn't set" then we can do this:

const settings = {
	...defaultSettings,
	...customSettings,
};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The thing here is that I don't need all the settings (there are currently 64 settings, some of them are arrays of objects), so I'd need at least a lodash.pick( ... ) anyway.

Then, the assumption is that, if settings exist, it's already populated server-side.
defaultSettings is pretty much there only for the first uncached load, and that's why it returns early and doesn't let the function proceed to the gmt_offset logic.

So while I'd love to spread here, I'd say it would result in more code (and conditionals) for no real readability improvements.

value={ startOfWeek || 0 }
>
{ moment.weekdays().map( ( day, index ) =>
<option key={ index } value={ index }>
Copy link
Member

@dmsnell dmsnell Mar 7, 2017

Choose a reason for hiding this comment

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

it's no more difficult to just use day as the key here but it's much more reliable and semantic

{ translate( 'Time Format' ) }
</FormLabel>
{ defaultTimeFormats.map( ( format, index ) =>
<FormLabel key={ index }>
Copy link
Member

Choose a reason for hiding this comment

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

danger, React key as loop index!

args: localizedDate.format( phpToMomentDatetimeFormat( timeFormat ) ),
comment: 'Date/time format preview'
} )
: ''
Copy link
Member

Choose a reason for hiding this comment

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

see my note above on the ternary

{ dateFormat
? localizedDate.format( phpToMomentDatetimeFormat( dateFormat ) )
: ''
} &bull;&nbsp;
Copy link
Member

Choose a reason for hiding this comment

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

I'm calling your bull on this one…

} &bull;&nbsp;
{ timeFormat
? localizedDate.format( phpToMomentDatetimeFormat( timeFormat ) )
: ''
Copy link
Member

Choose a reason for hiding this comment

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

hrm…was this spitting out false as a string without the ternary…?

@dmsnell
Copy link
Member

dmsnell commented Mar 7, 2017

@Copons really coming together with this. I'm a big fan of the idea to follow-up with the token input for date fields - that's so much better of a UI than needing to know date format identifiers.

- Remove numeric `key={ index }`.
- Remove unnecessary ternaries.
- Use `lodash.pick()` to pick site settings.
- Fix an i18n error on “Week starts on”.
@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Mar 7, 2017
/>
<FormSettingExplanation>
{ isCustom && timeFormat &&
translate( 'Preview: %s', {
Copy link

Choose a reason for hiding this comment

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

Hi! I've found a possible matching string that has already been translated 67 times:
translate( 'Preview %s' ) ES Score: 18

Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).

} ) =>
<FormFieldset>
<FormLabel>
{ translate( 'Week starts on' ) }
Copy link

Choose a reason for hiding this comment

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

Hi! I've found a possible matching string that has already been translated 88 times:
translate( 'Week Starts On' ) ES Score: 14

Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).

start_of_week: 0,
time_format: '',
timezone_string: '',
};
Copy link
Member

Choose a reason for hiding this comment

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

if these are always constant then we might consider moving them into the module-global scope

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. That whole part was basically brought over form-general.jsx (which yes, could use a brush up).

@Copons
Copy link
Contributor Author

Copons commented Mar 7, 2017

@dmsnell Moved defaultSettings away from wrapSettingsForm and into the module constants.

/>
<FormSettingExplanation>
{ isCustom && timeFormat &&
translate( 'Preview: %s', {
Copy link

Choose a reason for hiding this comment

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

Hi! I've found a possible matching string that has already been translated 67 times:
translate( 'Preview %s' ) ES Score: 18

Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).

} ) =>
<FormFieldset>
<FormLabel>
{ translate( 'Week starts on' ) }
Copy link

Choose a reason for hiding this comment

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

Hi! I've found a possible matching string that has already been translated 88 times:
translate( 'Week Starts On' ) ES Score: 14

Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).

@Copons Copons merged commit 657c487 into master Mar 14, 2017
@Copons Copons deleted the add/site-settings/date-format-sub-page branch March 14, 2017 11:54
@Copons Copons removed [Status] Needs Copy Review Add this when you'd like to get a review / feedback from the Editorial team on your PR [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Mar 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Site Settings All other general site settings. [Size] XL Probably needs to be broken down into multiple smaller issues [Type] Enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants