@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
53 lines (49 loc) • 1.67 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = PostSyncStatus;
var _data = require("@wordpress/data");
var _i18n = require("@wordpress/i18n");
var _postPanelRow = _interopRequireDefault(require("../post-panel-row"));
var _store = require("../../store");
var _jsxRuntime = require("react/jsx-runtime");
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* Renders the sync status of a post.
*
* @return {JSX.Element|null} The rendered sync status component.
*/function PostSyncStatus() {
const {
syncStatus,
postType
} = (0, _data.useSelect)(select => {
const {
getEditedPostAttribute
} = select(_store.store);
const meta = getEditedPostAttribute('meta');
// When the post is first created, the top level wp_pattern_sync_status is not set so get meta value instead.
const currentSyncStatus = meta?.wp_pattern_sync_status === 'unsynced' ? 'unsynced' : getEditedPostAttribute('wp_pattern_sync_status');
return {
syncStatus: currentSyncStatus,
postType: getEditedPostAttribute('type')
};
});
if (postType !== 'wp_block') {
return null;
}
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_postPanelRow.default, {
label: (0, _i18n.__)('Sync status'),
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
className: "editor-post-sync-status__value",
children: syncStatus === 'unsynced' ? (0, _i18n._x)('Not synced', 'pattern (singular)') : (0, _i18n._x)('Synced', 'pattern (singular)')
})
});
}
//# sourceMappingURL=index.js.map