Skip to content

Commit 3dfa402

Browse files
committed
Check if save needed before initiating backend call
1 parent 3a033e5 commit 3dfa402

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

src/components/molecules/modals/SaveFlowModal.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,25 @@ import { updateEnvironmentFile, updateFlowTest } from 'service/collection';
77
import { toast } from 'react-toastify';
88
import { BUTTON_TYPES, OBJ_TYPES } from 'constants/Common';
99
import Button from 'components/atoms/common/Button';
10+
import { isSaveNeeded } from 'components/atoms/util';
1011

1112
export const saveHandle = (tab) => {
1213
if (tab.type == OBJ_TYPES.flowtest && tab.flowDataDraft) {
13-
updateFlowTest(tab.pathname, tab.flowDataDraft, tab.collectionId)
14-
.then((result) => {
15-
console.log(`Updated flowtest: path = ${tab.pathname}, collectionId = ${tab.collectionId}, result: ${result}`);
16-
toast.success(`Updated the flowtest: ${tab.pathname}`);
17-
})
18-
.catch((error) => {
19-
console.log(`Error updating flowtest = ${tab.pathname}: ${error}`);
20-
toast.error(`Error while updating flowtest: ${tab.pathname}`);
21-
});
14+
if (isSaveNeeded(tab.flowData, tab.flowDataDraft)) {
15+
updateFlowTest(tab.pathname, tab.flowDataDraft, tab.collectionId)
16+
.then((result) => {
17+
console.log(
18+
`Updated flowtest: path = ${tab.pathname}, collectionId = ${tab.collectionId}, result: ${result}`,
19+
);
20+
toast.success(`Updated the flowtest: ${tab.pathname}`);
21+
})
22+
.catch((error) => {
23+
console.log(`Error updating flowtest = ${tab.pathname}: ${error}`);
24+
toast.error(`Error while updating flowtest: ${tab.pathname}`);
25+
});
26+
} else {
27+
toast.info('Nothing to save');
28+
}
2229
} else if (tab.type == OBJ_TYPES.environment && tab.variablesDraft) {
2330
updateEnvironmentFile(tab.name, tab.collectionId, tab.variablesDraft)
2431
.then((result) => {

0 commit comments

Comments
 (0)