-
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.
Editor: Unify the more menu (#60910)
Co-authored-by: youknowriad <[email protected]> Co-authored-by: ntsekouras <[email protected]> Co-authored-by: jasmussen <[email protected]> Co-authored-by: jameskoster <[email protected]>
- Loading branch information
1 parent
69adf95
commit 6527034
Showing
20 changed files
with
274 additions
and
500 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
39 changes: 39 additions & 0 deletions
39
packages/edit-post/src/components/header/more-menu/manage-patterns-menu-item.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,39 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { MenuItem } from '@wordpress/components'; | ||
import { store as coreStore } from '@wordpress/core-data'; | ||
import { store as editorStore } from '@wordpress/editor'; | ||
import { useSelect } from '@wordpress/data'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { addQueryArgs } from '@wordpress/url'; | ||
|
||
function ManagePatternsMenuItem() { | ||
const url = useSelect( ( select ) => { | ||
const { canUser } = select( coreStore ); | ||
const { getEditorSettings } = select( editorStore ); | ||
|
||
const isBlockTheme = getEditorSettings().__unstableIsBlockBasedTheme; | ||
const defaultUrl = addQueryArgs( 'edit.php', { | ||
post_type: 'wp_block', | ||
} ); | ||
const patternsUrl = addQueryArgs( 'site-editor.php', { | ||
path: '/patterns', | ||
} ); | ||
|
||
// The site editor and templates both check whether the user has | ||
// edit_theme_options capabilities. We can leverage that here and not | ||
// display the manage patterns link if the user can't access it. | ||
return canUser( 'read', 'templates' ) && isBlockTheme | ||
? patternsUrl | ||
: defaultUrl; | ||
}, [] ); | ||
|
||
return ( | ||
<MenuItem role="menuitem" href={ url }> | ||
{ __( 'Manage patterns' ) } | ||
</MenuItem> | ||
); | ||
} | ||
|
||
export default ManagePatternsMenuItem; |
File renamed without changes.
31 changes: 0 additions & 31 deletions
31
packages/edit-post/src/components/header/preferences-menu-item/index.js
This file was deleted.
Oops, something went wrong.
73 changes: 0 additions & 73 deletions
73
packages/edit-post/src/components/header/writing-menu/index.js
This file was deleted.
Oops, something went wrong.
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
28 changes: 0 additions & 28 deletions
28
packages/edit-post/src/components/preferences-modal/test/index.js
This file was deleted.
Oops, something went wrong.
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
29 changes: 0 additions & 29 deletions
29
packages/edit-post/src/plugins/copy-content-menu-item/index.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.