@griddo/ax 11.15.7 → 11.15.8-rc.0

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.
Files changed (88) hide show
  1. package/package.json +2 -2
  2. package/src/__tests__/components/Fields/Wysiwyg/Wysiwyg.atoms.test.tsx +409 -0
  3. package/src/__tests__/components/Fields/Wysiwyg/Wysiwyg.helpers.test.tsx +418 -0
  4. package/src/__tests__/components/Fields/Wysiwyg/Wysiwyg.test.tsx +776 -29
  5. package/src/__tests__/components/FieldsBehavior/FieldsBehavior.test.tsx +368 -11
  6. package/src/__tests__/modules/Users/UserList/UserList.test.tsx +6 -6
  7. package/src/components/Fields/IntegrationsField/IntegrationItem/atoms.tsx +14 -5
  8. package/src/components/Fields/IntegrationsField/IntegrationItem/index.tsx +1 -8
  9. package/src/components/Fields/UrlField/index.tsx +5 -4
  10. package/src/components/Fields/Wysiwyg/atoms.tsx +140 -0
  11. package/src/components/Fields/Wysiwyg/config.tsx +190 -9
  12. package/src/components/Fields/Wysiwyg/helpers.tsx +54 -1
  13. package/src/components/Fields/Wysiwyg/index.tsx +210 -61
  14. package/src/components/Fields/Wysiwyg/style.tsx +32 -1
  15. package/src/components/Fields/Wysiwyg/vendors.tsx +0 -1
  16. package/src/components/FieldsBehavior/index.tsx +66 -31
  17. package/src/components/Icon/components/Sync.js +16 -0
  18. package/src/components/Icon/svgs/Sync.svg +3 -0
  19. package/src/components/RestoreModal/index.tsx +1 -3
  20. package/src/components/ScheduleModal/index.tsx +3 -3
  21. package/src/components/TableList/index.tsx +5 -3
  22. package/src/containers/FileDrive/actions.tsx +5 -5
  23. package/src/containers/Forms/actions.tsx +40 -38
  24. package/src/containers/Gallery/actions.tsx +27 -27
  25. package/src/containers/Integrations/actions.tsx +2 -2
  26. package/src/containers/Navigation/Defaults/actions.tsx +1 -1
  27. package/src/containers/PageEditor/actions.tsx +3 -5
  28. package/src/containers/Redirects/actions.tsx +2 -2
  29. package/src/containers/Sites/actions.tsx +15 -8
  30. package/src/containers/StructuredData/actions.tsx +5 -5
  31. package/src/containers/Users/actions.tsx +2 -2
  32. package/src/modules/Categories/CategoriesList/CategoryItem/index.tsx +36 -43
  33. package/src/modules/Categories/CategoriesList/CategoryPanel/index.tsx +15 -11
  34. package/src/modules/Categories/CategoriesList/atoms.tsx +42 -12
  35. package/src/modules/Categories/CategoriesList/index.tsx +8 -30
  36. package/src/modules/Content/PageItem/index.tsx +6 -5
  37. package/src/modules/Content/atoms.tsx +7 -3
  38. package/src/modules/Content/index.tsx +8 -16
  39. package/src/modules/FileDrive/FileModal/DetailPanel/index.tsx +14 -14
  40. package/src/modules/FileDrive/FolderItem/index.tsx +46 -54
  41. package/src/modules/FileDrive/GridItem/index.tsx +32 -37
  42. package/src/modules/FileDrive/ListItem/index.tsx +31 -37
  43. package/src/modules/FileDrive/atoms.tsx +59 -12
  44. package/src/modules/FileDrive/index.tsx +88 -98
  45. package/src/modules/Forms/FormCategoriesList/CategoryItem/index.tsx +42 -34
  46. package/src/modules/Forms/FormCategoriesList/atoms.tsx +17 -6
  47. package/src/modules/Forms/FormCategoriesList/index.tsx +30 -34
  48. package/src/modules/Forms/FormEditor/index.tsx +14 -6
  49. package/src/modules/Forms/FormList/FormItem/index.tsx +5 -1
  50. package/src/modules/Forms/FormList/index.tsx +15 -9
  51. package/src/modules/Forms/atoms.tsx +7 -4
  52. package/src/modules/GlobalEditor/atoms.tsx +77 -0
  53. package/src/modules/GlobalEditor/index.tsx +24 -7
  54. package/src/modules/MediaGallery/FolderItem/index.tsx +36 -52
  55. package/src/modules/MediaGallery/GridItem/index.tsx +27 -38
  56. package/src/modules/MediaGallery/ImageModal/DetailPanel/index.tsx +13 -13
  57. package/src/modules/MediaGallery/ImageModal/index.tsx +2 -16
  58. package/src/modules/MediaGallery/ListItem/index.tsx +25 -37
  59. package/src/modules/MediaGallery/atoms.tsx +84 -15
  60. package/src/modules/MediaGallery/index.tsx +62 -122
  61. package/src/modules/Navigation/Defaults/Item/atoms.tsx +2 -4
  62. package/src/modules/Navigation/Defaults/Item/index.tsx +80 -94
  63. package/src/modules/Navigation/Defaults/atoms.tsx +179 -7
  64. package/src/modules/Navigation/Defaults/index.tsx +51 -18
  65. package/src/modules/Navigation/Defaults/style.tsx +10 -7
  66. package/src/modules/Navigation/Menus/List/Table/Item/atoms.tsx +33 -19
  67. package/src/modules/Navigation/Menus/List/Table/Item/index.tsx +18 -19
  68. package/src/modules/Navigation/Menus/List/Table/index.tsx +15 -13
  69. package/src/modules/Navigation/Menus/List/index.tsx +1 -1
  70. package/src/modules/PageEditor/atoms.tsx +14 -11
  71. package/src/modules/PageEditor/index.tsx +11 -16
  72. package/src/modules/Redirects/RedirectItem/index.tsx +37 -39
  73. package/src/modules/Redirects/atoms.tsx +58 -12
  74. package/src/modules/Redirects/index.tsx +30 -58
  75. package/src/modules/Settings/Integrations/IntegrationItem/CopyModal/index.tsx +1 -1
  76. package/src/modules/Settings/Integrations/IntegrationItem/index.tsx +57 -69
  77. package/src/modules/Settings/Integrations/atoms.tsx +72 -8
  78. package/src/modules/Settings/Integrations/index.tsx +34 -48
  79. package/src/modules/StructuredData/Form/index.tsx +25 -8
  80. package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/atoms.tsx +26 -75
  81. package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/index.tsx +15 -33
  82. package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/index.tsx +63 -41
  83. package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/style.tsx +13 -8
  84. package/src/modules/StructuredData/StructuredDataList/index.tsx +11 -16
  85. package/src/modules/StructuredData/{StructuredDataList/atoms.tsx → atoms.tsx} +25 -28
  86. package/src/modules/Users/UserList/UserItem/index.tsx +18 -35
  87. package/src/modules/Users/UserList/atoms.tsx +61 -0
  88. package/src/modules/Users/UserList/index.tsx +12 -32
@@ -1,8 +1,8 @@
1
- import { useEffect, useState } from "react";
1
+ import { useCallback, useEffect, useState } from "react";
2
2
 
3
3
  import { IconAction, Tooltip } from "@ax/components";
4
4
  import { getValidity } from "@ax/forms";
5
- import { getFieldByPath, isEmptyContainer } from "@ax/helpers";
5
+ import { getFieldByPath, isEmptyContainer, slugify } from "@ax/helpers";
6
6
  import type { IErrorItem } from "@ax/types";
7
7
 
8
8
  import * as S from "./style";
@@ -28,66 +28,90 @@ const FieldsBehavior = (props: IFieldsBehaviorProps): JSX.Element => {
28
28
  editorID,
29
29
  objKey,
30
30
  inversed = false,
31
+ selectedContent,
32
+ updateValue,
31
33
  } = props;
32
34
 
33
35
  const [showAdvanced, setShowAdvanced] = useState(false);
34
36
  const [errorField, setErrorField] = useState(false);
35
37
  const [message, setMessage] = useState(helptext);
36
38
 
37
- // biome-ignore lint/correctness/useExhaustiveDependencies: TODO: fix this
39
+ const handleValidation = useCallback(
40
+ (newValue: string | any[], fieldValidators?: Record<string, unknown>) => {
41
+ const validatorWithErrors = error ? { ...validators, ...error.validator } : validators;
42
+ const allValidators = fieldValidators ? { ...validatorWithErrors, ...fieldValidators } : validatorWithErrors;
43
+ const { isValid, errorText } = getValidity(allValidators, newValue);
44
+ if (isValid) {
45
+ setMessage(helptext);
46
+ error && deleteError && deleteError(error);
47
+ } else {
48
+ setMessage(errorText);
49
+ }
50
+ setErrorField(!isValid);
51
+ },
52
+ [error, validators, helptext, deleteError],
53
+ );
54
+
55
+ const resetValidation = useCallback(() => {
56
+ setMessage(helptext);
57
+ error && deleteError && deleteError(error);
58
+ setErrorField(false);
59
+ }, [helptext, error, deleteError]);
60
+
38
61
  useEffect(() => {
39
62
  setErrorField(false);
40
63
  setMessage(helptext);
41
64
  if (error) {
42
65
  handleValidation(value);
43
66
  }
44
- }, [editorID, error]);
45
-
46
- const helpTextWrapper = message ? (
47
- <S.HelpText error={errorField} inversed={inversed}>
48
- {message}
49
- </S.HelpText>
50
- ) : (
51
- <></>
52
- );
67
+ }, [error, value, helptext, handleValidation]);
53
68
 
69
+ // Field type checks
54
70
  const isComponentArray = fieldType === "ComponentArray" || fieldType === "FormFieldArray";
55
71
  const isComponentContainer = fieldType === "ComponentContainer";
56
72
  const isFormContainer = fieldType === "FormContainer";
57
73
  const hasMultipleOptions: boolean = (!!whiteList && whiteList.length > 1) || isFormContainer;
58
74
 
75
+ // Page slug field (only for pages)
76
+ const isPageSlug = editorID === 0 && objKey === "slug";
77
+ const isSlugDisabled =
78
+ isPageSlug &&
79
+ (`/${slugify(selectedContent?.title || "")}` === value ||
80
+ !selectedContent?.title ||
81
+ selectedContent?.title.trim() === "");
82
+
83
+ // Title visibility: show if field has title AND is not a component array
59
84
  const hasTitle = !!title && !isComponentArray;
85
+
60
86
  const Field = getFieldByPath(fieldType);
61
87
 
62
88
  const toggleAdvanced = () => setShowAdvanced(!showAdvanced);
63
89
 
90
+ // Check if container is empty (only for ComponentContainer type)
64
91
  const containerInfo = isComponentContainer && !!value && isEmptyContainer(value, hasMultipleOptions);
65
-
66
92
  const isEmpty = containerInfo ? containerInfo.isEmpty : false;
93
+
94
+ // Show title if field has title AND (is not empty OR has multiple options)
67
95
  const showTitle = hasTitle && (!isEmpty || hasMultipleOptions);
68
96
 
69
97
  const Asterisk = () => (mandatory ? <S.Asterisk>*</S.Asterisk> : null);
70
98
 
71
99
  const wrapperClass = filled ? `${className} filled` : className;
72
100
 
73
- const handleValidation = (newValue: string | any[], fieldValidators?: Record<string, unknown>) => {
74
- const validatorWithErrors = error ? { ...validators, ...error.validator } : validators;
75
- const allValidators = fieldValidators ? { ...validatorWithErrors, ...fieldValidators } : validatorWithErrors;
76
- const { isValid, errorText } = getValidity(allValidators, newValue);
77
- if (isValid) {
78
- setMessage(helptext);
79
- error && deleteError && deleteError(error);
80
- } else {
81
- setMessage(errorText);
82
- }
83
- setErrorField(!isValid);
101
+ const handleSyncSlug = () => {
102
+ const newSlug = `/${slugify(selectedContent?.title || "")}`;
103
+ updateValue?.("slug", newSlug);
84
104
  };
85
105
 
86
- const resetValidation = () => {
87
- setMessage(helptext);
88
- error && deleteError && deleteError(error);
89
- setErrorField(false);
90
- };
106
+ const tooltipText = isSlugDisabled ? (
107
+ "The slug already matches the page name"
108
+ ) : (
109
+ <>
110
+ This action updates the slug based on the current
111
+ <br />
112
+ page name, modifies the URL, and sets up a redirect.
113
+ </>
114
+ );
91
115
 
92
116
  return (
93
117
  <S.Wrapper className={wrapperClass} showTitle={showTitle} id={`gdd_${objKey}`}>
@@ -118,8 +142,17 @@ const FieldsBehavior = (props: IFieldsBehaviorProps): JSX.Element => {
118
142
  </Tooltip>
119
143
  )}
120
144
  </S.Icons>
145
+ {isPageSlug && (
146
+ <Tooltip content={tooltipText}>
147
+ <IconAction icon="sync" size="s" onClick={handleSyncSlug} disabled={isSlugDisabled} />
148
+ </Tooltip>
149
+ )}
121
150
  </S.Header>
122
- {helpTextWrapper}
151
+ {message && (
152
+ <S.HelpText error={errorField} inversed={inversed}>
153
+ {message}
154
+ </S.HelpText>
155
+ )}
123
156
  </S.Wrapper>
124
157
  );
125
158
  };
@@ -139,12 +172,14 @@ interface IFieldsBehaviorProps {
139
172
  disabled?: boolean;
140
173
  filled?: boolean;
141
174
  validators?: Record<string, unknown>;
142
- error?: any; // TODO add type IErrorItem?
175
+ error?: any;
143
176
  deleteError?: (error: IErrorItem) => void;
144
177
  editorID?: string | number;
145
178
  objKey?: string | number;
146
179
  inversed?: boolean;
147
180
  [key: string]: unknown;
181
+ selectedContent?: { title?: string } & Record<string, any>;
182
+ updateValue?: (key: string, value: any, templateID?: number, slugTo?: string) => void;
148
183
  }
149
184
 
150
185
  export default FieldsBehavior;
@@ -0,0 +1,16 @@
1
+ import * as React from "react";
2
+ const SvgSync = (props) => (
3
+ <svg
4
+ xmlns="http://www.w3.org/2000/svg"
5
+ width={24}
6
+ height={24}
7
+ fill="none"
8
+ {...props}
9
+ >
10
+ <path
11
+ fill="#5057FF"
12
+ d="M4 12H1l4 4 4-4H6c0-3.31 2.69-6 6-6 1.01 0 1.97.25 2.8.7l1.46-1.46A7.93 7.93 0 0 0 12 4c-4.42 0-8 3.58-8 8Zm14 0c0 3.31-2.69 6-6 6a5.87 5.87 0 0 1-2.8-.7l-1.46 1.46A7.93 7.93 0 0 0 12 20c4.42 0 8-3.58 8-8h3l-4-4-4 4h3Z"
13
+ />
14
+ </svg>
15
+ );
16
+ export default SvgSync;
@@ -0,0 +1,3 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M4 12L1 12L5 16L9 12L6 12C6 8.69 8.69 6 12 6C13.01 6 13.97 6.25 14.8 6.7L16.26 5.24C15.03 4.46 13.57 4 12 4C7.58 4 4 7.58 4 12ZM18 12C18 15.31 15.31 18 12 18C10.99 18 10.03 17.75 9.2 17.3L7.74 18.76C8.97 19.54 10.43 20 12 20C16.42 20 20 16.42 20 12L23 12L19 8L15 12L18 12Z" fill="#5057FF"/>
3
+ </svg>
@@ -1,7 +1,5 @@
1
- import React from "react";
2
-
3
- import { IModal } from "@ax/types";
4
1
  import { Modal } from "@ax/components";
2
+ import type { IModal } from "@ax/types";
5
3
 
6
4
  import * as S from "./style";
7
5
 
@@ -1,8 +1,8 @@
1
- import React, { useState } from "react";
1
+ import { useState } from "react";
2
2
 
3
- import { IModal } from "@ax/types";
4
- import { Modal, FieldsBehavior } from "@ax/components";
3
+ import { FieldsBehavior, Modal } from "@ax/components";
5
4
  import { stringToDate } from "@ax/helpers";
5
+ import type { IModal } from "@ax/types";
6
6
 
7
7
  import * as S from "./style";
8
8
 
@@ -6,7 +6,8 @@ import type { IRootState } from "@ax/types";
6
6
  import * as S from "./style";
7
7
 
8
8
  const TableList = (props: ITableListProps): JSX.Element => {
9
- const { tableHeader, children, pagination, isLoading, onScroll, hasFixedHeader, tableRef, className } = props;
9
+ const { tableHeader, children, pagination, isLoading, skipLoading, onScroll, hasFixedHeader, tableRef, className } =
10
+ props;
10
11
 
11
12
  const showPagination = pagination && pagination.totalItems > pagination.itemsPerPage;
12
13
 
@@ -16,7 +17,7 @@ const TableList = (props: ITableListProps): JSX.Element => {
16
17
  <S.TableHeader hasFixedHeader={hasFixedHeader} data-testid="table-list-header" className={className}>
17
18
  {tableHeader}
18
19
  </S.TableHeader>
19
- {isLoading ? (
20
+ {isLoading && !skipLoading ? (
20
21
  <Loading />
21
22
  ) : (
22
23
  <S.TableBody data-testid="table-body" className={className}>
@@ -25,7 +26,7 @@ const TableList = (props: ITableListProps): JSX.Element => {
25
26
  )}
26
27
  </S.Table>
27
28
  <S.PaginationWrapper>
28
- {showPagination && !isLoading && (
29
+ {showPagination && !(isLoading && !skipLoading) && (
29
30
  <Pagination
30
31
  totalItems={pagination.totalItems}
31
32
  setPage={pagination.setPage}
@@ -52,6 +53,7 @@ export interface ITableListProps {
52
53
  currPage: number;
53
54
  };
54
55
  isLoading?: boolean;
56
+ skipLoading?: boolean;
55
57
  onScroll?: any;
56
58
  hasFixedHeader?: boolean;
57
59
  tableRef?: any;
@@ -166,7 +166,7 @@ function updateFolder(
166
166
  };
167
167
  const callback = async () => files.updateFolder(folderID, data);
168
168
 
169
- return await handleRequest(callback, responseActions, [])(dispatch);
169
+ return await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
170
170
  } catch (e) {
171
171
  console.log(e);
172
172
  return false;
@@ -186,7 +186,7 @@ function deleteFolder(folder: IFolder): (dispatch: Dispatch, getState: any) => P
186
186
  };
187
187
  const callback = async () => files.deleteFolder(folder.id);
188
188
 
189
- return await handleRequest(callback, responseActions, [])(dispatch);
189
+ return await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
190
190
  } catch (e) {
191
191
  console.log(e);
192
192
  return false;
@@ -285,7 +285,7 @@ function deleteFile(
285
285
  };
286
286
  const callback = async () => (Array.isArray(fileID) ? files.deleteFilesBulk(fileID) : files.deleteFile(fileID));
287
287
 
288
- return await handleRequest(callback, responseActions, [])(dispatch);
288
+ return await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
289
289
  } catch (e) {
290
290
  console.log(e);
291
291
  return false;
@@ -313,7 +313,7 @@ function moveFile(
313
313
  const callback = async () =>
314
314
  Array.isArray(fileID) ? files.moveFilesBulk(fileID, folderID) : files.moveFile(fileID, folderID);
315
315
 
316
- return await handleRequest(callback, responseActions, [])(dispatch);
316
+ return await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
317
317
  } catch (e) {
318
318
  console.log(e);
319
319
  return false;
@@ -390,7 +390,7 @@ function downloadFiles(
390
390
 
391
391
  const callback = async () => files.downloadFiles(fileID, zip);
392
392
 
393
- await handleRequest(callback, responseActions, [])(dispatch);
393
+ await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
394
394
  } catch (e) {
395
395
  console.log(e);
396
396
  }
@@ -1,5 +1,26 @@
1
- import { Dispatch } from "redux";
1
+ import { forms, images } from "@ax/api";
2
+ import { appActions } from "@ax/containers/App";
2
3
  import {
4
+ findByEditorID,
5
+ generateEditorIDs,
6
+ getLastComponentEditorID,
7
+ getNewBreadcrumb,
8
+ getParentKey,
9
+ moveElement,
10
+ parseData,
11
+ updateByEditorID,
12
+ updateComponent,
13
+ } from "@ax/forms";
14
+ import {
15
+ deepClone,
16
+ getDefaultFormTemplate,
17
+ getDefaultSchema,
18
+ getImageFromIFrame,
19
+ getSchema,
20
+ handleRequest,
21
+ isReqOk,
22
+ } from "@ax/helpers";
23
+ import type {
3
24
  FormCategoriesList,
4
25
  FormCategoriesOrderParams,
5
26
  FormCategory,
@@ -13,62 +34,43 @@ import {
13
34
  ISchema,
14
35
  ListForm,
15
36
  } from "@ax/types";
37
+
38
+ import type { Dispatch } from "redux";
39
+
16
40
  import {
17
- deepClone,
18
- getDefaultFormTemplate,
19
- getDefaultSchema,
20
- getImageFromIFrame,
21
- getSchema,
22
- handleRequest,
23
- isReqOk,
24
- } from "@ax/helpers";
25
- import {
26
- findByEditorID,
27
- generateEditorIDs,
28
- getLastComponentEditorID,
29
- getNewBreadcrumb,
30
- getParentKey,
31
- moveElement,
32
- parseData,
33
- updateByEditorID,
34
- updateComponent,
35
- } from "@ax/forms";
36
- import { appActions } from "@ax/containers/App";
37
- import { forms, images } from "@ax/api";
38
- import {
41
+ DEFAULT_PARAMS,
39
42
  SET_BREADCRUMB,
40
43
  SET_COPY_MODULE,
44
+ SET_CURRENT_FORM_CATEGORIES,
41
45
  SET_CURRENT_FORM_ID,
42
46
  SET_FORM_CONTENT,
43
47
  SET_FORMS,
48
+ SET_IS_IA_TRANSLATED,
49
+ SET_IS_NEW_TRANSLATION,
44
50
  SET_SCHEMA,
45
51
  SET_SELECTED_CONTENT,
46
52
  SET_SELECTED_EDITOR_ID,
47
53
  SET_SELECTED_PARENT,
54
+ SET_SUMMARY,
48
55
  SET_TAB,
49
56
  SET_TEMPLATE,
50
- SET_SUMMARY,
51
- DEFAULT_PARAMS,
52
- SET_CURRENT_FORM_CATEGORIES,
53
- SET_IS_NEW_TRANSLATION,
54
- SET_IS_IA_TRANSLATED,
55
57
  } from "./constants";
56
- import {
58
+ import type {
57
59
  ISetBreadcrumb,
58
60
  ISetCopyModule,
61
+ ISetCurrentFormCategories,
59
62
  ISetCurrentFormID,
60
63
  ISetFormContent,
61
64
  ISetForms,
65
+ ISetIsIATranslated,
66
+ ISetIsNewTranslation,
62
67
  ISetSchema,
63
68
  ISetSelectedContent,
64
69
  ISetSelectedEditorID,
65
70
  ISetSelectedParent,
71
+ ISetSummary,
66
72
  ISetTab,
67
73
  ISetTemplate,
68
- ISetSummary,
69
- ISetCurrentFormCategories,
70
- ISetIsNewTranslation,
71
- ISetIsIATranslated,
72
74
  } from "./interfaces";
73
75
  import { getUpdatedComponents } from "./utils";
74
76
 
@@ -349,7 +351,7 @@ function saveForm(
349
351
  }
350
352
 
351
353
  const isNewForm = !formContent.id;
352
- formContent["language"] = lang.id;
354
+ formContent.language = lang.id;
353
355
 
354
356
  const callback = async () =>
355
357
  isNewForm ? await forms.createForm(formContent) : await forms.updateForm(formContent.id, formContent);
@@ -360,7 +362,7 @@ function saveForm(
360
362
  if (updateState) {
361
363
  const isUpdated = await forms.updateFormState(pageContent.id, updateState);
362
364
  if (isUpdated) {
363
- pageContent["state"] = updateState;
365
+ pageContent.state = updateState;
364
366
  }
365
367
  }
366
368
  if (isNewForm) {
@@ -413,7 +415,7 @@ function deleteForm(id: number | number[]): (dispatch: Dispatch, getState: () =>
413
415
 
414
416
  const callback = async () => (Array.isArray(id) ? await forms.deleteFormBulk(id) : await forms.deleteForm(id));
415
417
 
416
- return await handleRequest(callback, responseActions, [])(dispatch);
418
+ return await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
417
419
  } catch (e) {
418
420
  console.log(e);
419
421
  return false;
@@ -443,7 +445,7 @@ function updateFormState(
443
445
  handleError: (response: any) => handleError(response)(dispatch),
444
446
  };
445
447
 
446
- return await handleRequest(callback, responseActions, [])(dispatch);
448
+ return await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
447
449
  } catch (e) {
448
450
  console.log(e);
449
451
  return false;
@@ -808,7 +810,7 @@ function deleteFormCategory(
808
810
  const callback = async () =>
809
811
  Array.isArray(id) ? forms.deleteFormCategoryBulk(id) : forms.deleteFormCategory(id);
810
812
 
811
- return await handleRequest(callback, responseActions, [])(dispatch);
813
+ return await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
812
814
  } catch (e) {
813
815
  console.log(e);
814
816
  return false;
@@ -1,8 +1,7 @@
1
- import { Dispatch } from "redux";
2
-
3
- import { handleRequest, isReqOk, compressImage, getNewBreadcrumb } from "@ax/helpers";
4
- import { images, sites, folders } from "@ax/api";
5
- import {
1
+ import { folders, images, sites } from "@ax/api";
2
+ import { appActions } from "@ax/containers/App";
3
+ import { compressImage, getNewBreadcrumb, handleRequest, isReqOk } from "@ax/helpers";
4
+ import type {
6
5
  IFolder,
7
6
  IFolderTree,
8
7
  IGetFolderParams,
@@ -12,37 +11,38 @@ import {
12
11
  IImageForm,
13
12
  IRootState,
14
13
  } from "@ax/types";
15
- import { appActions } from "@ax/containers/App";
14
+
15
+ import type { Dispatch } from "redux";
16
16
 
17
17
  import {
18
+ SET_BREADCRUMB,
19
+ SET_CURRENT_FOLDER,
20
+ SET_CURRENT_FOLDER_CONTENT,
18
21
  SET_DATA,
22
+ SET_DISPLAY_MODE,
23
+ SET_FOLDERS_TREE,
19
24
  SET_IS_LOADING,
20
25
  SET_IS_SAVING,
21
26
  SET_IS_UPLOADING,
22
- SET_UPLOAD_SUCCESS,
23
- SET_UPLOAD_ERROR,
24
- SET_DISPLAY_MODE,
25
27
  SET_SELECTED_TAB,
26
- SET_CURRENT_FOLDER_CONTENT,
27
- SET_CURRENT_FOLDER,
28
- SET_BREADCRUMB,
29
- SET_FOLDERS_TREE,
28
+ SET_UPLOAD_ERROR,
29
+ SET_UPLOAD_SUCCESS,
30
30
  } from "./constants";
31
- import {
31
+ import type {
32
+ ISetBreadcrumb,
33
+ ISetCurrentFolder,
34
+ ISetCurrentFolderContent,
32
35
  ISetData,
36
+ ISetDisplayMode,
37
+ ISetFoldersTree,
33
38
  ISetIsLoading,
34
39
  ISetIsSaving,
35
40
  ISetIsUploading,
36
- ISetUploadSuccess,
37
- ISetUploadError,
38
- ISetDisplayMode,
39
41
  ISetSelectedTab,
40
- ISetCurrentFolderContent,
41
- ISetCurrentFolder,
42
- ISetBreadcrumb,
43
- ISetFoldersTree,
42
+ ISetUploadError,
43
+ ISetUploadSuccess,
44
44
  } from "./interfaces";
45
- import { IData, IIsLoading, IIsSaving } from "./reducer";
45
+ import type { IData, IIsLoading, IIsSaving } from "./reducer";
46
46
 
47
47
  const thumbWidth = 192;
48
48
  const thumbHeight = 144;
@@ -229,7 +229,7 @@ function deleteImage(
229
229
 
230
230
  const callback = async () => (isBulk ? images.deleteImageBulk(imageID) : images.deleteImage(imageID));
231
231
 
232
- return await handleRequest(callback, responseActions, [])(dispatch);
232
+ return await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
233
233
  } catch (e) {
234
234
  console.log(e);
235
235
  return false;
@@ -374,7 +374,7 @@ function updateFolder(
374
374
  };
375
375
  const callback = async () => folders.updateFolder(folderID, data);
376
376
 
377
- return await handleRequest(callback, responseActions, [])(dispatch);
377
+ return await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
378
378
  } catch (e) {
379
379
  console.log(e);
380
380
  return false;
@@ -397,7 +397,7 @@ function deleteFolder(
397
397
  };
398
398
  const callback = async () => folders.deleteFolder(folder.id, "images");
399
399
 
400
- return await handleRequest(callback, responseActions, [])(dispatch);
400
+ return await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
401
401
  } catch (e) {
402
402
  console.log(e);
403
403
  return false;
@@ -422,7 +422,7 @@ function moveImage(
422
422
  const callback = async () =>
423
423
  Array.isArray(imageID) ? images.moveImageBulk(imageID, folderID) : images.moveImage(imageID, folderID);
424
424
 
425
- return await handleRequest(callback, responseActions, [])(dispatch);
425
+ return await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
426
426
  } catch (e) {
427
427
  console.log(e);
428
428
  return false;
@@ -452,7 +452,7 @@ function downloadImages(
452
452
 
453
453
  const callback = async () => images.downloadImages(imageID, zip);
454
454
 
455
- await handleRequest(callback, responseActions, [])(dispatch);
455
+ await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
456
456
  } catch (e) {
457
457
  console.log(e);
458
458
  }
@@ -79,7 +79,7 @@ function deleteIntegration(
79
79
  handleError: (response: any) => appActions.handleError(response)(dispatch),
80
80
  };
81
81
 
82
- return await handleRequest(callback, responseActions, [])(dispatch);
82
+ return await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
83
83
  } catch (e) {
84
84
  console.log(e);
85
85
  return false;
@@ -112,7 +112,7 @@ function changeIntegrationState(
112
112
  handleError: (response: any) => appActions.handleError(response)(dispatch),
113
113
  };
114
114
 
115
- return await handleRequest(callback, responseActions, [])(dispatch);
115
+ return await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
116
116
  } catch (e) {
117
117
  console.log(e);
118
118
  return false;
@@ -383,7 +383,7 @@ function deleteNavigation(
383
383
  const callback = async () =>
384
384
  Array.isArray(navID) ? navigation.deleteNavigationBulk(navID) : navigation.deleteNavigation(navID);
385
385
 
386
- return await handleRequest(callback, responseActions, [appActions.setIsLoading])(dispatch);
386
+ return await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
387
387
  } catch (e) {
388
388
  console.log(e); // TODO: capturar error bien
389
389
  return false;
@@ -540,7 +540,7 @@ function deletePage(params?: ISavePageParams): (dispatch: Dispatch, getState: ()
540
540
 
541
541
  const callback = async () => pages.deletePage(page.id);
542
542
 
543
- return await handleRequest(callback, responseActions, [])(dispatch);
543
+ return await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
544
544
  } catch (e) {
545
545
  console.log(e);
546
546
  return false;
@@ -563,9 +563,9 @@ function deleteBulk(ids: any): (dispatch: Dispatch) => Promise<boolean> {
563
563
  },
564
564
  };
565
565
 
566
- const callback = async () => pages.bulkDelete(ids);
566
+ const callback = async () => await pages.bulkDelete(ids);
567
567
 
568
- return await handleRequest(callback, responseActions, [])(dispatch);
568
+ return await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
569
569
  } catch (e) {
570
570
  console.log(e);
571
571
  return false;
@@ -605,7 +605,6 @@ function updatePageStatus(
605
605
  ): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
606
606
  return async (dispatch, getState) => {
607
607
  try {
608
- dispatch(setIsSaving(true));
609
608
  const {
610
609
  app: {
611
610
  globalSettings: { skipReviewOnPublish },
@@ -661,7 +660,6 @@ function updatePageStatus(
661
660
 
662
661
  return await handleRequest(callback, responseActions, [setIsSaving])(dispatch);
663
662
  } catch (e) {
664
- dispatch(setIsSaving(false));
665
663
  console.log(e); // TODO: capturar error bien
666
664
  return false;
667
665
  }
@@ -128,7 +128,7 @@ function deleteRedirect(
128
128
  const responseActions = {
129
129
  handleSuccess: () => {
130
130
  const params = { ...DEFAULT_PARAMS };
131
- const siteFilterQuery = currentSiteInfo && currentSiteInfo.id ? `&sites=${currentSiteInfo.id}` : filter;
131
+ const siteFilterQuery = currentSiteInfo?.id ? `&sites=${currentSiteInfo.id}` : filter;
132
132
  dispatch(getRedirects(params, siteFilterQuery));
133
133
  },
134
134
  handleError: (response: any) => {
@@ -141,7 +141,7 @@ function deleteRedirect(
141
141
  },
142
142
  };
143
143
 
144
- return await handleRequest(callback, responseActions, [])(dispatch);
144
+ return await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
145
145
  } catch (e) {
146
146
  console.log(e);
147
147
  return false;
@@ -638,11 +638,16 @@ function importPageFromGlobal(
638
638
  function removeUsersBulk(siteId: number, users: number[]): (dispatch: Dispatch) => Promise<void> {
639
639
  return async (dispatch) => {
640
640
  try {
641
- const response = await sites.removeUsersBulk(siteId, users);
642
- if (isReqOk(response.status)) {
643
- const params = { filterQuery: "?order=dateCreated" };
644
- getUsers(params, siteId)(dispatch);
645
- }
641
+ const responseActions = {
642
+ handleSuccess: async () => {
643
+ const params = { filterQuery: "?order=dateCreated" };
644
+ await getUsers(params, siteId)(dispatch);
645
+ },
646
+ handleError: (response: any) => appActions.handleError(response)(dispatch),
647
+ };
648
+ const callback = async () => await sites.removeUsersBulk(siteId, users);
649
+
650
+ await handleRequest(callback, responseActions, [setIsSaving])(dispatch);
646
651
  } catch (e) {
647
652
  console.log(e); // TODO: capturar error bien
648
653
  }
@@ -688,7 +693,7 @@ function removePageFromSite(
688
693
  ? sites.removePageBulk(currentSiteInfo.id, pageID)
689
694
  : sites.removePage(currentSiteInfo.id, pageID);
690
695
 
691
- return await handleRequest(callback, responseActions, [])(dispatch);
696
+ return await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
692
697
  } catch (e) {
693
698
  console.log(e);
694
699
  return false;
@@ -756,14 +761,16 @@ function deleteAndRemoveFromSiteBulk(
756
761
  let errors = 0;
757
762
 
758
763
  if (pageNoGlobalIds.length > 0) {
759
- const result = await handleRequest(callbackPages, responsePageActions, [])(dispatch);
764
+ const result = await handleRequest(callbackPages, responsePageActions, [appActions.setIsSaving])(dispatch);
760
765
  if (!result) {
761
766
  errors = errors + 1;
762
767
  }
763
768
  }
764
769
 
765
770
  if (globalPageIds.length > 0) {
766
- const result = await handleRequest(callbackGlobalPages, responseGlobalPageActions, [])(dispatch);
771
+ const result = await handleRequest(callbackGlobalPages, responseGlobalPageActions, [appActions.setIsSaving])(
772
+ dispatch,
773
+ );
767
774
  if (!result) {
768
775
  errors = errors + 1;
769
776
  }