Skip to content

Commit

Permalink
Merge pull request #636 from publishpress/release-3.1.6
Browse files Browse the repository at this point in the history
Release 3.1.6
  • Loading branch information
andergmartins authored Dec 20, 2023
2 parents 2f51578 + 205927f commit 12b8352
Show file tree
Hide file tree
Showing 54 changed files with 617 additions and 440 deletions.
10 changes: 10 additions & 0 deletions assets/css/edit.css
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,13 @@ div.pe-qe-fields > div {
text-align: center;
width: 30px;
}

.post-expirator-panel .future-action-warning {
line-height: 20px;
width: 100%;
}

.post-expirator-panel .future-action-warning .components-base-control__field > div {
padding: 14px;
background: #dae1f0;
}
2 changes: 1 addition & 1 deletion assets/js/block-editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/block-editor.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/bulk-edit.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/bulk-edit.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/classic-editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/classic-editor.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/quick-edit.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/quick-edit.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/settings-post-types.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/settings-post-types.js.map

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions assets/jsx/block-editor.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { createStore } from './data';
import { FutureActionPanelBlockEditor } from './components';
import { select } from '@wp/data';
import { registerPlugin } from '@wp/plugins';
import { select } from '&wp.data';
import { registerPlugin } from '&wp.plugins';
import {
actionsSelectOptions,
is12Hour,
timeFormat,
startOfWeek,
strings,
taxonomyName,
postTypeDefaultConfig,
defaultDate
} from "@config/block-editor";
} from "&config.block-editor";

const storeName = 'publishpress-future/future-action';

Expand All @@ -32,6 +33,7 @@ const BlockEditorFutureActionPlugin = () => {
isCleanNewPost={select('core/editor').isCleanNewPost()}
actionsSelectOptions={actionsSelectOptions}
is12Hour={is12Hour}
timeFormat={timeFormat}
startOfWeek={startOfWeek}
storeName={storeName}
strings={strings}
Expand Down
51 changes: 30 additions & 21 deletions assets/jsx/bulk-edit.jsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import { FutureActionPanelBulkEdit } from './components';
import { createStore } from './data';
import { createRoot } from '@wp/element';
import { select, dispatch } from '@wp/data';
import { inlineEditPost } from "@window";
import { createRoot } from '&wp.element';
import { select, dispatch } from '&wp.data';
import { inlineEditPost } from "&window";
import {
postTypeDefaultConfig,
defaultDate,
postType,
isNewPost,
actionsSelectOptions,
is12Hour,
timeFormat,
startOfWeek,
strings,
taxonomyName,
nonce
} from "@config/bulk-edit";
} from "&config.bulk-edit";
import { render } from "&ReactDOM";

const storeName = 'publishpress-future/future-action-bulk-edit';
const delayToUnmountAfterSaving = 1000;
Expand Down Expand Up @@ -64,36 +66,43 @@ inlineEditPost.setBulk = function (id) {
});
}

const saveButton = document.querySelector('#bulk_edit');
if (saveButton) {
saveButton.onclick = function() {
setTimeout(() => {
root.unmount();
}, delayToUnmountAfterSaving);
};
}

const container = document.getElementById("publishpress-future-bulk-edit");
const root = createRoot(container);

root.render(
const component = (
<FutureActionPanelBulkEdit
storeName={storeName}
postType={postType}
isNewPost={isNewPost}
actionsSelectOptions={actionsSelectOptions}
is12Hour={is12Hour}
timeFormat={timeFormat}
startOfWeek={startOfWeek}
strings={strings}
taxonomyName={taxonomyName}
nonce={nonce}
/>
);

inlineEditPost.revert = function () {
root.unmount();
if (createRoot) {
const root = createRoot(container);

root.render(component);

// Call the original WP revert function.
wpInlineEditRevert.apply(this, arguments);
};
const saveButton = document.querySelector('#bulk_edit');
if (saveButton) {
saveButton.onclick = function() {
setTimeout(() => {
root.unmount();
}, delayToUnmountAfterSaving);
};
}

inlineEditPost.revert = function () {
root.unmount();

// Call the original WP revert function.
wpInlineEditRevert.apply(this, arguments);
};
} else {
render(component, container);
}
};
19 changes: 13 additions & 6 deletions assets/jsx/classic-editor.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import { FutureActionPanelClassicEditor } from './components';
import { createStore } from './data';
import { isGutenbergEnabled } from './utils';
import { createRoot } from '@wp/element';
import { select } from '@wp/data';
import { createRoot } from '&wp.element';
import { select } from '&wp.data';
import {
postType,
isNewPost,
actionsSelectOptions,
is12Hour,
timeFormat,
startOfWeek,
strings,
taxonomyName,
postTypeDefaultConfig,
defaultDate
} from "@config/classic-editor";
} from "&config.classic-editor";
import { render } from "&ReactDOM";

if (! isGutenbergEnabled()) {
const storeName = 'publishpress-future/future-action';
Expand All @@ -32,18 +34,23 @@ if (! isGutenbergEnabled()) {
}

const container = document.getElementById("publishpress-future-classic-editor");
const root = createRoot(container);

root.render(
const component = (
<FutureActionPanelClassicEditor
storeName={storeName}
postType={postType}
isNewPost={isNewPost}
actionsSelectOptions={actionsSelectOptions}
is12Hour={is12Hour}
timeFormat={timeFormat}
startOfWeek={startOfWeek}
strings={strings}
taxonomyName={taxonomyName}
/>
);

if (createRoot) {
createRoot(container).render(component);
} else {
render(component, container);
}
}
5 changes: 2 additions & 3 deletions assets/jsx/components/CheckboxControl.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/*
* Copyright (c) 2023. PublishPress, All rights reserved.
*/
import { Fragment, useState } from "&wp.element";
import { CheckboxControl as WPCheckboxControl } from "&wp.components";

export const CheckboxControl = function (props) {
const { Fragment, useState } = wp.element;
const WPCheckboxControl = wp.components.CheckboxControl;

const [checked, setChecked] = useState(props.checked || false);

let description;
Expand Down
4 changes: 2 additions & 2 deletions assets/jsx/components/DateTimePicker.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { normalizeUnixTimeToMilliseconds } from "../time";
import { DateTimePicker as WPDateTimePicker } from "&wp.components";

export const DateTimePicker = ({currentDate, onChange, is12Hour, startOfWeek}) => {
const WPDateTimePicker = wp.components.DateTimePicker;

export const DateTimePicker = ({currentDate, onChange, is12Hour, startOfWeek}) => {
if (typeof currentDate === 'number') {
currentDate = normalizeUnixTimeToMilliseconds(currentDate);
}
Expand Down
90 changes: 42 additions & 48 deletions assets/jsx/components/FutureActionPanel.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { compact } from '../utils';
import { ToggleCalendarDatePicker } from './ToggleCalendarDatePicker';

const { PanelRow, CheckboxControl, SelectControl, FormTokenField, Spinner, BaseControl, Container } = wp.components;
const { Fragment, useEffect, useState } = wp.element;
const { PanelRow, CheckboxControl, SelectControl, FormTokenField, Spinner, BaseControl } = wp.components;
const { Fragment, useEffect } = wp.element;
const { decodeEntities } = wp.htmlEntities;
const { addQueryArgs } = wp.url;
const {
Expand Down Expand Up @@ -118,46 +118,19 @@ export const FutureActionPanel = (props) => {

setIsFetchingTerms(true);

if ((!taxonomy && props.postType === 'post') || taxonomy === 'category') {
apiFetch({
path: addQueryArgs('wp/v2/categories', { per_page: -1 }),
}).then((list) => {
list.forEach(cat => {
termsListByName[cat.name] = cat;
termsListById[cat.id] = cat.name;
});

setTermsListByName(termsListByName);
setTermsListById(termsListById);
setTaxonomyName(props.strings.category);
setIsFetchingTerms(false);
apiFetch({
path: addQueryArgs(`publishpress-future/v1/terms/${taxonomy}`),
}).then((result) => {
result.terms.forEach(term => {
termsListByName[decodeEntities(term.name)] = term;
termsListById[term.id] = decodeEntities(term.name);
});
} else {
apiFetch({
path: addQueryArgs(`publishpress-future/v1/taxonomies/` + props.postType),
}).then((response) => {
if (parseInt(response.count) > 0) {
apiFetch({
path: addQueryArgs(`wp/v2/taxonomies/${taxonomy}`, { context: 'edit', per_page: -1 }),
}).then((taxonomyAttributes) => {
// fetch all terms
apiFetch({
path: addQueryArgs(`wp/v2/${taxonomyAttributes.rest_base}`, { context: 'edit', per_page: -1 }),
}).then((terms) => {
terms.forEach(term => {
termsListByName[decodeEntities(term.name)] = term;
termsListById[term.id] = decodeEntities(term.name);
});

setTermsListByName(termsListByName);
setTermsListById(termsListById);
setTaxonomyName(decodeEntities(taxonomyAttributes.name));
setIsFetchingTerms(false);
});
});
}
});
}

setTermsListByName(termsListByName);
setTermsListById(termsListById);
setTaxonomyName(decodeEntities(result.taxonomyName));
setIsFetchingTerms(false);
});
}

const storeCalendarIsVisibleOnStorage = (value) => {
Expand Down Expand Up @@ -219,6 +192,13 @@ export const FutureActionPanel = (props) => {
const contentPanelClass = calendarIsVisible ? 'future-action-panel-content' : 'future-action-panel-content hidden-calendar';
const datePanelClass = calendarIsVisible ? 'future-action-date-panel' : 'future-action-date-panel hidden-calendar';

let is24hour;
if (props.timeFormat === 'inherited') {
is24hour = ! props.is12Hour;
} else {
is24hour = props.timeFormat === '24h';
}


const replaceCurlyBracketsWithLink = (string, href, target) => {
const parts = string.split('{');
Expand All @@ -239,6 +219,14 @@ export const FutureActionPanel = (props) => {
return result;
};

// Remove items from actions list if related to taxonomies and there is no taxonmoy for the post type
let actionsSelectOptions = props.actionsSelectOptions;
if (! props.taxonomy) {
actionsSelectOptions = props.actionsSelectOptions.filter((item) => {
return ['category', 'category-add', 'category-remove'].indexOf(item.value) === -1;
});
}

const HelpText = replaceCurlyBracketsWithLink(props.strings.timezoneSettingsHelp, '/wp-admin/options-general.php#timezone_string', '_blank');

return (
Expand All @@ -263,7 +251,7 @@ export const FutureActionPanel = (props) => {
<SelectControl
label={props.strings.action}
value={action}
options={props.actionsSelectOptions}
options={actionsSelectOptions}
onChange={handleActionChange}
/>
</PanelRow>
Expand All @@ -280,16 +268,20 @@ export const FutureActionPanel = (props) => {
)
|| (!taxonomy && (
<PanelRow>
<BaseControl label={taxonomyName}>
<i className="dashicons dashicons-warning"></i> {props.strings.noTaxonomyFound}
<BaseControl label={taxonomyName} className="future-action-warning">
<div>
<i className="dashicons dashicons-warning"></i> {props.strings.noTaxonomyFound}
</div>
</BaseControl>
</PanelRow>
)
|| (
termsListByNameKeys.length === 0 && (
<PanelRow>
<BaseControl label={taxonomyName}>
<i className="dashicons dashicons-warning"></i> {props.strings.noTermsFound}
<BaseControl label={taxonomyName} className="future-action-warning">
<div>
<i className="dashicons dashicons-warning"></i> {props.strings.noTermsFound}
</div>
</BaseControl>
</PanelRow>
)
Expand All @@ -301,7 +293,9 @@ export const FutureActionPanel = (props) => {
value={selectedTerms}
suggestions={termsListByNameKeys}
onChange={handleTermsChange}
maxSuggestions={10}
maxSuggestions={1000}
__experimentalExpandOnFocus={true}
__experimentalAutoSelectFirstMatch={true}
/>
</BaseControl>
</PanelRow>
Expand All @@ -316,7 +310,7 @@ export const FutureActionPanel = (props) => {
currentDate={date}
onChangeDate={handleDateChange}
onToggleCalendar={() => setCalendarIsVisible(!calendarIsVisible)}
is12Hour={props.is12Hour}
is12Hour={!is24hour}
startOfWeek={props.startOfWeek}
isExpanded={calendarIsVisible}
strings={props.strings}
Expand Down
1 change: 1 addition & 0 deletions assets/jsx/components/FutureActionPanelBlockEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const FutureActionPanelBlockEditor = (props) => {
taxonomyName={props.taxonomyName}
onChangeData={onChangeData}
is12Hour={props.is12Hour}
timeFormat={props.timeFormat}
startOfWeek={props.startOfWeek}
storeName={props.storeName}
strings={props.strings} />
Expand Down
1 change: 1 addition & 0 deletions assets/jsx/components/FutureActionPanelBulkEdit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const FutureActionPanelBulkEdit = (props) => {
taxonomyName={props.taxonomyName}
onChangeData={onChangeData}
is12Hour={props.is12Hour}
timeFormat={props.timeFormat}
startOfWeek={props.startOfWeek}
storeName={props.storeName}
strings={props.strings} />
Expand Down
3 changes: 2 additions & 1 deletion assets/jsx/components/FutureActionPanelClassicEditor.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FutureActionPanel } from "./";
import { select } from "&wp.data";

export const FutureActionPanelClassicEditor = (props) => {
const { select } = wp.data;
const browserTimezoneOffset = new Date().getTimezoneOffset();

const getElementByName = (name) => {
Expand Down Expand Up @@ -42,6 +42,7 @@ export const FutureActionPanelClassicEditor = (props) => {
taxonomyName={props.taxonomyName}
onChangeData={onChangeData}
is12Hour={props.is12Hour}
timeFormat={props.timeFormat}
startOfWeek={props.startOfWeek}
storeName={props.storeName}
strings={props.strings} />
Expand Down
Loading

0 comments on commit 12b8352

Please sign in to comment.