@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
79 lines (68 loc) • 2.26 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PublishButtonLabel = PublishButtonLabel;
exports.default = void 0;
var _lodash = require("lodash");
var _i18n = require("@wordpress/i18n");
var _compose = require("@wordpress/compose");
var _data = require("@wordpress/data");
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
function PublishButtonLabel({
isPublished,
isBeingScheduled,
isSaving,
isPublishing,
hasPublishAction,
isAutosaving,
hasNonPostEntityChanges
}) {
if (isPublishing) {
/* translators: button label text should, if possible, be under 16 characters. */
return (0, _i18n.__)('Publishing…');
} else if (isPublished && isSaving && !isAutosaving) {
/* translators: button label text should, if possible, be under 16 characters. */
return (0, _i18n.__)('Updating…');
} else if (isBeingScheduled && isSaving && !isAutosaving) {
/* translators: button label text should, if possible, be under 16 characters. */
return (0, _i18n.__)('Scheduling…');
}
if (!hasPublishAction) {
return hasNonPostEntityChanges ? (0, _i18n.__)('Submit for Review…') : (0, _i18n.__)('Submit for Review');
} else if (isPublished) {
return hasNonPostEntityChanges ? (0, _i18n.__)('Update…') : (0, _i18n.__)('Update');
} else if (isBeingScheduled) {
return hasNonPostEntityChanges ? (0, _i18n.__)('Schedule…') : (0, _i18n.__)('Schedule');
}
return (0, _i18n.__)('Publish');
}
var _default = (0, _compose.compose)([(0, _data.withSelect)((select, {
forceIsSaving
}) => {
const {
isCurrentPostPublished,
isEditedPostBeingScheduled,
isSavingPost,
isPublishingPost,
getCurrentPost,
getCurrentPostType,
isAutosavingPost
} = select('core/editor');
return {
isPublished: isCurrentPostPublished(),
isBeingScheduled: isEditedPostBeingScheduled(),
isSaving: forceIsSaving || isSavingPost(),
isPublishing: isPublishingPost(),
hasPublishAction: (0, _lodash.get)(getCurrentPost(), ['_links', 'wp:action-publish'], false),
postType: getCurrentPostType(),
isAutosaving: isAutosavingPost()
};
})])(PublishButtonLabel);
exports.default = _default;
//# sourceMappingURL=label.js.map