forked from WordPress/gutenberg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Site Editor: Prepare route registration by refactoring the site edito…
…r router (WordPress#66030) Co-authored-by: youknowriad <[email protected]> Co-authored-by: ramonjd <[email protected]> Co-authored-by: jsnajdr <[email protected]> Co-authored-by: mcsf <[email protected]> Co-authored-by: kevin940726 <[email protected]>
- Loading branch information
1 parent
b372527
commit 52d0b99
Showing
27 changed files
with
615 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
packages/edit-site/src/components/site-editor-routes/home-edit.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import Editor from '../editor'; | ||
import SidebarNavigationScreenMain from '../sidebar-navigation-screen-main'; | ||
|
||
export const homeEditRoute = { | ||
name: 'home-edit', | ||
match: ( params ) => { | ||
return params.canvas === 'edit'; | ||
}, | ||
areas: { | ||
sidebar: <SidebarNavigationScreenMain />, | ||
preview: <Editor />, | ||
mobile: <Editor />, | ||
}, | ||
}; |
16 changes: 16 additions & 0 deletions
16
packages/edit-site/src/components/site-editor-routes/home-view.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import Editor from '../editor'; | ||
import SidebarNavigationScreenMain from '../sidebar-navigation-screen-main'; | ||
|
||
export const homeViewRoute = { | ||
name: 'home-view', | ||
match: ( params ) => { | ||
return params.canvas !== 'edit'; | ||
}, | ||
areas: { | ||
sidebar: <SidebarNavigationScreenMain />, | ||
preview: <Editor />, | ||
}, | ||
}; |
60 changes: 60 additions & 0 deletions
60
packages/edit-site/src/components/site-editor-routes/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useRegistry, useDispatch } from '@wordpress/data'; | ||
import { useEffect } from '@wordpress/element'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { unlock } from '../../lock-unlock'; | ||
import { store as siteEditorStore } from '../../store'; | ||
import { homeViewRoute } from './home-view'; | ||
import { homeEditRoute } from './home-edit'; | ||
import { navigationViewRoute } from './navigation-view'; | ||
import { navigationEditRoute } from './navigation-edit'; | ||
import { navigationItemEditRoute } from './navigation-item-edit'; | ||
import { navigationItemViewRoute } from './navigation-item-view'; | ||
import { stylesEditRoute } from './styles-edit'; | ||
import { stylesViewRoute } from './styles-view'; | ||
import { patternsEditRoute } from './patterns-edit'; | ||
import { patternsViewRoute } from './patterns-view'; | ||
import { templatesEditRoute } from './templates-edit'; | ||
import { templatesListViewRoute } from './templates-list-view'; | ||
import { templatesViewRoute } from './templates-view'; | ||
import { pagesViewRoute } from './pages-view'; | ||
import { pagesEditRoute } from './pages-edit'; | ||
import { pagesListViewRoute } from './pages-list-view'; | ||
import { pagesListViewQuickEditRoute } from './pages-list-view-quick-edit'; | ||
import { pagesViewQuickEditRoute } from './pages-view-quick-edit'; | ||
|
||
const routes = [ | ||
pagesListViewQuickEditRoute, | ||
pagesListViewRoute, | ||
pagesViewQuickEditRoute, | ||
pagesViewRoute, | ||
pagesEditRoute, | ||
templatesEditRoute, | ||
templatesListViewRoute, | ||
templatesViewRoute, | ||
patternsViewRoute, | ||
patternsEditRoute, | ||
stylesViewRoute, | ||
stylesEditRoute, | ||
navigationItemViewRoute, | ||
navigationItemEditRoute, | ||
navigationViewRoute, | ||
navigationEditRoute, | ||
homeViewRoute, | ||
homeEditRoute, | ||
]; | ||
|
||
export function useRegisterSiteEditorRoutes() { | ||
const registry = useRegistry(); | ||
const { registerRoute } = unlock( useDispatch( siteEditorStore ) ); | ||
useEffect( () => { | ||
registry.batch( () => { | ||
routes.forEach( registerRoute ); | ||
} ); | ||
}, [ registry, registerRoute ] ); | ||
} |
22 changes: 22 additions & 0 deletions
22
packages/edit-site/src/components/site-editor-routes/navigation-edit.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { NAVIGATION_POST_TYPE } from '../../utils/constants'; | ||
import Editor from '../editor'; | ||
import SidebarNavigationScreenNavigationMenus from '../sidebar-navigation-screen-navigation-menus'; | ||
|
||
export const navigationEditRoute = { | ||
name: 'navigation-edit', | ||
match: ( params ) => { | ||
return ( | ||
params.postType === NAVIGATION_POST_TYPE && | ||
! params.postId && | ||
params.canvas === 'edit' | ||
); | ||
}, | ||
areas: { | ||
sidebar: <SidebarNavigationScreenNavigationMenus backPath={ {} } />, | ||
preview: <Editor />, | ||
mobile: <Editor />, | ||
}, | ||
}; |
Oops, something went wrong.