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.
Commands: Unify the editor context between post and site editors (Wor…
- Loading branch information
1 parent
b2487bd
commit ad0d82f
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.