@griddo/ax 1.62.6 → 1.62.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@griddo/ax",
3
3
  "description": "Griddo Author Experience",
4
- "version": "1.62.6",
4
+ "version": "1.62.7",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Carlos Torres <carlos.torres@secuoyas.com>",
@@ -244,5 +244,5 @@
244
244
  "publishConfig": {
245
245
  "access": "public"
246
246
  },
247
- "gitHead": "b0c7944b7f9e7b51dd7bb08bc1a033f87a23bf87"
247
+ "gitHead": "4e5c524d81f99f83db5dc9f753d7857017014149"
248
248
  }
@@ -230,7 +230,8 @@ function createNavigation(): (dispatch: Dispatch, getState: any) => Promise<bool
230
230
  const cleanValues = removeEditorIds(navigationValues);
231
231
 
232
232
  const successAction = async (response: any) => {
233
- generateContent(response, dispatch, getState);
233
+ const updatedContent = { ...editorContent, ...response };
234
+ generateContent(updatedContent, dispatch, getState);
234
235
  dispatch(setIsNewTranslation(false));
235
236
  };
236
237
 
@@ -89,7 +89,6 @@ const useIsDirty = (
89
89
  const [isResetting, setIsResetting] = useState(false);
90
90
 
91
91
  const prevContent = usePrevious(updatedValues, isSaved);
92
- const isTranslatedVersion: boolean = prevContent?.language !== updatedValues?.language;
93
92
 
94
93
  const hasChanged = () => {
95
94
  if (prevContent && updatedValues) {
@@ -98,7 +97,7 @@ const useIsDirty = (
98
97
 
99
98
  const { cleanUpdatedValues, cleanOriginalValues } = cleanPageValues(updatedValuesCloned, originalValuesCloned);
100
99
 
101
- const hasChanged = !isTranslatedVersion && !isEqual(cleanUpdatedValues, cleanOriginalValues);
100
+ const hasChanged = !isEqual(cleanUpdatedValues, cleanOriginalValues);
102
101
 
103
102
  return hasChanged;
104
103
  }
@@ -72,6 +72,11 @@ const GlobalEditor = (props: IProps) => {
72
72
  // eslint-disable-next-line react-hooks/exhaustive-deps
73
73
  }, []);
74
74
 
75
+ useEffect(() => {
76
+ resetDirty();
77
+ // eslint-disable-next-line react-hooks/exhaustive-deps
78
+ }, [lang]);
79
+
75
80
  useEffect(() => {
76
81
  const { pageID, sendPagePing, currentUserID } = props;
77
82
  if (userEditing && userEditing.id !== currentUserID) {
@@ -31,15 +31,12 @@ const DefaultsEditor = (props: IProps) => {
31
31
  setHeader,
32
32
  setFooter,
33
33
  setHistoryPush,
34
- header,
35
- footer,
36
34
  } = props;
37
35
 
38
36
  const { isOpen, toggleModal } = useModal();
39
37
  const { isDirty, setIsDirty, resetDirty } = useIsDirty(editorContent, isNewTranslation);
40
-
41
38
  const currentDefaultNav = currentDefaultsContent.find((item: any) => item.setAsDefault);
42
- const isNew = !header && !footer;
39
+ const isNew = !editorContent?.id || null;
43
40
  const isSetAsDefault = editorContent && editorContent.setAsDefault;
44
41
 
45
42
  useEffect(() => {
@@ -50,6 +47,11 @@ const DefaultsEditor = (props: IProps) => {
50
47
  // eslint-disable-next-line react-hooks/exhaustive-deps
51
48
  }, []);
52
49
 
50
+ useEffect(() => {
51
+ resetDirty();
52
+ // eslint-disable-next-line react-hooks/exhaustive-deps
53
+ }, [lang]);
54
+
53
55
  const save = () => {
54
56
  isNew || isNewTranslation
55
57
  ? createNavigation().then((isSaved: boolean) => {
@@ -76,8 +78,8 @@ const DefaultsEditor = (props: IProps) => {
76
78
  };
77
79
 
78
80
  const rightButtonProps = {
79
- label: !isDirty ? "Saved" : isSaving ? "Saving" : "Save",
80
- disabled: isSaving || !isDirty,
81
+ label: !isDirty && !isNewTranslation && !isNew ? "Saved" : isSaving ? "Saving" : "Save",
82
+ disabled: (!isDirty && !isNewTranslation && !isNew) || isSaving,
81
83
  action: () => saveButtonAction(),
82
84
  };
83
85
 
@@ -88,7 +90,7 @@ const DefaultsEditor = (props: IProps) => {
88
90
  };
89
91
 
90
92
  const createNewTranslation = (isNewTranslation: boolean) => {
91
- setIsDirty(false);
93
+ setIsDirty(true);
92
94
  createTranslation(isNewTranslation);
93
95
  };
94
96
 
@@ -89,6 +89,7 @@ const PageEditor = (props: IProps) => {
89
89
 
90
90
  useEffect(() => {
91
91
  getDefaults();
92
+ resetDirty();
92
93
  // eslint-disable-next-line react-hooks/exhaustive-deps
93
94
  }, [lang]);
94
95