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

Date: Mark getSettings as experimental #10636

Merged
merged 7 commits into from
Oct 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/reference/deprecated.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Gutenberg's deprecation policy is intended to support backwards-compatibility for releases, when possible. The current deprecations are listed below and are grouped by _the version at which they will be removed completely_. If your plugin depends on these behaviors, you must update to the recommended alternative before the noted version.

# 4.4.0
- `wp.date.getSettings` has been removed. Please use `wp.date.__experimentalGetSettings` instead.

# 4.3.0

- `isEditorSidebarPanelOpened` selector (`core/edit-post`) has been removed. Please use `isEditorPanelEnabled` instead.
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/latest-posts/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
Toolbar,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { dateI18n, format, getSettings } from '@wordpress/date';
import { dateI18n, format, __experimentalGetSettings } from '@wordpress/date';
import { decodeEntities } from '@wordpress/html-entities';
import {
InspectorControls,
Expand Down Expand Up @@ -116,7 +116,7 @@ class LatestPostsEdit extends Component {
},
];

const dateFormat = getSettings().formats.date;
const dateFormat = __experimentalGetSettings().formats.date;

return (
<Fragment>
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/date-time/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ Render a DateTimePicker.

```jsx
import { DateTimePicker } from '@wordpress/components';
import { getSettings } from '@wordpress/date';
import { __experimentalGetSettings } from '@wordpress/date';
import { withState } from '@wordpress/compose';

const MyDateTimePicker = withState( {
date: new Date(),
} )( ( { date, setState } ) => {
const settings = getSettings();
const settings = __experimentalGetSettings();

// To know if the current timezone is a 12 hour time with look for an "a" in the time format.
// We also make sure this a is not escaped by a "/".
Expand Down
6 changes: 6 additions & 0 deletions packages/date/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 2.2.0 (unreleased)

### Breaking Change

- Marked getSettings as experimental

## 2.1.0 (2018-09-26)

### New Features
Expand Down
16 changes: 16 additions & 0 deletions packages/date/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import momentLib from 'moment';
import 'moment-timezone';
import 'moment-timezone/moment-timezone-utils';

/**
* WordPress dependencies
*/
import deprecated from '@wordpress/deprecated';

// Changes made here will likely need to be made in `lib/client-assets.php` as
// well because it uses the `setSettings()` function to change these settings.
let settings = {
Expand Down Expand Up @@ -85,7 +90,18 @@ export function setSettings( dateSettings ) {
*
* @return {Object} Settings, including locale data.
*/
export function __experimentalGetSettings() {
return settings;
}

// deprecations
export function getSettings() {
deprecated( 'wp.date.getSettings', {
version: '4.4',
alternative: 'wp.date.__experimentalGetSettings',
ajitbohra marked this conversation as resolved.
Show resolved Hide resolved
plugin: 'Gutenberg',
hint: 'Unstable APIs are strongly discouraged to be used, and are subject to removal without notice.',
} );
return settings;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/editor/src/components/post-schedule/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
* WordPress dependencies
*/
import { getSettings } from '@wordpress/date';
import { __experimentalGetSettings } from '@wordpress/date';
import { withSelect, withDispatch } from '@wordpress/data';
import { compose } from '@wordpress/compose';
import { DateTimePicker } from '@wordpress/components';

export function PostSchedule( { date, onUpdateDate } ) {
const settings = getSettings();
const settings = __experimentalGetSettings();
// To know if the current timezone is a 12 hour time with look for "a" in the time format
// We also make sure this a is not escaped by a "/"
const is12HourTime = /a(?!\\)/i.test(
Expand Down
4 changes: 2 additions & 2 deletions packages/editor/src/components/post-schedule/label.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { dateI18n, getSettings } from '@wordpress/date';
import { dateI18n, __experimentalGetSettings } from '@wordpress/date';
import { withSelect } from '@wordpress/data';

export function PostScheduleLabel( { date, isFloating } ) {
const settings = getSettings();
const settings = __experimentalGetSettings();

return date && ! isFloating ?
dateI18n( settings.formats.datetimeAbbreviated, date ) :
Expand Down