Skip to content

Commit

Permalink
Merge pull request #738 from alleyinteractive/hotfix/APPLE-36/section…
Browse files Browse the repository at this point in the history
…s-by-category-default-fix

APPLE-36: sections by category default fix
  • Loading branch information
kevinfodness authored Jun 23, 2020
2 parents 96c01fc + aa5d65b commit 306cefa
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 65 deletions.
2 changes: 1 addition & 1 deletion apple-news.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* Plugin Name: Publish to Apple News
* Plugin URI: http://github.com/alleyinteractive/apple-news
* Description: Export and sync posts to Apple format.
* Version: 2.0.6
* Version: 2.0.7
* Author: Alley
* Author URI: https://alley.co
* Text Domain: apple-news
Expand Down
65 changes: 37 additions & 28 deletions assets/js/pluginsidebar/components/sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,14 @@ class Sidebar extends React.PureComponent {
} = {},
} = this.props;

const parsedSelectedSections = safeJsonParseArray(selectedSections) || [];

apiFetch({ path })
.then((settings) => this.setState({
autoAssignCategories: 'null' === selectedSections
autoAssignCategories: (
null === parsedSelectedSections
|| 0 === parsedSelectedSections.length
)
&& true === settings.automaticAssignment,
settings,
}))
Expand Down Expand Up @@ -554,7 +559,7 @@ class Sidebar extends React.PureComponent {
dismissNotification={this.dismissNotification}
notifications={notifications}
/>
<h3>Sections</h3>
<h3>{__('Sections', 'apple-news')}</h3>
{automaticAssignment && [
<CheckboxControl
label={__('Assign sections by category', 'apple-news')}
Expand Down Expand Up @@ -586,32 +591,36 @@ class Sidebar extends React.PureComponent {
/>,
<hr />,
]}
{(! autoAssignCategories || ! automaticAssignment) && [
<h4>Manual Section Selection</h4>,
Array.isArray(sections) && (
<ul className="apple-news-sections">
{sections.map(({ id, name }) => (
<li key={id}>
<CheckboxControl
label={name}
checked={- 1 !== selectedSectionsArray.indexOf(id)}
onChange={
(checked) => this.updateSelectedSections(checked, id)
}
/>
</li>
))}
</ul>
),
]}
<p>
<em>
{
// eslint-disable-next-line max-len
__('Select the sections in which to publish this article. If none are selected, it will be published to the default section.', 'apple-news')
}
</em>
</p>
{(! autoAssignCategories || ! automaticAssignment) && (
sections && 0 < sections.length && (
<>
<h4>Manual Section Selection</h4>
{Array.isArray(sections) && (
<ul className="apple-news-sections">
{sections.map(({ id, name }) => (
<li key={id}>
<CheckboxControl
label={name}
checked={- 1 !== selectedSectionsArray.indexOf(id)}
onChange={
(checked) => this.updateSelectedSections(checked, id) // eslint-disable-line max-len
}
/>
</li>
))}
</ul>
)}
<p>
<em>
{
// eslint-disable-next-line max-len
__('Select the sections in which to publish this article. If none are selected, it will be published to the default section.', 'apple-news')
}
</em>
</p>
</>
)
)}
<h3>{__('Paid Article', 'apple-news')}</h3>
<CheckboxControl
// eslint-disable-next-line max-len
Expand Down
2 changes: 1 addition & 1 deletion includes/class-apple-news.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Apple_News {
* @var string
* @access public
*/
public static $version = '2.0.6';
public static $version = '2.0.7';

/**
* Link to support for the plugin on WordPress.org.
Expand Down
49 changes: 16 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "publish-to-apple-news",
"version": "2.0.6",
"version": "2.0.7",
"license": "GPLv3",
"main": "index.php",
"engines": {
Expand Down
6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tags: publish, apple, news, iOS
Requires at least: 4.0
Tested up to: 5.4.0
Requires PHP: 5.6
Stable tag: 2.0.6
Stable tag: 2.0.7
License: GPLv3 or later
License URI: https://www.gnu.org/licenses/gpl.html

Expand Down Expand Up @@ -46,6 +46,10 @@ Please visit our [wiki](https://github.com/alleyinteractive/apple-news/wiki) for

== Changelog ==

= 2.0.7 =
* Fixes a bug where sections by category is not checked by default for new posts.
* Fixes visual bug when manual section selection are visible.

= 2.0.6 =
* Bugfix: Rolled back support for Button elements for now due to a problematic implementation.

Expand Down

0 comments on commit 306cefa

Please sign in to comment.