-
-
Save Shelob9/ec4f694f4f4840b3dfcbebb78f5095ec to your computer and use it in GitHub Desktop.
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
const el = wp.element.createElement; |
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
import CalderaProcessors from './CalderaProcessors'; | |
import {withSelect,withDispatch} from '@wordpress/data'; | |
import {CALDERA_FORMS_PROCESSORS_STORE_SLUG } from "./state/processorsStore"; | |
/** | |
* Main processors UI container wrapped with Redux(-like) state management | |
*/ | |
const CalderaProcessorsWithState = withSelect( (select, ownProps ) => { | |
const { | |
getProcessorsCollection, | |
getProcessorTypes, | |
getProcessorFromCollection, | |
} = select(CALDERA_FORMS_PROCESSORS_STORE_SLUG); | |
const processors = getProcessorsCollection(); | |
const processorTypes = getProcessorTypes(); | |
return { | |
getProcessorFromCollection, | |
processors, | |
processorTypes, | |
getProcessorTypes, | |
form: ownProps.form | |
}; | |
} )( withDispatch( ( dispatch ) => { | |
const { | |
addProcessor, | |
newProcessor, | |
removeProcessor, | |
updateProcessor, | |
setProcessorType | |
} = dispatch( CALDERA_FORMS_PROCESSORS_STORE_SLUG ); | |
return { | |
onAddProcessor(processorConfig) { | |
addProcessor( processorConfig ); | |
}, | |
onNewProcessor(){ | |
newProcessor() | |
}, | |
onRemoveProcessor(processorId){ | |
removeProcessor(processorId); | |
}, | |
onUpdateProcessor(processor){ | |
updateProcessor(processor); | |
}, | |
onUpdateProcessorType(processorType, processorTypeIdentifier){ | |
setProcessorType(processorType, processorTypeIdentifier) | |
} | |
}; | |
} )( CalderaProcessors ) ); | |
export default CalderaProcessorsWithState; |
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
import { Component } from '@wordpress/element'; |
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
import { Component } from '@wordpress/element'; |
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
npm i -D @wordpress/element |
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
npm i @wordpress/element |
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
import { Component } from '@wordpress/element'; |
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
import React from 'react'; | |
import PropTypes from 'prop-types'; | |
import {List} from "./components/Processors/List"; | |
import {NewProcessor} from "./components/Processors/NewProcessor"; | |
class CalderaProcessors extends React.PureComponent { | |
render() { | |
return( | |
<div className="caldera-forms-processors"> | |
<List | |
form={this.props.form} | |
processors={this.props.processors} | |
onUpdateProcessor={this.props.onUpdateProcessor} | |
onRemoveProcessor={this.props.onRemoveProcessor} | |
getProcessorFromCollection={this.props.getProcessorFromCollection} | |
getProcessorTypes={this.props.getProcessorTypes} | |
/> | |
<NewProcessor | |
onNewProcessor={this.props.onNewProcessor} | |
/> | |
</div> | |
); | |
} | |
} | |
CalderaProcessors.propTypes = { | |
processors: PropTypes.instanceOf(Map).isRequired, | |
processorTypes: PropTypes.instanceOf(Map).isRequired, | |
form: PropTypes.object, | |
onAddProcessor: PropTypes.func.isRequired, | |
onNewProcessor: PropTypes.func.isRequired, | |
onRemoveProcessor: PropTypes.func.isRequired, | |
onUpdateProcessor: PropTypes.func.isRequired, | |
onUpdateProcessorType: PropTypes.func.isRequired, | |
getProcessorFromCollection: PropTypes.func.isRequired, | |
getProcessorTypes: PropTypes.func.isRequired, | |
}; |
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
import CalderaProcessors from './CalderaProcessors'; | |
import {withSelect,withDispatch} from '@wordpress/data'; | |
import {CALDERA_FORMS_PROCESSORS_STORE_SLUG } from "./state/processorsStore"; | |
const CalderaProcessorsWithState = withSelect( (select, ownProps ) => { | |
const { | |
getProcessorsCollection, | |
getProcessorTypes, | |
getProcessorFromCollection, | |
} = select(CALDERA_FORMS_PROCESSORS_STORE_SLUG); | |
const processors = getProcessorsCollection(); | |
const processorTypes = getProcessorTypes(); | |
return { | |
getProcessorFromCollection, | |
processors, | |
processorTypes, | |
getProcessorTypes, | |
form: ownProps.form | |
}; | |
} )( CalderaProcessors ); | |
export default CalderaProcessorsWithState; |
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
import CalderaProcessors from './CalderaProcessors'; | |
import {withSelect,withDispatch} from '@wordpress/data'; | |
import {CALDERA_FORMS_PROCESSORS_STORE_SLUG } from "./state/processorsStore"; | |
const CalderaProcessorsWithState = withDispatch( ( dispatch ) => { | |
const { | |
addProcessor, | |
newProcessor, | |
removeProcessor, | |
updateProcessor, | |
setProcessorType | |
} = dispatch( CALDERA_FORMS_PROCESSORS_STORE_SLUG ); | |
return { | |
onAddProcessor(processorConfig) { | |
addProcessor( processorConfig ); | |
}, | |
onNewProcessor(){ | |
newProcessor() | |
}, | |
onRemoveProcessor(processorId){ | |
removeProcessor(processorId); | |
}, | |
onUpdateProcessor(processor){ | |
updateProcessor(processor); | |
}, | |
onUpdateProcessorType(processorType, processorTypeIdentifier){ | |
setProcessorType(processorType, processorTypeIdentifier) | |
} | |
}; | |
} )( CalderaProcessors ); | |
export default CalderaProcessorsWithState; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment