diff --git a/lib/experimental/posts/load.php b/lib/experimental/posts/load.php
index 7321392b11a25d..699534f1886f52 100644
--- a/lib/experimental/posts/load.php
+++ b/lib/experimental/posts/load.php
@@ -69,18 +69,6 @@ function gutenberg_posts_dashboard() {
echo '
';
}
-/**
- * Redirects to the new posts dashboard page and adds the postType query arg.
- */
-function gutenberg_add_post_type_arg() {
- global $pagenow;
- if ( 'admin.php' === $pagenow && isset( $_GET['page'] ) && 'gutenberg-posts-dashboard' === $_GET['page'] && empty( $_GET['postType'] ) ) {
- wp_redirect( admin_url( '/admin.php?page=gutenberg-posts-dashboard&postType=post' ) );
- exit;
- }
-}
-add_action( 'admin_init', 'gutenberg_add_post_type_arg' );
-
/**
* Replaces the default posts menu item with the new posts dashboard.
*/
diff --git a/lib/experimental/site-editor-permalinks.php b/lib/experimental/site-editor-permalinks.php
index d286cbccb64a17..347488e6b99204 100644
--- a/lib/experimental/site-editor-permalinks.php
+++ b/lib/experimental/site-editor-permalinks.php
@@ -3,9 +3,16 @@
function gutenberg_rewrite_wp_admin_permalinks() {
add_rewrite_rule(
'^wp-admin/design/?(.*)?',
- 'wp-admin/site-editor.php?path=$1',
+ 'wp-admin/site-editor.php?p=$1',
'top'
);
+
+ add_rewrite_rule(
+ '^wp-admin/post/?(.*)?',
+ 'wp-admin/admin.php?page=gutenberg-posts-dashboard&p=$1',
+ 'top'
+ );
+
flush_rewrite_rules();
}
add_action( 'init', 'gutenberg_rewrite_wp_admin_permalinks' );
@@ -119,3 +126,20 @@ function gutenberg_redirect_site_editor_to_design() {
exit;
}
add_action( 'admin_init', 'gutenberg_redirect_site_editor_to_design' );
+
+function gutenberg_redirect_posts_dataviews_to_post() {
+ global $pagenow;
+ if (
+ 'admin.php' !== $pagenow ||
+ ! isset( $_REQUEST['page'] ) ||
+ 'gutenberg-posts-dashboard' !== $_REQUEST['page'] ||
+ ! strpos( $_SERVER['REQUEST_URI'], 'wp-admin/admin.php' )
+ ) {
+ return;
+ }
+
+ wp_redirect( admin_url( '/post' ), 301 );
+ exit;
+}
+
+add_action( 'admin_init', 'gutenberg_redirect_posts_dataviews_to_post' );
diff --git a/packages/edit-site/src/components/editor/index.js b/packages/edit-site/src/components/editor/index.js
index 7e3d4ab4fecc46..c045bafd8a6839 100644
--- a/packages/edit-site/src/components/editor/index.js
+++ b/packages/edit-site/src/components/editor/index.js
@@ -96,6 +96,8 @@ function getListPathForPostType( postType ) {
return '/template';
case 'page':
return '/page';
+ case 'post':
+ return '/';
}
throw 'Unknown post type';
}
@@ -108,6 +110,7 @@ function getNavigationPath( location, postType ) {
'template-part-item',
'page-item',
'template-item',
+ 'post-item',
].includes( name )
) {
return getListPathForPostType( postType );
diff --git a/packages/edit-site/src/components/editor/use-resolve-edited-entity.js b/packages/edit-site/src/components/editor/use-resolve-edited-entity.js
index 336a77f6ba88a6..8da076f9f00b71 100644
--- a/packages/edit-site/src/components/editor/use-resolve-edited-entity.js
+++ b/packages/edit-site/src/components/editor/use-resolve-edited-entity.js
@@ -43,6 +43,8 @@ export function useResolveEditedEntity() {
postType = TEMPLATE_POST_TYPE;
} else if ( name === 'page-item' || name === 'pages' ) {
postType = 'page';
+ } else if ( name === 'post-item' || name === 'posts' ) {
+ postType = 'post';
}
const homePage = useSelect( ( select ) => {
diff --git a/packages/edit-site/src/components/posts-app-routes/home.js b/packages/edit-site/src/components/posts-app-routes/home.js
deleted file mode 100644
index ec99cbd8899f1d..00000000000000
--- a/packages/edit-site/src/components/posts-app-routes/home.js
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * WordPress dependencies
- */
-import { privateApis as routerPrivateApis } from '@wordpress/router';
-
-/**
- * Internal dependencies
- */
-import Editor from '../editor';
-import SidebarNavigationScreenMain from '../sidebar-navigation-screen-main';
-import { unlock } from '../../lock-unlock';
-
-const { useLocation } = unlock( routerPrivateApis );
-
-function HomeMobileView() {
- const { params = {} } = useLocation();
- const { canvas = 'view' } = params;
-
- return canvas === 'edit' ? (
-
- ) : (
-
- );
-}
-
-export const homeRoute = {
- name: 'home',
- match: () => {
- return true;
- },
- areas: {
- sidebar: ,
- preview: ,
- mobile: HomeMobileView,
- },
-};
diff --git a/packages/edit-site/src/components/posts-app-routes/index.js b/packages/edit-site/src/components/posts-app-routes/index.js
index e850bbd382200d..3919ea3930d073 100644
--- a/packages/edit-site/src/components/posts-app-routes/index.js
+++ b/packages/edit-site/src/components/posts-app-routes/index.js
@@ -9,21 +9,10 @@ import { useEffect } from '@wordpress/element';
*/
import { unlock } from '../../lock-unlock';
import { store as siteEditorStore } from '../../store';
-import { homeRoute } from './home';
-import { postsListViewQuickEditRoute } from './posts-list-view-quick-edit';
-import { postsListViewRoute } from './posts-list-view';
-import { postsViewQuickEditRoute } from './posts-view-quick-edit';
-import { postsViewRoute } from './posts-view';
-import { postsEditRoute } from './posts-edit';
+import { postsRoute } from './posts';
+import { postItemRoute } from './post-item';
-const routes = [
- postsListViewQuickEditRoute,
- postsListViewRoute,
- postsViewQuickEditRoute,
- postsViewRoute,
- postsEditRoute,
- homeRoute,
-];
+const routes = [ postItemRoute, postsRoute ];
export function useRegisterPostsAppRoutes() {
const registry = useRegistry();
diff --git a/packages/edit-site/src/components/posts-app-routes/posts-edit.js b/packages/edit-site/src/components/posts-app-routes/post-item.js
similarity index 62%
rename from packages/edit-site/src/components/posts-app-routes/posts-edit.js
rename to packages/edit-site/src/components/posts-app-routes/post-item.js
index d3958245595416..54131814f1ae22 100644
--- a/packages/edit-site/src/components/posts-app-routes/posts-edit.js
+++ b/packages/edit-site/src/components/posts-app-routes/post-item.js
@@ -6,25 +6,21 @@ import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
-import PostList from '../post-list';
+import Editor from '../editor';
import DataViewsSidebarContent from '../sidebar-dataviews';
import SidebarNavigationScreen from '../sidebar-navigation-screen';
-import Editor from '../editor';
-export const postsEditRoute = {
- name: 'posts-edit',
- match: ( params ) => {
- return params.postType === 'post' && params.canvas === 'edit';
- },
+export const postItemRoute = {
+ name: 'post-item',
+ path: '/post/:postId',
areas: {
sidebar: (
}
+ content={ }
/>
),
- content: ,
mobile: ,
preview: ,
},
diff --git a/packages/edit-site/src/components/posts-app-routes/posts-list-view-quick-edit.js b/packages/edit-site/src/components/posts-app-routes/posts-list-view-quick-edit.js
deleted file mode 100644
index d2434b390ffd9f..00000000000000
--- a/packages/edit-site/src/components/posts-app-routes/posts-list-view-quick-edit.js
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * WordPress dependencies
- */
-import { __ } from '@wordpress/i18n';
-import { privateApis as routerPrivateApis } from '@wordpress/router';
-
-/**
- * Internal dependencies
- */
-import PostList from '../post-list';
-import DataViewsSidebarContent from '../sidebar-dataviews';
-import SidebarNavigationScreen from '../sidebar-navigation-screen';
-import { unlock } from '../../lock-unlock';
-import { PostEdit } from '../post-edit';
-import Editor from '../editor';
-
-const { useLocation } = unlock( routerPrivateApis );
-
-function PostQuickEdit() {
- const { params } = useLocation();
- return ;
-}
-
-export const postsListViewQuickEditRoute = {
- name: 'posts-list-view-quick-edit',
- match: ( params ) => {
- return (
- params.isCustom !== 'true' &&
- ( params.layout ?? 'list' ) === 'list' &&
- !! params.quickEdit &&
- params.postType === 'post' &&
- params.canvas !== 'edit'
- );
- },
- areas: {
- sidebar: (
- }
- />
- ),
- content: ,
- mobile: ,
- preview: ,
- edit: ,
- },
- widths: {
- content: 380,
- edit: 380,
- },
-};
diff --git a/packages/edit-site/src/components/posts-app-routes/posts-list-view.js b/packages/edit-site/src/components/posts-app-routes/posts-list-view.js
deleted file mode 100644
index 68aa86c7fb2392..00000000000000
--- a/packages/edit-site/src/components/posts-app-routes/posts-list-view.js
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * WordPress dependencies
- */
-import { __ } from '@wordpress/i18n';
-
-/**
- * Internal dependencies
- */
-import PostList from '../post-list';
-import DataViewsSidebarContent from '../sidebar-dataviews';
-import SidebarNavigationScreen from '../sidebar-navigation-screen';
-import Editor from '../editor';
-
-export const postsListViewRoute = {
- name: 'posts-list-view',
- match: ( params ) => {
- return (
- params.isCustom !== 'true' &&
- ( params.layout ?? 'list' ) === 'list' &&
- ! params.quickEdit &&
- params.postType === 'post' &&
- params.canvas !== 'edit'
- );
- },
- areas: {
- sidebar: (
- }
- />
- ),
- content: ,
- preview: ,
- mobile: ,
- },
- widths: {
- content: 380,
- },
-};
diff --git a/packages/edit-site/src/components/posts-app-routes/posts-view-quick-edit.js b/packages/edit-site/src/components/posts-app-routes/posts-view-quick-edit.js
deleted file mode 100644
index 52e6f9a2d26ef6..00000000000000
--- a/packages/edit-site/src/components/posts-app-routes/posts-view-quick-edit.js
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * WordPress dependencies
- */
-import { __ } from '@wordpress/i18n';
-import { privateApis as routerPrivateApis } from '@wordpress/router';
-
-/**
- * Internal dependencies
- */
-import PostList from '../post-list';
-import DataViewsSidebarContent from '../sidebar-dataviews';
-import SidebarNavigationScreen from '../sidebar-navigation-screen';
-import { unlock } from '../../lock-unlock';
-import { PostEdit } from '../post-edit';
-
-const { useLocation } = unlock( routerPrivateApis );
-
-function PostQuickEdit() {
- const { params } = useLocation();
- return ;
-}
-
-export const postsViewQuickEditRoute = {
- name: 'posts-view-quick-edit',
- match: ( params ) => {
- return (
- ( params.isCustom === 'true' ||
- ( params.layout ?? 'list' ) !== 'list' ) &&
- !! params.quickEdit &&
- params.postType === 'post' &&
- params.canvas !== 'edit'
- );
- },
- areas: {
- sidebar: (
- }
- />
- ),
- content: ,
- mobile: ,
- edit: ,
- },
- widths: {
- edit: 380,
- },
-};
diff --git a/packages/edit-site/src/components/posts-app-routes/posts-view.js b/packages/edit-site/src/components/posts-app-routes/posts-view.js
deleted file mode 100644
index 6559991475d278..00000000000000
--- a/packages/edit-site/src/components/posts-app-routes/posts-view.js
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * WordPress dependencies
- */
-import { __ } from '@wordpress/i18n';
-
-/**
- * Internal dependencies
- */
-import PostList from '../post-list';
-import DataViewsSidebarContent from '../sidebar-dataviews';
-import SidebarNavigationScreen from '../sidebar-navigation-screen';
-
-export const postsViewRoute = {
- name: 'posts-view',
- match: ( params ) => {
- return (
- ( params.isCustom === 'true' ||
- ( params.layout ?? 'list' ) !== 'list' ) &&
- ! params.quickEdit &&
- params.postType === 'post' &&
- params.canvas !== 'edit'
- );
- },
- areas: {
- sidebar: (
- }
- />
- ),
- content: ,
- mobile: ,
- },
-};
diff --git a/packages/edit-site/src/components/posts-app-routes/posts.js b/packages/edit-site/src/components/posts-app-routes/posts.js
new file mode 100644
index 00000000000000..80af8a75fbc800
--- /dev/null
+++ b/packages/edit-site/src/components/posts-app-routes/posts.js
@@ -0,0 +1,66 @@
+/**
+ * WordPress dependencies
+ */
+import { privateApis as routerPrivateApis } from '@wordpress/router';
+import { __ } from '@wordpress/i18n';
+
+/**
+ * Internal dependencies
+ */
+import Editor from '../editor';
+import SidebarNavigationScreen from '../sidebar-navigation-screen';
+import DataViewsSidebarContent from '../sidebar-dataviews';
+import PostList from '../post-list';
+import { unlock } from '../../lock-unlock';
+import { PostEdit } from '../post-edit';
+
+const { useLocation } = unlock( routerPrivateApis );
+
+function MobilePostsView() {
+ const { query = {} } = useLocation();
+ const { canvas = 'view' } = query;
+
+ return canvas === 'edit' ? : ;
+}
+
+export const postsRoute = {
+ name: 'posts',
+ path: '/',
+ areas: {
+ sidebar: (
+ }
+ />
+ ),
+ content: ,
+ preview( { query } ) {
+ const isListView =
+ ( query.layout === 'list' || ! query.layout ) &&
+ query.isCustom !== 'true';
+ return isListView ? : undefined;
+ },
+ mobile: ,
+ edit( { query } ) {
+ const hasQuickEdit =
+ ( query.layout ?? 'list' ) === 'list' && !! query.quickEdit;
+ return hasQuickEdit ? (
+
+ ) : undefined;
+ },
+ },
+ widths: {
+ content( { query } ) {
+ const isListView =
+ ( query.layout === 'list' || ! query.layout ) &&
+ query.isCustom !== 'true';
+ return isListView ? 380 : undefined;
+ },
+ edit( { query } ) {
+ const hasQuickEdit =
+ ( query.layout ?? 'list' ) === 'list' && !! query.quickEdit;
+ return hasQuickEdit ? 380 : undefined;
+ },
+ },
+};
diff --git a/packages/edit-site/src/components/posts-app/index.js b/packages/edit-site/src/components/posts-app/index.js
index 72e5b1eb997498..d05205987f0286 100644
--- a/packages/edit-site/src/components/posts-app/index.js
+++ b/packages/edit-site/src/components/posts-app/index.js
@@ -6,6 +6,7 @@ import {
privateApis as editorPrivateApis,
} from '@wordpress/editor';
import { privateApis as routerPrivateApis } from '@wordpress/router';
+import { useSelect } from '@wordpress/data';
/**
* Internal dependencies
@@ -13,23 +14,21 @@ import { privateApis as routerPrivateApis } from '@wordpress/router';
import Layout from '../layout';
import { useRegisterPostsAppRoutes } from '../posts-app-routes';
import { unlock } from '../../lock-unlock';
-import useActiveRoute from '../layout/router';
+import { store as editSiteStore } from '../../store';
const { RouterProvider } = unlock( routerPrivateApis );
const { GlobalStylesProvider } = unlock( editorPrivateApis );
-function PostsLayout() {
- useRegisterPostsAppRoutes();
- const route = useActiveRoute();
- return ;
-}
-
export default function PostsApp() {
+ useRegisterPostsAppRoutes();
+ const routes = useSelect( ( select ) => {
+ return unlock( select( editSiteStore ) ).getRoutes();
+ }, [] );
return (
-
-
+
+
);