saving colors when not modified

This commit is contained in:
ari committed 2022-05-19 23:22:16 -04:00
1 parent 7afda7eb1c
commit 48decb2e16
2 files changed
+11 -2

No files matched your search

@@ -20,7 +20,10 @@ export const useEditorNodeState = (originalNode: AutomationNode, isErrored: bool
setAllState({ ...allState, node: originalNode, isModified: false, })
// eslint-disable-next-line
}, [originalNode])
const setState = (node: AutomationNode) => setAllState(({ ...allState, node, isModified: true, }));
const setState = (node: AutomationNode) => setAllState(({
...allState, node,
isModified: JSON.stringify(node) !== JSON.stringify(originalNode),
}));
const setYamlMode = (yamlMode: boolean) => setAllState({ ...allState, yamlMode, });
const setStateForManualYaml = (yaml: any) => {
try {
+7 -1
View File
@@ -66,7 +66,13 @@ export const NodeEditor: FC<NodeEditorProps> = ({
<Button
className="node-editor--footer--save"
onClick={() => {
areYouSureNotReady('save') && onSave(state.data)
if (areYouSureNotReady('save')) {
if (JSON.stringify(state.data) !== JSON.stringify(node)) {
onSave(state.data)
} else {
onClose()
}
}
}}
title={
!isReady ? "Some fields have not been properly filled up" : ""