@wordpress/edit-post
Version:
Edit Post module for WordPress.
8 lines (7 loc) • 1.76 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../../src/components/more-menu/manage-patterns-menu-item.js"],
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { addQueryArgs } from '@wordpress/url';\n\nfunction ManagePatternsMenuItem() {\n\tconst url = useSelect( ( select ) => {\n\t\tconst { canUser } = select( coreStore );\n\t\tconst defaultUrl = addQueryArgs( 'edit.php', {\n\t\t\tpost_type: 'wp_block',\n\t\t} );\n\t\tconst patternsUrl = addQueryArgs( 'site-editor.php', {\n\t\t\tp: '/pattern',\n\t\t} );\n\n\t\t// The site editor and templates both check whether the user has\n\t\t// edit_theme_options capabilities. We can leverage that here and not\n\t\t// display the manage patterns link if the user can't access it.\n\t\treturn canUser( 'create', {\n\t\t\tkind: 'postType',\n\t\t\tname: 'wp_template',\n\t\t} )\n\t\t\t? patternsUrl\n\t\t\t: defaultUrl;\n\t}, [] );\n\n\treturn (\n\t\t<MenuItem role=\"menuitem\" href={ url }>\n\t\t\t{ __( 'Manage patterns' ) }\n\t\t</MenuItem>\n\t);\n}\n\nexport default ManagePatternsMenuItem;\n"],
"mappings": ";AAGA,SAAS,gBAAgB;AACzB,SAAS,SAAS,iBAAiB;AACnC,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAwB3B;AAtBF,SAAS,yBAAyB;AACjC,QAAM,MAAM,UAAW,CAAE,WAAY;AACpC,UAAM,EAAE,QAAQ,IAAI,OAAQ,SAAU;AACtC,UAAM,aAAa,aAAc,YAAY;AAAA,MAC5C,WAAW;AAAA,IACZ,CAAE;AACF,UAAM,cAAc,aAAc,mBAAmB;AAAA,MACpD,GAAG;AAAA,IACJ,CAAE;AAKF,WAAO,QAAS,UAAU;AAAA,MACzB,MAAM;AAAA,MACN,MAAM;AAAA,IACP,CAAE,IACC,cACA;AAAA,EACJ,GAAG,CAAC,CAAE;AAEN,SACC,oBAAC,YAAS,MAAK,YAAW,MAAO,KAC9B,aAAI,iBAAkB,GACzB;AAEF;AAEA,IAAO,oCAAQ;",
"names": []
}