-
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.
Commands: Unify the editor context between post and site editors (#61862
- Loading branch information
1 parent
22622bf
commit 6fbc6c7
Showing
11 changed files
with
154 additions
and
141 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
37 changes: 0 additions & 37 deletions
37
packages/edit-site/src/components/pattern-modal/duplicate.js
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
50 changes: 50 additions & 0 deletions
50
packages/editor/src/components/pattern-duplicate-modal/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,50 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useDispatch, useSelect } from '@wordpress/data'; | ||
import { privateApis as patternsPrivateApis } from '@wordpress/patterns'; | ||
import { store as coreStore } from '@wordpress/core-data'; | ||
import { store as interfaceStore } from '@wordpress/interface'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { unlock } from '../../lock-unlock'; | ||
import { store as editorStore } from '../../store'; | ||
import { PATTERN_POST_TYPE } from '../../store/constants'; | ||
|
||
const { DuplicatePatternModal } = unlock( patternsPrivateApis ); | ||
export const modalName = 'editor/pattern-duplicate'; | ||
|
||
export default function PatternDuplicateModal() { | ||
const { record, postType } = useSelect( ( select ) => { | ||
const { getCurrentPostType, getCurrentPostId } = select( editorStore ); | ||
const { getEditedEntityRecord } = select( coreStore ); | ||
const _postType = getCurrentPostType(); | ||
return { | ||
record: getEditedEntityRecord( | ||
'postType', | ||
_postType, | ||
getCurrentPostId() | ||
), | ||
postType: _postType, | ||
}; | ||
}, [] ); | ||
const { closeModal } = useDispatch( interfaceStore ); | ||
|
||
const isActive = useSelect( ( select ) => | ||
select( interfaceStore ).isModalActive( modalName ) | ||
); | ||
|
||
if ( ! isActive || postType !== PATTERN_POST_TYPE ) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<DuplicatePatternModal | ||
onClose={ closeModal } | ||
onSuccess={ () => closeModal() } | ||
pattern={ record } | ||
/> | ||
); | ||
} |
44 changes: 44 additions & 0 deletions
44
packages/editor/src/components/pattern-rename-modal/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,44 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useDispatch, useSelect } from '@wordpress/data'; | ||
import { privateApis as patternsPrivateApis } from '@wordpress/patterns'; | ||
import { store as coreStore } from '@wordpress/core-data'; | ||
import { store as interfaceStore } from '@wordpress/interface'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { unlock } from '../../lock-unlock'; | ||
import { store as editorStore } from '../../store'; | ||
import { PATTERN_POST_TYPE } from '../../store/constants'; | ||
|
||
const { RenamePatternModal } = unlock( patternsPrivateApis ); | ||
export const modalName = 'editor/pattern-rename'; | ||
|
||
export default function PatternRenameModal() { | ||
const { record, postType } = useSelect( ( select ) => { | ||
const { getCurrentPostType, getCurrentPostId } = select( editorStore ); | ||
const { getEditedEntityRecord } = select( coreStore ); | ||
const _postType = getCurrentPostType(); | ||
return { | ||
record: getEditedEntityRecord( | ||
'postType', | ||
_postType, | ||
getCurrentPostId() | ||
), | ||
postType: _postType, | ||
}; | ||
}, [] ); | ||
const { closeModal } = useDispatch( interfaceStore ); | ||
|
||
const isActive = useSelect( ( select ) => | ||
select( interfaceStore ).isModalActive( modalName ) | ||
); | ||
|
||
if ( ! isActive || postType !== PATTERN_POST_TYPE ) { | ||
return null; | ||
} | ||
|
||
return <RenamePatternModal onClose={ closeModal } pattern={ record } />; | ||
} |
Oops, something went wrong.
6fbc6c7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flaky tests detected in 6fbc6c7.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9196899143
📝 Reported issues:
/test/e2e/specs/site-editor/zoom-out.spec.js