@griddo/ax 11.13.2 → 11.13.3-rc.1
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/config/jest/setup.js +10 -0
- package/package.json +2 -2
- package/src/GlobalStore.tsx +1 -1
- package/src/__tests__/components/Fields/AsyncCheckGroup/AsyncCheckGroup.test.tsx +276 -66
- package/src/__tests__/components/FloatingMenu/FloatingMenu.test.tsx +300 -99
- package/src/__tests__/modules/Settings/Social/Social.test.tsx +12 -4
- package/src/api/checkgroups.tsx +4 -3
- package/src/api/selects.tsx +12 -5
- package/src/components/ActionMenu/index.tsx +1 -3
- package/src/components/Browser/index.tsx +12 -3
- package/src/components/Browser/style.tsx +7 -0
- package/src/components/ConfigPanel/Form/index.tsx +47 -53
- package/src/components/Fields/AnalyticsField/PageAnalytics/atoms.tsx +9 -13
- package/src/components/Fields/AnalyticsField/PageAnalytics/index.tsx +37 -29
- package/src/components/Fields/AnalyticsField/StructuredDataAnalytics/atoms.tsx +9 -13
- package/src/components/Fields/AnalyticsField/StructuredDataAnalytics/index.tsx +17 -11
- package/src/components/Fields/AnalyticsField/index.tsx +1 -2
- package/src/components/Fields/AnalyticsField/utils.tsx +4 -4
- package/src/components/Fields/AsyncCheckGroup/index.tsx +97 -79
- package/src/components/Fields/AsyncSelect/index.tsx +33 -22
- package/src/components/Fields/DateField/DatePickerInput/index.tsx +2 -2
- package/src/components/Fields/DateField/index.tsx +3 -3
- package/src/components/Fields/IntegrationsField/SideModal/index.tsx +2 -2
- package/src/components/Fields/IntegrationsField/index.tsx +14 -10
- package/src/components/Fields/MultiCheckSelect/index.tsx +6 -6
- package/src/components/Fields/MultiCheckSelectGroup/index.tsx +39 -37
- package/src/components/Fields/MultiCheckSelectGroup/style.tsx +1 -1
- package/src/components/Fields/ReferenceField/ManualPanel/index.tsx +0 -2
- package/src/components/Fields/RichText/index.tsx +15 -7
- package/src/components/Fields/TextArea/index.tsx +9 -6
- package/src/components/FloatingMenu/index.tsx +32 -31
- package/src/components/FloatingMenu/style.tsx +23 -5
- package/src/components/Loader/components/SmallCircle.js +3 -3
- package/src/components/MainWrapper/AppBar/style.tsx +1 -0
- package/src/components/SideModal/index.tsx +1 -1
- package/src/components/TableFilters/CategoryFilter/index.tsx +14 -15
- package/src/containers/App/actions.tsx +7 -1
- package/src/containers/App/constants.tsx +2 -0
- package/src/containers/App/interfaces.tsx +5 -0
- package/src/containers/App/reducer.tsx +11 -2
- package/src/containers/Forms/actions.tsx +5 -7
- package/src/containers/Integrations/actions.tsx +1 -3
- package/src/containers/Navigation/Menu/actions.tsx +2 -2
- package/src/containers/PageEditor/actions.tsx +3 -2
- package/src/containers/Settings/DataPacks/actions.tsx +35 -29
- package/src/containers/Sites/actions.tsx +40 -33
- package/src/containers/StructuredData/actions.tsx +3 -9
- package/src/modules/ActivityLog/LogFilters/DateFilter/index.tsx +5 -4
- package/src/modules/Content/NewContentModal/PageImporter/index.tsx +1 -2
- package/src/modules/Content/index.tsx +8 -3
- package/src/modules/Content/style.tsx +7 -0
- package/src/modules/Navigation/Defaults/DefaultsEditor/index.tsx +58 -45
- package/src/modules/Navigation/Defaults/index.tsx +103 -104
- package/src/modules/PageEditor/index.tsx +9 -1
- package/src/modules/PublicPreview/index.tsx +2 -1
- package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/index.tsx +60 -44
- package/src/modules/Settings/ContentTypes/DataPacks/Config/index.tsx +32 -37
- package/src/modules/Sites/index.tsx +3 -3
- package/src/modules/Users/UserList/index.tsx +1 -1
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import { memo, useEffect, useRef, useState } from "react";
|
|
2
3
|
import { Editor } from "react-draft-wysiwyg";
|
|
3
|
-
|
|
4
|
-
import {
|
|
4
|
+
|
|
5
|
+
import { ContentState, convertFromRaw, convertToRaw, EditorState } from "draft-js";
|
|
6
|
+
import { stateFromHTML } from "draft-js-import-html";
|
|
5
7
|
import draftToHtml from "draftjs-to-html";
|
|
6
8
|
import htmlToDraft from "html-to-draftjs";
|
|
7
|
-
import {
|
|
8
|
-
import { formatIframe } from "./utils";
|
|
9
|
+
import { draftToMarkdown, markdownToDraft } from "markdown-draft-js";
|
|
9
10
|
import "react-draft-wysiwyg/dist/react-draft-wysiwyg.css";
|
|
10
11
|
|
|
12
|
+
import { formatIframe } from "./utils";
|
|
13
|
+
|
|
11
14
|
import * as S from "./style";
|
|
12
15
|
|
|
13
16
|
const RichText = (props: IRichTextProps): JSX.Element => {
|
|
@@ -32,6 +35,7 @@ const RichText = (props: IRichTextProps): JSX.Element => {
|
|
|
32
35
|
|
|
33
36
|
const [editorState, setEditorState] = useState(() => EditorState.createWithContent(contentState));
|
|
34
37
|
const timeOutRef = useRef<ReturnType<typeof setTimeout>>();
|
|
38
|
+
const isMountRef = useRef(true);
|
|
35
39
|
|
|
36
40
|
// biome-ignore lint/correctness/useExhaustiveDependencies: TODO: fix this
|
|
37
41
|
useEffect(() => {
|
|
@@ -43,6 +47,10 @@ const RichText = (props: IRichTextProps): JSX.Element => {
|
|
|
43
47
|
|
|
44
48
|
// biome-ignore lint/correctness/useExhaustiveDependencies: TODO: fix this
|
|
45
49
|
useEffect(() => {
|
|
50
|
+
if (isMountRef.current) {
|
|
51
|
+
isMountRef.current = false;
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
46
54
|
if (delayed !== false) {
|
|
47
55
|
timeOutRef.current && clearTimeout(timeOutRef.current);
|
|
48
56
|
timeOutRef.current = setTimeout(() => {
|
|
@@ -77,9 +85,9 @@ const RichText = (props: IRichTextProps): JSX.Element => {
|
|
|
77
85
|
return false;
|
|
78
86
|
};
|
|
79
87
|
|
|
80
|
-
const handleOnBlur = (
|
|
88
|
+
const handleOnBlur = (_event: React.FocusEvent<HTMLTextAreaElement>, editorState: EditorState) => {
|
|
81
89
|
const plainContent = editorState.getCurrentContent().getPlainText();
|
|
82
|
-
handleValidation
|
|
90
|
+
handleValidation?.(plainContent, validators);
|
|
83
91
|
};
|
|
84
92
|
|
|
85
93
|
const toolbar = {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import { memo, useEffect, useRef, useState } from "react";
|
|
2
3
|
|
|
3
4
|
import * as S from "./style";
|
|
4
5
|
|
|
@@ -10,10 +11,12 @@ const TextArea = (props: ITextAreaProps): JSX.Element => {
|
|
|
10
11
|
|
|
11
12
|
// biome-ignore lint/correctness/useExhaustiveDependencies: TODO: fix this
|
|
12
13
|
useEffect(() => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
if (state !== value) {
|
|
15
|
+
timeOutRef.current && clearTimeout(timeOutRef.current);
|
|
16
|
+
timeOutRef.current = setTimeout(() => {
|
|
17
|
+
delayedChange();
|
|
18
|
+
}, 300);
|
|
19
|
+
}
|
|
17
20
|
}, [state]);
|
|
18
21
|
|
|
19
22
|
// biome-ignore lint/correctness/useExhaustiveDependencies: TODO: fix this
|
|
@@ -31,7 +34,7 @@ const TextArea = (props: ITextAreaProps): JSX.Element => {
|
|
|
31
34
|
};
|
|
32
35
|
|
|
33
36
|
const handleOnBlur = (e: React.FocusEvent<HTMLTextAreaElement>) => {
|
|
34
|
-
handleValidation
|
|
37
|
+
handleValidation?.(e.target.value);
|
|
35
38
|
};
|
|
36
39
|
|
|
37
40
|
return (
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { useCallback, useLayoutEffect, useRef, useState, type ReactNode } from "react";
|
|
3
3
|
|
|
4
4
|
import { useHandleClickOutside } from "@ax/hooks";
|
|
5
5
|
|
|
6
6
|
import * as S from "./style";
|
|
7
7
|
|
|
8
|
+
const CLOSED_POSITION = { openUpward: false, leftwardOffset: 0, isVisible: false };
|
|
9
|
+
|
|
8
10
|
const FloatingMenu = (props: IFloatingProps): JSX.Element => {
|
|
9
11
|
const {
|
|
10
12
|
children,
|
|
@@ -24,43 +26,37 @@ const FloatingMenu = (props: IFloatingProps): JSX.Element => {
|
|
|
24
26
|
const buttonRef = useRef<HTMLDivElement | null>(null);
|
|
25
27
|
const menuOptionsRef = useRef<HTMLDivElement | null>(null);
|
|
26
28
|
const [isOpen, setOpen] = useState(false);
|
|
29
|
+
const [menuPosition, setMenuPosition] = useState(CLOSED_POSITION);
|
|
27
30
|
|
|
28
|
-
|
|
29
|
-
if (isOpen
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
}
|
|
31
|
+
useLayoutEffect(() => {
|
|
32
|
+
if (!isOpen || !menuOptionsRef.current) return;
|
|
33
|
+
|
|
34
|
+
const bounding = menuOptionsRef.current.getBoundingClientRect();
|
|
35
|
+
const openUpward = bounding.bottom > document.documentElement.clientHeight;
|
|
36
|
+
const rightOverflow = bounding.right - document.documentElement.clientWidth;
|
|
37
|
+
const leftwardOffset = rightOverflow > 0 ? rightOverflow : 0;
|
|
38
|
+
|
|
39
|
+
setMenuPosition({ openUpward, leftwardOffset, isVisible: true });
|
|
39
40
|
}, [isOpen]);
|
|
40
41
|
|
|
42
|
+
const closeMenu = useCallback(() => {
|
|
43
|
+
actionOnClose?.();
|
|
44
|
+
setOpen(false);
|
|
45
|
+
setMenuPosition(CLOSED_POSITION);
|
|
46
|
+
}, [actionOnClose]);
|
|
47
|
+
|
|
41
48
|
const handleClickOutside = (e: MouseEvent) => {
|
|
42
49
|
if (wrapperRef.current?.contains(e.target as HTMLElement)) {
|
|
43
50
|
return;
|
|
44
51
|
}
|
|
45
52
|
|
|
46
|
-
|
|
47
|
-
actionOnClose();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
setOpen(false);
|
|
53
|
+
closeMenu();
|
|
51
54
|
};
|
|
52
55
|
|
|
53
56
|
const closeWhenChecked = (e: React.MouseEvent<HTMLDivElement>) => {
|
|
54
57
|
const target = e.target as HTMLInputElement;
|
|
55
58
|
const isChecked = target?.checked;
|
|
56
|
-
isChecked &&
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const closeWhenApply = (e: React.MouseEvent<HTMLDivElement>) => {
|
|
60
|
-
const target = e.target as HTMLSpanElement;
|
|
61
|
-
if (target.innerHTML === "Apply") {
|
|
62
|
-
setOpen(false);
|
|
63
|
-
}
|
|
59
|
+
isChecked && closeMenu();
|
|
64
60
|
};
|
|
65
61
|
|
|
66
62
|
const handleClick = (e: React.MouseEvent<HTMLDivElement>) => {
|
|
@@ -70,20 +66,22 @@ const FloatingMenu = (props: IFloatingProps): JSX.Element => {
|
|
|
70
66
|
const optionWasSelected = isOpen && menuOptionsRef.current?.contains(e.target as HTMLElement);
|
|
71
67
|
|
|
72
68
|
if (buttonWasClicked) {
|
|
73
|
-
setOpen(
|
|
69
|
+
isOpen ? closeMenu() : setOpen(true);
|
|
74
70
|
}
|
|
75
71
|
|
|
76
72
|
if (optionWasSelected) {
|
|
77
|
-
|
|
73
|
+
if ((e.target as HTMLElement).closest("[data-close-menu]")) {
|
|
74
|
+
closeMenu();
|
|
75
|
+
} else {
|
|
76
|
+
closeOnSelect ? (isCheckGroup ? closeWhenChecked(e) : closeMenu()) : setOpen(true);
|
|
77
|
+
}
|
|
78
78
|
}
|
|
79
|
-
|
|
80
|
-
closeWhenApply(e);
|
|
81
79
|
};
|
|
82
80
|
|
|
83
81
|
const handleMouseEnter = (e: React.MouseEvent<HTMLDivElement>) =>
|
|
84
82
|
reactiveToHover && !isOpen ? handleClick(e) : null;
|
|
85
83
|
|
|
86
|
-
const handleMouseLeave = () => reactiveToHover && isOpen &&
|
|
84
|
+
const handleMouseLeave = () => reactiveToHover && isOpen && closeMenu();
|
|
87
85
|
|
|
88
86
|
useHandleClickOutside(isOpen, handleClickOutside);
|
|
89
87
|
|
|
@@ -105,6 +103,9 @@ const FloatingMenu = (props: IFloatingProps): JSX.Element => {
|
|
|
105
103
|
ref={menuOptionsRef}
|
|
106
104
|
position={position}
|
|
107
105
|
offset={offset}
|
|
106
|
+
openUpward={menuPosition.openUpward}
|
|
107
|
+
leftwardOffset={menuPosition.leftwardOffset}
|
|
108
|
+
isVisible={menuPosition.isVisible}
|
|
108
109
|
data-testid="floating-menu-wrapper"
|
|
109
110
|
>
|
|
110
111
|
<S.Menu hasMargin={hasMargin} width={fixedWidth}>
|
|
@@ -117,7 +118,7 @@ const FloatingMenu = (props: IFloatingProps): JSX.Element => {
|
|
|
117
118
|
};
|
|
118
119
|
|
|
119
120
|
export interface IFloatingProps {
|
|
120
|
-
children:
|
|
121
|
+
children: ReactNode;
|
|
121
122
|
Button: (props?: any) => React.JSX.Element;
|
|
122
123
|
isInAppBar?: boolean;
|
|
123
124
|
position?: string;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import styled from "styled-components";
|
|
2
2
|
|
|
3
|
-
const Wrapper = styled.div
|
|
3
|
+
const Wrapper = styled.div`
|
|
4
|
+
position: relative;
|
|
5
|
+
`;
|
|
4
6
|
|
|
5
7
|
const ButtonWrapper = styled.div`
|
|
6
8
|
display: flex;
|
|
@@ -8,12 +10,28 @@ const ButtonWrapper = styled.div`
|
|
|
8
10
|
cursor: pointer;
|
|
9
11
|
`;
|
|
10
12
|
|
|
11
|
-
const MenuWrapper = styled.div<{
|
|
13
|
+
const MenuWrapper = styled.div<{
|
|
14
|
+
isInAppBar?: boolean;
|
|
15
|
+
position: string;
|
|
16
|
+
offset?: number;
|
|
17
|
+
openUpward?: boolean;
|
|
18
|
+
leftwardOffset?: number;
|
|
19
|
+
isVisible?: boolean;
|
|
20
|
+
}>`
|
|
21
|
+
&& {
|
|
22
|
+
max-width: initial;
|
|
23
|
+
}
|
|
12
24
|
position: absolute;
|
|
13
25
|
z-index: 7;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
26
|
+
visibility: ${(p) => (p.isVisible ? "visible" : "hidden")};
|
|
27
|
+
${(p) =>
|
|
28
|
+
p.leftwardOffset
|
|
29
|
+
? `right: ${p.leftwardOffset}px; left: auto;`
|
|
30
|
+
: `${p.position}: ${p.offset ? `${p.offset}px` : "0"};`}
|
|
31
|
+
${(p) =>
|
|
32
|
+
p.openUpward
|
|
33
|
+
? `bottom: 100%; padding-bottom: ${p.theme.spacing.xs};`
|
|
34
|
+
: `top: 100%; padding-top: ${p.isInAppBar ? p.theme.spacing.s : p.theme.spacing.xs};`}
|
|
17
35
|
`;
|
|
18
36
|
|
|
19
37
|
const Menu = styled.div<{ hasMargin: boolean; width?: number }>`
|
|
@@ -8,9 +8,9 @@ function SvgSmallCircle(props) {
|
|
|
8
8
|
r="40"
|
|
9
9
|
fill="none"
|
|
10
10
|
stroke="#5057FF"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
strokeWidth="10"
|
|
12
|
+
strokeLinecap="round"
|
|
13
|
+
strokeDasharray="200 300"
|
|
14
14
|
>
|
|
15
15
|
<animateTransform
|
|
16
16
|
attributeName="transform"
|
|
@@ -144,6 +144,7 @@ const Header = styled.section<{ inversed?: boolean }>`
|
|
|
144
144
|
padding-right: ${(p) => p.theme.spacing.s};
|
|
145
145
|
margin-bottom: 1px;
|
|
146
146
|
border-bottom: ${(p) => `1px solid ${p.theme.color.uiLine}`};
|
|
147
|
+
min-width: 1280px;
|
|
147
148
|
|
|
148
149
|
button:first-child {
|
|
149
150
|
margin-left: ${(p) => p.theme.spacing.m};
|
|
@@ -138,7 +138,7 @@ const SideModal = (props: ISideModalProps): JSX.Element | null => {
|
|
|
138
138
|
return getCategoryItem(category, i);
|
|
139
139
|
});
|
|
140
140
|
|
|
141
|
-
const filteredOptions = options.options?.map((option) => {
|
|
141
|
+
const filteredOptions = options.options?.map((option, i) => {
|
|
142
142
|
const optionComponent = typeof option === "string" ? option : option.component;
|
|
143
143
|
const optionKey = typeof option === "string" ? option : (option.id ?? option.editorID ?? optionComponent);
|
|
144
144
|
const displayName = getDisplayName(optionComponent);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
2
|
|
|
3
3
|
import { CheckGroup, FloatingMenu, Icon, ListTitle } from "@ax/components";
|
|
4
4
|
import { areEquals, isReqOk, trimText } from "@ax/helpers";
|
|
5
5
|
import { checkgroups } from "@ax/api";
|
|
6
|
-
import { IFilterValue, IQueryValue } from "@ax/types";
|
|
6
|
+
import type { IFilterValue, IQueryValue } from "@ax/types";
|
|
7
7
|
|
|
8
8
|
import * as S from "./style";
|
|
9
9
|
|
|
@@ -52,24 +52,23 @@ const CategoryFilter = (props: ICategoryFilterProps): JSX.Element => {
|
|
|
52
52
|
console.log(e);
|
|
53
53
|
}
|
|
54
54
|
setIsLoading(false);
|
|
55
|
-
return
|
|
55
|
+
return [];
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
// biome-ignore lint/correctness/useExhaustiveDependencies: TODO: fix this
|
|
59
59
|
useEffect(() => {
|
|
60
60
|
getSelectCategories().then((items) => {
|
|
61
|
-
items
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
});
|
|
61
|
+
items?.forEach((item: { value: string; title: string }) => {
|
|
62
|
+
if (hideValues.includes(item.value)) {
|
|
63
|
+
setHideFilter(true);
|
|
64
|
+
}
|
|
65
|
+
const newFilter = {
|
|
66
|
+
name: item.value,
|
|
67
|
+
value: item.value,
|
|
68
|
+
title: item.title,
|
|
69
|
+
};
|
|
70
|
+
filters.push(newFilter);
|
|
71
|
+
});
|
|
73
72
|
setOptions(filters);
|
|
74
73
|
});
|
|
75
74
|
}, [siteID]);
|
|
@@ -11,6 +11,7 @@ import history from "../../routes/history";
|
|
|
11
11
|
import {
|
|
12
12
|
IS_LOGGING_IN,
|
|
13
13
|
LOGOUT,
|
|
14
|
+
RESET_LOADING,
|
|
14
15
|
SET_ERROR,
|
|
15
16
|
SET_GLOBAL_LANGUAGES,
|
|
16
17
|
SET_GLOBAL_SETTINGS,
|
|
@@ -25,6 +26,7 @@ import {
|
|
|
25
26
|
import type {
|
|
26
27
|
IIsLoggingInAction,
|
|
27
28
|
ILogoutAction,
|
|
29
|
+
IResetLoading,
|
|
28
30
|
ISetErrorAction,
|
|
29
31
|
ISetGlobalLanguages,
|
|
30
32
|
ISetGlobalSettings,
|
|
@@ -50,8 +52,12 @@ function setHasAnimation(hasAnimation: boolean): ISetHasAnimation {
|
|
|
50
52
|
return { type: SET_HAS_ANIMATION, payload: { hasAnimation } };
|
|
51
53
|
}
|
|
52
54
|
|
|
55
|
+
function resetLoading(): IResetLoading {
|
|
56
|
+
return { type: RESET_LOADING };
|
|
57
|
+
}
|
|
58
|
+
|
|
53
59
|
const resetStateValues = (dispatch: Dispatch) => {
|
|
54
|
-
dispatch(
|
|
60
|
+
dispatch(resetLoading());
|
|
55
61
|
dispatch(setIsSaving(false));
|
|
56
62
|
};
|
|
57
63
|
|
|
@@ -12,10 +12,12 @@ const SET_GLOBAL_SETTINGS = `${NAME}/SET_GLOBAL_SETTINGS`;
|
|
|
12
12
|
const SET_USER = `${NAME}/SET_USER`;
|
|
13
13
|
const SET_SESSION_STARTED_AT = `${NAME}/SET_SESSION_STARTED_AT`;
|
|
14
14
|
const SET_HAS_ANIMATION = `${NAME}/SET_HAS_ANIMATION`;
|
|
15
|
+
const RESET_LOADING = `${NAME}/RESET_LOADING`;
|
|
15
16
|
|
|
16
17
|
export {
|
|
17
18
|
IS_LOGGING_IN,
|
|
18
19
|
LOGOUT,
|
|
20
|
+
RESET_LOADING,
|
|
19
21
|
SET_ERROR,
|
|
20
22
|
SET_GLOBAL_LANGUAGES,
|
|
21
23
|
SET_GLOBAL_SETTINGS,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
IS_LOGGING_IN,
|
|
3
3
|
LOGOUT,
|
|
4
|
+
RESET_LOADING,
|
|
4
5
|
SET_ERROR,
|
|
5
6
|
SET_GLOBAL_LANGUAGES,
|
|
6
7
|
SET_GLOBAL_SETTINGS,
|
|
@@ -76,6 +77,10 @@ export interface ISetHasAnimation {
|
|
|
76
77
|
payload: { hasAnimation: boolean };
|
|
77
78
|
}
|
|
78
79
|
|
|
80
|
+
export interface IResetLoading {
|
|
81
|
+
type: typeof RESET_LOADING;
|
|
82
|
+
}
|
|
83
|
+
|
|
79
84
|
export type AppActionsCreators = ISetIsLoading & ISetIsSaving;
|
|
80
85
|
|
|
81
86
|
export type AuthActionsCreators = ISetTokenAction &
|
|
@@ -5,6 +5,7 @@ import { REHYDRATE } from "redux-persist/lib/constants";
|
|
|
5
5
|
import {
|
|
6
6
|
IS_LOGGING_IN,
|
|
7
7
|
LOGOUT,
|
|
8
|
+
RESET_LOADING,
|
|
8
9
|
SET_ERROR,
|
|
9
10
|
SET_GLOBAL_LANGUAGES,
|
|
10
11
|
SET_GLOBAL_SETTINGS,
|
|
@@ -20,6 +21,7 @@ import {
|
|
|
20
21
|
export interface IAppState {
|
|
21
22
|
isRehydrated: boolean;
|
|
22
23
|
isLoading: boolean;
|
|
24
|
+
loadingCount: number;
|
|
23
25
|
isSaving: boolean;
|
|
24
26
|
error: IError;
|
|
25
27
|
user: IUser;
|
|
@@ -65,6 +67,7 @@ export interface IGlobalSettings {
|
|
|
65
67
|
export const initialState = {
|
|
66
68
|
isRehydrated: true,
|
|
67
69
|
isLoading: true,
|
|
70
|
+
loadingCount: 0,
|
|
68
71
|
isSaving: false,
|
|
69
72
|
error: {
|
|
70
73
|
code: undefined,
|
|
@@ -103,9 +106,15 @@ export const initialState = {
|
|
|
103
106
|
export function reducer(state = initialState, action: any): IAppState {
|
|
104
107
|
switch (action.type) {
|
|
105
108
|
case REHYDRATE:
|
|
106
|
-
return { ...state, isRehydrated: true, schemasLoading: false, schemasError: null };
|
|
109
|
+
return { ...state, isRehydrated: true, loadingCount: 0, schemasLoading: false, schemasError: null };
|
|
110
|
+
case SET_IS_LOADING: {
|
|
111
|
+
const delta = action.payload.isLoading ? 1 : -1;
|
|
112
|
+
const loadingCount = Math.max(0, state.loadingCount + delta);
|
|
113
|
+
return { ...state, loadingCount, isLoading: loadingCount > 0 };
|
|
114
|
+
}
|
|
115
|
+
case RESET_LOADING:
|
|
116
|
+
return { ...state, loadingCount: 0, isLoading: true };
|
|
107
117
|
case SET_TOKEN:
|
|
108
|
-
case SET_IS_LOADING:
|
|
109
118
|
case SET_IS_SAVING:
|
|
110
119
|
case IS_LOGGING_IN:
|
|
111
120
|
case LOGOUT:
|
|
@@ -190,10 +190,10 @@ function getForm(formID: number | null): (dispatch: Dispatch, getState: () => IR
|
|
|
190
190
|
const formData: Partial<FormContent> = response.data;
|
|
191
191
|
if (isNewTranslation) {
|
|
192
192
|
delete formData.id;
|
|
193
|
-
formData
|
|
194
|
-
formData
|
|
195
|
-
formData
|
|
196
|
-
formData
|
|
193
|
+
formData.state = "inactive";
|
|
194
|
+
formData.canBeTranslated = true;
|
|
195
|
+
formData.originalLanguage = formData.language;
|
|
196
|
+
formData.formInUse = null;
|
|
197
197
|
}
|
|
198
198
|
generateFormContent(formData)(dispatch, getState);
|
|
199
199
|
dispatch(setCurrentFormID(response.data.id));
|
|
@@ -821,8 +821,6 @@ function orderFormCategory(
|
|
|
821
821
|
): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
|
|
822
822
|
return async (dispatch, getState) => {
|
|
823
823
|
try {
|
|
824
|
-
dispatch(setIsLoading(true));
|
|
825
|
-
|
|
826
824
|
const responseActions = {
|
|
827
825
|
handleSuccess: () => getFormCategories(data.categoryType)(dispatch, getState),
|
|
828
826
|
handleError: (response: any) => appActions.handleError(response)(dispatch),
|
|
@@ -830,7 +828,7 @@ function orderFormCategory(
|
|
|
830
828
|
|
|
831
829
|
const callback = async () => forms.orderFormCategory(data);
|
|
832
830
|
|
|
833
|
-
return await handleRequest(callback, responseActions, [])(dispatch);
|
|
831
|
+
return await handleRequest(callback, responseActions, [setIsLoading])(dispatch);
|
|
834
832
|
} catch (e) {
|
|
835
833
|
console.log(e);
|
|
836
834
|
return false;
|
|
@@ -188,8 +188,6 @@ function orderIntegration(
|
|
|
188
188
|
sites: { currentSiteInfo },
|
|
189
189
|
} = getState();
|
|
190
190
|
|
|
191
|
-
dispatch(appActions.setIsLoading(true));
|
|
192
|
-
|
|
193
191
|
const callback = async () => integrations.orderIntegration(id, newOrder);
|
|
194
192
|
const responseActions = {
|
|
195
193
|
handleSuccess: () => {
|
|
@@ -198,7 +196,7 @@ function orderIntegration(
|
|
|
198
196
|
},
|
|
199
197
|
handleError: (response: any) => appActions.handleError(response)(dispatch),
|
|
200
198
|
};
|
|
201
|
-
return await handleRequest(callback, responseActions, [])(dispatch);
|
|
199
|
+
return await handleRequest(callback, responseActions, [appActions.setIsLoading])(dispatch);
|
|
202
200
|
} catch (e) {
|
|
203
201
|
console.log(e);
|
|
204
202
|
return false;
|
|
@@ -83,7 +83,7 @@ function getMenus(hasLoading = true): (dispatch: Dispatch, getState: () => IRoot
|
|
|
83
83
|
return async (dispatch, getState) => {
|
|
84
84
|
try {
|
|
85
85
|
const { currentSiteInfo, type } = getStateValues(getState);
|
|
86
|
-
const id = currentSiteInfo
|
|
86
|
+
const id = currentSiteInfo?.id;
|
|
87
87
|
|
|
88
88
|
const responseActions = {
|
|
89
89
|
handleSuccess: (menus: IMenu[]) => {
|
|
@@ -114,9 +114,9 @@ function getCurrentMenu(menuType: string): (dispatch: Dispatch, getState: () =>
|
|
|
114
114
|
const { savedMenus } = getStateValues(getState);
|
|
115
115
|
setEditorMenuContent(savedMenus || [], menuType, dispatch);
|
|
116
116
|
updateTotalItems(dispatch, getState);
|
|
117
|
+
dispatch(setIsLoading(false));
|
|
117
118
|
} catch (e) {
|
|
118
119
|
console.log("Error", e);
|
|
119
|
-
dispatch(setIsLoading(false));
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
122
|
}
|
|
@@ -392,8 +392,8 @@ function getPage(
|
|
|
392
392
|
await getTemplateConfig(template)(dispatch, getState);
|
|
393
393
|
generateNewPage(dispatch, getState, baseSchema);
|
|
394
394
|
}
|
|
395
|
-
} catch (e) {
|
|
396
395
|
dispatch(setIsLoading(false));
|
|
396
|
+
} catch (e) {
|
|
397
397
|
console.log(e); // TODO: capturar error bien
|
|
398
398
|
}
|
|
399
399
|
};
|
|
@@ -410,8 +410,8 @@ function getTemplatePage(template: string): (dispatch: Dispatch, getState: () =>
|
|
|
410
410
|
await getTemplateConfig(template)(dispatch, getState);
|
|
411
411
|
await getDefaults()(dispatch, getState);
|
|
412
412
|
generateNewPage(dispatch, getState, baseSchema);
|
|
413
|
-
} catch (e) {
|
|
414
413
|
dispatch(setIsLoading(false));
|
|
414
|
+
} catch (e) {
|
|
415
415
|
console.log(e); // TODO: capturar error bien
|
|
416
416
|
}
|
|
417
417
|
};
|
|
@@ -1456,6 +1456,7 @@ function getGlobalFromLocalPage(): (dispatch: Dispatch, getState: any) => Promis
|
|
|
1456
1456
|
dispatch(setCurrentPageID(originalGlobalPage));
|
|
1457
1457
|
structuredDataActions.setSelectedStructuredData(structuredData, "global")(dispatch, getState);
|
|
1458
1458
|
usersActions.getUserCurrentPermissions()(dispatch, getState);
|
|
1459
|
+
dispatch(setIsLoading(false));
|
|
1459
1460
|
} catch (e) {
|
|
1460
1461
|
console.log(e);
|
|
1461
1462
|
}
|