@wordpress/editor 14.19.0 → 14.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/commands/index.js +1 -1
- package/build/components/commands/index.js.map +1 -1
- package/build/components/document-bar/index.js +3 -2
- package/build/components/document-bar/index.js.map +1 -1
- package/build/components/document-outline/index.js +21 -1
- package/build/components/document-outline/index.js.map +1 -1
- package/build/components/document-outline/item.js +32 -20
- package/build/components/document-outline/item.js.map +1 -1
- package/build/components/entities-saved-states/entity-record-item.js +2 -2
- package/build/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build/components/post-actions/actions.js +10 -8
- package/build/components/post-actions/actions.js.map +1 -1
- package/build/components/post-card-panel/index.js +3 -3
- package/build/components/post-card-panel/index.js.map +1 -1
- package/build/components/post-publish-panel/maybe-category-panel.js +19 -3
- package/build/components/post-publish-panel/maybe-category-panel.js.map +1 -1
- package/build/components/post-publish-panel/maybe-tags-panel.js +16 -6
- package/build/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
- package/build/components/post-status/index.js +1 -1
- package/build/components/post-status/index.js.map +1 -1
- package/build/components/post-sticky/index.js +1 -1
- package/build/components/post-sticky/index.js.map +1 -1
- package/build/components/post-template/hooks.js +6 -5
- package/build/components/post-template/hooks.js.map +1 -1
- package/build/components/post-template/swap-template-button.js +2 -3
- package/build/components/post-template/swap-template-button.js.map +1 -1
- package/build/components/post-visibility/index.js +39 -109
- package/build/components/post-visibility/index.js.map +1 -1
- package/build/components/post-visibility/label.js +2 -2
- package/build/components/post-visibility/label.js.map +1 -1
- package/build/components/post-visibility/utils.js +14 -15
- package/build/components/post-visibility/utils.js.map +1 -1
- package/build/components/provider/index.js +7 -4
- package/build/components/provider/index.js.map +1 -1
- package/build/store/private-selectors.js +1 -1
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/selectors.js +8 -7
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/commands/index.js +1 -1
- package/build-module/components/commands/index.js.map +1 -1
- package/build-module/components/document-bar/index.js +3 -2
- package/build-module/components/document-bar/index.js.map +1 -1
- package/build-module/components/document-outline/index.js +21 -1
- package/build-module/components/document-outline/index.js.map +1 -1
- package/build-module/components/document-outline/item.js +32 -20
- package/build-module/components/document-outline/item.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-record-item.js +2 -2
- package/build-module/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build-module/components/post-actions/actions.js +10 -8
- package/build-module/components/post-actions/actions.js.map +1 -1
- package/build-module/components/post-card-panel/index.js +3 -3
- package/build-module/components/post-card-panel/index.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-category-panel.js +19 -3
- package/build-module/components/post-publish-panel/maybe-category-panel.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-tags-panel.js +16 -6
- package/build-module/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
- package/build-module/components/post-status/index.js +1 -1
- package/build-module/components/post-status/index.js.map +1 -1
- package/build-module/components/post-sticky/index.js +1 -1
- package/build-module/components/post-sticky/index.js.map +1 -1
- package/build-module/components/post-template/hooks.js +6 -5
- package/build-module/components/post-template/hooks.js.map +1 -1
- package/build-module/components/post-template/swap-template-button.js +2 -3
- package/build-module/components/post-template/swap-template-button.js.map +1 -1
- package/build-module/components/post-visibility/index.js +41 -111
- package/build-module/components/post-visibility/index.js.map +1 -1
- package/build-module/components/post-visibility/label.js +3 -3
- package/build-module/components/post-visibility/label.js.map +1 -1
- package/build-module/components/post-visibility/utils.js +13 -14
- package/build-module/components/post-visibility/utils.js.map +1 -1
- package/build-module/components/provider/index.js +7 -4
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/store/private-selectors.js +1 -1
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/selectors.js +8 -7
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +4 -138
- package/build-style/style.css +4 -138
- package/build-types/components/document-outline/index.d.ts.map +1 -1
- package/build-types/components/document-outline/item.d.ts +2 -1
- package/build-types/components/document-outline/item.d.ts.map +1 -1
- package/build-types/components/entities-saved-states/entity-record-item.d.ts.map +1 -1
- package/build-types/components/post-actions/actions.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/maybe-category-panel.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/maybe-tags-panel.d.ts.map +1 -1
- package/build-types/components/post-template/hooks.d.ts.map +1 -1
- package/build-types/components/post-template/swap-template-button.d.ts +1 -1
- package/build-types/components/post-template/swap-template-button.d.ts.map +1 -1
- package/build-types/components/post-visibility/index.d.ts.map +1 -1
- package/build-types/components/post-visibility/label.d.ts.map +1 -1
- package/build-types/components/post-visibility/utils.d.ts +5 -20
- package/build-types/components/post-visibility/utils.d.ts.map +1 -1
- package/build-types/components/provider/index.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/build-types/store/selectors.d.ts.map +1 -1
- package/package.json +37 -37
- package/src/components/autocompleters/style.scss +2 -3
- package/src/components/commands/index.js +1 -1
- package/src/components/document-bar/index.js +2 -2
- package/src/components/document-outline/index.js +27 -1
- package/src/components/document-outline/item.js +38 -23
- package/src/components/document-outline/style.scss +2 -0
- package/src/components/entities-saved-states/entity-record-item.js +1 -4
- package/src/components/post-actions/actions.js +13 -8
- package/src/components/post-card-panel/index.js +2 -2
- package/src/components/post-publish-panel/maybe-category-panel.js +20 -5
- package/src/components/post-publish-panel/maybe-tags-panel.js +39 -22
- package/src/components/post-status/index.js +1 -1
- package/src/components/post-sticky/index.js +1 -1
- package/src/components/post-template/hooks.js +12 -8
- package/src/components/post-template/swap-template-button.js +6 -4
- package/src/components/post-visibility/index.js +41 -118
- package/src/components/post-visibility/label.js +7 -4
- package/src/components/post-visibility/utils.js +11 -8
- package/src/components/provider/index.js +9 -4
- package/src/store/private-selectors.js +2 -4
- package/src/store/selectors.js +9 -14
- package/src/style.scss +0 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/src/components/post-visibility/style.scss +0 -27
|
@@ -31,7 +31,8 @@ const TagsPanel = () => {
|
|
|
31
31
|
};
|
|
32
32
|
const MaybeTagsPanel = () => {
|
|
33
33
|
const {
|
|
34
|
-
|
|
34
|
+
postHasTags,
|
|
35
|
+
siteHasTags,
|
|
35
36
|
isPostTypeSupported
|
|
36
37
|
} = useSelect(select => {
|
|
37
38
|
const postType = select(editorStore).getCurrentPostType();
|
|
@@ -39,13 +40,22 @@ const MaybeTagsPanel = () => {
|
|
|
39
40
|
const _isPostTypeSupported = tagsTaxonomy?.types?.includes(postType);
|
|
40
41
|
const areTagsFetched = tagsTaxonomy !== undefined;
|
|
41
42
|
const tags = tagsTaxonomy && select(editorStore).getEditedPostAttribute(tagsTaxonomy.rest_base);
|
|
43
|
+
const siteTags = _isPostTypeSupported ? !!select(coreStore).getEntityRecords('taxonomy', 'post_tag', {
|
|
44
|
+
per_page: 1
|
|
45
|
+
})?.length : false;
|
|
42
46
|
return {
|
|
43
|
-
|
|
47
|
+
postHasTags: !!tags?.length,
|
|
48
|
+
siteHasTags: siteTags,
|
|
44
49
|
isPostTypeSupported: areTagsFetched && _isPostTypeSupported
|
|
45
50
|
};
|
|
46
51
|
}, []);
|
|
47
|
-
const [hadTagsWhenOpeningThePanel] = useState(
|
|
48
|
-
|
|
52
|
+
const [hadTagsWhenOpeningThePanel] = useState(postHasTags);
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* We only want to show the tag panel if the post type supports
|
|
56
|
+
* tags and the site has tags.
|
|
57
|
+
*/
|
|
58
|
+
if (!isPostTypeSupported || !siteHasTags) {
|
|
49
59
|
return null;
|
|
50
60
|
}
|
|
51
61
|
|
|
@@ -53,9 +63,9 @@ const MaybeTagsPanel = () => {
|
|
|
53
63
|
* We only want to show the tag panel if the post didn't have
|
|
54
64
|
* any tags when the user hit the Publish button.
|
|
55
65
|
*
|
|
56
|
-
* We can't use the prop.
|
|
66
|
+
* We can't use the prop.postHasTags because it'll change to true
|
|
57
67
|
* if the user adds a new tag within the pre-publish panel.
|
|
58
|
-
* This would force a re-render and a new prop.
|
|
68
|
+
* This would force a re-render and a new prop.postHasTags check,
|
|
59
69
|
* hiding this panel and keeping the user from adding
|
|
60
70
|
* more than one tag.
|
|
61
71
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","useState","useSelect","PanelBody","store","coreStore","FlatTermSelector","editorStore","jsx","_jsx","jsxs","_jsxs","TagsPanel","panelBodyTitle","className","children","initialOpen","title","slug","__nextHasNoMarginBottom","MaybeTagsPanel","
|
|
1
|
+
{"version":3,"names":["__","useState","useSelect","PanelBody","store","coreStore","FlatTermSelector","editorStore","jsx","_jsx","jsxs","_jsxs","TagsPanel","panelBodyTitle","className","children","initialOpen","title","slug","__nextHasNoMarginBottom","MaybeTagsPanel","postHasTags","siteHasTags","isPostTypeSupported","select","postType","getCurrentPostType","tagsTaxonomy","getEntityRecord","_isPostTypeSupported","types","includes","areTagsFetched","undefined","tags","getEditedPostAttribute","rest_base","siteTags","getEntityRecords","per_page","length","hadTagsWhenOpeningThePanel"],"sources":["@wordpress/editor/src/components/post-publish-panel/maybe-tags-panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { PanelBody } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport FlatTermSelector from '../post-taxonomies/flat-term-selector';\nimport { store as editorStore } from '../../store';\n\nconst TagsPanel = () => {\n\tconst panelBodyTitle = [\n\t\t__( 'Suggestion:' ),\n\t\t<span className=\"editor-post-publish-panel__link\" key=\"label\">\n\t\t\t{ __( 'Add tags' ) }\n\t\t</span>,\n\t];\n\n\treturn (\n\t\t<PanelBody initialOpen={ false } title={ panelBodyTitle }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'Tags help users and search engines navigate your site and find your content. Add a few keywords to describe your post.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<FlatTermSelector slug=\"post_tag\" __nextHasNoMarginBottom />\n\t\t</PanelBody>\n\t);\n};\n\nconst MaybeTagsPanel = () => {\n\tconst { postHasTags, siteHasTags, isPostTypeSupported } = useSelect(\n\t\t( select ) => {\n\t\t\tconst postType = select( editorStore ).getCurrentPostType();\n\t\t\tconst tagsTaxonomy = select( coreStore ).getEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'taxonomy',\n\t\t\t\t'post_tag'\n\t\t\t);\n\t\t\tconst _isPostTypeSupported =\n\t\t\t\ttagsTaxonomy?.types?.includes( postType );\n\t\t\tconst areTagsFetched = tagsTaxonomy !== undefined;\n\t\t\tconst tags =\n\t\t\t\ttagsTaxonomy &&\n\t\t\t\tselect( editorStore ).getEditedPostAttribute(\n\t\t\t\t\ttagsTaxonomy.rest_base\n\t\t\t\t);\n\t\t\tconst siteTags = _isPostTypeSupported\n\t\t\t\t? !! select( coreStore ).getEntityRecords(\n\t\t\t\t\t\t'taxonomy',\n\t\t\t\t\t\t'post_tag',\n\t\t\t\t\t\t{ per_page: 1 }\n\t\t\t\t )?.length\n\t\t\t\t: false;\n\n\t\t\treturn {\n\t\t\t\tpostHasTags: !! tags?.length,\n\t\t\t\tsiteHasTags: siteTags,\n\t\t\t\tisPostTypeSupported: areTagsFetched && _isPostTypeSupported,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst [ hadTagsWhenOpeningThePanel ] = useState( postHasTags );\n\n\t/**\n\t * We only want to show the tag panel if the post type supports\n\t * tags and the site has tags.\n\t */\n\tif ( ! isPostTypeSupported || ! siteHasTags ) {\n\t\treturn null;\n\t}\n\n\t/*\n\t * We only want to show the tag panel if the post didn't have\n\t * any tags when the user hit the Publish button.\n\t *\n\t * We can't use the prop.postHasTags because it'll change to true\n\t * if the user adds a new tag within the pre-publish panel.\n\t * This would force a re-render and a new prop.postHasTags check,\n\t * hiding this panel and keeping the user from adding\n\t * more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uB,eAAe,CACvD,MAAM,EACN,UAAU,EACV,UACD,CAAC;IACD,MAAMC,oBAAoB,GACzBF,YAAY,EAAEG,KAAK,EAAEC,QAAQ,CAAEN,QAAS,CAAC;IAC1C,MAAMO,cAAc,GAAGL,YAAY,KAAKM,SAAS;IACjD,MAAMC,IAAI,GACTP,YAAY,IACZH,MAAM,CAAEjB,WAAY,CAAC,CAAC4B,sBAAsB,CAC3CR,YAAY,CAACS,SACd,CAAC;IACF,MAAMC,QAAQ,GAAGR,oBAAoB,GAClC,CAAC,CAAEL,MAAM,CAAEnB,SAAU,CAAC,CAACiC,gBAAgB,CACvC,UAAU,EACV,UAAU,EACV;MAAEC,QAAQ,EAAE;IAAE,CACd,CAAC,EAAEC,MAAM,GACT,KAAK;IAER,OAAO;MACNnB,WAAW,EAAE,CAAC,CAAEa,IAAI,EAAEM,MAAM;MAC5BlB,WAAW,EAAEe,QAAQ;MACrBd,mBAAmB,EAAES,cAAc,IAAIH;IACxC,CAAC;EACF,CAAC,EACD,EACD,CAAC;EACD,MAAM,CAAEY,0BAA0B,CAAE,GAAGxC,QAAQ,CAAEoB,WAAY,CAAC;;EAE9D;AACD;AACA;AACA;EACC,IAAK,CAAEE,mBAAmB,IAAI,CAAED,WAAW,EAAG;IAC7C,OAAO,IAAI;EACZ;;EAEA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,IAAK,CAAEmB,0BAA0B,EAAG;IACnC,oBAAOhC,IAAA,CAACG,SAAS,IAAE,CAAC;EACrB;EAEA,OAAO,IAAI;AACZ,CAAC;AAED,eAAeQ,cAAc","ignoreList":[]}
|
|
@@ -198,7 +198,7 @@ export default function PostStatus() {
|
|
|
198
198
|
children: [/*#__PURE__*/_jsx(CheckboxControl, {
|
|
199
199
|
__nextHasNoMarginBottom: true,
|
|
200
200
|
label: __('Password protected'),
|
|
201
|
-
help: __('Only visible to those who know the password'),
|
|
201
|
+
help: __('Only visible to those who know the password.'),
|
|
202
202
|
checked: showPassword,
|
|
203
203
|
onChange: handleTogglePassword
|
|
204
204
|
}), showPassword && /*#__PURE__*/_jsx("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Button","CheckboxControl","Dropdown","__experimentalVStack","VStack","TextControl","RadioControl","__","sprintf","useDispatch","useSelect","useState","useMemo","store","coreStore","__experimentalInspectorPopoverHeader","InspectorPopoverHeader","useInstanceId","drafts","published","scheduled","pending","notAllowed","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","PATTERN_POST_TYPE","NAVIGATION_POST_TYPE","PostPanelRow","PostSticky","PrivatePostSchedule","editorStore","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","postStatusesInfo","label","icon","draft","private","future","publish","STATUS_OPTIONS","value","description","DESIGN_POST_TYPES","PostStatus","status","date","password","postId","postType","canEdit","select","_getCurrentPost$_link","getEditedPostAttribute","getCurrentPostId","getCurrentPostType","getCurrentPost","_links","showPassword","setShowPassword","passwordInputId","editEntityRecord","popoverAnchor","setPopoverAnchor","popoverProps","anchor","headerTitle","placement","offset","shift","includes","updatePost","newStatus","newPassword","newDate","handleTogglePassword","handleStatus","Date","ref","children","className","contentClassName","focusOnMount","renderToggle","onToggle","isOpen","variant","size","onClick","renderContent","onClose","title","spacing","hideLabelFromVision","options","onChange","selected","showPopoverHeaderActions","isCompact","as","__nextHasNoMarginBottom","help","checked","placeholder","type","id","__next40pxDefaultSize","maxLength"],"sources":["@wordpress/editor/src/components/post-status/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tCheckboxControl,\n\tDropdown,\n\t__experimentalVStack as VStack,\n\tTextControl,\n\tRadioControl,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { useInstanceId } from '@wordpress/compose';\nimport {\n\tdrafts,\n\tpublished,\n\tscheduled,\n\tpending,\n\tnotAllowed,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tPATTERN_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n} from '../../store/constants';\nimport PostPanelRow from '../post-panel-row';\nimport PostSticky from '../post-sticky';\nimport { PrivatePostSchedule } from '../post-schedule';\nimport { store as editorStore } from '../../store';\n\nconst postStatusesInfo = {\n\t'auto-draft': { label: __( 'Draft' ), icon: drafts },\n\tdraft: { label: __( 'Draft' ), icon: drafts },\n\tpending: { label: __( 'Pending' ), icon: pending },\n\tprivate: { label: __( 'Private' ), icon: notAllowed },\n\tfuture: { label: __( 'Scheduled' ), icon: scheduled },\n\tpublish: { label: __( 'Published' ), icon: published },\n};\n\nexport const STATUS_OPTIONS = [\n\t{\n\t\tlabel: __( 'Draft' ),\n\t\tvalue: 'draft',\n\t\tdescription: __( 'Not ready to publish.' ),\n\t},\n\t{\n\t\tlabel: __( 'Pending' ),\n\t\tvalue: 'pending',\n\t\tdescription: __( 'Waiting for review before publishing.' ),\n\t},\n\t{\n\t\tlabel: __( 'Private' ),\n\t\tvalue: 'private',\n\t\tdescription: __( 'Only visible to site admins and editors.' ),\n\t},\n\t{\n\t\tlabel: __( 'Scheduled' ),\n\t\tvalue: 'future',\n\t\tdescription: __( 'Publish automatically on a chosen date.' ),\n\t},\n\t{\n\t\tlabel: __( 'Published' ),\n\t\tvalue: 'publish',\n\t\tdescription: __( 'Visible to everyone.' ),\n\t},\n];\n\nconst DESIGN_POST_TYPES = [\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tPATTERN_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n];\n\nexport default function PostStatus() {\n\tconst { status, date, password, postId, postType, canEdit } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEditedPostAttribute,\n\t\t\t\tgetCurrentPostId,\n\t\t\t\tgetCurrentPostType,\n\t\t\t\tgetCurrentPost,\n\t\t\t} = select( editorStore );\n\t\t\treturn {\n\t\t\t\tstatus: getEditedPostAttribute( 'status' ),\n\t\t\t\tdate: getEditedPostAttribute( 'date' ),\n\t\t\t\tpassword: getEditedPostAttribute( 'password' ),\n\t\t\t\tpostId: getCurrentPostId(),\n\t\t\t\tpostType: getCurrentPostType(),\n\t\t\t\tcanEdit:\n\t\t\t\t\tgetCurrentPost()._links?.[ 'wp:action-publish' ] ?? false,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst [ showPassword, setShowPassword ] = useState( !! password );\n\tconst passwordInputId = useInstanceId(\n\t\tPostStatus,\n\t\t'editor-change-status__password-input'\n\t);\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\t'aria-label': __( 'Status & visibility' ),\n\t\t\theaderTitle: __( 'Status & visibility' ),\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor ]\n\t);\n\n\tif ( DESIGN_POST_TYPES.includes( postType ) ) {\n\t\treturn null;\n\t}\n\n\tconst updatePost = ( {\n\t\tstatus: newStatus = status,\n\t\tpassword: newPassword = password,\n\t\tdate: newDate = date,\n\t} ) => {\n\t\teditEntityRecord( 'postType', postType, postId, {\n\t\t\tstatus: newStatus,\n\t\t\tdate: newDate,\n\t\t\tpassword: newPassword,\n\t\t} );\n\t};\n\n\tconst handleTogglePassword = ( value ) => {\n\t\tsetShowPassword( value );\n\t\tif ( ! value ) {\n\t\t\tupdatePost( { password: '' } );\n\t\t}\n\t};\n\n\tconst handleStatus = ( value ) => {\n\t\tlet newDate = date;\n\t\tlet newPassword = password;\n\t\tif ( status === 'future' && new Date( date ) > new Date() ) {\n\t\t\tnewDate = null;\n\t\t}\n\t\tif ( value === 'private' && password ) {\n\t\t\tnewPassword = '';\n\t\t}\n\t\tupdatePost( {\n\t\t\tstatus: value,\n\t\t\tdate: newDate,\n\t\t\tpassword: newPassword,\n\t\t} );\n\t};\n\n\treturn (\n\t\t<PostPanelRow label={ __( 'Status' ) } ref={ setPopoverAnchor }>\n\t\t\t{ canEdit ? (\n\t\t\t\t<Dropdown\n\t\t\t\t\tclassName=\"editor-post-status\"\n\t\t\t\t\tcontentClassName=\"editor-change-status__content\"\n\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\tfocusOnMount\n\t\t\t\t\trenderToggle={ ( { onToggle, isOpen } ) => (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName=\"editor-post-status__toggle\"\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\ticon={ postStatusesInfo[ status ]?.icon }\n\t\t\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Current post status.\n\t\t\t\t\t\t\t\t__( 'Change status: %s' ),\n\t\t\t\t\t\t\t\tpostStatusesInfo[ status ]?.label\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ postStatusesInfo[ status ]?.label }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<InspectorPopoverHeader\n\t\t\t\t\t\t\t\ttitle={ __( 'Status & visibility' ) }\n\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<form>\n\t\t\t\t\t\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t\t\t\t\t\t<RadioControl\n\t\t\t\t\t\t\t\t\t\tclassName=\"editor-change-status__options\"\n\t\t\t\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Status' ) }\n\t\t\t\t\t\t\t\t\t\toptions={ STATUS_OPTIONS }\n\t\t\t\t\t\t\t\t\t\tonChange={ handleStatus }\n\t\t\t\t\t\t\t\t\t\tselected={\n\t\t\t\t\t\t\t\t\t\t\tstatus === 'auto-draft'\n\t\t\t\t\t\t\t\t\t\t\t\t? 'draft'\n\t\t\t\t\t\t\t\t\t\t\t\t: status\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t{ status === 'future' && (\n\t\t\t\t\t\t\t\t\t\t<div className=\"editor-change-status__publish-date-wrapper\">\n\t\t\t\t\t\t\t\t\t\t\t<PrivatePostSchedule\n\t\t\t\t\t\t\t\t\t\t\t\tshowPopoverHeaderActions={\n\t\t\t\t\t\t\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tisCompact\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ status !== 'private' && (\n\t\t\t\t\t\t\t\t\t\t<VStack\n\t\t\t\t\t\t\t\t\t\t\tas=\"fieldset\"\n\t\t\t\t\t\t\t\t\t\t\tspacing={ 4 }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"editor-change-status__password-fieldset\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'Password protected'\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'Only visible to those who know the password'\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\tchecked={ showPassword }\n\t\t\t\t\t\t\t\t\t\t\t\tonChange={\n\t\t\t\t\t\t\t\t\t\t\t\t\thandleTogglePassword\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t{ showPassword && (\n\t\t\t\t\t\t\t\t\t\t\t\t<div className=\"editor-change-status__password-input\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Password'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tupdatePost( {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpassword: value,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tvalue={ password }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tplaceholder={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Use a secure password'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid={ passwordInputId }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmaxLength={ 255 }\n\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</VStack>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t<PostSticky />\n\t\t\t\t\t\t\t\t</VStack>\n\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t) : (\n\t\t\t\t<div className=\"editor-post-status is-read-only\">\n\t\t\t\t\t{ postStatusesInfo[ status ]?.label }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</PostPanelRow>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,MAAM,EACNC,eAAe,EACfC,QAAQ,EACRC,oBAAoB,IAAIC,MAAM,EAC9BC,WAAW,EACXC,YAAY,QACN,uBAAuB;AAC9B,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,QAAQ,EAAEC,OAAO,QAAQ,oBAAoB;AACtD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,oCAAoC,IAAIC,sBAAsB,QAAQ,yBAAyB;AACxG,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SACCC,MAAM,EACNC,SAAS,EACTC,SAAS,EACTC,OAAO,EACPC,UAAU,QACJ,kBAAkB;;AAEzB;AACA;AACA;AACA,SACCC,kBAAkB,EAClBC,uBAAuB,EACvBC,iBAAiB,EACjBC,oBAAoB,QACd,uBAAuB;AAC9B,OAAOC,YAAY,MAAM,mBAAmB;AAC5C,OAAOC,UAAU,MAAM,gBAAgB;AACvC,SAASC,mBAAmB,QAAQ,kBAAkB;AACtD,SAAShB,KAAK,IAAIiB,WAAW,QAAQ,aAA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AS,EAAG;gBAAK,CACjB;cAAC,CACE,CACL;YAAA,CACM,CACR,eACD/E,IAAA,CAACJ,UAAU,IAAE,CAAC;UAAA,CACP;QAAC,CACJ,CAAC;MAAA,CACN;IACA,CACH,CAAC,gBAEFI,IAAA;MAAKoD,SAAS,EAAC,iCAAiC;MAAAD,QAAA,EAC7C9C,gBAAgB,CAAEY,MAAM,CAAE,EAAEX;IAAK,CAC/B;EACL,CACY,CAAC;AAEjB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Button","CheckboxControl","Dropdown","__experimentalVStack","VStack","TextControl","RadioControl","__","sprintf","useDispatch","useSelect","useState","useMemo","store","coreStore","__experimentalInspectorPopoverHeader","InspectorPopoverHeader","useInstanceId","drafts","published","scheduled","pending","notAllowed","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","PATTERN_POST_TYPE","NAVIGATION_POST_TYPE","PostPanelRow","PostSticky","PrivatePostSchedule","editorStore","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","postStatusesInfo","label","icon","draft","private","future","publish","STATUS_OPTIONS","value","description","DESIGN_POST_TYPES","PostStatus","status","date","password","postId","postType","canEdit","select","_getCurrentPost$_link","getEditedPostAttribute","getCurrentPostId","getCurrentPostType","getCurrentPost","_links","showPassword","setShowPassword","passwordInputId","editEntityRecord","popoverAnchor","setPopoverAnchor","popoverProps","anchor","headerTitle","placement","offset","shift","includes","updatePost","newStatus","newPassword","newDate","handleTogglePassword","handleStatus","Date","ref","children","className","contentClassName","focusOnMount","renderToggle","onToggle","isOpen","variant","size","onClick","renderContent","onClose","title","spacing","hideLabelFromVision","options","onChange","selected","showPopoverHeaderActions","isCompact","as","__nextHasNoMarginBottom","help","checked","placeholder","type","id","__next40pxDefaultSize","maxLength"],"sources":["@wordpress/editor/src/components/post-status/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tCheckboxControl,\n\tDropdown,\n\t__experimentalVStack as VStack,\n\tTextControl,\n\tRadioControl,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { useInstanceId } from '@wordpress/compose';\nimport {\n\tdrafts,\n\tpublished,\n\tscheduled,\n\tpending,\n\tnotAllowed,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tPATTERN_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n} from '../../store/constants';\nimport PostPanelRow from '../post-panel-row';\nimport PostSticky from '../post-sticky';\nimport { PrivatePostSchedule } from '../post-schedule';\nimport { store as editorStore } from '../../store';\n\nconst postStatusesInfo = {\n\t'auto-draft': { label: __( 'Draft' ), icon: drafts },\n\tdraft: { label: __( 'Draft' ), icon: drafts },\n\tpending: { label: __( 'Pending' ), icon: pending },\n\tprivate: { label: __( 'Private' ), icon: notAllowed },\n\tfuture: { label: __( 'Scheduled' ), icon: scheduled },\n\tpublish: { label: __( 'Published' ), icon: published },\n};\n\nexport const STATUS_OPTIONS = [\n\t{\n\t\tlabel: __( 'Draft' ),\n\t\tvalue: 'draft',\n\t\tdescription: __( 'Not ready to publish.' ),\n\t},\n\t{\n\t\tlabel: __( 'Pending' ),\n\t\tvalue: 'pending',\n\t\tdescription: __( 'Waiting for review before publishing.' ),\n\t},\n\t{\n\t\tlabel: __( 'Private' ),\n\t\tvalue: 'private',\n\t\tdescription: __( 'Only visible to site admins and editors.' ),\n\t},\n\t{\n\t\tlabel: __( 'Scheduled' ),\n\t\tvalue: 'future',\n\t\tdescription: __( 'Publish automatically on a chosen date.' ),\n\t},\n\t{\n\t\tlabel: __( 'Published' ),\n\t\tvalue: 'publish',\n\t\tdescription: __( 'Visible to everyone.' ),\n\t},\n];\n\nconst DESIGN_POST_TYPES = [\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tPATTERN_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n];\n\nexport default function PostStatus() {\n\tconst { status, date, password, postId, postType, canEdit } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEditedPostAttribute,\n\t\t\t\tgetCurrentPostId,\n\t\t\t\tgetCurrentPostType,\n\t\t\t\tgetCurrentPost,\n\t\t\t} = select( editorStore );\n\t\t\treturn {\n\t\t\t\tstatus: getEditedPostAttribute( 'status' ),\n\t\t\t\tdate: getEditedPostAttribute( 'date' ),\n\t\t\t\tpassword: getEditedPostAttribute( 'password' ),\n\t\t\t\tpostId: getCurrentPostId(),\n\t\t\t\tpostType: getCurrentPostType(),\n\t\t\t\tcanEdit:\n\t\t\t\t\tgetCurrentPost()._links?.[ 'wp:action-publish' ] ?? false,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst [ showPassword, setShowPassword ] = useState( !! password );\n\tconst passwordInputId = useInstanceId(\n\t\tPostStatus,\n\t\t'editor-change-status__password-input'\n\t);\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\t'aria-label': __( 'Status & visibility' ),\n\t\t\theaderTitle: __( 'Status & visibility' ),\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor ]\n\t);\n\n\tif ( DESIGN_POST_TYPES.includes( postType ) ) {\n\t\treturn null;\n\t}\n\n\tconst updatePost = ( {\n\t\tstatus: newStatus = status,\n\t\tpassword: newPassword = password,\n\t\tdate: newDate = date,\n\t} ) => {\n\t\teditEntityRecord( 'postType', postType, postId, {\n\t\t\tstatus: newStatus,\n\t\t\tdate: newDate,\n\t\t\tpassword: newPassword,\n\t\t} );\n\t};\n\n\tconst handleTogglePassword = ( value ) => {\n\t\tsetShowPassword( value );\n\t\tif ( ! value ) {\n\t\t\tupdatePost( { password: '' } );\n\t\t}\n\t};\n\n\tconst handleStatus = ( value ) => {\n\t\tlet newDate = date;\n\t\tlet newPassword = password;\n\t\tif ( status === 'future' && new Date( date ) > new Date() ) {\n\t\t\tnewDate = null;\n\t\t}\n\t\tif ( value === 'private' && password ) {\n\t\t\tnewPassword = '';\n\t\t}\n\t\tupdatePost( {\n\t\t\tstatus: value,\n\t\t\tdate: newDate,\n\t\t\tpassword: newPassword,\n\t\t} );\n\t};\n\n\treturn (\n\t\t<PostPanelRow label={ __( 'Status' ) } ref={ setPopoverAnchor }>\n\t\t\t{ canEdit ? (\n\t\t\t\t<Dropdown\n\t\t\t\t\tclassName=\"editor-post-status\"\n\t\t\t\t\tcontentClassName=\"editor-change-status__content\"\n\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\tfocusOnMount\n\t\t\t\t\trenderToggle={ ( { onToggle, isOpen } ) => (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName=\"editor-post-status__toggle\"\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\ticon={ postStatusesInfo[ status ]?.icon }\n\t\t\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Current post status.\n\t\t\t\t\t\t\t\t__( 'Change status: %s' ),\n\t\t\t\t\t\t\t\tpostStatusesInfo[ status ]?.label\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ postStatusesInfo[ status ]?.label }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<InspectorPopoverHeader\n\t\t\t\t\t\t\t\ttitle={ __( 'Status & visibility' ) }\n\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<form>\n\t\t\t\t\t\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t\t\t\t\t\t<RadioControl\n\t\t\t\t\t\t\t\t\t\tclassName=\"editor-change-status__options\"\n\t\t\t\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Status' ) }\n\t\t\t\t\t\t\t\t\t\toptions={ STATUS_OPTIONS }\n\t\t\t\t\t\t\t\t\t\tonChange={ handleStatus }\n\t\t\t\t\t\t\t\t\t\tselected={\n\t\t\t\t\t\t\t\t\t\t\tstatus === 'auto-draft'\n\t\t\t\t\t\t\t\t\t\t\t\t? 'draft'\n\t\t\t\t\t\t\t\t\t\t\t\t: status\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t{ status === 'future' && (\n\t\t\t\t\t\t\t\t\t\t<div className=\"editor-change-status__publish-date-wrapper\">\n\t\t\t\t\t\t\t\t\t\t\t<PrivatePostSchedule\n\t\t\t\t\t\t\t\t\t\t\t\tshowPopoverHeaderActions={\n\t\t\t\t\t\t\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tisCompact\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ status !== 'private' && (\n\t\t\t\t\t\t\t\t\t\t<VStack\n\t\t\t\t\t\t\t\t\t\t\tas=\"fieldset\"\n\t\t\t\t\t\t\t\t\t\t\tspacing={ 4 }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"editor-change-status__password-fieldset\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'Password protected'\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'Only visible to those who know the password.'\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\tchecked={ showPassword }\n\t\t\t\t\t\t\t\t\t\t\t\tonChange={\n\t\t\t\t\t\t\t\t\t\t\t\t\thandleTogglePassword\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t{ showPassword && (\n\t\t\t\t\t\t\t\t\t\t\t\t<div className=\"editor-change-status__password-input\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Password'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tupdatePost( {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpassword: value,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tvalue={ password }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tplaceholder={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Use a secure password'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid={ passwordInputId }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmaxLength={ 255 }\n\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</VStack>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t<PostSticky />\n\t\t\t\t\t\t\t\t</VStack>\n\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t) : (\n\t\t\t\t<div className=\"editor-post-status is-read-only\">\n\t\t\t\t\t{ postStatusesInfo[ status ]?.label }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</PostPanelRow>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,MAAM,EACNC,eAAe,EACfC,QAAQ,EACRC,oBAAoB,IAAIC,MAAM,EAC9BC,WAAW,EACXC,YAAY,QACN,uBAAuB;AAC9B,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,QAAQ,EAAEC,OAAO,QAAQ,oBAAoB;AACtD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,oCAAoC,IAAIC,sBAAsB,QAAQ,yBAAyB;AACxG,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SACCC,MAAM,EACNC,SAAS,EACTC,SAAS,EACTC,OAAO,EACPC,UAAU,QACJ,kBAAkB;;AAEzB;AACA;AACA;AACA,SACCC,kBAAkB,EAClBC,u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Q,EAAEN;kBACX,CAAE,CACF;kBACDA,KAAK,EAAGM,QAAU;kBAClBwD,WAAW,EAAGpG,EAAE,CACf,uBACD,CAAG;kBACHqG,IAAI,EAAC,MAAM;kBACXC,EAAE,EAAG7C,eAAiB;kBACtB8C,qBAAqB;kBACrBN,uBAAuB;kBACvBO,SAAS,EAAG;gBAAK,CACjB;cAAC,CACE,CACL;YAAA,CACM,CACR,eACD/E,IAAA,CAACJ,UAAU,IAAE,CAAC;UAAA,CACP;QAAC,CACJ,CAAC;MAAA,CACN;IACA,CACH,CAAC,gBAEFI,IAAA;MAAKoD,SAAS,EAAC,iCAAiC;MAAAD,QAAA,EAC7C9C,gBAAgB,CAAEY,MAAM,CAAE,EAAEX;IAAK,CAC/B;EACL,CACY,CAAC;AAEjB","ignoreList":[]}
|
|
@@ -29,7 +29,7 @@ export default function PostSticky() {
|
|
|
29
29
|
children: /*#__PURE__*/_jsx(CheckboxControl, {
|
|
30
30
|
className: "editor-post-sticky__checkbox-control",
|
|
31
31
|
label: __('Sticky'),
|
|
32
|
-
help: __('Pin this post to the top of the blog'),
|
|
32
|
+
help: __('Pin this post to the top of the blog.'),
|
|
33
33
|
checked: postSticky,
|
|
34
34
|
onChange: () => editPost({
|
|
35
35
|
sticky: !postSticky
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","CheckboxControl","useDispatch","useSelect","PostStickyCheck","store","editorStore","jsx","_jsx","PostSticky","postSticky","select","_select$getEditedPost","getEditedPostAttribute","editPost","children","className","label","help","checked","onChange","sticky","__nextHasNoMarginBottom"],"sources":["@wordpress/editor/src/components/post-sticky/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { CheckboxControl } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport PostStickyCheck from './check';\nimport { store as editorStore } from '../../store';\n\n/**\n * Renders the PostSticky component. It provides a checkbox control for the sticky post feature.\n *\n * @return {React.ReactNode} The rendered component.\n */\nexport default function PostSticky() {\n\tconst postSticky = useSelect( ( select ) => {\n\t\treturn (\n\t\t\tselect( editorStore ).getEditedPostAttribute( 'sticky' ) ?? false\n\t\t);\n\t}, [] );\n\tconst { editPost } = useDispatch( editorStore );\n\n\treturn (\n\t\t<PostStickyCheck>\n\t\t\t<CheckboxControl\n\t\t\t\tclassName=\"editor-post-sticky__checkbox-control\"\n\t\t\t\tlabel={ __( 'Sticky' ) }\n\t\t\t\thelp={ __( 'Pin this post to the top of the blog' ) }\n\t\t\t\tchecked={ postSticky }\n\t\t\t\tonChange={ () => editPost( { sticky: ! postSticky } ) }\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t/>\n\t\t</PostStickyCheck>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;;AAExD;AACA;AACA;AACA,OAAOC,eAAe,MAAM,SAAS;AACrC,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;;AAElD;AACA;AACA;AACA;AACA;AAJA,SAAAC,GAAA,IAAAC,IAAA;AAKA,eAAe,SAASC,UAAUA,CAAA,EAAG;EACpC,MAAMC,UAAU,GAAGP,SAAS,CAAIQ,MAAM,IAAM;IAAA,IAAAC,qBAAA;IAC3C,QAAAA,qBAAA,GACCD,MAAM,CAAEL,WAAY,CAAC,CAACO,sBAAsB,CAAE,QAAS,CAAC,cAAAD,qBAAA,cAAAA,qBAAA,GAAI,KAAK;EAEnE,CAAC,EAAE,EAAG,CAAC;EACP,MAAM;IAAEE;EAAS,CAAC,GAAGZ,WAAW,CAAEI,WAAY,CAAC;EAE/C,oBACCE,IAAA,CAACJ,eAAe;IAAAW,QAAA,eACfP,IAAA,CAACP,eAAe;MACfe,SAAS,EAAC,sCAAsC;MAChDC,KAAK,EAAGjB,EAAE,CAAE,QAAS,CAAG;MACxBkB,IAAI,EAAGlB,EAAE,CAAE,
|
|
1
|
+
{"version":3,"names":["__","CheckboxControl","useDispatch","useSelect","PostStickyCheck","store","editorStore","jsx","_jsx","PostSticky","postSticky","select","_select$getEditedPost","getEditedPostAttribute","editPost","children","className","label","help","checked","onChange","sticky","__nextHasNoMarginBottom"],"sources":["@wordpress/editor/src/components/post-sticky/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { CheckboxControl } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport PostStickyCheck from './check';\nimport { store as editorStore } from '../../store';\n\n/**\n * Renders the PostSticky component. It provides a checkbox control for the sticky post feature.\n *\n * @return {React.ReactNode} The rendered component.\n */\nexport default function PostSticky() {\n\tconst postSticky = useSelect( ( select ) => {\n\t\treturn (\n\t\t\tselect( editorStore ).getEditedPostAttribute( 'sticky' ) ?? false\n\t\t);\n\t}, [] );\n\tconst { editPost } = useDispatch( editorStore );\n\n\treturn (\n\t\t<PostStickyCheck>\n\t\t\t<CheckboxControl\n\t\t\t\tclassName=\"editor-post-sticky__checkbox-control\"\n\t\t\t\tlabel={ __( 'Sticky' ) }\n\t\t\t\thelp={ __( 'Pin this post to the top of the blog.' ) }\n\t\t\t\tchecked={ postSticky }\n\t\t\t\tonChange={ () => editPost( { sticky: ! postSticky } ) }\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t/>\n\t\t</PostStickyCheck>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;;AAExD;AACA;AACA;AACA,OAAOC,eAAe,MAAM,SAAS;AACrC,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;;AAElD;AACA;AACA;AACA;AACA;AAJA,SAAAC,GAAA,IAAAC,IAAA;AAKA,eAAe,SAASC,UAAUA,CAAA,EAAG;EACpC,MAAMC,UAAU,GAAGP,SAAS,CAAIQ,MAAM,IAAM;IAAA,IAAAC,qBAAA;IAC3C,QAAAA,qBAAA,GACCD,MAAM,CAAEL,WAAY,CAAC,CAACO,sBAAsB,CAAE,QAAS,CAAC,cAAAD,qBAAA,cAAAA,qBAAA,GAAI,KAAK;EAEnE,CAAC,EAAE,EAAG,CAAC;EACP,MAAM;IAAEE;EAAS,CAAC,GAAGZ,WAAW,CAAEI,WAAY,CAAC;EAE/C,oBACCE,IAAA,CAACJ,eAAe;IAAAW,QAAA,eACfP,IAAA,CAACP,eAAe;MACfe,SAAS,EAAC,sCAAsC;MAChDC,KAAK,EAAGjB,EAAE,CAAE,QAAS,CAAG;MACxBkB,IAAI,EAAGlB,EAAE,CAAE,uCAAwC,CAAG;MACtDmB,OAAO,EAAGT,UAAY;MACtBU,QAAQ,EAAGA,CAAA,KAAMN,QAAQ,CAAE;QAAEO,MAAM,EAAE,CAAEX;MAAW,CAAE,CAAG;MACvDY,uBAAuB;IAAA,CACvB;EAAC,CACc,CAAC;AAEpB","ignoreList":[]}
|
|
@@ -36,16 +36,17 @@ export function useAllowSwitchingTemplates() {
|
|
|
36
36
|
kind: 'root',
|
|
37
37
|
name: 'site'
|
|
38
38
|
}) ? getEntityRecord('root', 'site') : undefined;
|
|
39
|
-
const templates = getEntityRecords('postType', 'wp_template', {
|
|
40
|
-
per_page: -1
|
|
41
|
-
});
|
|
42
39
|
const isPostsPage = +postId === siteSettings?.page_for_posts;
|
|
40
|
+
const isFrontPage = postType === 'page' && +postId === siteSettings?.page_on_front;
|
|
43
41
|
// If current page is set front page or posts page, we also need
|
|
44
42
|
// to check if the current theme has a template for it. If not
|
|
45
|
-
const
|
|
43
|
+
const templates = isFrontPage ? getEntityRecords('postType', 'wp_template', {
|
|
44
|
+
per_page: -1
|
|
45
|
+
}) : [];
|
|
46
|
+
const hasFrontPage = isFrontPage && !!templates?.some(({
|
|
46
47
|
slug
|
|
47
48
|
}) => slug === 'front-page');
|
|
48
|
-
return !isPostsPage && !
|
|
49
|
+
return !isPostsPage && !hasFrontPage;
|
|
49
50
|
}, [postId, postType]);
|
|
50
51
|
}
|
|
51
52
|
function useTemplates(postType) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useMemo","store","coreStore","editorStore","useEditedPostContext","select","getCurrentPostId","getCurrentPostType","postId","postType","useAllowSwitchingTemplates","canUser","getEntityRecord","getEntityRecords","siteSettings","kind","name","undefined","
|
|
1
|
+
{"version":3,"names":["useSelect","useMemo","store","coreStore","editorStore","useEditedPostContext","select","getCurrentPostId","getCurrentPostType","postId","postType","useAllowSwitchingTemplates","canUser","getEntityRecord","getEntityRecords","siteSettings","kind","name","undefined","isPostsPage","page_for_posts","isFrontPage","page_on_front","templates","per_page","hasFrontPage","some","slug","useTemplates","post_type","useAvailableTemplates","currentTemplateSlug","useCurrentTemplateSlug","allowSwitchingTemplate","filter","template","is_custom","content","raw","entityTemplate","post","getEditedEntityRecord","find"],"sources":["@wordpress/editor/src/components/post-template/hooks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport function useEditedPostContext() {\n\treturn useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\treturn {\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n}\nexport function useAllowSwitchingTemplates() {\n\tconst { postType, postId } = useEditedPostContext();\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser, getEntityRecord, getEntityRecords } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst siteSettings = canUser( 'read', {\n\t\t\t\tkind: 'root',\n\t\t\t\tname: 'site',\n\t\t\t} )\n\t\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t\t: undefined;\n\n\t\t\tconst isPostsPage = +postId === siteSettings?.page_for_posts;\n\t\t\tconst isFrontPage =\n\t\t\t\tpostType === 'page' && +postId === siteSettings?.page_on_front;\n\t\t\t// If current page is set front page or posts page, we also need\n\t\t\t// to check if the current theme has a template for it. If not\n\t\t\tconst templates = isFrontPage\n\t\t\t\t? getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\t\t\tper_page: -1,\n\t\t\t\t } )\n\t\t\t\t: [];\n\t\t\tconst hasFrontPage =\n\t\t\t\tisFrontPage &&\n\t\t\t\t!! templates?.some( ( { slug } ) => slug === 'front-page' );\n\t\t\treturn ! isPostsPage && ! hasFrontPage;\n\t\t},\n\t\t[ postId, postType ]\n\t);\n}\n\nfunction useTemplates( postType ) {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\tper_page: -1,\n\t\t\t\tpost_type: postType,\n\t\t\t} ),\n\t\t[ postType ]\n\t);\n}\n\nexport function useAvailableTemplates( postType ) {\n\tconst currentTemplateSlug = useCurrentTemplateSlug();\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\tconst templates = useTemplates( postType );\n\treturn useMemo(\n\t\t() =>\n\t\t\tallowSwitchingTemplate &&\n\t\t\ttemplates?.filter(\n\t\t\t\t( template ) =>\n\t\t\t\t\ttemplate.is_custom &&\n\t\t\t\t\ttemplate.slug !== currentTemplateSlug &&\n\t\t\t\t\t!! template.content.raw // Skip empty templates.\n\t\t\t),\n\t\t[ templates, currentTemplateSlug, allowSwitchingTemplate ]\n\t);\n}\n\nexport function useCurrentTemplateSlug() {\n\tconst { postType, postId } = useEditedPostContext();\n\tconst templates = useTemplates( postType );\n\tconst entityTemplate = useSelect(\n\t\t( select ) => {\n\t\t\tconst post = select( coreStore ).getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId\n\t\t\t);\n\t\t\treturn post?.template;\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\tif ( ! entityTemplate ) {\n\t\treturn;\n\t}\n\t// If a page has a `template` set and is not included in the list\n\t// of the theme's templates, do not return it, in order to resolve\n\t// to the current theme's default template.\n\treturn templates?.find( ( template ) => template.slug === entityTemplate )\n\t\t?.slug;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,aAAa;AAElD,OAAO,SAASC,oBAAoBA,CAAA,EAAG;EACtC,OAAOL,SAAS,CAAIM,MAAM,IAAM;IAC/B,MAAM;MAAEC,gBAAgB;MAAEC;IAAmB,CAAC,GAAGF,MAAM,CAAEF,WAAY,CAAC;IACtE,OAAO;MACNK,MAAM,EAAEF,gBAAgB,CAAC,CAAC;MAC1BG,QAAQ,EAAEF,kBAAkB,CAAC;IAC9B,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR;AACA,OAAO,SAASG,0BAA0BA,CAAA,EAAG;EAC5C,MAAM;IAAED,QAAQ;IAAED;EAAO,CAAC,GAAGJ,oBAAoB,CAAC,CAAC;EACnD,OAAOL,SAAS,CACbM,MAAM,IAAM;IACb,MAAM;MAAEM,OAAO;MAAEC,eAAe;MAAEC;IAAiB,CAAC,GACnDR,MAAM,CAAEH,SAAU,CAAC;IACpB,MAAMY,YAAY,GAAGH,OAAO,CAAE,MAAM,EAAE;MACrCI,IAAI,EAAE,MAAM;MACZC,IAAI,EAAE;IACP,CAAE,CAAC,GACAJ,eAAe,CAAE,MAAM,EAAE,MAAO,CAAC,GACjCK,SAAS;IAEZ,MAAMC,WAAW,GAAG,CAACV,MAAM,KAAKM,YAAY,EAAEK,cAAc;IAC5D,MA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AAsBA,CAAA,EAAG;EACxC,MAAM;IAAEtB,QAAQ;IAAED;EAAO,CAAC,GAAGJ,oBAAoB,CAAC,CAAC;EACnD,MAAMkB,SAAS,GAAGK,YAAY,CAAElB,QAAS,CAAC;EAC1C,MAAM6B,cAAc,GAAGvC,SAAS,CAC7BM,MAAM,IAAM;IACb,MAAMkC,IAAI,GAAGlC,MAAM,CAAEH,SAAU,CAAC,CAACsC,qBAAqB,CACrD,UAAU,EACV/B,QAAQ,EACRD,MACD,CAAC;IACD,OAAO+B,IAAI,EAAEL,QAAQ;EACtB,CAAC,EACD,CAAEzB,QAAQ,EAAED,MAAM,CACnB,CAAC;EAED,IAAK,CAAE8B,cAAc,EAAG;IACvB;EACD;EACA;EACA;EACA;EACA,OAAOhB,SAAS,EAAEmB,IAAI,CAAIP,QAAQ,IAAMA,QAAQ,CAACR,IAAI,KAAKY,cAAe,CAAC,EACvEZ,IAAI;AACR","ignoreList":[]}
|
|
@@ -27,9 +27,6 @@ export default function SwapTemplateButton({
|
|
|
27
27
|
const {
|
|
28
28
|
editEntityRecord
|
|
29
29
|
} = useDispatch(coreStore);
|
|
30
|
-
if (!availableTemplates?.length) {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
30
|
const onTemplateSelect = async template => {
|
|
34
31
|
editEntityRecord('postType', postType, postId, {
|
|
35
32
|
template: template.name
|
|
@@ -41,6 +38,8 @@ export default function SwapTemplateButton({
|
|
|
41
38
|
};
|
|
42
39
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
43
40
|
children: [/*#__PURE__*/_jsx(MenuItem, {
|
|
41
|
+
disabled: !availableTemplates?.length,
|
|
42
|
+
accessibleWhenDisabled: true,
|
|
44
43
|
onClick: () => setShowModal(true),
|
|
45
44
|
children: __('Change template')
|
|
46
45
|
}), showModal && /*#__PURE__*/_jsx(Modal, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","useState","decodeEntities","__experimentalBlockPatternsList","BlockPatternsList","MenuItem","Modal","__","useDispatch","store","coreStore","parse","useAvailableTemplates","useEditedPostContext","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","SwapTemplateButton","onClick","showModal","setShowModal","postType","postId","availableTemplates","editEntityRecord","
|
|
1
|
+
{"version":3,"names":["useMemo","useState","decodeEntities","__experimentalBlockPatternsList","BlockPatternsList","MenuItem","Modal","__","useDispatch","store","coreStore","parse","useAvailableTemplates","useEditedPostContext","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","SwapTemplateButton","onClick","showModal","setShowModal","postType","postId","availableTemplates","editEntityRecord","onTemplateSelect","template","name","undoIgnore","children","disabled","length","accessibleWhenDisabled","title","onRequestClose","overlayClassName","isFullScreen","className","TemplatesList","onSelect","templatesAsPatterns","map","slug","blocks","content","raw","rendered","id","label","blockPatterns","onClickPattern"],"sources":["@wordpress/editor/src/components/post-template/swap-template-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';\nimport { MenuItem, Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { parse } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useAvailableTemplates, useEditedPostContext } from './hooks';\n\nexport default function SwapTemplateButton( { onClick } ) {\n\tconst [ showModal, setShowModal ] = useState( false );\n\tconst { postType, postId } = useEditedPostContext();\n\tconst availableTemplates = useAvailableTemplates( postType );\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\n\tconst onTemplateSelect = async ( template ) => {\n\t\teditEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tpostId,\n\t\t\t{ template: template.name },\n\t\t\t{ undoIgnore: true }\n\t\t);\n\t\tsetShowModal( false ); // Close the template suggestions modal first.\n\t\tonClick();\n\t};\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tdisabled={ ! availableTemplates?.length }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () => setShowModal( true ) }\n\t\t\t>\n\t\t\t\t{ __( 'Change template' ) }\n\t\t\t</MenuItem>\n\t\t\t{ showModal && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Choose a template' ) }\n\t\t\t\t\tonRequestClose={ () => setShowModal( false ) }\n\t\t\t\t\toverlayClassName=\"editor-post-template__swap-template-modal\"\n\t\t\t\t\tisFullScreen\n\t\t\t\t>\n\t\t\t\t\t<div className=\"editor-post-template__swap-template-modal-content\">\n\t\t\t\t\t\t<TemplatesList\n\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\tonSelect={ onTemplateSelect }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction TemplatesList( { postType, onSelect } ) {\n\tconst availableTemplates = useAvailableTemplates( postType );\n\tconst templatesAsPatterns = useMemo(\n\t\t() =>\n\t\t\tavailableTemplates.map( ( template ) => ( {\n\t\t\t\tname: template.slug,\n\t\t\t\tblocks: parse( template.content.raw ),\n\t\t\t\ttitle: decodeEntities( template.title.rendered ),\n\t\t\t\tid: template.id,\n\t\t\t} ) ),\n\t\t[ availableTemplates ]\n\t);\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tlabel={ __( 'Templates' ) }\n\t\t\tblockPatterns={ templatesAsPatterns }\n\t\t\tonClickPattern={ onSelect }\n\t\t/>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACtD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,+BAA+B,IAAIC,iBAAiB,QAAQ,yBAAyB;AAC9F,SAASC,QAAQ,EAAEC,KAAK,QAAQ,uBAAuB;AACvD,SAASC,EAAE,Q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B,CAAG;MACnC8B,cAAc,EAAGA,CAAA,KAAMd,YAAY,CAAE,KAAM,CAAG;MAC9Ce,gBAAgB,EAAC,2CAA2C;MAC5DC,YAAY;MAAAP,QAAA,eAEZjB,IAAA;QAAKyB,SAAS,EAAC,mDAAmD;QAAAR,QAAA,eACjEjB,IAAA,CAAC0B,aAAa;UACbjB,QAAQ,EAAGA,QAAU;UACrBkB,QAAQ,EAAGd;QAAkB,CAC7B;MAAC,CACE;IAAC,CACA,CACP;EAAA,CACA,CAAC;AAEL;AAEA,SAASa,aAAaA,CAAE;EAAEjB,QAAQ;EAAEkB;AAAS,CAAC,EAAG;EAChD,MAAMhB,kBAAkB,GAAGd,qBAAqB,CAAEY,QAAS,CAAC;EAC5D,MAAMmB,mBAAmB,GAAG3C,OAAO,CAClC,MACC0B,kBAAkB,CAACkB,GAAG,CAAIf,QAAQ,KAAQ;IACzCC,IAAI,EAAED,QAAQ,CAACgB,IAAI;IACnBC,MAAM,EAAEnC,KAAK,CAAEkB,QAAQ,CAACkB,OAAO,CAACC,GAAI,CAAC;IACrCZ,KAAK,EAAElC,cAAc,CAAE2B,QAAQ,CAACO,KAAK,CAACa,QAAS,CAAC;IAChDC,EAAE,EAAErB,QAAQ,CAACqB;EACd,CAAC,CAAG,CAAC,EACN,CAAExB,kBAAkB,CACrB,CAAC;EACD,oBACCX,IAAA,CAACX,iBAAiB;IACjB+C,KAAK,EAAG5C,EAAE,CAAE,WAAY,CAAG;IAC3B6C,aAAa,EAAGT,mBAAqB;IACrCU,cAAc,EAAGX;EAAU,CAC3B,CAAC;AAEJ","ignoreList":[]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { useState } from '@wordpress/element';
|
|
6
|
-
import {
|
|
6
|
+
import { TextControl, RadioControl, __experimentalVStack as VStack } from '@wordpress/components';
|
|
7
7
|
import { useInstanceId } from '@wordpress/compose';
|
|
8
8
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
9
9
|
import { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';
|
|
@@ -11,7 +11,7 @@ import { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '
|
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies
|
|
13
13
|
*/
|
|
14
|
-
import {
|
|
14
|
+
import { VISIBILITY_OPTIONS } from './utils';
|
|
15
15
|
import { store as editorStore } from '../../store';
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -36,43 +36,30 @@ export default function PostVisibility({
|
|
|
36
36
|
password: select(editorStore).getEditedPostAttribute('password')
|
|
37
37
|
}));
|
|
38
38
|
const {
|
|
39
|
-
editPost
|
|
40
|
-
savePost
|
|
39
|
+
editPost
|
|
41
40
|
} = useDispatch(editorStore);
|
|
42
41
|
const [hasPassword, setHasPassword] = useState(!!password);
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
function updateVisibility(value) {
|
|
43
|
+
const nextValues = {
|
|
44
|
+
public: {
|
|
45
|
+
status: visibility === 'private' ? 'draft' : status,
|
|
46
|
+
password: ''
|
|
47
|
+
},
|
|
48
|
+
private: {
|
|
49
|
+
status: 'private',
|
|
50
|
+
password: ''
|
|
51
|
+
},
|
|
52
|
+
password: {
|
|
53
|
+
status: visibility === 'private' ? 'draft' : status,
|
|
54
|
+
password: password || ''
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
editPost(nextValues[value]);
|
|
58
|
+
setHasPassword(value === 'password');
|
|
59
|
+
}
|
|
60
|
+
const updatePassword = value => {
|
|
45
61
|
editPost({
|
|
46
|
-
|
|
47
|
-
password: ''
|
|
48
|
-
});
|
|
49
|
-
setHasPassword(false);
|
|
50
|
-
};
|
|
51
|
-
const setPrivate = () => {
|
|
52
|
-
setShowPrivateConfirmDialog(true);
|
|
53
|
-
};
|
|
54
|
-
const confirmPrivate = () => {
|
|
55
|
-
editPost({
|
|
56
|
-
status: 'private',
|
|
57
|
-
password: ''
|
|
58
|
-
});
|
|
59
|
-
setHasPassword(false);
|
|
60
|
-
setShowPrivateConfirmDialog(false);
|
|
61
|
-
savePost();
|
|
62
|
-
};
|
|
63
|
-
const handleDialogCancel = () => {
|
|
64
|
-
setShowPrivateConfirmDialog(false);
|
|
65
|
-
};
|
|
66
|
-
const setPasswordProtected = () => {
|
|
67
|
-
editPost({
|
|
68
|
-
status: visibility === 'private' ? 'draft' : status,
|
|
69
|
-
password: password || ''
|
|
70
|
-
});
|
|
71
|
-
setHasPassword(true);
|
|
72
|
-
};
|
|
73
|
-
const updatePassword = event => {
|
|
74
|
-
editPost({
|
|
75
|
-
password: event.target.value
|
|
62
|
+
password: value
|
|
76
63
|
});
|
|
77
64
|
};
|
|
78
65
|
return /*#__PURE__*/_jsxs("div", {
|
|
@@ -81,82 +68,25 @@ export default function PostVisibility({
|
|
|
81
68
|
title: __('Visibility'),
|
|
82
69
|
help: __('Control how this post is viewed.'),
|
|
83
70
|
onClose: onClose
|
|
84
|
-
}), /*#__PURE__*/_jsxs(
|
|
85
|
-
|
|
86
|
-
children: [/*#__PURE__*/_jsx(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
onChange: setPrivate
|
|
103
|
-
}), /*#__PURE__*/_jsx(PostVisibilityChoice, {
|
|
104
|
-
instanceId: instanceId,
|
|
105
|
-
value: "password",
|
|
106
|
-
label: visibilityOptions.password.label,
|
|
107
|
-
info: visibilityOptions.password.info,
|
|
108
|
-
checked: hasPassword,
|
|
109
|
-
onChange: setPasswordProtected
|
|
110
|
-
}), hasPassword && /*#__PURE__*/_jsxs("div", {
|
|
111
|
-
className: "editor-post-visibility__password",
|
|
112
|
-
children: [/*#__PURE__*/_jsx(VisuallyHidden, {
|
|
113
|
-
as: "label",
|
|
114
|
-
htmlFor: `editor-post-visibility__password-input-${instanceId}`,
|
|
115
|
-
children: __('Create password')
|
|
116
|
-
}), /*#__PURE__*/_jsx("input", {
|
|
117
|
-
className: "editor-post-visibility__password-input",
|
|
118
|
-
id: `editor-post-visibility__password-input-${instanceId}`,
|
|
119
|
-
type: "text",
|
|
120
|
-
onChange: updatePassword,
|
|
121
|
-
value: password,
|
|
122
|
-
placeholder: __('Use a secure password')
|
|
123
|
-
})]
|
|
71
|
+
}), /*#__PURE__*/_jsxs(VStack, {
|
|
72
|
+
spacing: 4,
|
|
73
|
+
children: [/*#__PURE__*/_jsx(RadioControl, {
|
|
74
|
+
label: __('Visibility'),
|
|
75
|
+
hideLabelFromVision: true,
|
|
76
|
+
options: VISIBILITY_OPTIONS,
|
|
77
|
+
selected: hasPassword ? 'password' : visibility,
|
|
78
|
+
onChange: updateVisibility
|
|
79
|
+
}), hasPassword && /*#__PURE__*/_jsx(TextControl, {
|
|
80
|
+
label: __('Password'),
|
|
81
|
+
onChange: updatePassword,
|
|
82
|
+
value: password,
|
|
83
|
+
placeholder: __('Use a secure password'),
|
|
84
|
+
type: "text",
|
|
85
|
+
id: `editor-post-visibility__password-input-${instanceId}`,
|
|
86
|
+
__next40pxDefaultSize: true,
|
|
87
|
+
__nextHasNoMarginBottom: true,
|
|
88
|
+
maxLength: 255
|
|
124
89
|
})]
|
|
125
|
-
}), /*#__PURE__*/_jsx(ConfirmDialog, {
|
|
126
|
-
isOpen: showPrivateConfirmDialog,
|
|
127
|
-
onConfirm: confirmPrivate,
|
|
128
|
-
onCancel: handleDialogCancel,
|
|
129
|
-
confirmButtonText: __('Publish'),
|
|
130
|
-
size: "medium",
|
|
131
|
-
children: __('Would you like to privately publish this post now?')
|
|
132
|
-
})]
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
function PostVisibilityChoice({
|
|
136
|
-
instanceId,
|
|
137
|
-
value,
|
|
138
|
-
label,
|
|
139
|
-
info,
|
|
140
|
-
...props
|
|
141
|
-
}) {
|
|
142
|
-
return /*#__PURE__*/_jsxs("div", {
|
|
143
|
-
className: "editor-post-visibility__choice",
|
|
144
|
-
children: [/*#__PURE__*/_jsx("input", {
|
|
145
|
-
type: "radio",
|
|
146
|
-
name: `editor-post-visibility__setting-${instanceId}`,
|
|
147
|
-
value: value,
|
|
148
|
-
id: `editor-post-${value}-${instanceId}`,
|
|
149
|
-
"aria-describedby": `editor-post-${value}-${instanceId}-description`,
|
|
150
|
-
className: "editor-post-visibility__radio",
|
|
151
|
-
...props
|
|
152
|
-
}), /*#__PURE__*/_jsx("label", {
|
|
153
|
-
htmlFor: `editor-post-${value}-${instanceId}`,
|
|
154
|
-
className: "editor-post-visibility__label",
|
|
155
|
-
children: label
|
|
156
|
-
}), /*#__PURE__*/_jsx("p", {
|
|
157
|
-
id: `editor-post-${value}-${instanceId}-description`,
|
|
158
|
-
className: "editor-post-visibility__info",
|
|
159
|
-
children: info
|
|
160
90
|
})]
|
|
161
91
|
});
|
|
162
92
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","useState","VisuallyHidden","__experimentalConfirmDialog","ConfirmDialog","useInstanceId","useSelect","useDispatch","__experimentalInspectorPopoverHeader","InspectorPopoverHeader","visibilityOptions","store","editorStore","jsx","_jsx","jsxs","_jsxs","PostVisibility","onClose","instanceId","status","visibility","password","select","getEditedPostAttribute","getEditedPostVisibility","editPost","savePost","hasPassword","setHasPassword","showPrivateConfirmDialog","setShowPrivateConfirmDialog","setPublic","setPrivate","confirmPrivate","handleDialogCancel","setPasswordProtected","updatePassword","event","target","value","className","children","title","help","as","PostVisibilityChoice","label","public","info","checked","onChange","private","htmlFor","id","type","placeholder","isOpen","onConfirm","onCancel","confirmButtonText","size","props","name"],"sources":["@wordpress/editor/src/components/post-visibility/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport {\n\tVisuallyHidden,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { visibilityOptions } from './utils';\nimport { store as editorStore } from '../../store';\n\n/**\n * Allows users to set the visibility of a post.\n *\n * @param {Object} props The component props.\n * @param {Function} props.onClose Function to call when the popover is closed.\n * @return {React.ReactNode} The rendered component.\n */\nexport default function PostVisibility( { onClose } ) {\n\tconst instanceId = useInstanceId( PostVisibility );\n\n\tconst { status, visibility, password } = useSelect( ( select ) => ( {\n\t\tstatus: select( editorStore ).getEditedPostAttribute( 'status' ),\n\t\tvisibility: select( editorStore ).getEditedPostVisibility(),\n\t\tpassword: select( editorStore ).getEditedPostAttribute( 'password' ),\n\t} ) );\n\n\tconst { editPost, savePost } = useDispatch( editorStore );\n\n\tconst [ hasPassword, setHasPassword ] = useState( !! password );\n\tconst [ showPrivateConfirmDialog, setShowPrivateConfirmDialog ] =\n\t\tuseState( false );\n\n\tconst setPublic = () => {\n\t\teditPost( {\n\t\t\tstatus: visibility === 'private' ? 'draft' : status,\n\t\t\tpassword: '',\n\t\t} );\n\t\tsetHasPassword( false );\n\t};\n\n\tconst setPrivate = () => {\n\t\tsetShowPrivateConfirmDialog( true );\n\t};\n\n\tconst confirmPrivate = () => {\n\t\teditPost( { status: 'private', password: '' } );\n\t\tsetHasPassword( false );\n\t\tsetShowPrivateConfirmDialog( false );\n\t\tsavePost();\n\t};\n\n\tconst handleDialogCancel = () => {\n\t\tsetShowPrivateConfirmDialog( false );\n\t};\n\n\tconst setPasswordProtected = () => {\n\t\teditPost( {\n\t\t\tstatus: visibility === 'private' ? 'draft' : status,\n\t\t\tpassword: password || '',\n\t\t} );\n\t\tsetHasPassword( true );\n\t};\n\n\tconst updatePassword = ( event ) => {\n\t\teditPost( { password: event.target.value } );\n\t};\n\n\treturn (\n\t\t<div className=\"editor-post-visibility\">\n\t\t\t<InspectorPopoverHeader\n\t\t\t\ttitle={ __( 'Visibility' ) }\n\t\t\t\thelp={ __( 'Control how this post is viewed.' ) }\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t\t<fieldset className=\"editor-post-visibility__fieldset\">\n\t\t\t\t<VisuallyHidden as=\"legend\">\n\t\t\t\t\t{ __( 'Visibility' ) }\n\t\t\t\t</VisuallyHidden>\n\t\t\t\t<PostVisibilityChoice\n\t\t\t\t\tinstanceId={ instanceId }\n\t\t\t\t\tvalue=\"public\"\n\t\t\t\t\tlabel={ visibilityOptions.public.label }\n\t\t\t\t\tinfo={ visibilityOptions.public.info }\n\t\t\t\t\tchecked={ visibility === 'public' && ! hasPassword }\n\t\t\t\t\tonChange={ setPublic }\n\t\t\t\t/>\n\t\t\t\t<PostVisibilityChoice\n\t\t\t\t\tinstanceId={ instanceId }\n\t\t\t\t\tvalue=\"private\"\n\t\t\t\t\tlabel={ visibilityOptions.private.label }\n\t\t\t\t\tinfo={ visibilityOptions.private.info }\n\t\t\t\t\tchecked={ visibility === 'private' }\n\t\t\t\t\tonChange={ setPrivate }\n\t\t\t\t/>\n\t\t\t\t<PostVisibilityChoice\n\t\t\t\t\tinstanceId={ instanceId }\n\t\t\t\t\tvalue=\"password\"\n\t\t\t\t\tlabel={ visibilityOptions.password.label }\n\t\t\t\t\tinfo={ visibilityOptions.password.info }\n\t\t\t\t\tchecked={ hasPassword }\n\t\t\t\t\tonChange={ setPasswordProtected }\n\t\t\t\t/>\n\t\t\t\t{ hasPassword && (\n\t\t\t\t\t<div className=\"editor-post-visibility__password\">\n\t\t\t\t\t\t<VisuallyHidden\n\t\t\t\t\t\t\tas=\"label\"\n\t\t\t\t\t\t\thtmlFor={ `editor-post-visibility__password-input-${ instanceId }` }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Create password' ) }\n\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\tclassName=\"editor-post-visibility__password-input\"\n\t\t\t\t\t\t\tid={ `editor-post-visibility__password-input-${ instanceId }` }\n\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\tonChange={ updatePassword }\n\t\t\t\t\t\t\tvalue={ password }\n\t\t\t\t\t\t\tplaceholder={ __( 'Use a secure password' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</fieldset>\n\t\t\t<ConfirmDialog\n\t\t\t\tisOpen={ showPrivateConfirmDialog }\n\t\t\t\tonConfirm={ confirmPrivate }\n\t\t\t\tonCancel={ handleDialogCancel }\n\t\t\t\tconfirmButtonText={ __( 'Publish' ) }\n\t\t\t\tsize=\"medium\"\n\t\t\t>\n\t\t\t\t{ __( 'Would you like to privately publish this post now?' ) }\n\t\t\t</ConfirmDialog>\n\t\t</div>\n\t);\n}\n\nfunction PostVisibilityChoice( { instanceId, value, label, info, ...props } ) {\n\treturn (\n\t\t<div className=\"editor-post-visibility__choice\">\n\t\t\t<input\n\t\t\t\ttype=\"radio\"\n\t\t\t\tname={ `editor-post-visibility__setting-${ instanceId }` }\n\t\t\t\tvalue={ value }\n\t\t\t\tid={ `editor-post-${ value }-${ instanceId }` }\n\t\t\t\taria-describedby={ `editor-post-${ value }-${ instanceId }-description` }\n\t\t\t\tclassName=\"editor-post-visibility__radio\"\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t\t<label\n\t\t\t\thtmlFor={ `editor-post-${ value }-${ instanceId }` }\n\t\t\t\tclassName=\"editor-post-visibility__label\"\n\t\t\t>\n\t\t\t\t{ label }\n\t\t\t</label>\n\t\t\t<p\n\t\t\t\tid={ `editor-post-${ value }-${ instanceId }-description` }\n\t\t\t\tclassName=\"editor-post-visibility__info\"\n\t\t\t>\n\t\t\t\t{ info }\n\t\t\t</p>\n\t\t</div>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EA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experimentalVStack","VStack","useInstanceId","useSelect","useDispatch","__experimentalInspectorPopoverHeader","InspectorPopoverHeader","VISIBILITY_OPTIONS","store","editorStore","jsx","_jsx","jsxs","_jsxs","PostVisibility","onClose","instanceId","status","visibility","password","select","getEditedPostAttribute","getEditedPostVisibility","editPost","hasPassword","setHasPassword","updateVisibility","value","nextValues","public","private","updatePassword","className","children","title","help","spacing","label","hideLabelFromVision","options","selected","onChange","placeholder","type","id","__next40pxDefaultSize","__nextHasNoMarginBottom","maxLength"],"sources":["@wordpress/editor/src/components/post-visibility/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport {\n\tTextControl,\n\tRadioControl,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { VISIBILITY_OPTIONS } from './utils';\nimport { store as editorStore } from '../../store';\n\n/**\n * Allows users to set the visibility of a post.\n *\n * @param {Object} props The component props.\n * @param {Function} props.onClose Function to call when the popover is closed.\n * @return {React.ReactNode} The rendered component.\n */\nexport default function PostVisibility( { onClose } ) {\n\tconst instanceId = useInstanceId( PostVisibility );\n\n\tconst { status, visibility, password } = useSelect( ( select ) => ( {\n\t\tstatus: select( editorStore ).getEditedPostAttribute( 'status' ),\n\t\tvisibility: select( editorStore ).getEditedPostVisibility(),\n\t\tpassword: select( editorStore ).getEditedPostAttribute( 'password' ),\n\t} ) );\n\n\tconst { editPost } = useDispatch( editorStore );\n\n\tconst [ hasPassword, setHasPassword ] = useState( !! password );\n\n\tfunction updateVisibility( value ) {\n\t\tconst nextValues = {\n\t\t\tpublic: {\n\t\t\t\tstatus: visibility === 'private' ? 'draft' : status,\n\t\t\t\tpassword: '',\n\t\t\t},\n\t\t\tprivate: { status: 'private', password: '' },\n\t\t\tpassword: {\n\t\t\t\tstatus: visibility === 'private' ? 'draft' : status,\n\t\t\t\tpassword: password || '',\n\t\t\t},\n\t\t};\n\n\t\teditPost( nextValues[ value ] );\n\t\tsetHasPassword( value === 'password' );\n\t}\n\n\tconst updatePassword = ( value ) => {\n\t\teditPost( { password: value } );\n\t};\n\n\treturn (\n\t\t<div className=\"editor-post-visibility\">\n\t\t\t<InspectorPopoverHeader\n\t\t\t\ttitle={ __( 'Visibility' ) }\n\t\t\t\thelp={ __( 'Control how this post is viewed.' ) }\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t<RadioControl\n\t\t\t\t\tlabel={ __( 'Visibility' ) }\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\toptions={ VISIBILITY_OPTIONS }\n\t\t\t\t\tselected={ hasPassword ? 'password' : visibility }\n\t\t\t\t\tonChange={ updateVisibility }\n\t\t\t\t/>\n\t\t\t\t{ hasPassword && (\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tlabel={ __( 'Password' ) }\n\t\t\t\t\t\tonChange={ updatePassword }\n\t\t\t\t\t\tvalue={ password }\n\t\t\t\t\t\tplaceholder={ __( 'Use a secure password' ) }\n\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\tid={ `editor-post-visibility__password-input-${ instanceId }` }\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tmaxLength={ 255 }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</VStack>\n\t\t</div>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SACCC,WAAW,EACXC,YAAY,EACZC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,SAAS,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* Internal dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import { VISIBILITY_OPTIONS } from './utils';
|
|
10
10
|
import { store as editorStore } from '../../store';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -24,7 +24,7 @@ export default function PostVisibilityLabel() {
|
|
|
24
24
|
* @return {string} Post visibility label.
|
|
25
25
|
*/
|
|
26
26
|
export function usePostVisibilityLabel() {
|
|
27
|
-
const visibility = useSelect(select => select(editorStore).getEditedPostVisibility());
|
|
28
|
-
return
|
|
27
|
+
const visibility = useSelect(select => select(editorStore).getEditedPostVisibility(), []);
|
|
28
|
+
return VISIBILITY_OPTIONS.find(option => option.value === visibility)?.label;
|
|
29
29
|
}
|
|
30
30
|
//# sourceMappingURL=label.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","
|
|
1
|
+
{"version":3,"names":["useSelect","VISIBILITY_OPTIONS","store","editorStore","PostVisibilityLabel","usePostVisibilityLabel","visibility","select","getEditedPostVisibility","find","option","value","label"],"sources":["@wordpress/editor/src/components/post-visibility/label.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { VISIBILITY_OPTIONS } from './utils';\nimport { store as editorStore } from '../../store';\n\n/**\n * Returns the label for the current post visibility setting.\n *\n * @return {string} Post visibility label.\n */\nexport default function PostVisibilityLabel() {\n\treturn usePostVisibilityLabel();\n}\n\n/**\n * Get the label for the current post visibility setting.\n *\n * @return {string} Post visibility label.\n */\nexport function usePostVisibilityLabel() {\n\tconst visibility = useSelect(\n\t\t( select ) => select( editorStore ).getEditedPostVisibility(),\n\t\t[]\n\t);\n\n\treturn VISIBILITY_OPTIONS.find( ( option ) => option.value === visibility )\n\t\t?.label;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,kBAAkB,QAAQ,SAAS;AAC5C,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;;AAElD;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,mBAAmBA,CAAA,EAAG;EAC7C,OAAOC,sBAAsB,CAAC,CAAC;AAChC;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,sBAAsBA,CAAA,EAAG;EACxC,MAAMC,UAAU,GAAGN,SAAS,CACzBO,MAAM,IAAMA,MAAM,CAAEJ,WAAY,CAAC,CAACK,uBAAuB,CAAC,CAAC,EAC7D,EACD,CAAC;EAED,OAAOP,kBAAkB,CAACQ,IAAI,CAAIC,MAAM,IAAMA,MAAM,CAACC,KAAK,KAAKL,UAAW,CAAC,EACxEM,KAAK;AACT","ignoreList":[]}
|
|
@@ -2,18 +2,17 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
export const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
5
|
+
export const VISIBILITY_OPTIONS = [{
|
|
6
|
+
label: __('Public'),
|
|
7
|
+
value: 'public',
|
|
8
|
+
description: __('Visible to everyone.')
|
|
9
|
+
}, {
|
|
10
|
+
label: __('Private'),
|
|
11
|
+
value: 'private',
|
|
12
|
+
description: __('Only visible to site admins and editors.')
|
|
13
|
+
}, {
|
|
14
|
+
label: __('Password protected'),
|
|
15
|
+
value: 'password',
|
|
16
|
+
description: __('Only visible to those who know the password.')
|
|
17
|
+
}];
|
|
19
18
|
//# sourceMappingURL=utils.js.map
|