-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ba1da0
commit 7644e68
Showing
4 changed files
with
61 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { SlotFillProvider } from '@wordpress/components'; | ||
import { UnsavedChangesWarning } from '@wordpress/editor'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { Routes } from '../routes'; | ||
import Editor from '../editor'; | ||
import List from '../list'; | ||
import NavigationSidebar from '../navigation-sidebar'; | ||
import getIsListPage from '../../utils/get-is-list-page'; | ||
|
||
export default function EditSiteApp( { reboot } ) { | ||
return ( | ||
<SlotFillProvider> | ||
<UnsavedChangesWarning /> | ||
|
||
<Routes> | ||
{ ( { params } ) => { | ||
const isListPage = getIsListPage( params ); | ||
|
||
return ( | ||
<> | ||
{ isListPage ? ( | ||
<List /> | ||
) : ( | ||
<Editor onError={ reboot } /> | ||
) } | ||
{ /* Keep the instance of the sidebar to ensure focus will not be lost | ||
* when navigating to other pages. */ } | ||
<NavigationSidebar | ||
// Open the navigation sidebar by default when in the list page. | ||
isDefaultOpen={ !! isListPage } | ||
activeTemplateType={ | ||
isListPage ? params.postType : undefined | ||
} | ||
/> | ||
</> | ||
); | ||
} } | ||
</Routes> | ||
</SlotFillProvider> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* Returns if the params match the list page route. | ||
* | ||
* @param {Object} params The search params. | ||
* @param {string} params.postId The post ID. | ||
* @param {string} params.postType The post type. | ||
* @return {boolean} Is list page or not. | ||
*/ | ||
export default function getIsListPage( { postId, postType } ) { | ||
return !! ( ! postId && postType ); | ||
} |