@wordpress/edit-site 6.35.2-next.dc3f6d3c1.0 → 6.36.1-next.8b30e05b0.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 +1 -1
- package/build/components/add-new-template-legacy/add-custom-generic-template-modal-content.js +109 -0
- package/build/components/add-new-template-legacy/add-custom-generic-template-modal-content.js.map +7 -0
- package/build/components/add-new-template-legacy/add-custom-template-modal-content.js +328 -0
- package/build/components/add-new-template-legacy/add-custom-template-modal-content.js.map +7 -0
- package/build/components/add-new-template-legacy/index.js +389 -0
- package/build/components/add-new-template-legacy/index.js.map +7 -0
- package/build/components/add-new-template-legacy/utils.js +620 -0
- package/build/components/add-new-template-legacy/utils.js.map +7 -0
- package/build/components/page-templates/fields.js +3 -1
- package/build/components/page-templates/fields.js.map +2 -2
- package/build/components/page-templates/index-legacy.js +185 -0
- package/build/components/page-templates/index-legacy.js.map +7 -0
- package/build/components/post-list/index.js +10 -0
- package/build/components/post-list/index.js.map +2 -2
- package/build/components/sidebar-navigation-screen-templates-browse/content-legacy.js +101 -0
- package/build/components/sidebar-navigation-screen-templates-browse/content-legacy.js.map +7 -0
- package/build/components/sidebar-navigation-screen-templates-browse/index.js +2 -1
- package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +3 -3
- package/build/components/site-editor-routes/templates.js +10 -2
- package/build/components/site-editor-routes/templates.js.map +3 -3
- package/build/components/site-hub/index.js +1 -1
- package/build/components/site-hub/index.js.map +2 -2
- package/build/utils/constants.js +6 -0
- package/build/utils/constants.js.map +2 -2
- package/build-module/components/add-new-template-legacy/add-custom-generic-template-modal-content.js +93 -0
- package/build-module/components/add-new-template-legacy/add-custom-generic-template-modal-content.js.map +7 -0
- package/build-module/components/add-new-template-legacy/add-custom-template-modal-content.js +316 -0
- package/build-module/components/add-new-template-legacy/add-custom-template-modal-content.js.map +7 -0
- package/build-module/components/add-new-template-legacy/index.js +390 -0
- package/build-module/components/add-new-template-legacy/index.js.map +7 -0
- package/build-module/components/add-new-template-legacy/utils.js +589 -0
- package/build-module/components/add-new-template-legacy/utils.js.map +7 -0
- package/build-module/components/page-templates/fields.js +3 -1
- package/build-module/components/page-templates/fields.js.map +2 -2
- package/build-module/components/page-templates/index-legacy.js +154 -0
- package/build-module/components/page-templates/index-legacy.js.map +7 -0
- package/build-module/components/post-list/index.js +12 -0
- package/build-module/components/post-list/index.js.map +2 -2
- package/build-module/components/sidebar-navigation-screen-templates-browse/content-legacy.js +70 -0
- package/build-module/components/sidebar-navigation-screen-templates-browse/content-legacy.js.map +7 -0
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +2 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +2 -2
- package/build-module/components/site-editor-routes/templates.js +10 -2
- package/build-module/components/site-editor-routes/templates.js.map +2 -2
- package/build-module/components/site-hub/index.js +1 -1
- package/build-module/components/site-hub/index.js.map +2 -2
- package/build-module/utils/constants.js +4 -0
- package/build-module/utils/constants.js.map +2 -2
- package/build-style/style-rtl.css +263 -27
- package/build-style/style.css +263 -27
- package/package.json +46 -46
- package/src/components/add-new-template-legacy/add-custom-generic-template-modal-content.js +94 -0
- package/src/components/add-new-template-legacy/add-custom-template-modal-content.js +314 -0
- package/src/components/add-new-template-legacy/index.js +454 -0
- package/src/components/add-new-template-legacy/utils.js +760 -0
- package/src/components/page-templates/fields.js +13 -9
- package/src/components/page-templates/index-legacy.js +166 -0
- package/src/components/post-list/index.js +13 -0
- package/src/components/sidebar-navigation-screen-templates-browse/content-legacy.js +79 -0
- package/src/components/sidebar-navigation-screen-templates-browse/index.js +8 -1
- package/src/components/site-editor-routes/templates.js +22 -3
- package/src/components/site-hub/index.js +1 -1
- package/src/utils/constants.js +2 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/add-new-template-legacy/utils.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useMemo, useCallback } from '@wordpress/element';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { blockMeta, post, archive } from '@wordpress/icons';\nimport { safeDecodeURI } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\n\nconst EMPTY_OBJECT = {};\n\n/**\n * @typedef IHasNameAndId\n * @property {string|number} id The entity's id.\n * @property {string} name The entity's name.\n */\n\nconst getValueFromObjectPath = ( object, path ) => {\n\tlet value = object;\n\tpath.split( '.' ).forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\n};\n\n/**\n * Helper that adds a prefix to a post slug. The slug needs to be URL-decoded first,\n * so that we have raw Unicode characters there. The server will truncate the slug to\n * 200 characters, respecing Unicode char boundary. On the other hand, the server\n * doesn't detect urlencoded octet boundary and can possibly construct slugs that\n * are not valid urlencoded strings.\n * @param {string} prefix The prefix to add to the slug.\n * @param {string} slug The slug to add the prefix to.\n * @return {string} The slug with the prefix.\n */\nfunction prefixSlug( prefix, slug ) {\n\treturn `${ prefix }-${ safeDecodeURI( slug ) }`;\n}\n\n/**\n * Helper util to map records to add a `name` prop from a\n * provided path, in order to handle all entities in the same\n * fashion(implementing`IHasNameAndId` interface).\n *\n * @param {Object[]} entities The array of entities.\n * @param {string} path The path to map a `name` property from the entity.\n * @return {IHasNameAndId[]} An array of entities that now implement the `IHasNameAndId` interface.\n */\nexport const mapToIHasNameAndId = ( entities, path ) => {\n\treturn ( entities || [] ).map( ( entity ) => ( {\n\t\t...entity,\n\t\tname: decodeEntities( getValueFromObjectPath( entity, path ) ),\n\t} ) );\n};\n\n/**\n * @typedef {Object} EntitiesInfo\n * @property {boolean} hasEntities If an entity has available records(posts, terms, etc..).\n * @property {number[]} existingEntitiesIds An array of the existing entities ids.\n */\n\nexport const useExistingTemplates = () => {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t}\n\t\t\t),\n\t\t[]\n\t);\n};\n\nexport const useDefaultTemplateTypes = () => {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getCurrentTheme()?.default_template_types || [],\n\t\t[]\n\t);\n};\n\nconst usePublicPostTypes = () => {\n\tconst postTypes = useSelect(\n\t\t( select ) => select( coreStore ).getPostTypes( { per_page: -1 } ),\n\t\t[]\n\t);\n\treturn useMemo( () => {\n\t\tconst excludedPostTypes = [ 'attachment' ];\n\t\treturn postTypes\n\t\t\t?.filter(\n\t\t\t\t( { viewable, slug } ) =>\n\t\t\t\t\tviewable && ! excludedPostTypes.includes( slug )\n\t\t\t)\n\t\t\t.sort( ( a, b ) => {\n\t\t\t\t// Sort post types alphabetically by name,\n\t\t\t\t// but exclude the built-in 'post' type from sorting.\n\t\t\t\tif ( a.slug === 'post' || b.slug === 'post' ) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\n\t\t\t\treturn a.name.localeCompare( b.name );\n\t\t\t} );\n\t}, [ postTypes ] );\n};\n\nconst usePublicTaxonomies = () => {\n\tconst taxonomies = useSelect(\n\t\t( select ) => select( coreStore ).getTaxonomies( { per_page: -1 } ),\n\t\t[]\n\t);\n\treturn useMemo( () => {\n\t\treturn taxonomies?.filter(\n\t\t\t( { visibility } ) => visibility?.publicly_queryable\n\t\t);\n\t}, [ taxonomies ] );\n};\n\nexport function usePostTypeArchiveMenuItems() {\n\tconst publicPostTypes = usePublicPostTypes();\n\tconst postTypesWithArchives = useMemo(\n\t\t() => publicPostTypes?.filter( ( postType ) => postType.has_archive ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst existingTemplates = useExistingTemplates();\n\t// We need to keep track of naming conflicts. If a conflict\n\t// occurs, we need to add slug.\n\tconst postTypeLabels = useMemo(\n\t\t() =>\n\t\t\tpublicPostTypes?.reduce( ( accumulator, { labels } ) => {\n\t\t\t\tconst singularName = labels.singular_name.toLowerCase();\n\t\t\t\taccumulator[ singularName ] =\n\t\t\t\t\t( accumulator[ singularName ] || 0 ) + 1;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst needsUniqueIdentifier = useCallback(\n\t\t( { labels, slug } ) => {\n\t\t\tconst singularName = labels.singular_name.toLowerCase();\n\t\t\treturn postTypeLabels[ singularName ] > 1 && singularName !== slug;\n\t\t},\n\t\t[ postTypeLabels ]\n\t);\n\treturn useMemo(\n\t\t() =>\n\t\t\tpostTypesWithArchives\n\t\t\t\t?.filter(\n\t\t\t\t\t( postType ) =>\n\t\t\t\t\t\t! ( existingTemplates || [] ).some(\n\t\t\t\t\t\t\t( existingTemplate ) =>\n\t\t\t\t\t\t\t\texistingTemplate.slug ===\n\t\t\t\t\t\t\t\t'archive-' + postType.slug\n\t\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t.map( ( postType ) => {\n\t\t\t\t\tlet title;\n\t\t\t\t\tif ( needsUniqueIdentifier( postType ) ) {\n\t\t\t\t\t\ttitle = sprintf(\n\t\t\t\t\t\t\t// translators: %1s: Name of the post type e.g: \"Post\"; %2s: Slug of the post type e.g: \"book\".\n\t\t\t\t\t\t\t__( 'Archive: %1$s (%2$s)' ),\n\t\t\t\t\t\t\tpostType.labels.singular_name,\n\t\t\t\t\t\t\tpostType.slug\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttitle = sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t\t\t__( 'Archive: %s' ),\n\t\t\t\t\t\t\tpostType.labels.singular_name\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\tslug: 'archive-' + postType.slug,\n\t\t\t\t\t\tdescription: sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t'Displays an archive with the latest posts of type: %s.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tpostType.labels.singular_name\n\t\t\t\t\t\t),\n\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t// `icon` is the `menu_icon` property of a post type. We\n\t\t\t\t\t\t// only handle `dashicons` for now, even if the `menu_icon`\n\t\t\t\t\t\t// also supports urls and svg as values.\n\t\t\t\t\t\ticon:\n\t\t\t\t\t\t\ttypeof postType.icon === 'string' &&\n\t\t\t\t\t\t\tpostType.icon.startsWith( 'dashicons-' )\n\t\t\t\t\t\t\t\t? postType.icon.slice( 10 )\n\t\t\t\t\t\t\t\t: archive,\n\t\t\t\t\t\ttemplatePrefix: 'archive',\n\t\t\t\t\t};\n\t\t\t\t} ) || [],\n\t\t[ postTypesWithArchives, existingTemplates, needsUniqueIdentifier ]\n\t);\n}\n\nexport const usePostTypeMenuItems = ( onClickMenuItem ) => {\n\tconst publicPostTypes = usePublicPostTypes();\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\t// We need to keep track of naming conflicts. If a conflict\n\t// occurs, we need to add slug.\n\tconst templateLabels = useMemo(\n\t\t() =>\n\t\t\tpublicPostTypes?.reduce( ( accumulator, { labels } ) => {\n\t\t\t\tconst templateName = (\n\t\t\t\t\tlabels.template_name || labels.singular_name\n\t\t\t\t).toLowerCase();\n\t\t\t\taccumulator[ templateName ] =\n\t\t\t\t\t( accumulator[ templateName ] || 0 ) + 1;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst needsUniqueIdentifier = useCallback(\n\t\t( { labels, slug } ) => {\n\t\t\tconst templateName = (\n\t\t\t\tlabels.template_name || labels.singular_name\n\t\t\t).toLowerCase();\n\t\t\treturn templateLabels[ templateName ] > 1 && templateName !== slug;\n\t\t},\n\t\t[ templateLabels ]\n\t);\n\n\t// `page`is a special case in template hierarchy.\n\tconst templatePrefixes = useMemo(\n\t\t() =>\n\t\t\tpublicPostTypes?.reduce( ( accumulator, { slug } ) => {\n\t\t\t\tlet suffix = slug;\n\t\t\t\tif ( slug !== 'page' ) {\n\t\t\t\t\tsuffix = `single-${ suffix }`;\n\t\t\t\t}\n\t\t\t\taccumulator[ slug ] = suffix;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst postTypesInfo = useEntitiesInfo( 'postType', templatePrefixes );\n\tconst existingTemplateSlugs = ( existingTemplates || [] ).map(\n\t\t( { slug } ) => slug\n\t);\n\tconst menuItems = ( publicPostTypes || [] ).reduce(\n\t\t( accumulator, postType ) => {\n\t\t\tconst { slug, labels, icon } = postType;\n\t\t\t// We need to check if the general template is part of the\n\t\t\t// defaultTemplateTypes. If it is, just use that info and\n\t\t\t// augment it with the specific template functionality.\n\t\t\tconst generalTemplateSlug = templatePrefixes[ slug ];\n\t\t\tconst defaultTemplateType = defaultTemplateTypes?.find(\n\t\t\t\t( { slug: _slug } ) => _slug === generalTemplateSlug\n\t\t\t);\n\t\t\tconst hasGeneralTemplate =\n\t\t\t\texistingTemplateSlugs?.includes( generalTemplateSlug );\n\t\t\tconst _needsUniqueIdentifier = needsUniqueIdentifier( postType );\n\t\t\tlet menuItemTitle =\n\t\t\t\tlabels.template_name ||\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t__( 'Single item: %s' ),\n\t\t\t\t\tlabels.singular_name\n\t\t\t\t);\n\t\t\tif ( _needsUniqueIdentifier ) {\n\t\t\t\tmenuItemTitle = labels.template_name\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: 1: Name of the template e.g: \"Single Item: Post\". 2: Slug of the post type e.g: \"book\".\n\t\t\t\t\t\t\t_x( '%1$s (%2$s)', 'post type menu label' ),\n\t\t\t\t\t\t\tlabels.template_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// translators: 1: Name of the post type e.g: \"Post\". 2: Slug of the post type e.g: \"book\".\n\t\t\t\t\t\t\t_x(\n\t\t\t\t\t\t\t\t'Single item: %1$s (%2$s)',\n\t\t\t\t\t\t\t\t'post type menu label'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tlabels.singular_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t );\n\t\t\t}\n\t\t\tconst menuItem = defaultTemplateType\n\t\t\t\t? {\n\t\t\t\t\t\t...defaultTemplateType,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tslug: generalTemplateSlug,\n\t\t\t\t\t\ttitle: menuItemTitle,\n\t\t\t\t\t\tdescription: sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t\t\t__( 'Displays a single item: %s.' ),\n\t\t\t\t\t\t\tlabels.singular_name\n\t\t\t\t\t\t),\n\t\t\t\t\t\t// `icon` is the `menu_icon` property of a post type. We\n\t\t\t\t\t\t// only handle `dashicons` for now, even if the `menu_icon`\n\t\t\t\t\t\t// also supports urls and svg as values.\n\t\t\t\t\t\ticon:\n\t\t\t\t\t\t\ttypeof icon === 'string' &&\n\t\t\t\t\t\t\ticon.startsWith( 'dashicons-' )\n\t\t\t\t\t\t\t\t? icon.slice( 10 )\n\t\t\t\t\t\t\t\t: post,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t };\n\t\t\tconst hasEntities = postTypesInfo?.[ slug ]?.hasEntities;\n\t\t\t// We have a different template creation flow only if they have entities.\n\t\t\tif ( hasEntities ) {\n\t\t\t\tmenuItem.onClick = ( template ) => {\n\t\t\t\t\tonClickMenuItem( {\n\t\t\t\t\t\ttype: 'postType',\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\trecordNamePath: 'title.rendered',\n\t\t\t\t\t\t\tqueryArgs: ( { search } ) => {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t_fields: 'id,title,slug,link',\n\t\t\t\t\t\t\t\t\torderBy: search ? 'relevance' : 'modified',\n\t\t\t\t\t\t\t\t\texclude:\n\t\t\t\t\t\t\t\t\t\tpostTypesInfo[ slug ]\n\t\t\t\t\t\t\t\t\t\t\t.existingEntitiesIds,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tgetSpecificTemplate: ( suggestion ) => {\n\t\t\t\t\t\t\t\tconst templateSlug = prefixSlug(\n\t\t\t\t\t\t\t\t\ttemplatePrefixes[ slug ],\n\t\t\t\t\t\t\t\t\tsuggestion.slug\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttitle: templateSlug,\n\t\t\t\t\t\t\t\t\tslug: templateSlug,\n\t\t\t\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tlabels,\n\t\t\t\t\t\thasGeneralTemplate,\n\t\t\t\t\t\ttemplate,\n\t\t\t\t\t} );\n\t\t\t\t};\n\t\t\t}\n\t\t\t// We don't need to add the menu item if there are no\n\t\t\t// entities and the general template exists.\n\t\t\tif ( ! hasGeneralTemplate || hasEntities ) {\n\t\t\t\taccumulator.push( menuItem );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t},\n\t\t[]\n\t);\n\t// Split menu items into two groups: one for the default post types\n\t// and one for the rest.\n\tconst postTypesMenuItems = useMemo(\n\t\t() =>\n\t\t\tmenuItems.reduce(\n\t\t\t\t( accumulator, postType ) => {\n\t\t\t\t\tconst { slug } = postType;\n\t\t\t\t\tlet key = 'postTypesMenuItems';\n\t\t\t\t\tif ( slug === 'page' ) {\n\t\t\t\t\t\tkey = 'defaultPostTypesMenuItems';\n\t\t\t\t\t}\n\t\t\t\t\taccumulator[ key ].push( postType );\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{ defaultPostTypesMenuItems: [], postTypesMenuItems: [] }\n\t\t\t),\n\t\t[ menuItems ]\n\t);\n\treturn postTypesMenuItems;\n};\n\nexport const useTaxonomiesMenuItems = ( onClickMenuItem ) => {\n\tconst publicTaxonomies = usePublicTaxonomies();\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\t// `category` and `post_tag` are special cases in template hierarchy.\n\tconst templatePrefixes = useMemo(\n\t\t() =>\n\t\t\tpublicTaxonomies?.reduce( ( accumulator, { slug } ) => {\n\t\t\t\tlet suffix = slug;\n\t\t\t\tif ( ! [ 'category', 'post_tag' ].includes( slug ) ) {\n\t\t\t\t\tsuffix = `taxonomy-${ suffix }`;\n\t\t\t\t}\n\t\t\t\tif ( slug === 'post_tag' ) {\n\t\t\t\t\tsuffix = `tag`;\n\t\t\t\t}\n\t\t\t\taccumulator[ slug ] = suffix;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicTaxonomies ]\n\t);\n\t// We need to keep track of naming conflicts. If a conflict\n\t// occurs, we need to add slug.\n\tconst taxonomyLabels = publicTaxonomies?.reduce(\n\t\t( accumulator, { labels } ) => {\n\t\t\tconst templateName = (\n\t\t\t\tlabels.template_name || labels.singular_name\n\t\t\t).toLowerCase();\n\t\t\taccumulator[ templateName ] =\n\t\t\t\t( accumulator[ templateName ] || 0 ) + 1;\n\t\t\treturn accumulator;\n\t\t},\n\t\t{}\n\t);\n\tconst needsUniqueIdentifier = ( labels, slug ) => {\n\t\tif ( [ 'category', 'post_tag' ].includes( slug ) ) {\n\t\t\treturn false;\n\t\t}\n\t\tconst templateName = (\n\t\t\tlabels.template_name || labels.singular_name\n\t\t).toLowerCase();\n\t\treturn taxonomyLabels[ templateName ] > 1 && templateName !== slug;\n\t};\n\tconst taxonomiesInfo = useEntitiesInfo( 'taxonomy', templatePrefixes );\n\tconst existingTemplateSlugs = ( existingTemplates || [] ).map(\n\t\t( { slug } ) => slug\n\t);\n\tconst menuItems = ( publicTaxonomies || [] ).reduce(\n\t\t( accumulator, taxonomy ) => {\n\t\t\tconst { slug, labels } = taxonomy;\n\t\t\t// We need to check if the general template is part of the\n\t\t\t// defaultTemplateTypes. If it is, just use that info and\n\t\t\t// augment it with the specific template functionality.\n\t\t\tconst generalTemplateSlug = templatePrefixes[ slug ];\n\t\t\tconst defaultTemplateType = defaultTemplateTypes?.find(\n\t\t\t\t( { slug: _slug } ) => _slug === generalTemplateSlug\n\t\t\t);\n\t\t\tconst hasGeneralTemplate =\n\t\t\t\texistingTemplateSlugs?.includes( generalTemplateSlug );\n\t\t\tconst _needsUniqueIdentifier = needsUniqueIdentifier(\n\t\t\t\tlabels,\n\t\t\t\tslug\n\t\t\t);\n\t\t\tlet menuItemTitle = labels.template_name || labels.singular_name;\n\t\t\tif ( _needsUniqueIdentifier ) {\n\t\t\t\tmenuItemTitle = labels.template_name\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: 1: Name of the template e.g: \"Products by Category\". 2: Slug of the taxonomy e.g: \"product_cat\".\n\t\t\t\t\t\t\t_x( '%1$s (%2$s)', 'taxonomy template menu label' ),\n\t\t\t\t\t\t\tlabels.template_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// translators: 1: Name of the taxonomy e.g: \"Category\". 2: Slug of the taxonomy e.g: \"product_cat\".\n\t\t\t\t\t\t\t_x( '%1$s (%2$s)', 'taxonomy menu label' ),\n\t\t\t\t\t\t\tlabels.singular_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t );\n\t\t\t}\n\t\t\tconst menuItem = defaultTemplateType\n\t\t\t\t? {\n\t\t\t\t\t\t...defaultTemplateType,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tslug: generalTemplateSlug,\n\t\t\t\t\t\ttitle: menuItemTitle,\n\t\t\t\t\t\tdescription: sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the taxonomy e.g: \"Product Categories\".\n\t\t\t\t\t\t\t__( 'Displays taxonomy: %s.' ),\n\t\t\t\t\t\t\tlabels.singular_name\n\t\t\t\t\t\t),\n\t\t\t\t\t\ticon: blockMeta,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t };\n\t\t\tconst hasEntities = taxonomiesInfo?.[ slug ]?.hasEntities;\n\t\t\t// We have a different template creation flow only if they have entities.\n\t\t\tif ( hasEntities ) {\n\t\t\t\tmenuItem.onClick = ( template ) => {\n\t\t\t\t\tonClickMenuItem( {\n\t\t\t\t\t\ttype: 'taxonomy',\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\tqueryArgs: ( { search } ) => {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t_fields: 'id,name,slug,link',\n\t\t\t\t\t\t\t\t\torderBy: search ? 'name' : 'count',\n\t\t\t\t\t\t\t\t\texclude:\n\t\t\t\t\t\t\t\t\t\ttaxonomiesInfo[ slug ]\n\t\t\t\t\t\t\t\t\t\t\t.existingEntitiesIds,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tgetSpecificTemplate: ( suggestion ) => {\n\t\t\t\t\t\t\t\tconst templateSlug = prefixSlug(\n\t\t\t\t\t\t\t\t\ttemplatePrefixes[ slug ],\n\t\t\t\t\t\t\t\t\tsuggestion.slug\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttitle: templateSlug,\n\t\t\t\t\t\t\t\t\tslug: templateSlug,\n\t\t\t\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tlabels,\n\t\t\t\t\t\thasGeneralTemplate,\n\t\t\t\t\t\ttemplate,\n\t\t\t\t\t} );\n\t\t\t\t};\n\t\t\t}\n\t\t\t// We don't need to add the menu item if there are no\n\t\t\t// entities and the general template exists.\n\t\t\tif ( ! hasGeneralTemplate || hasEntities ) {\n\t\t\t\taccumulator.push( menuItem );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t},\n\t\t[]\n\t);\n\t// Split menu items into two groups: one for the default taxonomies\n\t// and one for the rest.\n\tconst taxonomiesMenuItems = useMemo(\n\t\t() =>\n\t\t\tmenuItems.reduce(\n\t\t\t\t( accumulator, taxonomy ) => {\n\t\t\t\t\tconst { slug } = taxonomy;\n\t\t\t\t\tlet key = 'taxonomiesMenuItems';\n\t\t\t\t\tif ( [ 'category', 'tag' ].includes( slug ) ) {\n\t\t\t\t\t\tkey = 'defaultTaxonomiesMenuItems';\n\t\t\t\t\t}\n\t\t\t\t\taccumulator[ key ].push( taxonomy );\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{ defaultTaxonomiesMenuItems: [], taxonomiesMenuItems: [] }\n\t\t\t),\n\t\t[ menuItems ]\n\t);\n\treturn taxonomiesMenuItems;\n};\n\nconst USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX = { user: 'author' };\nconst USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS = { user: { who: 'authors' } };\nexport function useAuthorMenuItem( onClickMenuItem ) {\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\tconst authorInfo = useEntitiesInfo(\n\t\t'root',\n\t\tUSE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX,\n\t\tUSE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS\n\t);\n\tlet authorMenuItem = defaultTemplateTypes?.find(\n\t\t( { slug } ) => slug === 'author'\n\t);\n\tif ( ! authorMenuItem ) {\n\t\tauthorMenuItem = {\n\t\t\tdescription: __(\n\t\t\t\t'Displays latest posts written by a single author.'\n\t\t\t),\n\t\t\tslug: 'author',\n\t\t\ttitle: 'Author',\n\t\t};\n\t}\n\tconst hasGeneralTemplate = !! existingTemplates?.find(\n\t\t( { slug } ) => slug === 'author'\n\t);\n\tif ( authorInfo.user?.hasEntities ) {\n\t\tauthorMenuItem = { ...authorMenuItem, templatePrefix: 'author' };\n\t\tauthorMenuItem.onClick = ( template ) => {\n\t\t\tonClickMenuItem( {\n\t\t\t\ttype: 'root',\n\t\t\t\tslug: 'user',\n\t\t\t\tconfig: {\n\t\t\t\t\tqueryArgs: ( { search } ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t_fields: 'id,name,slug,link',\n\t\t\t\t\t\t\torderBy: search ? 'name' : 'registered_date',\n\t\t\t\t\t\t\texclude: authorInfo.user.existingEntitiesIds,\n\t\t\t\t\t\t\twho: 'authors',\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t\tgetSpecificTemplate: ( suggestion ) => {\n\t\t\t\t\t\tconst templateSlug = prefixSlug(\n\t\t\t\t\t\t\t'author',\n\t\t\t\t\t\t\tsuggestion.slug\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttitle: templateSlug,\n\t\t\t\t\t\t\tslug: templateSlug,\n\t\t\t\t\t\t\ttemplatePrefix: 'author',\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tlabels: {\n\t\t\t\t\tsingular_name: __( 'Author' ),\n\t\t\t\t\tsearch_items: __( 'Search Authors' ),\n\t\t\t\t\tnot_found: __( 'No authors found.' ),\n\t\t\t\t\tall_items: __( 'All Authors' ),\n\t\t\t\t},\n\t\t\t\thasGeneralTemplate,\n\t\t\t\ttemplate,\n\t\t\t} );\n\t\t};\n\t}\n\tif ( ! hasGeneralTemplate || authorInfo.user?.hasEntities ) {\n\t\treturn authorMenuItem;\n\t}\n}\n\n/**\n * Helper hook that filters all the existing templates by the given\n * object with the entity's slug as key and the template prefix as value.\n *\n * Example:\n * `existingTemplates` is: [ { slug: 'tag-apple' }, { slug: 'page-about' }, { slug: 'tag' } ]\n * `templatePrefixes` is: { post_tag: 'tag' }\n * It will return: { post_tag: ['apple'] }\n *\n * Note: We append the `-` to the given template prefix in this function for our checks.\n *\n * @param {Record<string,string>} templatePrefixes An object with the entity's slug as key and the template prefix as value.\n * @return {Record<string,string[]>} An object with the entity's slug as key and an array with the existing template slugs as value.\n */\nconst useExistingTemplateSlugs = ( templatePrefixes ) => {\n\tconst existingTemplates = useExistingTemplates();\n\tconst existingSlugs = useMemo( () => {\n\t\treturn Object.entries( templatePrefixes || {} ).reduce(\n\t\t\t( accumulator, [ slug, prefix ] ) => {\n\t\t\t\tconst slugsWithTemplates = ( existingTemplates || [] ).reduce(\n\t\t\t\t\t( _accumulator, existingTemplate ) => {\n\t\t\t\t\t\tconst _prefix = `${ prefix }-`;\n\t\t\t\t\t\tif ( existingTemplate.slug.startsWith( _prefix ) ) {\n\t\t\t\t\t\t\t_accumulator.push(\n\t\t\t\t\t\t\t\texistingTemplate.slug.substring(\n\t\t\t\t\t\t\t\t\t_prefix.length\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn _accumulator;\n\t\t\t\t\t},\n\t\t\t\t\t[]\n\t\t\t\t);\n\t\t\t\tif ( slugsWithTemplates.length ) {\n\t\t\t\t\taccumulator[ slug ] = slugsWithTemplates;\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t}, [ templatePrefixes, existingTemplates ] );\n\treturn existingSlugs;\n};\n\n/**\n * Helper hook that finds the existing records with an associated template,\n * as they need to be excluded from the template suggestions.\n *\n * @param {string} entityName The entity's name.\n * @param {Record<string,string>} templatePrefixes An object with the entity's slug as key and the template prefix as value.\n * @param {Record<string,Object>} additionalQueryParameters An object with the entity's slug as key and additional query parameters as value.\n * @return {Record<string,EntitiesInfo>} An object with the entity's slug as key and the existing records as value.\n */\nconst useTemplatesToExclude = (\n\tentityName,\n\ttemplatePrefixes,\n\tadditionalQueryParameters = {}\n) => {\n\tconst slugsToExcludePerEntity =\n\t\tuseExistingTemplateSlugs( templatePrefixes );\n\tconst recordsToExcludePerEntity = useSelect(\n\t\t( select ) => {\n\t\t\treturn Object.entries( slugsToExcludePerEntity || {} ).reduce(\n\t\t\t\t( accumulator, [ slug, slugsWithTemplates ] ) => {\n\t\t\t\t\tconst entitiesWithTemplates = select(\n\t\t\t\t\t\tcoreStore\n\t\t\t\t\t).getEntityRecords( entityName, slug, {\n\t\t\t\t\t\t_fields: 'id',\n\t\t\t\t\t\tcontext: 'view',\n\t\t\t\t\t\tslug: slugsWithTemplates,\n\t\t\t\t\t\t...additionalQueryParameters[ slug ],\n\t\t\t\t\t} );\n\t\t\t\t\tif ( entitiesWithTemplates?.length ) {\n\t\t\t\t\t\taccumulator[ slug ] = entitiesWithTemplates;\n\t\t\t\t\t}\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\t\t},\n\t\t[ slugsToExcludePerEntity ]\n\t);\n\treturn recordsToExcludePerEntity;\n};\n\n/**\n * Helper hook that returns information about an entity having\n * records that we can create a specific template for.\n *\n * For example we can search for `terms` in `taxonomy` entity or\n * `posts` in `postType` entity.\n *\n * First we need to find the existing records with an associated template,\n * to query afterwards for any remaining record, by excluding them.\n *\n * @param {string} entityName The entity's name.\n * @param {Record<string,string>} templatePrefixes An object with the entity's slug as key and the template prefix as value.\n * @param {Record<string,Object>} additionalQueryParameters An object with the entity's slug as key and additional query parameters as value.\n * @return {Record<string,EntitiesInfo>} An object with the entity's slug as key and the EntitiesInfo as value.\n */\nconst useEntitiesInfo = (\n\tentityName,\n\ttemplatePrefixes,\n\tadditionalQueryParameters = EMPTY_OBJECT\n) => {\n\tconst recordsToExcludePerEntity = useTemplatesToExclude(\n\t\tentityName,\n\t\ttemplatePrefixes,\n\t\tadditionalQueryParameters\n\t);\n\tconst entitiesHasRecords = useSelect(\n\t\t( select ) => {\n\t\t\treturn Object.keys( templatePrefixes || {} ).reduce(\n\t\t\t\t( accumulator, slug ) => {\n\t\t\t\t\tconst existingEntitiesIds =\n\t\t\t\t\t\trecordsToExcludePerEntity?.[ slug ]?.map(\n\t\t\t\t\t\t\t( { id } ) => id\n\t\t\t\t\t\t) || [];\n\t\t\t\t\taccumulator[ slug ] = !! select(\n\t\t\t\t\t\tcoreStore\n\t\t\t\t\t).getEntityRecords( entityName, slug, {\n\t\t\t\t\t\tper_page: 1,\n\t\t\t\t\t\t_fields: 'id',\n\t\t\t\t\t\tcontext: 'view',\n\t\t\t\t\t\texclude: existingEntitiesIds,\n\t\t\t\t\t\t...additionalQueryParameters[ slug ],\n\t\t\t\t\t} )?.length;\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\t\t},\n\t\t[\n\t\t\ttemplatePrefixes,\n\t\t\trecordsToExcludePerEntity,\n\t\t\tentityName,\n\t\t\tadditionalQueryParameters,\n\t\t]\n\t);\n\tconst entitiesInfo = useMemo( () => {\n\t\treturn Object.keys( templatePrefixes || {} ).reduce(\n\t\t\t( accumulator, slug ) => {\n\t\t\t\tconst existingEntitiesIds =\n\t\t\t\t\trecordsToExcludePerEntity?.[ slug ]?.map(\n\t\t\t\t\t\t( { id } ) => id\n\t\t\t\t\t) || [];\n\t\t\t\taccumulator[ slug ] = {\n\t\t\t\t\thasEntities: entitiesHasRecords[ slug ],\n\t\t\t\t\texistingEntitiesIds,\n\t\t\t\t};\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t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yBAAqB;AAAA,IAC1B,CAAE,WAAY;AACb,aAAO,OAAO,KAAM,oBAAoB,CAAC,CAAE,EAAE;AAAA,QAC5C,CAAE,aAAa,SAAU;AACxB,gBAAM,sBACL,4BAA6B,IAAK,GAAG;AAAA,YACpC,CAAE,EAAE,GAAG,MAAO;AAAA,UACf,KAAK,CAAC;AACP,sBAAa,IAAK,IAAI,CAAC,CAAE;AAAA,YACxB,iBAAAA;AAAA,UACD,EAAE,iBAAkB,YAAY,MAAM;AAAA,YACrC,UAAU;AAAA,YACV,SAAS;AAAA,YACT,SAAS;AAAA,YACT,SAAS;AAAA,YACT,GAAG,0BAA2B,IAAK;AAAA,UACpC,CAAE,GAAG;AACL,iBAAO;AAAA,QACR;AAAA,QACA,CAAC;AAAA,MACF;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AACA,QAAM,mBAAe,wBAAS,MAAM;AACnC,WAAO,OAAO,KAAM,oBAAoB,CAAC,CAAE,EAAE;AAAA,MAC5C,CAAE,aAAa,SAAU;AACxB,cAAM,sBACL,4BAA6B,IAAK,GAAG;AAAA,UACpC,CAAE,EAAE,GAAG,MAAO;AAAA,QACf,KAAK,CAAC;AACP,oBAAa,IAAK,IAAI;AAAA,UACrB,aAAa,mBAAoB,IAAK;AAAA,UACtC;AAAA,QACD;AACA,eAAO;AAAA,MACR;AAAA,MACA,CAAC;AAAA,IACF;AAAA,EACD,GAAG,CAAE,kBAAkB,2BAA2B,kBAAmB,CAAE;AACvE,SAAO;AACR;",
|
|
6
|
+
"names": ["coreStore"]
|
|
7
|
+
}
|
|
@@ -101,12 +101,14 @@ var previewField = {
|
|
|
101
101
|
var descriptionField = {
|
|
102
102
|
label: (0, import_i18n.__)("Description"),
|
|
103
103
|
id: "description",
|
|
104
|
-
render: function RenderDescription({ item }) {
|
|
104
|
+
render: window?.__experimentalTemplateActivate ? function RenderDescription({ item }) {
|
|
105
105
|
const defaultTemplateTypes = useAllDefaultTemplateTypes();
|
|
106
106
|
const defaultTemplateType = defaultTemplateTypes.find(
|
|
107
107
|
(type) => type.slug === item.slug
|
|
108
108
|
);
|
|
109
109
|
return item.description ? (0, import_html_entities.decodeEntities)(item.description) : defaultTemplateType?.description;
|
|
110
|
+
} : ({ item }) => {
|
|
111
|
+
return item.description && (0, import_html_entities.decodeEntities)(item.description);
|
|
110
112
|
},
|
|
111
113
|
enableSorting: false,
|
|
112
114
|
enableGlobalSearch: true
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/page-templates/fields.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\t__experimentalHStack as HStack,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useState, useMemo } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { parse } from '@wordpress/blocks';\nimport { BlockPreview } from '@wordpress/block-editor';\nimport {\n\tEditorProvider,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport {\n\tprivateApis as corePrivateApis,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useAddedBy } from './hooks';\nimport { useDefaultTemplateTypes } from '../add-new-template/utils';\nimport usePatternSettings from '../page-patterns/use-pattern-settings';\nimport { unlock } from '../../lock-unlock';\n\nconst { Badge } = unlock( componentsPrivateApis );\nconst { useEntityRecordsWithPermissions } = unlock( corePrivateApis );\nconst { useStyle } = unlock( editorPrivateApis );\n\nfunction useAllDefaultTemplateTypes() {\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\tconst { records: staticRecords } = useEntityRecordsWithPermissions(\n\t\t'root',\n\t\t'registeredTemplate'\n\t);\n\treturn [\n\t\t...defaultTemplateTypes,\n\t\t...staticRecords\n\t\t\t?.filter( ( record ) => ! record.is_custom )\n\t\t\t.map( ( record ) => {\n\t\t\t\treturn {\n\t\t\t\t\tslug: record.slug,\n\t\t\t\t\ttitle: record.title.rendered,\n\t\t\t\t\tdescription: record.description,\n\t\t\t\t};\n\t\t\t} ),\n\t];\n}\n\nfunction PreviewField( { item } ) {\n\tconst settings = usePatternSettings();\n\tconst backgroundColor = useStyle( 'color.background' ) ?? 'white';\n\tconst blocks = useMemo( () => {\n\t\treturn parse( item.content.raw );\n\t}, [ item.content.raw ] );\n\n\tconst isEmpty = ! blocks?.length;\n\t// Wrap everything in a block editor provider to ensure 'styles' that are needed\n\t// for the previews are synced between the site editor store and the block editor store.\n\t// Additionally we need to have the `__experimentalBlockPatterns` setting in order to\n\t// render patterns inside the previews.\n\t// TODO: Same approach is used in the patterns list and it becomes obvious that some of\n\t// the block editor settings are needed in context where we don't have the block editor.\n\t// Explore how we can solve this in a better way.\n\treturn (\n\t\t<EditorProvider post={ item } settings={ settings }>\n\t\t\t<div\n\t\t\t\tclassName=\"page-templates-preview-field\"\n\t\t\t\tstyle={ { backgroundColor } }\n\t\t\t>\n\t\t\t\t{ isEmpty && __( 'Empty template' ) }\n\t\t\t\t{ ! isEmpty && (\n\t\t\t\t\t<BlockPreview.Async>\n\t\t\t\t\t\t<BlockPreview blocks={ blocks } />\n\t\t\t\t\t</BlockPreview.Async>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</EditorProvider>\n\t);\n}\n\nexport const previewField = {\n\tlabel: __( 'Preview' ),\n\tid: 'preview',\n\trender: PreviewField,\n\tenableSorting: false,\n};\n\nexport const descriptionField = {\n\tlabel: __( 'Description' ),\n\tid: 'description',\n\trender: function RenderDescription( { item } ) {\n\t\tconst defaultTemplateTypes = useAllDefaultTemplateTypes();\n\t\tconst defaultTemplateType = defaultTemplateTypes.find(\n\t\t\t( type ) => type.slug === item.slug\n\t\t);\n\t\treturn item.description\n\t\t\t? decodeEntities( item.description )\n\t\t\t: defaultTemplateType?.description;\n\t},\n\tenableSorting: false,\n\tenableGlobalSearch: true,\n};\n\nfunction AuthorField( { item } ) {\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\tconst { text, icon, imageUrl } = useAddedBy( item.type, item.id );\n\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ imageUrl && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ clsx( 'page-templates-author-field__avatar', {\n\t\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<img\n\t\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\tsrc={ imageUrl }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ ! imageUrl && (\n\t\t\t\t<div className=\"page-templates-author-field__icon\">\n\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span className=\"page-templates-author-field__name\">{ text }</span>\n\t\t</HStack>\n\t);\n}\n\nexport const authorField = {\n\tlabel: __( 'Author' ),\n\tid: 'author',\n\tgetValue: ( { item } ) => item.author_text ?? item.author,\n\trender: AuthorField,\n};\n\nexport const activeField = {\n\tlabel: __( 'Status' ),\n\tid: 'active',\n\ttype: 'boolean',\n\tgetValue: ( { item } ) => item._isActive,\n\trender: function Render( { item } ) {\n\t\tconst activeLabel = item._isCustom\n\t\t\t? _x( 'Active when used', 'template' )\n\t\t\t: _x( 'Active', 'template' );\n\t\tconst activeIntent = item._isCustom ? 'info' : 'success';\n\t\tconst isActive = item._isActive;\n\t\treturn (\n\t\t\t<Badge intent={ isActive ? activeIntent : 'default' }>\n\t\t\t\t{ isActive ? activeLabel : _x( 'Inactive', 'template' ) }\n\t\t\t</Badge>\n\t\t);\n\t},\n};\n\nexport const useThemeField = () => {\n\tconst activeTheme = useSelect( ( select ) =>\n\t\tselect( coreStore ).getCurrentTheme()\n\t);\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tlabel: __( 'Compatible Theme' ),\n\t\t\tid: 'theme',\n\t\t\tgetValue: ( { item } ) => item.theme,\n\t\t\trender: function Render( { item } ) {\n\t\t\t\tif ( item.theme === activeTheme.stylesheet ) {\n\t\t\t\t\treturn <Badge intent=\"success\">{ item.theme }</Badge>;\n\t\t\t\t}\n\t\t\t\treturn <Badge intent=\"error\">{ item.theme }</Badge>;\n\t\t\t},\n\t\t} ),\n\t\t[ activeTheme ]\n\t);\n};\n\nexport const slugField = {\n\tlabel: __( 'Template Type' ),\n\tid: 'slug',\n\tgetValue: ( { item } ) => item.slug,\n\trender: function Render( { item } ) {\n\t\tconst defaultTemplateTypes = useAllDefaultTemplateTypes();\n\t\tconst defaultTemplateType = defaultTemplateTypes.find(\n\t\t\t( type ) => type.slug === item.slug\n\t\t);\n\t\treturn defaultTemplateType?.title || _x( 'Custom', 'template type' );\n\t},\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,wBAIO;AACP,kBAAuB;AACvB,qBAAkC;AAClC,2BAA+B;AAC/B,oBAAsB;AACtB,0BAA6B;AAC7B,oBAGO;AACP,uBAGO;AACP,kBAA0B;AAK1B,mBAA2B;AAC3B,mBAAwC;AACxC,kCAA+B;AAC/B,yBAAuB;AA2CpB;AAzCH,IAAM,EAAE,MAAM,QAAI,2BAAQ,kBAAAA,WAAsB;AAChD,IAAM,EAAE,gCAAgC,QAAI,2BAAQ,iBAAAC,WAAgB;AACpE,IAAM,EAAE,SAAS,QAAI,2BAAQ,cAAAC,WAAkB;AAE/C,SAAS,6BAA6B;AACrC,QAAM,2BAAuB,sCAAwB;AACrD,QAAM,EAAE,SAAS,cAAc,IAAI;AAAA,IAClC;AAAA,IACA;AAAA,EACD;AACA,SAAO;AAAA,IACN,GAAG;AAAA,IACH,GAAG,eACA,OAAQ,CAAE,WAAY,CAAE,OAAO,SAAU,EAC1C,IAAK,CAAE,WAAY;AACnB,aAAO;AAAA,QACN,MAAM,OAAO;AAAA,QACb,OAAO,OAAO,MAAM;AAAA,QACpB,aAAa,OAAO;AAAA,MACrB;AAAA,IACD,CAAE;AAAA,EACJ;AACD;AAEA,SAAS,aAAc,EAAE,KAAK,GAAI;AACjC,QAAM,eAAW,4BAAAC,SAAmB;AACpC,QAAM,kBAAkB,SAAU,kBAAmB,KAAK;AAC1D,QAAM,aAAS,wBAAS,MAAM;AAC7B,eAAO,qBAAO,KAAK,QAAQ,GAAI;AAAA,EAChC,GAAG,CAAE,KAAK,QAAQ,GAAI,CAAE;AAExB,QAAM,UAAU,CAAE,QAAQ;AAQ1B,SACC,4CAAC,gCAAe,MAAO,MAAO,UAC7B;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,OAAQ,EAAE,gBAAgB;AAAA,MAExB;AAAA,uBAAW,gBAAI,gBAAiB;AAAA,QAChC,CAAE,WACH,4CAAC,iCAAa,OAAb,EACA,sDAAC,oCAAa,QAAkB,GACjC;AAAA;AAAA;AAAA,EAEF,GACD;AAEF;AAEO,IAAM,eAAe;AAAA,EAC3B,WAAO,gBAAI,SAAU;AAAA,EACrB,IAAI;AAAA,EACJ,QAAQ;AAAA,EACR,eAAe;AAChB;AAEO,IAAM,mBAAmB;AAAA,EAC/B,WAAO,gBAAI,aAAc;AAAA,EACzB,IAAI;AAAA,EACJ,QAAQ,SAAS,kBAAmB,EAAE,KAAK,GAAI;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\t__experimentalHStack as HStack,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useState, useMemo } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { parse } from '@wordpress/blocks';\nimport { BlockPreview } from '@wordpress/block-editor';\nimport {\n\tEditorProvider,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport {\n\tprivateApis as corePrivateApis,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useAddedBy } from './hooks';\nimport { useDefaultTemplateTypes } from '../add-new-template/utils';\nimport usePatternSettings from '../page-patterns/use-pattern-settings';\nimport { unlock } from '../../lock-unlock';\n\nconst { Badge } = unlock( componentsPrivateApis );\nconst { useEntityRecordsWithPermissions } = unlock( corePrivateApis );\nconst { useStyle } = unlock( editorPrivateApis );\n\nfunction useAllDefaultTemplateTypes() {\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\tconst { records: staticRecords } = useEntityRecordsWithPermissions(\n\t\t'root',\n\t\t'registeredTemplate'\n\t);\n\treturn [\n\t\t...defaultTemplateTypes,\n\t\t...staticRecords\n\t\t\t?.filter( ( record ) => ! record.is_custom )\n\t\t\t.map( ( record ) => {\n\t\t\t\treturn {\n\t\t\t\t\tslug: record.slug,\n\t\t\t\t\ttitle: record.title.rendered,\n\t\t\t\t\tdescription: record.description,\n\t\t\t\t};\n\t\t\t} ),\n\t];\n}\n\nfunction PreviewField( { item } ) {\n\tconst settings = usePatternSettings();\n\tconst backgroundColor = useStyle( 'color.background' ) ?? 'white';\n\tconst blocks = useMemo( () => {\n\t\treturn parse( item.content.raw );\n\t}, [ item.content.raw ] );\n\n\tconst isEmpty = ! blocks?.length;\n\t// Wrap everything in a block editor provider to ensure 'styles' that are needed\n\t// for the previews are synced between the site editor store and the block editor store.\n\t// Additionally we need to have the `__experimentalBlockPatterns` setting in order to\n\t// render patterns inside the previews.\n\t// TODO: Same approach is used in the patterns list and it becomes obvious that some of\n\t// the block editor settings are needed in context where we don't have the block editor.\n\t// Explore how we can solve this in a better way.\n\treturn (\n\t\t<EditorProvider post={ item } settings={ settings }>\n\t\t\t<div\n\t\t\t\tclassName=\"page-templates-preview-field\"\n\t\t\t\tstyle={ { backgroundColor } }\n\t\t\t>\n\t\t\t\t{ isEmpty && __( 'Empty template' ) }\n\t\t\t\t{ ! isEmpty && (\n\t\t\t\t\t<BlockPreview.Async>\n\t\t\t\t\t\t<BlockPreview blocks={ blocks } />\n\t\t\t\t\t</BlockPreview.Async>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</EditorProvider>\n\t);\n}\n\nexport const previewField = {\n\tlabel: __( 'Preview' ),\n\tid: 'preview',\n\trender: PreviewField,\n\tenableSorting: false,\n};\n\nexport const descriptionField = {\n\tlabel: __( 'Description' ),\n\tid: 'description',\n\trender: window?.__experimentalTemplateActivate\n\t\t? function RenderDescription( { item } ) {\n\t\t\t\tconst defaultTemplateTypes = useAllDefaultTemplateTypes();\n\t\t\t\tconst defaultTemplateType = defaultTemplateTypes.find(\n\t\t\t\t\t( type ) => type.slug === item.slug\n\t\t\t\t);\n\t\t\t\treturn item.description\n\t\t\t\t\t? decodeEntities( item.description )\n\t\t\t\t\t: defaultTemplateType?.description;\n\t\t }\n\t\t: ( { item } ) => {\n\t\t\t\treturn item.description && decodeEntities( item.description );\n\t\t },\n\tenableSorting: false,\n\tenableGlobalSearch: true,\n};\n\nfunction AuthorField( { item } ) {\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\tconst { text, icon, imageUrl } = useAddedBy( item.type, item.id );\n\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ imageUrl && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ clsx( 'page-templates-author-field__avatar', {\n\t\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<img\n\t\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\tsrc={ imageUrl }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ ! imageUrl && (\n\t\t\t\t<div className=\"page-templates-author-field__icon\">\n\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span className=\"page-templates-author-field__name\">{ text }</span>\n\t\t</HStack>\n\t);\n}\n\nexport const authorField = {\n\tlabel: __( 'Author' ),\n\tid: 'author',\n\tgetValue: ( { item } ) => item.author_text ?? item.author,\n\trender: AuthorField,\n};\n\nexport const activeField = {\n\tlabel: __( 'Status' ),\n\tid: 'active',\n\ttype: 'boolean',\n\tgetValue: ( { item } ) => item._isActive,\n\trender: function Render( { item } ) {\n\t\tconst activeLabel = item._isCustom\n\t\t\t? _x( 'Active when used', 'template' )\n\t\t\t: _x( 'Active', 'template' );\n\t\tconst activeIntent = item._isCustom ? 'info' : 'success';\n\t\tconst isActive = item._isActive;\n\t\treturn (\n\t\t\t<Badge intent={ isActive ? activeIntent : 'default' }>\n\t\t\t\t{ isActive ? activeLabel : _x( 'Inactive', 'template' ) }\n\t\t\t</Badge>\n\t\t);\n\t},\n};\n\nexport const useThemeField = () => {\n\tconst activeTheme = useSelect( ( select ) =>\n\t\tselect( coreStore ).getCurrentTheme()\n\t);\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tlabel: __( 'Compatible Theme' ),\n\t\t\tid: 'theme',\n\t\t\tgetValue: ( { item } ) => item.theme,\n\t\t\trender: function Render( { item } ) {\n\t\t\t\tif ( item.theme === activeTheme.stylesheet ) {\n\t\t\t\t\treturn <Badge intent=\"success\">{ item.theme }</Badge>;\n\t\t\t\t}\n\t\t\t\treturn <Badge intent=\"error\">{ item.theme }</Badge>;\n\t\t\t},\n\t\t} ),\n\t\t[ activeTheme ]\n\t);\n};\n\nexport const slugField = {\n\tlabel: __( 'Template Type' ),\n\tid: 'slug',\n\tgetValue: ( { item } ) => item.slug,\n\trender: function Render( { item } ) {\n\t\tconst defaultTemplateTypes = useAllDefaultTemplateTypes();\n\t\tconst defaultTemplateType = defaultTemplateTypes.find(\n\t\t\t( type ) => type.slug === item.slug\n\t\t);\n\t\treturn defaultTemplateType?.title || _x( 'Custom', 'template type' );\n\t},\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,wBAIO;AACP,kBAAuB;AACvB,qBAAkC;AAClC,2BAA+B;AAC/B,oBAAsB;AACtB,0BAA6B;AAC7B,oBAGO;AACP,uBAGO;AACP,kBAA0B;AAK1B,mBAA2B;AAC3B,mBAAwC;AACxC,kCAA+B;AAC/B,yBAAuB;AA2CpB;AAzCH,IAAM,EAAE,MAAM,QAAI,2BAAQ,kBAAAA,WAAsB;AAChD,IAAM,EAAE,gCAAgC,QAAI,2BAAQ,iBAAAC,WAAgB;AACpE,IAAM,EAAE,SAAS,QAAI,2BAAQ,cAAAC,WAAkB;AAE/C,SAAS,6BAA6B;AACrC,QAAM,2BAAuB,sCAAwB;AACrD,QAAM,EAAE,SAAS,cAAc,IAAI;AAAA,IAClC;AAAA,IACA;AAAA,EACD;AACA,SAAO;AAAA,IACN,GAAG;AAAA,IACH,GAAG,eACA,OAAQ,CAAE,WAAY,CAAE,OAAO,SAAU,EAC1C,IAAK,CAAE,WAAY;AACnB,aAAO;AAAA,QACN,MAAM,OAAO;AAAA,QACb,OAAO,OAAO,MAAM;AAAA,QACpB,aAAa,OAAO;AAAA,MACrB;AAAA,IACD,CAAE;AAAA,EACJ;AACD;AAEA,SAAS,aAAc,EAAE,KAAK,GAAI;AACjC,QAAM,eAAW,4BAAAC,SAAmB;AACpC,QAAM,kBAAkB,SAAU,kBAAmB,KAAK;AAC1D,QAAM,aAAS,wBAAS,MAAM;AAC7B,eAAO,qBAAO,KAAK,QAAQ,GAAI;AAAA,EAChC,GAAG,CAAE,KAAK,QAAQ,GAAI,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CAAC,SAAM,QAAO,SAAU,eAAK,OAAO;AAAA,MAC5C;AAAA,IACD;AAAA,IACA,CAAE,WAAY;AAAA,EACf;AACD;AAEO,IAAM,YAAY;AAAA,EACxB,WAAO,gBAAI,eAAgB;AAAA,EAC3B,IAAI;AAAA,EACJ,UAAU,CAAE,EAAE,KAAK,MAAO,KAAK;AAAA,EAC/B,QAAQ,SAASA,QAAQ,EAAE,KAAK,GAAI;AACnC,UAAM,uBAAuB,2BAA2B;AACxD,UAAM,sBAAsB,qBAAqB;AAAA,MAChD,CAAE,SAAU,KAAK,SAAS,KAAK;AAAA,IAChC;AACA,WAAO,qBAAqB,aAAS,gBAAI,UAAU,eAAgB;AAAA,EACpE;AACD;",
|
|
6
6
|
"names": ["componentsPrivateApis", "corePrivateApis", "editorPrivateApis", "usePatternSettings", "HStack", "clsx", "coreStore", "Render"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// packages/edit-site/src/components/page-templates/index-legacy.js
|
|
31
|
+
var index_legacy_exports = {};
|
|
32
|
+
__export(index_legacy_exports, {
|
|
33
|
+
default: () => PageTemplates
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(index_legacy_exports);
|
|
36
|
+
var import_admin_ui = require("@wordpress/admin-ui");
|
|
37
|
+
var import_i18n = require("@wordpress/i18n");
|
|
38
|
+
var import_element = require("@wordpress/element");
|
|
39
|
+
var import_core_data = require("@wordpress/core-data");
|
|
40
|
+
var import_dataviews = require("@wordpress/dataviews");
|
|
41
|
+
var import_router = require("@wordpress/router");
|
|
42
|
+
var import_editor = require("@wordpress/editor");
|
|
43
|
+
var import_url = require("@wordpress/url");
|
|
44
|
+
var import_compose = require("@wordpress/compose");
|
|
45
|
+
var import_views = require("@wordpress/views");
|
|
46
|
+
var import_components = require("@wordpress/components");
|
|
47
|
+
var import_add_new_template_legacy = __toESM(require("../add-new-template-legacy"));
|
|
48
|
+
var import_constants = require("../../utils/constants");
|
|
49
|
+
var import_lock_unlock = require("../../lock-unlock");
|
|
50
|
+
var import_dataviews_actions = require("../dataviews-actions");
|
|
51
|
+
var import_fields = require("./fields");
|
|
52
|
+
var import_view_utils = require("./view-utils");
|
|
53
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
54
|
+
var { usePostActions, templateTitleField } = (0, import_lock_unlock.unlock)(import_editor.privateApis);
|
|
55
|
+
var { useHistory, useLocation } = (0, import_lock_unlock.unlock)(import_router.privateApis);
|
|
56
|
+
var { useEntityRecordsWithPermissions } = (0, import_lock_unlock.unlock)(import_core_data.privateApis);
|
|
57
|
+
function PageTemplates() {
|
|
58
|
+
const { path, query } = useLocation();
|
|
59
|
+
const { activeView = "active", postId } = query;
|
|
60
|
+
const [selection, setSelection] = (0, import_element.useState)([postId]);
|
|
61
|
+
const defaultView = (0, import_element.useMemo)(() => {
|
|
62
|
+
return (0, import_view_utils.getDefaultView)(activeView);
|
|
63
|
+
}, [activeView]);
|
|
64
|
+
const { view, updateView, isModified, resetToDefault } = (0, import_views.useView)({
|
|
65
|
+
kind: "postType",
|
|
66
|
+
name: import_constants.TEMPLATE_POST_TYPE,
|
|
67
|
+
slug: activeView,
|
|
68
|
+
defaultView,
|
|
69
|
+
queryParams: {
|
|
70
|
+
page: query.pageNumber,
|
|
71
|
+
search: query.search
|
|
72
|
+
},
|
|
73
|
+
onChangeQueryParams: (newQueryParams) => {
|
|
74
|
+
history.navigate(
|
|
75
|
+
(0, import_url.addQueryArgs)(path, {
|
|
76
|
+
...query,
|
|
77
|
+
pageNumber: newQueryParams.page,
|
|
78
|
+
search: newQueryParams.search || void 0
|
|
79
|
+
})
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
const { records, isResolving: isLoadingData } = useEntityRecordsWithPermissions("postType", import_constants.TEMPLATE_POST_TYPE, {
|
|
84
|
+
per_page: -1
|
|
85
|
+
});
|
|
86
|
+
const history = useHistory();
|
|
87
|
+
const onChangeSelection = (0, import_element.useCallback)(
|
|
88
|
+
(items) => {
|
|
89
|
+
setSelection(items);
|
|
90
|
+
if (view?.type === "list") {
|
|
91
|
+
history.navigate(
|
|
92
|
+
(0, import_url.addQueryArgs)(path, {
|
|
93
|
+
postId: items.length === 1 ? items[0] : void 0
|
|
94
|
+
})
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
[history, path, view?.type]
|
|
99
|
+
);
|
|
100
|
+
const authors = (0, import_element.useMemo)(() => {
|
|
101
|
+
if (!records) {
|
|
102
|
+
return [];
|
|
103
|
+
}
|
|
104
|
+
const authorsSet = /* @__PURE__ */ new Set();
|
|
105
|
+
records.forEach((template) => {
|
|
106
|
+
authorsSet.add(template.author_text);
|
|
107
|
+
});
|
|
108
|
+
return Array.from(authorsSet).map((author) => ({
|
|
109
|
+
value: author,
|
|
110
|
+
label: author
|
|
111
|
+
}));
|
|
112
|
+
}, [records]);
|
|
113
|
+
const fields = (0, import_element.useMemo)(
|
|
114
|
+
() => [
|
|
115
|
+
import_fields.previewField,
|
|
116
|
+
templateTitleField,
|
|
117
|
+
import_fields.descriptionField,
|
|
118
|
+
{
|
|
119
|
+
...import_fields.authorField,
|
|
120
|
+
elements: authors
|
|
121
|
+
}
|
|
122
|
+
],
|
|
123
|
+
[authors]
|
|
124
|
+
);
|
|
125
|
+
const { data, paginationInfo } = (0, import_element.useMemo)(() => {
|
|
126
|
+
return (0, import_dataviews.filterSortAndPaginate)(records, view, fields);
|
|
127
|
+
}, [records, view, fields]);
|
|
128
|
+
const postTypeActions = usePostActions({
|
|
129
|
+
postType: import_constants.TEMPLATE_POST_TYPE,
|
|
130
|
+
context: "list"
|
|
131
|
+
});
|
|
132
|
+
const editAction = (0, import_dataviews_actions.useEditPostAction)();
|
|
133
|
+
const actions = (0, import_element.useMemo)(
|
|
134
|
+
() => [editAction, ...postTypeActions],
|
|
135
|
+
[postTypeActions, editAction]
|
|
136
|
+
);
|
|
137
|
+
const onChangeView = (0, import_compose.useEvent)((newView) => {
|
|
138
|
+
if (newView.type !== view.type) {
|
|
139
|
+
history.invalidate();
|
|
140
|
+
}
|
|
141
|
+
updateView(newView);
|
|
142
|
+
});
|
|
143
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
144
|
+
import_admin_ui.Page,
|
|
145
|
+
{
|
|
146
|
+
className: "edit-site-page-templates",
|
|
147
|
+
title: (0, import_i18n.__)("Templates"),
|
|
148
|
+
actions: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
149
|
+
isModified && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
150
|
+
import_components.Button,
|
|
151
|
+
{
|
|
152
|
+
__next40pxDefaultSize: true,
|
|
153
|
+
onClick: () => {
|
|
154
|
+
resetToDefault();
|
|
155
|
+
history.invalidate();
|
|
156
|
+
},
|
|
157
|
+
children: (0, import_i18n.__)("Reset view")
|
|
158
|
+
}
|
|
159
|
+
),
|
|
160
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_add_new_template_legacy.default, {})
|
|
161
|
+
] }),
|
|
162
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
163
|
+
import_dataviews.DataViews,
|
|
164
|
+
{
|
|
165
|
+
paginationInfo,
|
|
166
|
+
fields,
|
|
167
|
+
actions,
|
|
168
|
+
data,
|
|
169
|
+
isLoading: isLoadingData,
|
|
170
|
+
view,
|
|
171
|
+
onChangeView,
|
|
172
|
+
onChangeSelection,
|
|
173
|
+
isItemClickable: () => true,
|
|
174
|
+
onClickItem: ({ id }) => {
|
|
175
|
+
history.navigate(`/wp_template/${id}?canvas=edit`);
|
|
176
|
+
},
|
|
177
|
+
selection,
|
|
178
|
+
defaultLayouts: import_view_utils.defaultLayouts
|
|
179
|
+
},
|
|
180
|
+
activeView
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=index-legacy.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/page-templates/index-legacy.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Page } from '@wordpress/admin-ui';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo, useCallback } from '@wordpress/element';\nimport { privateApis as corePrivateApis } from '@wordpress/core-data';\nimport { DataViews, filterSortAndPaginate } from '@wordpress/dataviews';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport { useEvent } from '@wordpress/compose';\nimport { useView } from '@wordpress/views';\nimport { Button } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport AddNewTemplate from '../add-new-template-legacy';\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\nimport { unlock } from '../../lock-unlock';\nimport { useEditPostAction } from '../dataviews-actions';\nimport { authorField, descriptionField, previewField } from './fields';\nimport { defaultLayouts, getDefaultView } from './view-utils';\n\nconst { usePostActions, templateTitleField } = unlock( editorPrivateApis );\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\nconst { useEntityRecordsWithPermissions } = unlock( corePrivateApis );\n\nexport default function PageTemplates() {\n\tconst { path, query } = useLocation();\n\tconst { activeView = 'active', postId } = query;\n\tconst [ selection, setSelection ] = useState( [ postId ] );\n\n\tconst defaultView = useMemo( () => {\n\t\treturn getDefaultView( activeView );\n\t}, [ activeView ] );\n\tconst { view, updateView, isModified, resetToDefault } = useView( {\n\t\tkind: 'postType',\n\t\tname: TEMPLATE_POST_TYPE,\n\t\tslug: activeView,\n\t\tdefaultView,\n\t\tqueryParams: {\n\t\t\tpage: query.pageNumber,\n\t\t\tsearch: query.search,\n\t\t},\n\t\tonChangeQueryParams: ( newQueryParams ) => {\n\t\t\thistory.navigate(\n\t\t\t\taddQueryArgs( path, {\n\t\t\t\t\t...query,\n\t\t\t\t\tpageNumber: newQueryParams.page,\n\t\t\t\t\tsearch: newQueryParams.search || undefined,\n\t\t\t\t} )\n\t\t\t);\n\t\t},\n\t} );\n\n\tconst { records, isResolving: isLoadingData } =\n\t\tuseEntityRecordsWithPermissions( 'postType', TEMPLATE_POST_TYPE, {\n\t\t\tper_page: -1,\n\t\t} );\n\tconst history = useHistory();\n\tconst onChangeSelection = useCallback(\n\t\t( items ) => {\n\t\t\tsetSelection( items );\n\t\t\tif ( view?.type === 'list' ) {\n\t\t\t\thistory.navigate(\n\t\t\t\t\taddQueryArgs( path, {\n\t\t\t\t\t\tpostId: items.length === 1 ? items[ 0 ] : undefined,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ history, path, view?.type ]\n\t);\n\n\tconst authors = useMemo( () => {\n\t\tif ( ! records ) {\n\t\t\treturn [];\n\t\t}\n\t\tconst authorsSet = new Set();\n\t\trecords.forEach( ( template ) => {\n\t\t\tauthorsSet.add( template.author_text );\n\t\t} );\n\t\treturn Array.from( authorsSet ).map( ( author ) => ( {\n\t\t\tvalue: author,\n\t\t\tlabel: author,\n\t\t} ) );\n\t}, [ records ] );\n\n\tconst fields = useMemo(\n\t\t() => [\n\t\t\tpreviewField,\n\t\t\ttemplateTitleField,\n\t\t\tdescriptionField,\n\t\t\t{\n\t\t\t\t...authorField,\n\t\t\t\telements: authors,\n\t\t\t},\n\t\t],\n\t\t[ authors ]\n\t);\n\n\tconst { data, paginationInfo } = useMemo( () => {\n\t\treturn filterSortAndPaginate( records, view, fields );\n\t}, [ records, view, fields ] );\n\n\tconst postTypeActions = usePostActions( {\n\t\tpostType: TEMPLATE_POST_TYPE,\n\t\tcontext: 'list',\n\t} );\n\tconst editAction = useEditPostAction();\n\tconst actions = useMemo(\n\t\t() => [ editAction, ...postTypeActions ],\n\t\t[ postTypeActions, editAction ]\n\t);\n\n\tconst onChangeView = useEvent( ( newView ) => {\n\t\tif ( newView.type !== view.type ) {\n\t\t\t// Retrigger the routing areas resolution.\n\t\t\thistory.invalidate();\n\t\t}\n\t\tupdateView( newView );\n\t} );\n\n\treturn (\n\t\t<Page\n\t\t\tclassName=\"edit-site-page-templates\"\n\t\t\ttitle={ __( 'Templates' ) }\n\t\t\tactions={\n\t\t\t\t<>\n\t\t\t\t\t{ isModified && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tresetToDefault();\n\t\t\t\t\t\t\t\thistory.invalidate();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Reset view' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\t\t\t\t\t<AddNewTemplate />\n\t\t\t\t</>\n\t\t\t}\n\t\t>\n\t\t\t<DataViews\n\t\t\t\tkey={ activeView }\n\t\t\t\tpaginationInfo={ paginationInfo }\n\t\t\t\tfields={ fields }\n\t\t\t\tactions={ actions }\n\t\t\t\tdata={ data }\n\t\t\t\tisLoading={ isLoadingData }\n\t\t\t\tview={ view }\n\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\tisItemClickable={ () => true }\n\t\t\t\tonClickItem={ ( { id } ) => {\n\t\t\t\t\thistory.navigate( `/wp_template/${ id }?canvas=edit` );\n\t\t\t\t} }\n\t\t\t\tselection={ selection }\n\t\t\t\tdefaultLayouts={ defaultLayouts }\n\t\t\t/>\n\t\t</Page>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAAqB;AACrB,kBAAmB;AACnB,qBAA+C;AAC/C,uBAA+C;AAC/C,uBAAiD;AACjD,oBAAiD;AACjD,oBAAiD;AACjD,iBAA6B;AAC7B,qBAAyB;AACzB,mBAAwB;AACxB,wBAAuB;AAKvB,qCAA2B;AAC3B,uBAAmC;AACnC,yBAAuB;AACvB,+BAAkC;AAClC,oBAA4D;AAC5D,wBAA+C;AA2G3C;AAzGJ,IAAM,EAAE,gBAAgB,mBAAmB,QAAI,2BAAQ,cAAAA,WAAkB;AACzE,IAAM,EAAE,YAAY,YAAY,QAAI,2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A,SACjB;AAAA,MAGD;AAAA,QAAC;AAAA;AAAA,UAEA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,WAAY;AAAA,UACZ;AAAA,UACA;AAAA,UACA;AAAA,UACA,iBAAkB,MAAM;AAAA,UACxB,aAAc,CAAE,EAAE,GAAG,MAAO;AAC3B,oBAAQ,SAAU,gBAAiB,EAAG,cAAe;AAAA,UACtD;AAAA,UACA;AAAA,UACA,gBAAiB;AAAA;AAAA,QAdX;AAAA,MAeP;AAAA;AAAA,EACD;AAEF;",
|
|
6
|
+
"names": ["editorPrivateApis", "routerPrivateApis", "corePrivateApis", "AddNewTemplate"]
|
|
7
|
+
}
|
|
@@ -125,6 +125,16 @@ function PostList({ postType }) {
|
|
|
125
125
|
} else if (filter.field === "author" && filter.operator === import_constants.OPERATOR_IS_NONE) {
|
|
126
126
|
filters.author_exclude = filter.value;
|
|
127
127
|
}
|
|
128
|
+
if (filter.field === "date") {
|
|
129
|
+
if (!filter.value) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (filter.operator === import_constants.OPERATOR_BEFORE) {
|
|
133
|
+
filters.before = filter.value;
|
|
134
|
+
} else if (filter.operator === import_constants.OPERATOR_AFTER) {
|
|
135
|
+
filters.after = filter.value;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
128
138
|
});
|
|
129
139
|
if (!filters.status || filters.status === "") {
|
|
130
140
|
filters.status = DEFAULT_STATUSES;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/post-list/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Page } from '@wordpress/admin-ui';\nimport { Button } from '@wordpress/components';\nimport {\n\tstore as coreStore,\n\tprivateApis as coreDataPrivateApis,\n} from '@wordpress/core-data';\nimport { useState, useMemo, useCallback, useEffect } from '@wordpress/element';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { useSelect } from '@wordpress/data';\nimport { DataViews, filterSortAndPaginate } from '@wordpress/dataviews';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\nimport { __ } from '@wordpress/i18n';\nimport { drawerRight } from '@wordpress/icons';\nimport { useEvent, usePrevious } from '@wordpress/compose';\nimport { addQueryArgs } from '@wordpress/url';\nimport { useView } from '@wordpress/views';\n\n/**\n * Internal dependencies\n */\nimport {\n\tOPERATOR_IS_ANY,\n\tOPERATOR_IS_NONE,\n\tLAYOUT_LIST,\n} from '../../utils/constants';\n\nimport AddNewPostModal from '../add-new-post';\nimport { unlock } from '../../lock-unlock';\nimport { useEditPostAction } from '../dataviews-actions';\nimport { defaultLayouts, getDefaultView } from './view-utils';\n\nconst { usePostActions, usePostFields } = unlock( editorPrivateApis );\nconst { useLocation, useHistory } = unlock( routerPrivateApis );\nconst { useEntityRecordsWithPermissions } = unlock( coreDataPrivateApis );\nconst EMPTY_ARRAY = [];\n\nconst DEFAULT_STATUSES = 'draft,future,pending,private,publish'; // All but 'trash'.\n\nfunction getItemId( item ) {\n\treturn item.id.toString();\n}\n\nfunction getItemLevel( item ) {\n\treturn item.level;\n}\n\nexport default function PostList( { postType } ) {\n\tconst { path, query } = useLocation();\n\tconst { activeView = 'all', postId, quickEdit = false } = query;\n\tconst history = useHistory();\n\tconst postTypeObject = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPostType } = select( coreStore );\n\t\t\treturn getPostType( postType );\n\t\t},\n\t\t[ postType ]\n\t);\n\tconst { view, updateView, isModified, resetToDefault } = useView( {\n\t\tkind: 'postType',\n\t\tname: postType,\n\t\tslug: activeView,\n\t\tqueryParams: {\n\t\t\tpage: query.pageNumber,\n\t\t\tsearch: query.search,\n\t\t},\n\t\tonChangeQueryParams: ( newQueryParams ) => {\n\t\t\thistory.navigate(\n\t\t\t\taddQueryArgs( path, {\n\t\t\t\t\t...query,\n\t\t\t\t\tpageNumber: newQueryParams.page,\n\t\t\t\t\tsearch: newQueryParams.search || undefined,\n\t\t\t\t} )\n\t\t\t);\n\t\t},\n\t\tdefaultView: getDefaultView( postTypeObject, activeView ),\n\t} );\n\n\tconst onChangeView = useEvent( ( newView ) => {\n\t\tif ( newView.type !== view.type ) {\n\t\t\t// Retrigger the routing areas resolution.\n\t\t\thistory.invalidate();\n\t\t}\n\t\tupdateView( newView );\n\t} );\n\n\tconst [ selection, setSelection ] = useState( postId?.split( ',' ) ?? [] );\n\tconst onChangeSelection = useCallback(\n\t\t( items ) => {\n\t\t\tsetSelection( items );\n\t\t\thistory.navigate(\n\t\t\t\taddQueryArgs( path, {\n\t\t\t\t\tpostId: items.join( ',' ),\n\t\t\t\t} )\n\t\t\t);\n\t\t},\n\t\t[ path, history ]\n\t);\n\n\tconst fields = usePostFields( {\n\t\tpostType,\n\t} );\n\n\tconst queryArgs = useMemo( () => {\n\t\tconst filters = {};\n\t\tview.filters?.forEach( ( filter ) => {\n\t\t\tif (\n\t\t\t\tfilter.field === 'status' &&\n\t\t\t\tfilter.operator === OPERATOR_IS_ANY\n\t\t\t) {\n\t\t\t\tfilters.status = filter.value;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tfilter.field === 'author' &&\n\t\t\t\tfilter.operator === OPERATOR_IS_ANY\n\t\t\t) {\n\t\t\t\tfilters.author = filter.value;\n\t\t\t} else if (\n\t\t\t\tfilter.field === 'author' &&\n\t\t\t\tfilter.operator === OPERATOR_IS_NONE\n\t\t\t) {\n\t\t\t\tfilters.author_exclude = filter.value;\n\t\t\t}\n\t\t} );\n\n\t\t// We want to provide a different default item for the status filter\n\t\t// than the REST API provides.\n\t\tif ( ! filters.status || filters.status === '' ) {\n\t\t\tfilters.status = DEFAULT_STATUSES;\n\t\t}\n\n\t\treturn {\n\t\t\tper_page: view.perPage,\n\t\t\tpage: view.page,\n\t\t\t_embed: 'author,wp:featuredmedia',\n\t\t\torder: view.sort?.direction,\n\t\t\torderby: view.sort?.field,\n\t\t\torderby_hierarchy: !! view.showLevels,\n\t\t\tsearch: view.search,\n\t\t\t...filters,\n\t\t};\n\t}, [ view ] );\n\tconst {\n\t\trecords,\n\t\tisResolving: isLoadingData,\n\t\ttotalItems,\n\t\ttotalPages,\n\t} = useEntityRecordsWithPermissions( 'postType', postType, queryArgs );\n\n\t// The REST API sort the authors by ID, but we want to sort them by name.\n\tconst data = useMemo( () => {\n\t\tif ( view?.sort?.field === 'author' ) {\n\t\t\treturn filterSortAndPaginate(\n\t\t\t\trecords,\n\t\t\t\t{ sort: { ...view.sort } },\n\t\t\t\tfields\n\t\t\t).data;\n\t\t}\n\n\t\treturn records;\n\t}, [ records, fields, view?.sort ] );\n\n\tconst ids = data?.map( ( record ) => getItemId( record ) ) ?? [];\n\tconst prevIds = usePrevious( ids ) ?? [];\n\tconst deletedIds = prevIds.filter( ( id ) => ! ids.includes( id ) );\n\tconst postIdWasDeleted = deletedIds.includes( postId );\n\n\tuseEffect( () => {\n\t\tif ( postIdWasDeleted ) {\n\t\t\thistory.navigate(\n\t\t\t\taddQueryArgs( path, {\n\t\t\t\t\tpostId: undefined,\n\t\t\t\t} )\n\t\t\t);\n\t\t}\n\t}, [ history, postIdWasDeleted, path ] );\n\n\tconst paginationInfo = useMemo(\n\t\t() => ( {\n\t\t\ttotalItems,\n\t\t\ttotalPages,\n\t\t} ),\n\t\t[ totalItems, totalPages ]\n\t);\n\n\tconst { labels, canCreateRecord } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPostType, canUser } = select( coreStore );\n\t\t\treturn {\n\t\t\t\tlabels: getPostType( postType )?.labels,\n\t\t\t\tcanCreateRecord: canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: postType,\n\t\t\t\t} ),\n\t\t\t};\n\t\t},\n\t\t[ postType ]\n\t);\n\n\tconst postTypeActions = usePostActions( {\n\t\tpostType,\n\t\tcontext: 'list',\n\t} );\n\tconst editAction = useEditPostAction();\n\tconst actions = useMemo(\n\t\t() => [ editAction, ...postTypeActions ],\n\t\t[ postTypeActions, editAction ]\n\t);\n\n\tconst [ showAddPostModal, setShowAddPostModal ] = useState( false );\n\n\tconst openModal = () => setShowAddPostModal( true );\n\tconst closeModal = () => setShowAddPostModal( false );\n\tconst handleNewPage = ( { type, id } ) => {\n\t\thistory.navigate( `/${ type }/${ id }?canvas=edit` );\n\t\tcloseModal();\n\t};\n\n\treturn (\n\t\t<Page\n\t\t\ttitle={ labels?.name }\n\t\t\tactions={\n\t\t\t\t<>\n\t\t\t\t\t{ isModified && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tresetToDefault();\n\t\t\t\t\t\t\t\thistory.invalidate();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Reset view' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\t\t\t\t\t{ labels?.add_new_item && canCreateRecord && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\tonClick={ openModal }\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ labels.add_new_item }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t{ showAddPostModal && (\n\t\t\t\t\t\t\t\t<AddNewPostModal\n\t\t\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\t\t\tonSave={ handleNewPage }\n\t\t\t\t\t\t\t\t\tonClose={ closeModal }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\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>\n\t\t\t<DataViews\n\t\t\t\tkey={ activeView }\n\t\t\t\tpaginationInfo={ paginationInfo }\n\t\t\t\tfields={ fields }\n\t\t\t\tactions={ actions }\n\t\t\t\tdata={ data || EMPTY_ARRAY }\n\t\t\t\tisLoading={ isLoadingData }\n\t\t\t\tview={ view }\n\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\tselection={ selection }\n\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\tisItemClickable={ ( item ) => item.status !== 'trash' }\n\t\t\t\tonClickItem={ ( { id } ) => {\n\t\t\t\t\thistory.navigate( `/${ postType }/${ id }?canvas=edit` );\n\t\t\t\t} }\n\t\t\t\tgetItemId={ getItemId }\n\t\t\t\tgetItemLevel={ getItemLevel }\n\t\t\t\tdefaultLayouts={ defaultLayouts }\n\t\t\t\theader={\n\t\t\t\t\twindow.__experimentalQuickEditDataViews &&\n\t\t\t\t\tview.type !== LAYOUT_LIST &&\n\t\t\t\t\tpostType === 'page' && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\tisPressed={ quickEdit }\n\t\t\t\t\t\t\ticon={ drawerRight }\n\t\t\t\t\t\t\tlabel={ __( 'Details' ) }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t\taddQueryArgs( path, {\n\t\t\t\t\t\t\t\t\t\tquickEdit: quickEdit ? undefined : true,\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\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</Page>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAAqB;AACrB,wBAAuB;AACvB,uBAGO;AACP,qBAA0D;AAC1D,oBAAiD;AACjD,kBAA0B;AAC1B,uBAAiD;AACjD,oBAAiD;AACjD,kBAAmB;AACnB,mBAA4B;AAC5B,qBAAsC;AACtC,iBAA6B;AAC7B,mBAAwB;AAKxB,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Page } from '@wordpress/admin-ui';\nimport { Button } from '@wordpress/components';\nimport {\n\tstore as coreStore,\n\tprivateApis as coreDataPrivateApis,\n} from '@wordpress/core-data';\nimport { useState, useMemo, useCallback, useEffect } from '@wordpress/element';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { useSelect } from '@wordpress/data';\nimport { DataViews, filterSortAndPaginate } from '@wordpress/dataviews';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\nimport { __ } from '@wordpress/i18n';\nimport { drawerRight } from '@wordpress/icons';\nimport { useEvent, usePrevious } from '@wordpress/compose';\nimport { addQueryArgs } from '@wordpress/url';\nimport { useView } from '@wordpress/views';\n\n/**\n * Internal dependencies\n */\nimport {\n\tOPERATOR_IS_ANY,\n\tOPERATOR_IS_NONE,\n\tOPERATOR_BEFORE,\n\tOPERATOR_AFTER,\n\tLAYOUT_LIST,\n} from '../../utils/constants';\n\nimport AddNewPostModal from '../add-new-post';\nimport { unlock } from '../../lock-unlock';\nimport { useEditPostAction } from '../dataviews-actions';\nimport { defaultLayouts, getDefaultView } from './view-utils';\n\nconst { usePostActions, usePostFields } = unlock( editorPrivateApis );\nconst { useLocation, useHistory } = unlock( routerPrivateApis );\nconst { useEntityRecordsWithPermissions } = unlock( coreDataPrivateApis );\nconst EMPTY_ARRAY = [];\n\nconst DEFAULT_STATUSES = 'draft,future,pending,private,publish'; // All but 'trash'.\n\nfunction getItemId( item ) {\n\treturn item.id.toString();\n}\n\nfunction getItemLevel( item ) {\n\treturn item.level;\n}\n\nexport default function PostList( { postType } ) {\n\tconst { path, query } = useLocation();\n\tconst { activeView = 'all', postId, quickEdit = false } = query;\n\tconst history = useHistory();\n\tconst postTypeObject = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPostType } = select( coreStore );\n\t\t\treturn getPostType( postType );\n\t\t},\n\t\t[ postType ]\n\t);\n\tconst { view, updateView, isModified, resetToDefault } = useView( {\n\t\tkind: 'postType',\n\t\tname: postType,\n\t\tslug: activeView,\n\t\tqueryParams: {\n\t\t\tpage: query.pageNumber,\n\t\t\tsearch: query.search,\n\t\t},\n\t\tonChangeQueryParams: ( newQueryParams ) => {\n\t\t\thistory.navigate(\n\t\t\t\taddQueryArgs( path, {\n\t\t\t\t\t...query,\n\t\t\t\t\tpageNumber: newQueryParams.page,\n\t\t\t\t\tsearch: newQueryParams.search || undefined,\n\t\t\t\t} )\n\t\t\t);\n\t\t},\n\t\tdefaultView: getDefaultView( postTypeObject, activeView ),\n\t} );\n\n\tconst onChangeView = useEvent( ( newView ) => {\n\t\tif ( newView.type !== view.type ) {\n\t\t\t// Retrigger the routing areas resolution.\n\t\t\thistory.invalidate();\n\t\t}\n\t\tupdateView( newView );\n\t} );\n\n\tconst [ selection, setSelection ] = useState( postId?.split( ',' ) ?? [] );\n\tconst onChangeSelection = useCallback(\n\t\t( items ) => {\n\t\t\tsetSelection( items );\n\t\t\thistory.navigate(\n\t\t\t\taddQueryArgs( path, {\n\t\t\t\t\tpostId: items.join( ',' ),\n\t\t\t\t} )\n\t\t\t);\n\t\t},\n\t\t[ path, history ]\n\t);\n\n\tconst fields = usePostFields( {\n\t\tpostType,\n\t} );\n\n\tconst queryArgs = useMemo( () => {\n\t\tconst filters = {};\n\t\tview.filters?.forEach( ( filter ) => {\n\t\t\tif (\n\t\t\t\tfilter.field === 'status' &&\n\t\t\t\tfilter.operator === OPERATOR_IS_ANY\n\t\t\t) {\n\t\t\t\tfilters.status = filter.value;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tfilter.field === 'author' &&\n\t\t\t\tfilter.operator === OPERATOR_IS_ANY\n\t\t\t) {\n\t\t\t\tfilters.author = filter.value;\n\t\t\t} else if (\n\t\t\t\tfilter.field === 'author' &&\n\t\t\t\tfilter.operator === OPERATOR_IS_NONE\n\t\t\t) {\n\t\t\t\tfilters.author_exclude = filter.value;\n\t\t\t}\n\t\t\tif ( filter.field === 'date' ) {\n\t\t\t\t// Skip if no value is set yet\n\t\t\t\tif ( ! filter.value ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif ( filter.operator === OPERATOR_BEFORE ) {\n\t\t\t\t\tfilters.before = filter.value;\n\t\t\t\t} else if ( filter.operator === OPERATOR_AFTER ) {\n\t\t\t\t\tfilters.after = filter.value;\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\n\t\t// We want to provide a different default item for the status filter\n\t\t// than the REST API provides.\n\t\tif ( ! filters.status || filters.status === '' ) {\n\t\t\tfilters.status = DEFAULT_STATUSES;\n\t\t}\n\n\t\treturn {\n\t\t\tper_page: view.perPage,\n\t\t\tpage: view.page,\n\t\t\t_embed: 'author,wp:featuredmedia',\n\t\t\torder: view.sort?.direction,\n\t\t\torderby: view.sort?.field,\n\t\t\torderby_hierarchy: !! view.showLevels,\n\t\t\tsearch: view.search,\n\t\t\t...filters,\n\t\t};\n\t}, [ view ] );\n\tconst {\n\t\trecords,\n\t\tisResolving: isLoadingData,\n\t\ttotalItems,\n\t\ttotalPages,\n\t} = useEntityRecordsWithPermissions( 'postType', postType, queryArgs );\n\n\t// The REST API sort the authors by ID, but we want to sort them by name.\n\tconst data = useMemo( () => {\n\t\tif ( view?.sort?.field === 'author' ) {\n\t\t\treturn filterSortAndPaginate(\n\t\t\t\trecords,\n\t\t\t\t{ sort: { ...view.sort } },\n\t\t\t\tfields\n\t\t\t).data;\n\t\t}\n\n\t\treturn records;\n\t}, [ records, fields, view?.sort ] );\n\n\tconst ids = data?.map( ( record ) => getItemId( record ) ) ?? [];\n\tconst prevIds = usePrevious( ids ) ?? [];\n\tconst deletedIds = prevIds.filter( ( id ) => ! ids.includes( id ) );\n\tconst postIdWasDeleted = deletedIds.includes( postId );\n\n\tuseEffect( () => {\n\t\tif ( postIdWasDeleted ) {\n\t\t\thistory.navigate(\n\t\t\t\taddQueryArgs( path, {\n\t\t\t\t\tpostId: undefined,\n\t\t\t\t} )\n\t\t\t);\n\t\t}\n\t}, [ history, postIdWasDeleted, path ] );\n\n\tconst paginationInfo = useMemo(\n\t\t() => ( {\n\t\t\ttotalItems,\n\t\t\ttotalPages,\n\t\t} ),\n\t\t[ totalItems, totalPages ]\n\t);\n\n\tconst { labels, canCreateRecord } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPostType, canUser } = select( coreStore );\n\t\t\treturn {\n\t\t\t\tlabels: getPostType( postType )?.labels,\n\t\t\t\tcanCreateRecord: canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: postType,\n\t\t\t\t} ),\n\t\t\t};\n\t\t},\n\t\t[ postType ]\n\t);\n\n\tconst postTypeActions = usePostActions( {\n\t\tpostType,\n\t\tcontext: 'list',\n\t} );\n\tconst editAction = useEditPostAction();\n\tconst actions = useMemo(\n\t\t() => [ editAction, ...postTypeActions ],\n\t\t[ postTypeActions, editAction ]\n\t);\n\n\tconst [ showAddPostModal, setShowAddPostModal ] = useState( false );\n\n\tconst openModal = () => setShowAddPostModal( true );\n\tconst closeModal = () => setShowAddPostModal( false );\n\tconst handleNewPage = ( { type, id } ) => {\n\t\thistory.navigate( `/${ type }/${ id }?canvas=edit` );\n\t\tcloseModal();\n\t};\n\n\treturn (\n\t\t<Page\n\t\t\ttitle={ labels?.name }\n\t\t\tactions={\n\t\t\t\t<>\n\t\t\t\t\t{ isModified && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tresetToDefault();\n\t\t\t\t\t\t\t\thistory.invalidate();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Reset view' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\t\t\t\t\t{ labels?.add_new_item && canCreateRecord && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\tonClick={ openModal }\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ labels.add_new_item }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t{ showAddPostModal && (\n\t\t\t\t\t\t\t\t<AddNewPostModal\n\t\t\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\t\t\tonSave={ handleNewPage }\n\t\t\t\t\t\t\t\t\tonClose={ closeModal }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\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>\n\t\t\t<DataViews\n\t\t\t\tkey={ activeView }\n\t\t\t\tpaginationInfo={ paginationInfo }\n\t\t\t\tfields={ fields }\n\t\t\t\tactions={ actions }\n\t\t\t\tdata={ data || EMPTY_ARRAY }\n\t\t\t\tisLoading={ isLoadingData }\n\t\t\t\tview={ view }\n\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\tselection={ selection }\n\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\tisItemClickable={ ( item ) => item.status !== 'trash' }\n\t\t\t\tonClickItem={ ( { id } ) => {\n\t\t\t\t\thistory.navigate( `/${ postType }/${ id }?canvas=edit` );\n\t\t\t\t} }\n\t\t\t\tgetItemId={ getItemId }\n\t\t\t\tgetItemLevel={ getItemLevel }\n\t\t\t\tdefaultLayouts={ defaultLayouts }\n\t\t\t\theader={\n\t\t\t\t\twindow.__experimentalQuickEditDataViews &&\n\t\t\t\t\tview.type !== LAYOUT_LIST &&\n\t\t\t\t\tpostType === 'page' && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\tisPressed={ quickEdit }\n\t\t\t\t\t\t\ticon={ drawerRight }\n\t\t\t\t\t\t\tlabel={ __( 'Details' ) }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\th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|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/content-legacy.js
|
|
31
|
+
var content_legacy_exports = {};
|
|
32
|
+
__export(content_legacy_exports, {
|
|
33
|
+
default: () => DataviewsTemplatesSidebarContent
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(content_legacy_exports);
|
|
36
|
+
var import_core_data = require("@wordpress/core-data");
|
|
37
|
+
var import_element = require("@wordpress/element");
|
|
38
|
+
var import_components = require("@wordpress/components");
|
|
39
|
+
var import_i18n = require("@wordpress/i18n");
|
|
40
|
+
var import_router = require("@wordpress/router");
|
|
41
|
+
var import_url = require("@wordpress/url");
|
|
42
|
+
var import_sidebar_navigation_item = __toESM(require("../sidebar-navigation-item"));
|
|
43
|
+
var import_hooks = require("../page-templates/hooks");
|
|
44
|
+
var import_icons = require("@wordpress/icons");
|
|
45
|
+
var import_constants = require("../../utils/constants");
|
|
46
|
+
var import_lock_unlock = require("../../lock-unlock");
|
|
47
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
48
|
+
var { useLocation } = (0, import_lock_unlock.unlock)(import_router.privateApis);
|
|
49
|
+
var EMPTY_ARRAY = [];
|
|
50
|
+
function TemplateDataviewItem({ template, isActive }) {
|
|
51
|
+
const { text, icon } = (0, import_hooks.useAddedBy)(template.type, template.id);
|
|
52
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
53
|
+
import_sidebar_navigation_item.default,
|
|
54
|
+
{
|
|
55
|
+
to: (0, import_url.addQueryArgs)("/template", { activeView: text }),
|
|
56
|
+
icon,
|
|
57
|
+
"aria-current": isActive,
|
|
58
|
+
children: text
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
function DataviewsTemplatesSidebarContent() {
|
|
63
|
+
const {
|
|
64
|
+
query: { activeView = "all" }
|
|
65
|
+
} = useLocation();
|
|
66
|
+
const { records } = (0, import_core_data.useEntityRecords)("postType", import_constants.TEMPLATE_POST_TYPE, {
|
|
67
|
+
per_page: -1
|
|
68
|
+
});
|
|
69
|
+
const firstItemPerAuthorText = (0, import_element.useMemo)(() => {
|
|
70
|
+
const firstItemPerAuthor = records?.reduce((acc, template) => {
|
|
71
|
+
const author = template.author_text;
|
|
72
|
+
if (author && !acc[author]) {
|
|
73
|
+
acc[author] = template;
|
|
74
|
+
}
|
|
75
|
+
return acc;
|
|
76
|
+
}, {});
|
|
77
|
+
return (firstItemPerAuthor && Object.values(firstItemPerAuthor)) ?? EMPTY_ARRAY;
|
|
78
|
+
}, [records]);
|
|
79
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalItemGroup, { className: "edit-site-sidebar-navigation-screen-templates-browse", children: [
|
|
80
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
81
|
+
import_sidebar_navigation_item.default,
|
|
82
|
+
{
|
|
83
|
+
to: "/template",
|
|
84
|
+
icon: import_icons.layout,
|
|
85
|
+
"aria-current": activeView === "all",
|
|
86
|
+
children: (0, import_i18n.__)("All templates")
|
|
87
|
+
}
|
|
88
|
+
),
|
|
89
|
+
firstItemPerAuthorText.map((template) => {
|
|
90
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
91
|
+
TemplateDataviewItem,
|
|
92
|
+
{
|
|
93
|
+
template,
|
|
94
|
+
isActive: activeView === template.author_text
|
|
95
|
+
},
|
|
96
|
+
template.author_text
|
|
97
|
+
);
|
|
98
|
+
})
|
|
99
|
+
] });
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=content-legacy.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/sidebar-navigation-screen-templates-browse/content-legacy.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { useMemo } from '@wordpress/element';\nimport { __experimentalItemGroup as ItemGroup } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationItem from '../sidebar-navigation-item';\nimport { useAddedBy } from '../page-templates/hooks';\nimport { layout } from '@wordpress/icons';\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\nimport { unlock } from '../../lock-unlock';\n\nconst { useLocation } = unlock( routerPrivateApis );\n\nconst EMPTY_ARRAY = [];\n\nfunction TemplateDataviewItem( { template, isActive } ) {\n\tconst { text, icon } = useAddedBy( template.type, template.id );\n\n\treturn (\n\t\t<SidebarNavigationItem\n\t\t\tto={ addQueryArgs( '/template', { activeView: text } ) }\n\t\t\ticon={ icon }\n\t\t\taria-current={ isActive }\n\t\t>\n\t\t\t{ text }\n\t\t</SidebarNavigationItem>\n\t);\n}\n\nexport default function DataviewsTemplatesSidebarContent() {\n\tconst {\n\t\tquery: { activeView = 'all' },\n\t} = useLocation();\n\tconst { records } = useEntityRecords( 'postType', TEMPLATE_POST_TYPE, {\n\t\tper_page: -1,\n\t} );\n\tconst firstItemPerAuthorText = useMemo( () => {\n\t\tconst firstItemPerAuthor = records?.reduce( ( acc, template ) => {\n\t\t\tconst author = template.author_text;\n\t\t\tif ( author && ! acc[ author ] ) {\n\t\t\t\tacc[ author ] = template;\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, {} );\n\t\treturn (\n\t\t\t( firstItemPerAuthor && Object.values( firstItemPerAuthor ) ) ??\n\t\t\tEMPTY_ARRAY\n\t\t);\n\t}, [ records ] );\n\n\treturn (\n\t\t<ItemGroup className=\"edit-site-sidebar-navigation-screen-templates-browse\">\n\t\t\t<SidebarNavigationItem\n\t\t\t\tto=\"/template\"\n\t\t\t\ticon={ layout }\n\t\t\t\taria-current={ activeView === 'all' }\n\t\t\t>\n\t\t\t\t{ __( 'All templates' ) }\n\t\t\t</SidebarNavigationItem>\n\t\t\t{ firstItemPerAuthorText.map( ( template ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<TemplateDataviewItem\n\t\t\t\t\t\tkey={ template.author_text }\n\t\t\t\t\t\ttemplate={ template }\n\t\t\t\t\t\tisActive={ activeView === template.author_text }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n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IAAG;AAAA,QACH,MAAO;AAAA,QACP,gBAAe,eAAe;AAAA,QAE5B,8BAAI,eAAgB;AAAA;AAAA,IACvB;AAAA,IACE,uBAAuB,IAAK,CAAE,aAAc;AAC7C,aACC;AAAA,QAAC;AAAA;AAAA,UAEA;AAAA,UACA,UAAW,eAAe,SAAS;AAAA;AAAA,QAF7B,SAAS;AAAA,MAGhB;AAAA,IAEF,CAAE;AAAA,KACH;AAEF;",
|
|
6
|
+
"names": ["routerPrivateApis", "SidebarNavigationItem", "ItemGroup"]
|
|
7
|
+
}
|
|
@@ -36,6 +36,7 @@ module.exports = __toCommonJS(sidebar_navigation_screen_templates_browse_exports
|
|
|
36
36
|
var import_i18n = require("@wordpress/i18n");
|
|
37
37
|
var import_sidebar_navigation_screen = __toESM(require("../sidebar-navigation-screen"));
|
|
38
38
|
var import_content = __toESM(require("./content"));
|
|
39
|
+
var import_content_legacy = __toESM(require("./content-legacy"));
|
|
39
40
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
40
41
|
function SidebarNavigationScreenTemplatesBrowse({ backPath }) {
|
|
41
42
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -46,7 +47,7 @@ function SidebarNavigationScreenTemplatesBrowse({ backPath }) {
|
|
|
46
47
|
"Create new templates, or reset any customizations made to the templates supplied by your theme."
|
|
47
48
|
),
|
|
48
49
|
backPath,
|
|
49
|
-
content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_content.default, {})
|
|
50
|
+
content: window?.__experimentalTemplateActivate ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_content.default, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_content_legacy.default, {})
|
|
50
51
|
}
|
|
51
52
|
);
|
|
52
53
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/sidebar-navigation-screen-templates-browse/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport DataviewsTemplatesSidebarContent from './content';\n\nexport default function SidebarNavigationScreenTemplatesBrowse( { backPath } ) {\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\ttitle={ __( 'Templates' ) }\n\t\t\tdescription={ __(\n\t\t\t\t'Create new templates, or reset any customizations made to the templates supplied by your theme.'\n\t\t\t) }\n\t\t\tbackPath={ backPath }\n\t\t\tcontent={ <DataviewsTemplatesSidebarContent
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AAKnB,uCAAoC;AACpC,qBAA6C;
|
|
6
|
-
"names": ["SidebarNavigationScreen", "DataviewsTemplatesSidebarContent"]
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport DataviewsTemplatesSidebarContent from './content';\nimport DataviewsTemplatesSidebarContentLegacy from './content-legacy';\n\nexport default function SidebarNavigationScreenTemplatesBrowse( { backPath } ) {\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\ttitle={ __( 'Templates' ) }\n\t\t\tdescription={ __(\n\t\t\t\t'Create new templates, or reset any customizations made to the templates supplied by your theme.'\n\t\t\t) }\n\t\t\tbackPath={ backPath }\n\t\t\tcontent={\n\t\t\t\twindow?.__experimentalTemplateActivate ? (\n\t\t\t\t\t<DataviewsTemplatesSidebarContent />\n\t\t\t\t) : (\n\t\t\t\t\t<DataviewsTemplatesSidebarContentLegacy />\n\t\t\t\t)\n\t\t\t}\n\t\t/>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AAKnB,uCAAoC;AACpC,qBAA6C;AAC7C,4BAAmD;AAY9C;AAVU,SAAR,uCAAyD,EAAE,SAAS,GAAI;AAC9E,SACC;AAAA,IAAC,iCAAAA;AAAA,IAAA;AAAA,MACA,WAAQ,gBAAI,WAAY;AAAA,MACxB,iBAAc;AAAA,QACb;AAAA,MACD;AAAA,MACA;AAAA,MACA,SACC,QAAQ,iCACP,4CAAC,eAAAC,SAAA,EAAiC,IAElC,4CAAC,sBAAAC,SAAA,EAAuC;AAAA;AAAA,EAG3C;AAEF;",
|
|
6
|
+
"names": ["SidebarNavigationScreen", "DataviewsTemplatesSidebarContent", "DataviewsTemplatesSidebarContentLegacy"]
|
|
7
7
|
}
|