-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bootstrap the dashboard layout (#62409)
Co-authored-by: youknowriad <youknowriad@git.wordpress.org> Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
- Loading branch information
1 parent
edd5fa4
commit 2d34e2a
Showing
7 changed files
with
148 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { | ||
UnsavedChangesWarning, | ||
privateApis as editorPrivateApis, | ||
} from '@wordpress/editor'; | ||
import { privateApis as routerPrivateApis } from '@wordpress/router'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import Layout from '../layout'; | ||
import Page from '../page'; | ||
import { unlock } from '../../lock-unlock'; | ||
|
||
const { RouterProvider } = unlock( routerPrivateApis ); | ||
const { GlobalStylesProvider } = unlock( editorPrivateApis ); | ||
|
||
const defaultRoute = { | ||
key: 'index', | ||
areas: { | ||
sidebar: 'Empty Sidebar', | ||
content: <Page>Welcome to Posts</Page>, | ||
preview: undefined, | ||
mobile: <Page>Welcome to Posts</Page>, | ||
}, | ||
}; | ||
|
||
export default function PostsApp() { | ||
return ( | ||
<GlobalStylesProvider> | ||
<UnsavedChangesWarning /> | ||
<RouterProvider> | ||
<Layout route={ defaultRoute } /> | ||
</RouterProvider> | ||
</GlobalStylesProvider> | ||
); | ||
} |
37 changes: 37 additions & 0 deletions
37
packages/edit-site/src/hooks/commands/use-set-command-context.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,37 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useSelect } from '@wordpress/data'; | ||
import { privateApis as commandsPrivateApis } from '@wordpress/commands'; | ||
import { store as blockEditorStore } from '@wordpress/block-editor'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { store as editSiteStore } from '../../store'; | ||
import { unlock } from '../../lock-unlock'; | ||
|
||
const { useCommandContext } = unlock( commandsPrivateApis ); | ||
|
||
/** | ||
* React hook used to set the correct command context based on the current state. | ||
*/ | ||
export default function useSetCommandContext() { | ||
const { hasBlockSelected, canvasMode } = useSelect( ( select ) => { | ||
const { getCanvasMode } = unlock( select( editSiteStore ) ); | ||
const { getBlockSelectionStart } = select( blockEditorStore ); | ||
return { | ||
canvasMode: getCanvasMode(), | ||
hasBlockSelected: getBlockSelectionStart(), | ||
}; | ||
}, [] ); | ||
// Sets the right context for the command palette | ||
let commandContext = 'site-editor'; | ||
if ( canvasMode === 'edit' ) { | ||
commandContext = 'entity-edit'; | ||
} | ||
if ( hasBlockSelected ) { | ||
commandContext = 'block-selection-edit'; | ||
} | ||
useCommandContext( commandContext ); | ||
} |
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