UNPKG

@wordpress/editor

Version:
61 lines (57 loc) 1.93 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _i18n = require("@wordpress/i18n"); var _components = require("@wordpress/components"); var _data = require("@wordpress/data"); var _store = require("../../store"); var _jsxRuntime = require("react/jsx-runtime"); /** * WordPress dependencies */ /** * Internal dependencies */ const COMMENT_OPTIONS = [{ label: (0, _i18n._x)('Open', 'Adjective: e.g. "Comments are open"'), value: 'open', description: (0, _i18n.__)('Visitors can add new comments and replies.') }, { label: (0, _i18n.__)('Closed'), value: 'closed', description: [(0, _i18n.__)('Visitors cannot add new comments or replies.'), (0, _i18n.__)('Existing comments remain visible.')].join(' ') }]; function PostComments() { const commentStatus = (0, _data.useSelect)(select => { var _select$getEditedPost; return (_select$getEditedPost = select(_store.store).getEditedPostAttribute('comment_status')) !== null && _select$getEditedPost !== void 0 ? _select$getEditedPost : 'open'; }, []); const { editPost } = (0, _data.useDispatch)(_store.store); const handleStatus = newCommentStatus => editPost({ comment_status: newCommentStatus }); return /*#__PURE__*/(0, _jsxRuntime.jsx)("form", { children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalVStack, { spacing: 4, children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.RadioControl, { className: "editor-change-status__options", hideLabelFromVision: true, label: (0, _i18n.__)('Comment status'), options: COMMENT_OPTIONS, onChange: handleStatus, selected: commentStatus }) }) }); } /** * A form for managing comment status. * * @return {JSX.Element} The rendered PostComments component. */ var _default = exports.default = PostComments; //# sourceMappingURL=index.js.map