-
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.
Blocks: move bootstrapped block types to Redux state
- Loading branch information
Showing
8 changed files
with
331 additions
and
268 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 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { processBlockType } from './process-block-type'; | ||
|
||
/** @typedef {import('../api/registration').WPBlockType} WPBlockType */ | ||
|
||
/** | ||
* Add block type metadata to the store. | ||
* | ||
* @param {string} name Block name. | ||
* @param {WPBlockType} blockType Block type metadata. | ||
*/ | ||
export function addBootstrappedBlock( name, blockType ) { | ||
return { | ||
type: 'ADD_BOOTSTRAPPED_BLOCK_TYPE', | ||
name, | ||
blockType, | ||
}; | ||
} | ||
|
||
/** | ||
* Add unprocessed block type settings to the store. | ||
* | ||
* @param {string} name Block name. | ||
* @param {WPBlockType} blockType Unprocessed block type settings. | ||
*/ | ||
export const addUnprocessedBlock = | ||
( name, blockType ) => | ||
( { dispatch } ) => { | ||
dispatch( { type: 'ADD_UNPROCESSED_BLOCK_TYPE', name, blockType } ); | ||
const processedBlockType = dispatch( | ||
processBlockType( name, blockType ) | ||
); | ||
if ( ! processedBlockType ) { | ||
return; | ||
} | ||
dispatch.addBlockTypes( processedBlockType ); | ||
}; |
Oops, something went wrong.