@wordpress/edit-site 5.3.3 → 5.3.5
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/build/components/add-new-template/new-template-part.js +3 -6
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/new-template.js +3 -6
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/global-styles/screen-border.js +1 -1
- package/build/components/global-styles/screen-border.js.map +1 -1
- package/build/components/global-styles/ui.js +1 -1
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/list/table.js +0 -1
- package/build/components/list/table.js.map +1 -1
- package/build/components/navigation-inspector/navigation-menu.js +4 -2
- package/build/components/navigation-inspector/navigation-menu.js.map +1 -1
- package/build/components/save-panel/index.js +11 -1
- package/build/components/save-panel/index.js.map +1 -1
- package/build/components/sidebar/index.js +14 -33
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js +8 -2
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +4 -7
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +3 -3
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-item/index.js +8 -12
- package/build/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js +1 -3
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-template/index.js +1 -14
- package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates/index.js +8 -12
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/index.js +8 -7
- package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +34 -32
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-path-with-url.js +67 -18
- package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build/utils/get-is-list-page.js +1 -1
- package/build/utils/get-is-list-page.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +3 -6
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +3 -6
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/global-styles/screen-border.js +1 -1
- package/build-module/components/global-styles/screen-border.js.map +1 -1
- package/build-module/components/global-styles/ui.js +1 -1
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/list/table.js +0 -1
- package/build-module/components/list/table.js.map +1 -1
- package/build-module/components/navigation-inspector/navigation-menu.js +4 -2
- package/build-module/components/navigation-inspector/navigation-menu.js.map +1 -1
- package/build-module/components/save-panel/index.js +8 -1
- package/build-module/components/save-panel/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +15 -32
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js +8 -2
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +5 -8
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +3 -3
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-item/index.js +9 -13
- package/build-module/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +1 -3
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-template/index.js +1 -13
- package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates/index.js +9 -13
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +7 -7
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +34 -32
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +67 -18
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build-module/utils/get-is-list-page.js +1 -1
- package/build-module/utils/get-is-list-page.js.map +1 -1
- package/build-style/style-rtl.css +19 -9
- package/build-style/style.css +19 -9
- package/package.json +21 -21
- package/src/components/add-new-template/new-template-part.js +3 -6
- package/src/components/add-new-template/new-template.js +3 -6
- package/src/components/editor/style.scss +0 -6
- package/src/components/global-styles/screen-border.js +1 -1
- package/src/components/global-styles/ui.js +1 -1
- package/src/components/layout/style.scss +8 -1
- package/src/components/list/table.js +0 -4
- package/src/components/navigation-inspector/navigation-menu.js +8 -2
- package/src/components/save-panel/index.js +8 -1
- package/src/components/sidebar/index.js +26 -27
- package/src/components/sidebar-edit-mode/global-styles-sidebar.js +3 -7
- package/src/components/sidebar-edit-mode/style.scss +16 -0
- package/src/components/sidebar-navigation-screen/index.js +31 -37
- package/src/components/sidebar-navigation-screen/style.scss +1 -0
- package/src/components/sidebar-navigation-screen-main/index.js +3 -3
- package/src/components/sidebar-navigation-screen-navigation-item/index.js +21 -15
- package/src/components/sidebar-navigation-screen-navigation-menus/index.js +0 -2
- package/src/components/sidebar-navigation-screen-template/index.js +1 -13
- package/src/components/sidebar-navigation-screen-templates/index.js +6 -10
- package/src/components/sidebar-navigation-screen-templates-browse/index.js +6 -11
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +31 -22
- package/src/components/sync-state-with-url/use-sync-path-with-url.js +78 -17
- package/src/utils/get-is-list-page.js +1 -1
|
@@ -28,7 +28,7 @@ var _privateApis = require("../../private-apis");
|
|
|
28
28
|
*/
|
|
29
29
|
function SidebarNavigationScreen(_ref) {
|
|
30
30
|
let {
|
|
31
|
-
|
|
31
|
+
isRoot,
|
|
32
32
|
title,
|
|
33
33
|
actions,
|
|
34
34
|
content
|
|
@@ -43,16 +43,13 @@ function SidebarNavigationScreen(_ref) {
|
|
|
43
43
|
dashboardLink: getSettings().__experimentalDashboardLink
|
|
44
44
|
};
|
|
45
45
|
}, []);
|
|
46
|
-
return (0, _element.createElement)(_components.
|
|
47
|
-
className: "edit-site-sidebar-navigation-screen",
|
|
48
|
-
path: path
|
|
49
|
-
}, (0, _element.createElement)(_components.__experimentalVStack, {
|
|
46
|
+
return (0, _element.createElement)(_components.__experimentalVStack, {
|
|
50
47
|
spacing: 2
|
|
51
48
|
}, (0, _element.createElement)(_components.__experimentalHStack, {
|
|
52
49
|
spacing: 4,
|
|
53
50
|
justify: "flex-start",
|
|
54
51
|
className: "edit-site-sidebar-navigation-screen__title-icon"
|
|
55
|
-
},
|
|
52
|
+
}, !isRoot ? (0, _element.createElement)(_components.__experimentalNavigatorToParentButton, {
|
|
56
53
|
className: "edit-site-sidebar-navigation-screen__back",
|
|
57
54
|
icon: (0, _i18n.isRTL)() ? _icons.chevronRight : _icons.chevronLeft,
|
|
58
55
|
"aria-label": (0, _i18n.__)('Back')
|
|
@@ -66,6 +63,6 @@ function SidebarNavigationScreen(_ref) {
|
|
|
66
63
|
className: "edit-site-sidebar-navigation-screen__title"
|
|
67
64
|
}, title), actions), (0, _element.createElement)("nav", {
|
|
68
65
|
className: "edit-site-sidebar-navigation-screen__content"
|
|
69
|
-
}, content))
|
|
66
|
+
}, content));
|
|
70
67
|
}
|
|
71
68
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen/index.js"],"names":["SidebarNavigationScreen","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen/index.js"],"names":["SidebarNavigationScreen","isRoot","title","actions","content","dashboardLink","select","getSettings","editSiteStore","__experimentalDashboardLink","chevronRight","chevronLeft"],"mappings":";;;;;;;;;AAGA;;AAMA;;AACA;;AACA;;AAKA;;AACA;;AAjBA;AACA;AACA;;AAWA;AACA;AACA;AAIe,SAASA,uBAAT,OAKX;AAAA,MAL6C;AAChDC,IAAAA,MADgD;AAEhDC,IAAAA,KAFgD;AAGhDC,IAAAA,OAHgD;AAIhDC,IAAAA;AAJgD,GAK7C;AACH,QAAM;AAAEC,IAAAA;AAAF,MAAoB,qBAAaC,MAAF,IAAc;AAClD,UAAM;AAAEC,MAAAA;AAAF,QAAkB,yBAAQD,MAAM,CAAEE,YAAF,CAAd,CAAxB;AACA,WAAO;AACNH,MAAAA,aAAa,EAAEE,WAAW,GAAGE;AADvB,KAAP;AAGA,GALyB,EAKvB,EALuB,CAA1B;AAOA,SACC,4BAAC,gCAAD;AAAQ,IAAA,OAAO,EAAG;AAAlB,KACC,4BAAC,gCAAD;AACC,IAAA,OAAO,EAAG,CADX;AAEC,IAAA,OAAO,EAAC,YAFT;AAGC,IAAA,SAAS,EAAC;AAHX,KAKG,CAAER,MAAF,GACD,4BAAC,iDAAD;AACC,IAAA,SAAS,EAAC,2CADX;AAEC,IAAA,IAAI,EAAG,qBAAUS,mBAAV,GAAyBC,kBAFjC;AAGC,kBAAa,cAAI,MAAJ;AAHd,IADC,GAOD,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,2CADX;AAEC,IAAA,IAAI,EAAG,qBAAUD,mBAAV,GAAyBC,kBAFjC;AAGC,kBAAa,cAAI,2BAAJ,CAHd;AAIC,IAAA,IAAI,EAAGN,aAAa,IAAI,WAJzB;AAKC,IAAA,KAAK,EAAG,cAAI,WAAJ;AALT,IAZF,EAoBC;AAAI,IAAA,SAAS,EAAC;AAAd,KACGH,KADH,CApBD,EAuBGC,OAvBH,CADD,EA2BC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGC,OADH,CA3BD,CADD;AAiCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalNavigatorToParentButton as NavigatorToParentButton,\n\tButton,\n} from '@wordpress/components';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { chevronRight, chevronLeft } from '@wordpress/icons';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../private-apis';\n\nexport default function SidebarNavigationScreen( {\n\tisRoot,\n\ttitle,\n\tactions,\n\tcontent,\n} ) {\n\tconst { dashboardLink } = useSelect( ( select ) => {\n\t\tconst { getSettings } = unlock( select( editSiteStore ) );\n\t\treturn {\n\t\t\tdashboardLink: getSettings().__experimentalDashboardLink,\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<VStack spacing={ 2 }>\n\t\t\t<HStack\n\t\t\t\tspacing={ 4 }\n\t\t\t\tjustify=\"flex-start\"\n\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen__title-icon\"\n\t\t\t>\n\t\t\t\t{ ! isRoot ? (\n\t\t\t\t\t<NavigatorToParentButton\n\t\t\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen__back\"\n\t\t\t\t\t\ticon={ isRTL() ? chevronRight : chevronLeft }\n\t\t\t\t\t\taria-label={ __( 'Back' ) }\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen__back\"\n\t\t\t\t\t\ticon={ isRTL() ? chevronRight : chevronLeft }\n\t\t\t\t\t\taria-label={ __( 'Navigate to the Dashboard' ) }\n\t\t\t\t\t\thref={ dashboardLink || 'index.php' }\n\t\t\t\t\t\tlabel={ __( 'Dashboard' ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<h2 className=\"edit-site-sidebar-navigation-screen__title\">\n\t\t\t\t\t{ title }\n\t\t\t\t</h2>\n\t\t\t\t{ actions }\n\t\t\t</HStack>\n\n\t\t\t<nav className=\"edit-site-sidebar-navigation-screen__content\">\n\t\t\t\t{ content }\n\t\t\t</nav>\n\t\t</VStack>\n\t);\n}\n"]}
|
|
@@ -45,7 +45,7 @@ function SidebarNavigationScreenMain() {
|
|
|
45
45
|
};
|
|
46
46
|
});
|
|
47
47
|
return (0, _element.createElement)(_sidebarNavigationScreen.default, {
|
|
48
|
-
|
|
48
|
+
isRoot: true,
|
|
49
49
|
title: (0, _i18n.__)('Design'),
|
|
50
50
|
content: (0, _element.createElement)(_components.__experimentalItemGroup, null, !!navigationMenus && navigationMenus.length > 0 && (0, _element.createElement)(_components.__experimentalNavigatorButton, {
|
|
51
51
|
as: _sidebarNavigationItem.default,
|
|
@@ -54,12 +54,12 @@ function SidebarNavigationScreenMain() {
|
|
|
54
54
|
icon: _icons.navigation
|
|
55
55
|
}, (0, _i18n.__)('Navigation')), (0, _element.createElement)(_components.__experimentalNavigatorButton, {
|
|
56
56
|
as: _sidebarNavigationItem.default,
|
|
57
|
-
path: "/
|
|
57
|
+
path: "/wp_template",
|
|
58
58
|
withChevron: true,
|
|
59
59
|
icon: _icons.layout
|
|
60
60
|
}, (0, _i18n.__)('Templates')), (0, _element.createElement)(_components.__experimentalNavigatorButton, {
|
|
61
61
|
as: _sidebarNavigationItem.default,
|
|
62
|
-
path: "/
|
|
62
|
+
path: "/wp_template_part",
|
|
63
63
|
withChevron: true,
|
|
64
64
|
icon: _icons.symbolFilled
|
|
65
65
|
}, (0, _i18n.__)('Template Parts')))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-main/index.js"],"names":["SidebarNavigationScreenMain","navigationMenus","select","getEntityRecords","coreStore","per_page","status","length","SidebarNavigationItem","navigation","layout","symbolFilled"],"mappings":";;;;;;;;;;;AAGA;;AAIA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAhBA;AACA;AACA;;AAUA;AACA;AACA;AAIe,SAASA,2BAAT,GAAuC;AACrD,QAAM;AAAEC,IAAAA;AAAF,MAAsB,qBAAaC,MAAF,IAAc;AACpD,UAAM;AAAEC,MAAAA;AAAF,QAAuBD,MAAM,CAAEE,eAAF,CAAnC;AACA,WAAO;AACNH,MAAAA,eAAe,EAAEE,gBAAgB,CAAE,UAAF,EAAc,eAAd,EAA+B;AAC/DE,QAAAA,QAAQ,EAAE,CAAC,CADoD;AAE/DC,QAAAA,MAAM,EAAE;AAFuD,OAA/B;AAD3B,KAAP;AAMA,GAR2B,CAA5B;AAUA,SACC,4BAAC,gCAAD;AACC,IAAA,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-main/index.js"],"names":["SidebarNavigationScreenMain","navigationMenus","select","getEntityRecords","coreStore","per_page","status","length","SidebarNavigationItem","navigation","layout","symbolFilled"],"mappings":";;;;;;;;;;;AAGA;;AAIA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAhBA;AACA;AACA;;AAUA;AACA;AACA;AAIe,SAASA,2BAAT,GAAuC;AACrD,QAAM;AAAEC,IAAAA;AAAF,MAAsB,qBAAaC,MAAF,IAAc;AACpD,UAAM;AAAEC,MAAAA;AAAF,QAAuBD,MAAM,CAAEE,eAAF,CAAnC;AACA,WAAO;AACNH,MAAAA,eAAe,EAAEE,gBAAgB,CAAE,UAAF,EAAc,eAAd,EAA+B;AAC/DE,QAAAA,QAAQ,EAAE,CAAC,CADoD;AAE/DC,QAAAA,MAAM,EAAE;AAFuD,OAA/B;AAD3B,KAAP;AAMA,GAR2B,CAA5B;AAUA,SACC,4BAAC,gCAAD;AACC,IAAA,MAAM,MADP;AAEC,IAAA,KAAK,EAAG,cAAI,QAAJ,CAFT;AAGC,IAAA,OAAO,EACN,4BAAC,mCAAD,QACG,CAAC,CAAEL,eAAH,IAAsBA,eAAe,CAACM,MAAhB,GAAyB,CAA/C,IACD,4BAAC,yCAAD;AACC,MAAA,EAAE,EAAGC,8BADN;AAEC,MAAA,IAAI,EAAC,aAFN;AAGC,MAAA,WAAW,MAHZ;AAIC,MAAA,IAAI,EAAGC;AAJR,OAMG,cAAI,YAAJ,CANH,CAFF,EAWC,4BAAC,yCAAD;AACC,MAAA,EAAE,EAAGD,8BADN;AAEC,MAAA,IAAI,EAAC,cAFN;AAGC,MAAA,WAAW,MAHZ;AAIC,MAAA,IAAI,EAAGE;AAJR,OAMG,cAAI,WAAJ,CANH,CAXD,EAmBC,4BAAC,yCAAD;AACC,MAAA,EAAE,EAAGF,8BADN;AAEC,MAAA,IAAI,EAAC,mBAFN;AAGC,MAAA,WAAW,MAHZ;AAIC,MAAA,IAAI,EAAGG;AAJR,OAMG,cAAI,gBAAJ,CANH,CAnBD;AAJF,IADD;AAoCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalNavigatorButton as NavigatorButton,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { layout, symbolFilled, navigation } from '@wordpress/icons';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport SidebarNavigationItem from '../sidebar-navigation-item';\n\nexport default function SidebarNavigationScreenMain() {\n\tconst { navigationMenus } = useSelect( ( select ) => {\n\t\tconst { getEntityRecords } = select( coreStore );\n\t\treturn {\n\t\t\tnavigationMenus: getEntityRecords( 'postType', 'wp_navigation', {\n\t\t\t\tper_page: -1,\n\t\t\t\tstatus: 'publish',\n\t\t\t} ),\n\t\t};\n\t} );\n\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\tisRoot\n\t\t\ttitle={ __( 'Design' ) }\n\t\t\tcontent={\n\t\t\t\t<ItemGroup>\n\t\t\t\t\t{ !! navigationMenus && navigationMenus.length > 0 && (\n\t\t\t\t\t\t<NavigatorButton\n\t\t\t\t\t\t\tas={ SidebarNavigationItem }\n\t\t\t\t\t\t\tpath=\"/navigation\"\n\t\t\t\t\t\t\twithChevron\n\t\t\t\t\t\t\ticon={ navigation }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Navigation' ) }\n\t\t\t\t\t\t</NavigatorButton>\n\t\t\t\t\t) }\n\t\t\t\t\t<NavigatorButton\n\t\t\t\t\t\tas={ SidebarNavigationItem }\n\t\t\t\t\t\tpath=\"/wp_template\"\n\t\t\t\t\t\twithChevron\n\t\t\t\t\t\ticon={ layout }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Templates' ) }\n\t\t\t\t\t</NavigatorButton>\n\t\t\t\t\t<NavigatorButton\n\t\t\t\t\t\tas={ SidebarNavigationItem }\n\t\t\t\t\t\tpath=\"/wp_template_part\"\n\t\t\t\t\t\twithChevron\n\t\t\t\t\t\ticon={ symbolFilled }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Template Parts' ) }\n\t\t\t\t\t</NavigatorButton>\n\t\t\t\t</ItemGroup>\n\t\t\t}\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -38,29 +38,25 @@ function SidebarNavigationScreenNavigationItem() {
|
|
|
38
38
|
const {
|
|
39
39
|
setCanvasMode
|
|
40
40
|
} = (0, _privateApis.unlock)((0, _data.useDispatch)(_store.store));
|
|
41
|
+
const {
|
|
42
|
+
params: {
|
|
43
|
+
postType,
|
|
44
|
+
postId
|
|
45
|
+
}
|
|
46
|
+
} = (0, _components.__experimentalUseNavigator)();
|
|
41
47
|
const {
|
|
42
48
|
post
|
|
43
49
|
} = (0, _data.useSelect)(select => {
|
|
44
|
-
var _getEditedPostContext;
|
|
45
|
-
|
|
46
|
-
const {
|
|
47
|
-
getEditedPostContext
|
|
48
|
-
} = select(_store.store);
|
|
49
50
|
const {
|
|
50
51
|
getEntityRecord
|
|
51
|
-
} = select(_coreData.store);
|
|
52
|
-
const {
|
|
53
|
-
postType,
|
|
54
|
-
postId
|
|
55
|
-
} = (_getEditedPostContext = getEditedPostContext()) !== null && _getEditedPostContext !== void 0 ? _getEditedPostContext : {}; // The currently selected entity to display.
|
|
52
|
+
} = select(_coreData.store); // The currently selected entity to display.
|
|
56
53
|
// Typically template or template part in the site editor.
|
|
57
54
|
|
|
58
55
|
return {
|
|
59
56
|
post: postId && postType ? getEntityRecord('postType', postType, postId) : null
|
|
60
57
|
};
|
|
61
|
-
}, []);
|
|
58
|
+
}, [postType, postId]);
|
|
62
59
|
return (0, _element.createElement)(_sidebarNavigationScreen.default, {
|
|
63
|
-
path: "/navigation/single",
|
|
64
60
|
title: post ? (0, _htmlEntities.decodeEntities)(post === null || post === void 0 ? void 0 : (_post$title = post.title) === null || _post$title === void 0 ? void 0 : _post$title.rendered) : null,
|
|
65
61
|
actions: (0, _element.createElement)(_components.Button, {
|
|
66
62
|
variant: "primary",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-item/index.js"],"names":["SidebarNavigationScreenNavigationItem","setCanvasMode","editSiteStore","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-item/index.js"],"names":["SidebarNavigationScreenNavigationItem","setCanvasMode","editSiteStore","params","postType","postId","post","select","getEntityRecord","coreStore","title","rendered","description"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AAIA;;AACA;;AAKA;;AACA;;AACA;;AAjBA;AACA;AACA;;AAUA;AACA;AACA;AAKe,SAASA,qCAAT,GAAiD;AAAA;;AAC/D,QAAM;AAAEC,IAAAA;AAAF,MAAoB,yBAAQ,uBAAaC,YAAb,CAAR,CAA1B;AACA,QAAM;AACLC,IAAAA,MAAM,EAAE;AAAEC,MAAAA,QAAF;AAAYC,MAAAA;AAAZ;AADH,MAEF,6CAFJ;AAIA,QAAM;AAAEC,IAAAA;AAAF,MAAW,qBACdC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA;AAAF,QAAsBD,MAAM,CAAEE,eAAF,CAAlC,CADa,CAGb;AACA;;AACA,WAAO;AACNH,MAAAA,IAAI,EACHD,MAAM,IAAID,QAAV,GACGI,eAAe,CAAE,UAAF,EAAcJ,QAAd,EAAwBC,MAAxB,CADlB,GAEG;AAJE,KAAP;AAMA,GAZe,EAahB,CAAED,QAAF,EAAYC,MAAZ,CAbgB,CAAjB;AAgBA,SACC,4BAAC,gCAAD;AACC,IAAA,KAAK,EAAGC,IAAI,GAAG,kCAAgBA,IAAhB,aAAgBA,IAAhB,sCAAgBA,IAAI,CAAEI,KAAtB,gDAAgB,YAAaC,QAA7B,CAAH,GAA6C,IAD1D;AAEC,IAAA,OAAO,EACN,4BAAC,kBAAD;AACC,MAAA,OAAO,EAAC,SADT;AAEC,MAAA,OAAO,EAAG,MAAMV,aAAa,CAAE,MAAF;AAF9B,OAIG,cAAI,MAAJ,CAJH,CAHF;AAUC,IAAA,OAAO,EACNK,IAAI,GAAG,kCAAgBA,IAAhB,aAAgBA,IAAhB,4CAAgBA,IAAI,CAAEM,WAAtB,sDAAgB,kBAAmBD,QAAnC,CAAH,GAAmD;AAXzD,IADD;AAgBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tButton,\n\t__experimentalUseNavigator as useNavigator,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport { unlock } from '../../private-apis';\nimport { store as editSiteStore } from '../../store';\n\nexport default function SidebarNavigationScreenNavigationItem() {\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst {\n\t\tparams: { postType, postId },\n\t} = useNavigator();\n\n\tconst { post } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\n\t\t\t// The currently selected entity to display.\n\t\t\t// Typically template or template part in the site editor.\n\t\t\treturn {\n\t\t\t\tpost:\n\t\t\t\t\tpostId && postType\n\t\t\t\t\t\t? getEntityRecord( 'postType', postType, postId )\n\t\t\t\t\t\t: null,\n\t\t\t};\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\ttitle={ post ? decodeEntities( post?.title?.rendered ) : null }\n\t\t\tactions={\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\tonClick={ () => setCanvasMode( 'edit' ) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Edit' ) }\n\t\t\t\t</Button>\n\t\t\t}\n\t\t\tcontent={\n\t\t\t\tpost ? decodeEntities( post?.description?.rendered ) : null\n\t\t\t}\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -34,13 +34,11 @@ function SidebarNavigationScreenNavigationMenus() {
|
|
|
34
34
|
if (attributes.kind === 'post-type' && attributes.id && attributes.type && history) {
|
|
35
35
|
history.push({
|
|
36
36
|
postType: attributes.type,
|
|
37
|
-
postId: attributes.id
|
|
38
|
-
path: '/navigation/single'
|
|
37
|
+
postId: attributes.id
|
|
39
38
|
});
|
|
40
39
|
}
|
|
41
40
|
}, [history]);
|
|
42
41
|
return (0, _element.createElement)(_sidebarNavigationScreen.default, {
|
|
43
|
-
path: "/navigation",
|
|
44
42
|
title: (0, _i18n.__)('Navigation'),
|
|
45
43
|
content: (0, _element.createElement)("div", {
|
|
46
44
|
className: "edit-site-sidebar-navigation-screen-navigation-menus"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-menus/index.js"],"names":["SidebarNavigationScreenNavigationMenus","history","onSelect","selectedBlock","attributes","kind","id","type","push","postType","postId"
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-menus/index.js"],"names":["SidebarNavigationScreenNavigationMenus","history","onSelect","selectedBlock","attributes","kind","id","type","push","postType","postId"],"mappings":";;;;;;;;;AAIA;;AADA;;AAMA;;AACA;;AACA;;AAXA;AACA;AACA;;AAIA;AACA;AACA;AAKe,SAASA,sCAAT,GAAkD;AAChE,QAAMC,OAAO,GAAG,yBAAhB;AACA,QAAMC,QAAQ,GAAG,0BACdC,aAAF,IAAqB;AACpB,UAAM;AAAEC,MAAAA;AAAF,QAAiBD,aAAvB;;AACA,QACCC,UAAU,CAACC,IAAX,KAAoB,WAApB,IACAD,UAAU,CAACE,EADX,IAEAF,UAAU,CAACG,IAFX,IAGAN,OAJD,EAKE;AACDA,MAAAA,OAAO,CAACO,IAAR,CAAc;AACbC,QAAAA,QAAQ,EAAEL,UAAU,CAACG,IADR;AAEbG,QAAAA,MAAM,EAAEN,UAAU,CAACE;AAFN,OAAd;AAIA;AACD,GAde,EAehB,CAAEL,OAAF,CAfgB,CAAjB;AAiBA,SACC,4BAAC,gCAAD;AACC,IAAA,KAAK,EAAG,cAAI,YAAJ,CADT;AAEC,IAAA,OAAO,EACN;AAAK,MAAA,SAAS,EAAC;AAAf,OACC,4BAAC,4BAAD;AAAqB,MAAA,QAAQ,EAAGC;AAAhC,MADD;AAHF,IADD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport NavigationInspector from '../navigation-inspector';\nimport { useHistory } from '../routes';\n\nexport default function SidebarNavigationScreenNavigationMenus() {\n\tconst history = useHistory();\n\tconst onSelect = useCallback(\n\t\t( selectedBlock ) => {\n\t\t\tconst { attributes } = selectedBlock;\n\t\t\tif (\n\t\t\t\tattributes.kind === 'post-type' &&\n\t\t\t\tattributes.id &&\n\t\t\t\tattributes.type &&\n\t\t\t\thistory\n\t\t\t) {\n\t\t\t\thistory.push( {\n\t\t\t\t\tpostType: attributes.type,\n\t\t\t\t\tpostId: attributes.id,\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ history ]\n\t);\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\ttitle={ __( 'Navigation' ) }\n\t\t\tcontent={\n\t\t\t\t<div className=\"edit-site-sidebar-navigation-screen-navigation-menus\">\n\t\t\t\t\t<NavigationInspector onSelect={ onSelect } />\n\t\t\t\t</div>\n\t\t\t}\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -30,19 +30,7 @@ var _store = require("../../store");
|
|
|
30
30
|
/**
|
|
31
31
|
* Internal dependencies
|
|
32
32
|
*/
|
|
33
|
-
|
|
34
|
-
wp_template: {
|
|
35
|
-
path: '/templates/single'
|
|
36
|
-
},
|
|
37
|
-
wp_template_part: {
|
|
38
|
-
path: '/template-parts/single'
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
function SidebarNavigationScreenTemplate(_ref) {
|
|
43
|
-
let {
|
|
44
|
-
postType = 'wp_template'
|
|
45
|
-
} = _ref;
|
|
33
|
+
function SidebarNavigationScreenTemplate() {
|
|
46
34
|
const {
|
|
47
35
|
setCanvasMode
|
|
48
36
|
} = (0, _privateApis.unlock)((0, _data.useDispatch)(_store.store));
|
|
@@ -58,7 +46,6 @@ function SidebarNavigationScreenTemplate(_ref) {
|
|
|
58
46
|
}
|
|
59
47
|
|
|
60
48
|
return (0, _element.createElement)(_sidebarNavigationScreen.default, {
|
|
61
|
-
path: config[postType].path,
|
|
62
49
|
title: getTitle(),
|
|
63
50
|
actions: (0, _element.createElement)(_components.Button, {
|
|
64
51
|
variant: "primary",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-template/index.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-template/index.js"],"names":["SidebarNavigationScreenTemplate","setCanvasMode","editSiteStore","getDescription","getTitle","record","description","is_custom","undefined"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAbA;AACA;AACA;;AAKA;AACA;AACA;AAMe,SAASA,+BAAT,GAA2C;AACzD,QAAM;AAAEC,IAAAA;AAAF,MAAoB,yBAAQ,uBAAaC,YAAb,CAAR,CAA1B;AACA,QAAM;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA,QAAlB;AAA4BC,IAAAA;AAA5B,MAAuC,qCAA7C;AACA,MAAIC,WAAW,GAAGH,cAAc,EAAhC;;AACA,MAAK,CAAEG,WAAF,IAAiBD,MAAM,CAACE,SAA7B,EAAyC;AACxCD,IAAAA,WAAW,GAAG,cACb,6EADa,CAAd;AAGA;;AAED,SACC,4BAAC,gCAAD;AACC,IAAA,KAAK,EAAGF,QAAQ,EADjB;AAEC,IAAA,OAAO,EACN,4BAAC,kBAAD;AACC,MAAA,OAAO,EAAC,SADT;AAEC,MAAA,OAAO,EAAG,MAAMH,aAAa,CAAE,MAAF;AAF9B,OAIG,cAAI,MAAJ,CAJH,CAHF;AAUC,IAAA,OAAO,EAAGK,WAAW,GAAG,uCAAKA,WAAL,CAAH,GAA4BE;AAVlD,IADD;AAcA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { Button } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport useEditedEntityRecord from '../use-edited-entity-record';\nimport { unlock } from '../../private-apis';\nimport { store as editSiteStore } from '../../store';\n\nexport default function SidebarNavigationScreenTemplate() {\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst { getDescription, getTitle, record } = useEditedEntityRecord();\n\tlet description = getDescription();\n\tif ( ! description && record.is_custom ) {\n\t\tdescription = __(\n\t\t\t'This is a custom template that can be applied manually to any Post or Page.'\n\t\t);\n\t}\n\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\ttitle={ getTitle() }\n\t\t\tactions={\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\tonClick={ () => setCanvasMode( 'edit' ) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Edit' ) }\n\t\t\t\t</Button>\n\t\t\t}\n\t\t\tcontent={ description ? <p>{ description }</p> : undefined }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -38,7 +38,6 @@ var _addNewTemplate = _interopRequireDefault(require("../add-new-template"));
|
|
|
38
38
|
*/
|
|
39
39
|
const config = {
|
|
40
40
|
wp_template: {
|
|
41
|
-
path: '/templates',
|
|
42
41
|
labels: {
|
|
43
42
|
title: (0, _i18n.__)('Templates'),
|
|
44
43
|
loading: (0, _i18n.__)('Loading templates'),
|
|
@@ -47,7 +46,6 @@ const config = {
|
|
|
47
46
|
}
|
|
48
47
|
},
|
|
49
48
|
wp_template_part: {
|
|
50
|
-
path: '/template-parts',
|
|
51
49
|
labels: {
|
|
52
50
|
title: (0, _i18n.__)('Template parts'),
|
|
53
51
|
loading: (0, _i18n.__)('Loading template parts'),
|
|
@@ -65,16 +63,17 @@ const TemplateItem = _ref => {
|
|
|
65
63
|
} = _ref;
|
|
66
64
|
const linkInfo = (0, _link.useLink)({
|
|
67
65
|
postType,
|
|
68
|
-
postId
|
|
69
|
-
path: config[postType].path + '/single'
|
|
66
|
+
postId
|
|
70
67
|
});
|
|
71
68
|
return (0, _element.createElement)(_sidebarNavigationItem.default, (0, _extends2.default)({}, linkInfo, props));
|
|
72
69
|
};
|
|
73
70
|
|
|
74
|
-
function SidebarNavigationScreenTemplates(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
function SidebarNavigationScreenTemplates() {
|
|
72
|
+
const {
|
|
73
|
+
params: {
|
|
74
|
+
postType
|
|
75
|
+
}
|
|
76
|
+
} = (0, _components.__experimentalUseNavigator)();
|
|
78
77
|
const isMobileViewport = (0, _compose.useViewportMatch)('medium', '<');
|
|
79
78
|
const {
|
|
80
79
|
records: templates,
|
|
@@ -83,12 +82,9 @@ function SidebarNavigationScreenTemplates(_ref2) {
|
|
|
83
82
|
per_page: -1
|
|
84
83
|
});
|
|
85
84
|
const browseAllLink = (0, _link.useLink)({
|
|
86
|
-
postType
|
|
87
|
-
postId: undefined,
|
|
88
|
-
path: config[postType].path + '/all'
|
|
85
|
+
path: '/' + postType + '/all'
|
|
89
86
|
});
|
|
90
87
|
return (0, _element.createElement)(_sidebarNavigationScreen.default, {
|
|
91
|
-
path: config[postType].path,
|
|
92
88
|
title: config[postType].labels.title,
|
|
93
89
|
actions: !isMobileViewport && (0, _element.createElement)(_addNewTemplate.default, {
|
|
94
90
|
templateType: postType,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-templates/index.js"],"names":["config","wp_template","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-templates/index.js"],"names":["config","wp_template","labels","title","loading","notFound","manage","wp_template_part","TemplateItem","postType","postId","props","linkInfo","SidebarNavigationScreenTemplates","params","isMobileViewport","records","templates","isResolving","isLoading","per_page","browseAllLink","path","className","length","map","template","id","rendered","slug"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAnBA;AACA;AACA;;AAWA;AACA;AACA;AAMA,MAAMA,MAAM,GAAG;AACdC,EAAAA,WAAW,EAAE;AACZC,IAAAA,MAAM,EAAE;AACPC,MAAAA,KAAK,EAAE,cAAI,WAAJ,CADA;AAEPC,MAAAA,OAAO,EAAE,cAAI,mBAAJ,CAFF;AAGPC,MAAAA,QAAQ,EAAE,cAAI,oBAAJ,CAHH;AAIPC,MAAAA,MAAM,EAAE,cAAI,sBAAJ;AAJD;AADI,GADC;AASdC,EAAAA,gBAAgB,EAAE;AACjBL,IAAAA,MAAM,EAAE;AACPC,M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,CAAES,QAAF,CAAN,CAAmBP,MAAnB,CAA0BE,OAD1C,EAEG,CAAEe,SAAF,IACD,4BAAC,mCAAD,QACG,EAAEF,SAAF,aAAEA,SAAF,eAAEA,SAAS,CAAEO,MAAb,KACD,4BAAC,8BAAD,QACGxB,MAAM,CAAES,QAAF,CAAN,CAAmBP,MAAnB,CAA0BG,QAD7B,CAFF,EAMG,CAAEY,SAAF,aAAEA,SAAF,cAAEA,SAAF,GAAe,EAAf,EAAoBQ,GAApB,CAA2BC,QAAF;AAAA;;AAAA,aAC1B,4BAAC,YAAD;AACC,QAAA,QAAQ,EAAGjB,QADZ;AAEC,QAAA,MAAM,EAAGiB,QAAQ,CAACC,EAFnB;AAGC,QAAA,GAAG,EAAGD,QAAQ,CAACC;AAHhB,SAKG,kCACD,oBAAAD,QAAQ,CAACvB,KAAT,oEAAgByB,QAAhB,KACCF,QAAQ,CAACG,IAFT,CALH,CAD0B;AAAA,KAAzB,CANH,EAkBG,CAAEd,gBAAF,IACD,4BAAC,8BAAD;AACC,MAAA,SAAS,EAAC;AADX,OAEMM,aAFN;AAGC,MAAA,QAAQ,EACPrB,MAAM,CAAES,QAAF,CAAN,CAAmBP,MAAnB,CAA0BI;AAJ5B,OAnBF,CAHF;AAdF,IADD;AAmDA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalItem as Item,\n\t__experimentalUseNavigator as useNavigator,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport { useLink } from '../routes/link';\nimport SidebarNavigationItem from '../sidebar-navigation-item';\nimport AddNewTemplate from '../add-new-template';\n\nconst config = {\n\twp_template: {\n\t\tlabels: {\n\t\t\ttitle: __( 'Templates' ),\n\t\t\tloading: __( 'Loading templates' ),\n\t\t\tnotFound: __( 'No templates found' ),\n\t\t\tmanage: __( 'Manage all templates' ),\n\t\t},\n\t},\n\twp_template_part: {\n\t\tlabels: {\n\t\t\ttitle: __( 'Template parts' ),\n\t\t\tloading: __( 'Loading template parts' ),\n\t\t\tnotFound: __( 'No template parts found' ),\n\t\t\tmanage: __( 'Manage all template parts' ),\n\t\t},\n\t},\n};\n\nconst TemplateItem = ( { postType, postId, ...props } ) => {\n\tconst linkInfo = useLink( {\n\t\tpostType,\n\t\tpostId,\n\t} );\n\treturn <SidebarNavigationItem { ...linkInfo } { ...props } />;\n};\n\nexport default function SidebarNavigationScreenTemplates() {\n\tconst {\n\t\tparams: { postType },\n\t} = useNavigator();\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\n\tconst { records: templates, isResolving: isLoading } = useEntityRecords(\n\t\t'postType',\n\t\tpostType,\n\t\t{\n\t\t\tper_page: -1,\n\t\t}\n\t);\n\n\tconst browseAllLink = useLink( {\n\t\tpath: '/' + postType + '/all',\n\t} );\n\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\ttitle={ config[ postType ].labels.title }\n\t\t\tactions={\n\t\t\t\t! isMobileViewport && (\n\t\t\t\t\t<AddNewTemplate\n\t\t\t\t\t\ttemplateType={ postType }\n\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\tclassName:\n\t\t\t\t\t\t\t\t'edit-site-sidebar-navigation-screen-templates__add-button',\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\tcontent={\n\t\t\t\t<>\n\t\t\t\t\t{ isLoading && config[ postType ].labels.loading }\n\t\t\t\t\t{ ! isLoading && (\n\t\t\t\t\t\t<ItemGroup>\n\t\t\t\t\t\t\t{ ! templates?.length && (\n\t\t\t\t\t\t\t\t<Item>\n\t\t\t\t\t\t\t\t\t{ config[ postType ].labels.notFound }\n\t\t\t\t\t\t\t\t</Item>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ ( templates ?? [] ).map( ( template ) => (\n\t\t\t\t\t\t\t\t<TemplateItem\n\t\t\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\t\t\tpostId={ template.id }\n\t\t\t\t\t\t\t\t\tkey={ template.id }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ decodeEntities(\n\t\t\t\t\t\t\t\t\t\ttemplate.title?.rendered ||\n\t\t\t\t\t\t\t\t\t\t\ttemplate.slug\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</TemplateItem>\n\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t{ ! isMobileViewport && (\n\t\t\t\t\t\t\t\t<SidebarNavigationItem\n\t\t\t\t\t\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen-templates__see-all\"\n\t\t\t\t\t\t\t\t\t{ ...browseAllLink }\n\t\t\t\t\t\t\t\t\tchildren={\n\t\t\t\t\t\t\t\t\t\tconfig[ postType ].labels.manage\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</ItemGroup>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t}\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -11,6 +11,8 @@ var _element = require("@wordpress/element");
|
|
|
11
11
|
|
|
12
12
|
var _i18n = require("@wordpress/i18n");
|
|
13
13
|
|
|
14
|
+
var _components = require("@wordpress/components");
|
|
15
|
+
|
|
14
16
|
var _sidebarNavigationScreen = _interopRequireDefault(require("../sidebar-navigation-screen"));
|
|
15
17
|
|
|
16
18
|
/**
|
|
@@ -22,21 +24,20 @@ var _sidebarNavigationScreen = _interopRequireDefault(require("../sidebar-naviga
|
|
|
22
24
|
*/
|
|
23
25
|
const config = {
|
|
24
26
|
wp_template: {
|
|
25
|
-
path: '/templates/all',
|
|
26
27
|
title: (0, _i18n.__)('All templates')
|
|
27
28
|
},
|
|
28
29
|
wp_template_part: {
|
|
29
|
-
path: '/template-parts/all',
|
|
30
30
|
title: (0, _i18n.__)('All template parts')
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
function SidebarNavigationScreenTemplatesBrowse(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
function SidebarNavigationScreenTemplatesBrowse() {
|
|
35
|
+
const {
|
|
36
|
+
params: {
|
|
37
|
+
postType
|
|
38
|
+
}
|
|
39
|
+
} = (0, _components.__experimentalUseNavigator)();
|
|
38
40
|
return (0, _element.createElement)(_sidebarNavigationScreen.default, {
|
|
39
|
-
path: config[postType].path,
|
|
40
41
|
title: config[postType].title
|
|
41
42
|
});
|
|
42
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-templates-browse/index.js"],"names":["config","wp_template","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-templates-browse/index.js"],"names":["config","wp_template","title","wp_template_part","SidebarNavigationScreenTemplatesBrowse","params","postType"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;AAGA,MAAMA,MAAM,GAAG;AACdC,EAAAA,WAAW,EAAE;AACZC,IAAAA,KAAK,EAAE,cAAI,eAAJ;AADK,GADC;AAIdC,EAAAA,gBAAgB,EAAE;AACjBD,IAAAA,KAAK,EAAE,cAAI,oBAAJ;AADU;AAJJ,CAAf;;AASe,SAASE,sCAAT,GAAkD;AAChE,QAAM;AACLC,IAAAA,MAAM,EAAE;AAAEC,MAAAA;AAAF;AADH,MAEF,6CAFJ;AAGA,SAAO,4BAAC,gCAAD;AAAyB,IAAA,KAAK,EAAGN,MAAM,CAAEM,QAAF,CAAN,CAAmBJ;AAApD,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { __experimentalUseNavigator as useNavigator } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\n\nconst config = {\n\twp_template: {\n\t\ttitle: __( 'All templates' ),\n\t},\n\twp_template_part: {\n\t\ttitle: __( 'All template parts' ),\n\t},\n};\n\nexport default function SidebarNavigationScreenTemplatesBrowse() {\n\tconst {\n\t\tparams: { postType },\n\t} = useNavigator();\n\treturn <SidebarNavigationScreen title={ config[ postType ].title } />;\n}\n"]}
|
|
@@ -26,8 +26,7 @@ function useInitEditedEntityFromURL() {
|
|
|
26
26
|
const {
|
|
27
27
|
params: {
|
|
28
28
|
postId,
|
|
29
|
-
postType
|
|
30
|
-
path = '/'
|
|
29
|
+
postType
|
|
31
30
|
} = {}
|
|
32
31
|
} = (0, _routes.useLocation)();
|
|
33
32
|
const {
|
|
@@ -49,40 +48,43 @@ function useInitEditedEntityFromURL() {
|
|
|
49
48
|
setPage
|
|
50
49
|
} = (0, _data.useDispatch)(_store.store);
|
|
51
50
|
(0, _element.useEffect)(() => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
if (postType && postId && // This is just a special case to support old WP versions that perform redirects.
|
|
52
|
+
// This code should be removed when we minimum WP version becomes 6.2.
|
|
53
|
+
postId !== 'none') {
|
|
54
|
+
switch (postType) {
|
|
55
|
+
case 'wp_template':
|
|
56
|
+
setTemplate(postId);
|
|
57
|
+
break;
|
|
56
58
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
case 'wp_template_part':
|
|
60
|
+
setTemplatePart(postId);
|
|
61
|
+
break;
|
|
60
62
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
default:
|
|
64
|
+
setPage({
|
|
65
|
+
context: {
|
|
66
|
+
postType,
|
|
67
|
+
postId
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
69
71
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
} else if (!isRequestingSite) {
|
|
80
|
-
setPage({
|
|
81
|
-
path: '/'
|
|
82
|
-
});
|
|
83
|
-
}
|
|
72
|
+
return;
|
|
73
|
+
} // In all other cases, we need to set the home page in the site editor view.
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
if (homepageId) {
|
|
77
|
+
setPage({
|
|
78
|
+
context: {
|
|
79
|
+
postType: 'page',
|
|
80
|
+
postId: homepageId
|
|
84
81
|
}
|
|
82
|
+
});
|
|
83
|
+
} else if (!isRequestingSite) {
|
|
84
|
+
setPage({
|
|
85
|
+
path: '/'
|
|
86
|
+
});
|
|
85
87
|
}
|
|
86
|
-
}, [
|
|
88
|
+
}, [postId, postType, homepageId, isRequestingSite, setPage, setTemplate, setTemplatePart]);
|
|
87
89
|
}
|
|
88
90
|
//# sourceMappingURL=use-init-edited-entity-from-url.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js"],"names":["useInitEditedEntityFromURL","params","postId","postType","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js"],"names":["useInitEditedEntityFromURL","params","postId","postType","isRequestingSite","homepageId","select","getSite","coreDataStore","siteData","show_on_front","page_on_front","setTemplate","setTemplatePart","setPage","editSiteStore","context","path"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AAXA;AACA;AACA;;AAKA;AACA;AACA;AAIe,SAASA,0BAAT,GAAsC;AACpD,QAAM;AAAEC,IAAAA,MAAM,EAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA;AAAV,QAAuB;AAAjC,MAAwC,0BAA9C;AACA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FE,EAGFE,UAHE,EAIFD,gBAJE,EAKFU,OALE,EAMFF,WANE,EAOFC,eAPE,CAlCH;AA2CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useLocation } from '../routes';\nimport { store as editSiteStore } from '../../store';\n\nexport default function useInitEditedEntityFromURL() {\n\tconst { params: { postId, postType } = {} } = useLocation();\n\tconst { isRequestingSite, homepageId } = useSelect( ( select ) => {\n\t\tconst { getSite } = select( coreDataStore );\n\t\tconst siteData = getSite();\n\n\t\treturn {\n\t\t\tisRequestingSite: ! siteData,\n\t\t\thomepageId:\n\t\t\t\tsiteData?.show_on_front === 'page'\n\t\t\t\t\t? siteData.page_on_front\n\t\t\t\t\t: null,\n\t\t};\n\t}, [] );\n\n\tconst { setTemplate, setTemplatePart, setPage } =\n\t\tuseDispatch( editSiteStore );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\tpostType &&\n\t\t\tpostId &&\n\t\t\t// This is just a special case to support old WP versions that perform redirects.\n\t\t\t// This code should be removed when we minimum WP version becomes 6.2.\n\t\t\tpostId !== 'none'\n\t\t) {\n\t\t\tswitch ( postType ) {\n\t\t\t\tcase 'wp_template':\n\t\t\t\t\tsetTemplate( postId );\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'wp_template_part':\n\t\t\t\t\tsetTemplatePart( postId );\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tsetPage( {\n\t\t\t\t\t\tcontext: { postType, postId },\n\t\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\t// In all other cases, we need to set the home page in the site editor view.\n\t\tif ( homepageId ) {\n\t\t\tsetPage( {\n\t\t\t\tcontext: { postType: 'page', postId: homepageId },\n\t\t\t} );\n\t\t} else if ( ! isRequestingSite ) {\n\t\t\tsetPage( {\n\t\t\t\tpath: '/',\n\t\t\t} );\n\t\t}\n\t}, [\n\t\tpostId,\n\t\tpostType,\n\t\thomepageId,\n\t\tisRequestingSite,\n\t\tsetPage,\n\t\tsetTemplate,\n\t\tsetTemplatePart,\n\t] );\n}\n"]}
|
|
@@ -21,33 +21,82 @@ var _routes = require("../routes");
|
|
|
21
21
|
function useSyncPathWithURL() {
|
|
22
22
|
const history = (0, _routes.useHistory)();
|
|
23
23
|
const {
|
|
24
|
-
params
|
|
24
|
+
params: urlParams
|
|
25
25
|
} = (0, _routes.useLocation)();
|
|
26
26
|
const {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const {
|
|
30
|
-
location,
|
|
27
|
+
location: navigatorLocation,
|
|
28
|
+
params: navigatorParams,
|
|
31
29
|
goTo
|
|
32
30
|
} = (0, _components.__experimentalUseNavigator)();
|
|
33
|
-
const
|
|
34
|
-
const
|
|
31
|
+
const currentUrlParams = (0, _element.useRef)(urlParams);
|
|
32
|
+
const currentPath = (0, _element.useRef)();
|
|
35
33
|
(0, _element.useEffect)(() => {
|
|
36
|
-
|
|
34
|
+
// Don't trust the navigator path on initial render.
|
|
35
|
+
if (currentPath.current === null) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
function updateUrlParams(newUrlParams) {
|
|
40
|
+
if (Object.entries(newUrlParams).every(_ref => {
|
|
41
|
+
let [key, value] = _ref;
|
|
42
|
+
return currentUrlParams.current[key] === value;
|
|
43
|
+
})) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const updatedParams = { ...currentUrlParams.current,
|
|
48
|
+
...newUrlParams
|
|
49
|
+
};
|
|
50
|
+
currentUrlParams.current = updatedParams;
|
|
51
|
+
history.push(updatedParams);
|
|
40
52
|
}
|
|
41
|
-
}, [path]);
|
|
42
|
-
(0, _element.useEffect)(() => {
|
|
43
|
-
currentNavigatorLocation.current = location.path;
|
|
44
53
|
|
|
45
|
-
if (
|
|
46
|
-
|
|
47
|
-
|
|
54
|
+
if (navigatorParams !== null && navigatorParams !== void 0 && navigatorParams.postType && navigatorParams !== null && navigatorParams !== void 0 && navigatorParams.postId) {
|
|
55
|
+
updateUrlParams({
|
|
56
|
+
postType: navigatorParams === null || navigatorParams === void 0 ? void 0 : navigatorParams.postType,
|
|
57
|
+
postId: navigatorParams === null || navigatorParams === void 0 ? void 0 : navigatorParams.postId,
|
|
58
|
+
path: undefined
|
|
59
|
+
});
|
|
60
|
+
} else if (navigatorParams !== null && navigatorParams !== void 0 && navigatorParams.postType && !(navigatorParams !== null && navigatorParams !== void 0 && navigatorParams.postId)) {
|
|
61
|
+
updateUrlParams({
|
|
62
|
+
postType: navigatorParams === null || navigatorParams === void 0 ? void 0 : navigatorParams.postType,
|
|
63
|
+
path: navigatorLocation.path,
|
|
64
|
+
postId: undefined
|
|
48
65
|
});
|
|
66
|
+
} else {
|
|
67
|
+
updateUrlParams({
|
|
68
|
+
postType: undefined,
|
|
69
|
+
postId: undefined,
|
|
70
|
+
path: navigatorLocation.path
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}, [navigatorLocation === null || navigatorLocation === void 0 ? void 0 : navigatorLocation.path, navigatorParams, history]);
|
|
74
|
+
(0, _element.useEffect)(() => {
|
|
75
|
+
var _urlParams$path;
|
|
76
|
+
|
|
77
|
+
currentUrlParams.current = urlParams;
|
|
78
|
+
let path = (_urlParams$path = urlParams === null || urlParams === void 0 ? void 0 : urlParams.path) !== null && _urlParams$path !== void 0 ? _urlParams$path : '/'; // Compute the navigator path based on the URL params.
|
|
79
|
+
|
|
80
|
+
if (urlParams !== null && urlParams !== void 0 && urlParams.postType && urlParams !== null && urlParams !== void 0 && urlParams.postId && // This is just a special case to support old WP versions that perform redirects.
|
|
81
|
+
// This code should be removed when we minimum WP version becomes 6.2.
|
|
82
|
+
(urlParams === null || urlParams === void 0 ? void 0 : urlParams.postId) !== 'none') {
|
|
83
|
+
switch (urlParams.postType) {
|
|
84
|
+
case 'wp_template':
|
|
85
|
+
case 'wp_template_part':
|
|
86
|
+
path = `/${encodeURIComponent(urlParams.postType)}/${encodeURIComponent(urlParams.postId)}`;
|
|
87
|
+
break;
|
|
88
|
+
|
|
89
|
+
default:
|
|
90
|
+
path = `/navigation/${encodeURIComponent(urlParams.postType)}/${encodeURIComponent(urlParams.postId)}`;
|
|
91
|
+
}
|
|
49
92
|
}
|
|
50
|
-
|
|
51
|
-
|
|
93
|
+
|
|
94
|
+
if (currentPath.current !== path) {
|
|
95
|
+
currentPath.current = path;
|
|
96
|
+
goTo(path);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
goTo(path);
|
|
100
|
+
}, [urlParams, goTo]);
|
|
52
101
|
}
|
|
53
102
|
//# sourceMappingURL=use-sync-path-with-url.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-sync-path-with-url.js"],"names":["useSyncPathWithURL","history","params","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-sync-path-with-url.js"],"names":["useSyncPathWithURL","history","params","urlParams","location","navigatorLocation","navigatorParams","goTo","currentUrlParams","currentPath","current","updateUrlParams","newUrlParams","Object","entries","every","key","value","updatedParams","push","postType","postId","path","undefined","encodeURIComponent"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;AAGe,SAASA,kBAAT,GAA8B;AAC5C,QAAMC,OAAO,GAAG,yBAAhB;AACA,QAAM;AAAEC,IAAAA,MAAM,EAAEC;AAAV,MAAwB,0BAA9B;AACA,QAAM;AACLC,IAAAA,QAAQ,EAAEC,iBADL;AAELH,IAAAA,MAAM,EAAEI,eAFH;AAGLC,IAAAA;AAHK,MAIF,6CAJJ;AAKA,QAAMC,gBAAgB,GAAG,qBAAQL,SAAR,CAAzB;AACA,QAAMM,WAAW,GAAG,sBAApB;AAEA,0B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F,CAAJ;AACA;;AACDf,IAAAA,IAAI,CAAEe,IAAF,CAAJ;AACA,GA/BD,EA+BG,CAAEnB,SAAF,EAAaI,IAAb,CA/BH;AAgCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalUseNavigator as useNavigator } from '@wordpress/components';\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useLocation, useHistory } from '../routes';\n\nexport default function useSyncPathWithURL() {\n\tconst history = useHistory();\n\tconst { params: urlParams } = useLocation();\n\tconst {\n\t\tlocation: navigatorLocation,\n\t\tparams: navigatorParams,\n\t\tgoTo,\n\t} = useNavigator();\n\tconst currentUrlParams = useRef( urlParams );\n\tconst currentPath = useRef();\n\n\tuseEffect( () => {\n\t\t// Don't trust the navigator path on initial render.\n\t\tif ( currentPath.current === null ) {\n\t\t\treturn;\n\t\t}\n\t\tfunction updateUrlParams( newUrlParams ) {\n\t\t\tif (\n\t\t\t\tObject.entries( newUrlParams ).every( ( [ key, value ] ) => {\n\t\t\t\t\treturn currentUrlParams.current[ key ] === value;\n\t\t\t\t} )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst updatedParams = {\n\t\t\t\t...currentUrlParams.current,\n\t\t\t\t...newUrlParams,\n\t\t\t};\n\t\t\tcurrentUrlParams.current = updatedParams;\n\t\t\thistory.push( updatedParams );\n\t\t}\n\n\t\tif ( navigatorParams?.postType && navigatorParams?.postId ) {\n\t\t\tupdateUrlParams( {\n\t\t\t\tpostType: navigatorParams?.postType,\n\t\t\t\tpostId: navigatorParams?.postId,\n\t\t\t\tpath: undefined,\n\t\t\t} );\n\t\t} else if ( navigatorParams?.postType && ! navigatorParams?.postId ) {\n\t\t\tupdateUrlParams( {\n\t\t\t\tpostType: navigatorParams?.postType,\n\t\t\t\tpath: navigatorLocation.path,\n\t\t\t\tpostId: undefined,\n\t\t\t} );\n\t\t} else {\n\t\t\tupdateUrlParams( {\n\t\t\t\tpostType: undefined,\n\t\t\t\tpostId: undefined,\n\t\t\t\tpath: navigatorLocation.path,\n\t\t\t} );\n\t\t}\n\t}, [ navigatorLocation?.path, navigatorParams, history ] );\n\n\tuseEffect( () => {\n\t\tcurrentUrlParams.current = urlParams;\n\t\tlet path = urlParams?.path ?? '/';\n\n\t\t// Compute the navigator path based on the URL params.\n\t\tif (\n\t\t\turlParams?.postType &&\n\t\t\turlParams?.postId &&\n\t\t\t// This is just a special case to support old WP versions that perform redirects.\n\t\t\t// This code should be removed when we minimum WP version becomes 6.2.\n\t\t\turlParams?.postId !== 'none'\n\t\t) {\n\t\t\tswitch ( urlParams.postType ) {\n\t\t\t\tcase 'wp_template':\n\t\t\t\tcase 'wp_template_part':\n\t\t\t\t\tpath = `/${ encodeURIComponent(\n\t\t\t\t\t\turlParams.postType\n\t\t\t\t\t) }/${ encodeURIComponent( urlParams.postId ) }`;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tpath = `/navigation/${ encodeURIComponent(\n\t\t\t\t\t\turlParams.postType\n\t\t\t\t\t) }/${ encodeURIComponent( urlParams.postId ) }`;\n\t\t\t}\n\t\t}\n\n\t\tif ( currentPath.current !== path ) {\n\t\t\tcurrentPath.current = path;\n\t\t\tgoTo( path );\n\t\t}\n\t\tgoTo( path );\n\t}, [ urlParams, goTo ] );\n}\n"]}
|