Skip to content

Commit

Permalink
#3425 don't try to save processors that do not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Shelob9 committed Jun 11, 2020
1 parent e88b719 commit fd7e34f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ dist/caldera-hot-load/*
!dist/react.min.js
!dist/react-dom.min.js

clients/build
clients/*/build
12 changes: 9 additions & 3 deletions clients/form-builder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const HandleSave = ({ jQuery, formId }) => {
ConditionalsContext
);
//Get processors
const { processors, hasProcessors } = React.useContext(ProcessorsContext);
const { processors } = React.useContext(ProcessorsContext);

//Track if we're saving or not
const [isSaving, setIsSaving] = React.useState(false);
Expand Down Expand Up @@ -111,8 +111,10 @@ const HandleSave = ({ jQuery, formId }) => {
data_fields.config.conditional_groups = {};
}

if (hasProcessors) {
//processors includes removed processors, so check legacy state
if (data_fields.config.processors) {
let _processors = {};
//Loop through processors in React state, prepare to save those known by legacy state
Object.keys(processors).forEach( processorId => {
if( data_fields.config.processors.hasOwnProperty(processorId ) ){
_processors[processorId] = processors[processorId];
Expand Down Expand Up @@ -262,7 +264,7 @@ const SubscribeToProcessorChanges = ({ jQuery }) => {
updateProcessor,
getProcessor,
setActiveProcessorId,
activeProcessorId,
addProcessor
} = React.useContext(ProcessorsContext);

React.useEffect(() => {
Expand All @@ -277,6 +279,10 @@ const SubscribeToProcessorChanges = ({ jQuery }) => {
}
});

jQuery(document).on('processor.added', (event, data) => {
addProcessor(data.processor.type, data.processor.id);
});

//Activate processor when clicked on
jQuery(".caldera-processor-nav a").on("click", function () {
setActiveProcessorId(jQuery(this).parent().data("pid"));
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"keywords": [
"WordPress"
],
"author": "Caldera Labs",
"author": "Caldera Forms",
"license": "GPL-2.0",
"bugs": {
"url": "https://github.com/CalderaWP/Caldera-Forms/issues"
Expand Down Expand Up @@ -44,7 +44,7 @@
"ie > 8"
],
"dependencies": {
"@calderajs/form-builder": "1.2.3",
"@calderajs/form-builder": "1.2.4",
"@cypress/webpack-preprocessor": "^4.1.1",
"@wordpress/api-fetch": "latest",
"@wordpress/keycodes": "^2.3.0",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1091,10 +1091,10 @@
"@babel/preset-env" "^7.3.1"
"@babel/preset-react" "^7.0.0"

"@calderajs/[email protected].3":
version "1.2.3"
resolved "https://registry.yarnpkg.com/@calderajs/form-builder/-/form-builder-1.2.3.tgz#938ca6438ce73cf5c1d6f87503cc5db3e37deed5"
integrity sha512-tudVAl8beCayzXfaytfRrw+nkmNbBXq06Za5SNqmcGFfjR35ox38nDeHwYL79I6OfEq2tmM8Y7c6WqYhdP2K+w==
"@calderajs/[email protected].4":
version "1.2.4"
resolved "https://registry.yarnpkg.com/@calderajs/form-builder/-/form-builder-1.2.4.tgz#37bb4caa46f2bc8e45bdf3257c45d0db89344ece"
integrity sha512-K1fQsbx6n0pCOPBGhSLDaJ2CmftR5tCA2y14KvN67MZn0i8fzaMb3iURewOeDUqp94cXRnk+Y7BDjJsPnTtR9w==
dependencies:
"@types/dot-object" "^1.7.0"
deep-clone "^3.0.3"
Expand Down

0 comments on commit fd7e34f

Please sign in to comment.