@griddo/ax 1.75.257 → 10.1.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.
- package/package.json +2 -2
- package/src/GlobalStore.tsx +3 -0
- package/src/__tests__/components/ConfigPanel/GlobalPageForm/GlobalPageForm.test.tsx +10 -1
- package/src/__tests__/components/Fields/IntegrationsField/IntegrationsField.test.tsx +391 -0
- package/src/__tests__/modules/Settings/Integrations/Integrations.test.tsx +167 -0
- package/src/api/index.tsx +3 -1
- package/src/api/integrations.tsx +153 -0
- package/src/api/sites.tsx +4 -2
- package/src/components/ActionMenu/index.tsx +3 -1
- package/src/components/ActionMenu/style.tsx +1 -0
- package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/Field/index.tsx +4 -1
- package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/index.tsx +3 -0
- package/src/components/ConfigPanel/GlobalPageForm/index.tsx +11 -2
- package/src/components/FieldContainer/index.tsx +2 -1
- package/src/components/Fields/IntegrationsField/IntegrationItem/CustomPanel/index.tsx +101 -0
- package/src/components/Fields/IntegrationsField/IntegrationItem/CustomPanel/style.tsx +23 -0
- package/src/components/Fields/IntegrationsField/IntegrationItem/VariablesPanel/helpers.ts +31 -0
- package/src/components/Fields/IntegrationsField/IntegrationItem/VariablesPanel/index.tsx +120 -0
- package/src/components/Fields/IntegrationsField/IntegrationItem/VariablesPanel/style.tsx +23 -0
- package/src/components/Fields/IntegrationsField/IntegrationItem/atoms.tsx +27 -0
- package/src/components/Fields/IntegrationsField/IntegrationItem/index.tsx +132 -0
- package/src/components/Fields/IntegrationsField/IntegrationItem/style.tsx +63 -0
- package/src/components/Fields/IntegrationsField/PasteIntegrationButton/index.tsx +30 -0
- package/src/components/Fields/IntegrationsField/SideModal/SideModalOption/index.tsx +52 -0
- package/src/components/Fields/IntegrationsField/SideModal/SideModalOption/style.tsx +54 -0
- package/src/components/Fields/IntegrationsField/SideModal/index.tsx +57 -0
- package/src/components/Fields/IntegrationsField/SideModal/style.tsx +50 -0
- package/src/components/Fields/IntegrationsField/index.tsx +145 -0
- package/src/components/Fields/IntegrationsField/style.tsx +29 -0
- package/src/components/Fields/ReferenceField/AutoPanel/index.tsx +11 -2
- package/src/components/Fields/TextArea/index.tsx +1 -1
- package/src/components/Fields/ToggleField/index.tsx +5 -3
- package/src/components/Fields/UrlField/index.tsx +8 -8
- package/src/components/Fields/index.tsx +2 -0
- package/src/components/Icon/components/Deactivate.js +14 -0
- package/src/components/Icon/components/Lock.js +15 -0
- package/src/components/Icon/svgs/Deactivate.svg +8 -0
- package/src/components/Icon/svgs/Lock.svg +6 -0
- package/src/components/PageFinder/SelectionListItem/index.tsx +46 -0
- package/src/components/PageFinder/SelectionListItem/style.tsx +46 -0
- package/src/components/{Fields/UrlField/PageFinder → PageFinder}/index.tsx +99 -21
- package/src/components/{Fields/UrlField/PageFinder → PageFinder}/style.tsx +14 -1
- package/src/components/TableFilters/CheckGroupFilter/index.tsx +83 -0
- package/src/components/TableFilters/CheckGroupFilter/style.tsx +40 -0
- package/src/components/TableFilters/StateFilter/index.tsx +66 -0
- package/src/components/TableFilters/StateFilter/style.tsx +30 -0
- package/src/components/TableFilters/index.tsx +4 -0
- package/src/components/index.tsx +9 -1
- package/src/containers/Integrations/actions.tsx +190 -0
- package/src/containers/Integrations/constants.tsx +14 -0
- package/src/containers/Integrations/index.tsx +4 -0
- package/src/containers/Integrations/interfaces.tsx +24 -0
- package/src/containers/Integrations/reducer.tsx +31 -0
- package/src/containers/PageEditor/actions.tsx +11 -1
- package/src/containers/PageEditor/utils.tsx +30 -2
- package/src/hooks/content.tsx +46 -2
- package/src/hooks/index.tsx +2 -1
- package/src/hooks/modals.tsx +4 -2
- package/src/modules/App/Routing/NavMenu/NavItem/style.tsx +13 -12
- package/src/modules/Content/index.tsx +5 -0
- package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/ConfigPanel/IntegrationsField/index.tsx +47 -0
- package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/ConfigPanel/IntegrationsField/style.tsx +7 -0
- package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/ConfigPanel/{Field → NavigationField}/index.tsx +2 -2
- package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/ConfigPanel/index.tsx +7 -7
- package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/index.tsx +1 -1
- package/src/modules/Settings/Integrations/BulkHeader/TableHeader/index.tsx +81 -0
- package/src/modules/Settings/Integrations/BulkHeader/TableHeader/style.tsx +35 -0
- package/src/modules/Settings/Integrations/BulkHeader/index.tsx +69 -0
- package/src/modules/Settings/Integrations/IntegrationForm/VariableItem/index.tsx +95 -0
- package/src/modules/Settings/Integrations/IntegrationForm/VariableItem/style.tsx +62 -0
- package/src/modules/Settings/Integrations/IntegrationForm/VariablePanel/index.tsx +138 -0
- package/src/modules/Settings/Integrations/IntegrationForm/VariablePanel/style.tsx +28 -0
- package/src/modules/Settings/Integrations/IntegrationForm/index.tsx +319 -0
- package/src/modules/Settings/Integrations/IntegrationForm/style.tsx +77 -0
- package/src/modules/Settings/Integrations/IntegrationItem/CopyModal/index.tsx +44 -0
- package/src/modules/Settings/Integrations/IntegrationItem/CopyModal/style.tsx +13 -0
- package/src/modules/Settings/Integrations/IntegrationItem/index.tsx +197 -0
- package/src/modules/Settings/Integrations/IntegrationItem/style.tsx +81 -0
- package/src/modules/Settings/Integrations/atoms.tsx +49 -0
- package/src/modules/Settings/Integrations/hooks.tsx +72 -0
- package/src/modules/Settings/Integrations/index.tsx +299 -0
- package/src/modules/Settings/Integrations/style.tsx +48 -0
- package/src/modules/Settings/Integrations/utils.tsx +39 -0
- package/src/routes/site.tsx +19 -0
- package/src/schemas/pages/Page.tsx +5 -0
- package/src/types/index.tsx +35 -0
- package/tsconfig.paths.json +2 -0
- package/src/components/Fields/UrlField/PageFinder/SelectionListItem/index.tsx +0 -34
- package/src/components/Fields/UrlField/PageFinder/SelectionListItem/style.tsx +0 -35
- /package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/ConfigPanel/{Field → NavigationField}/style.tsx +0 -0
package/src/components/index.tsx
CHANGED
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
VisualOption,
|
|
33
33
|
VisualUniqueSelection,
|
|
34
34
|
Wysiwyg,
|
|
35
|
+
IntegrationsField,
|
|
35
36
|
} from "./Fields";
|
|
36
37
|
import { ListTitle, ListItem } from "./Lists";
|
|
37
38
|
import {
|
|
@@ -44,7 +45,9 @@ import {
|
|
|
44
45
|
TranslationsFilter,
|
|
45
46
|
TypeFilter,
|
|
46
47
|
DateFilter,
|
|
47
|
-
|
|
48
|
+
CheckGroupFilter,
|
|
49
|
+
StateFilter,
|
|
50
|
+
LastAccessFilter,
|
|
48
51
|
} from "./TableFilters";
|
|
49
52
|
|
|
50
53
|
import ActionMenu from "./ActionMenu";
|
|
@@ -81,6 +84,7 @@ import MenuItem from "./MenuItem";
|
|
|
81
84
|
import Modal from "./Modal";
|
|
82
85
|
import Nav from "./Nav";
|
|
83
86
|
import Notification from "./Notification";
|
|
87
|
+
import PageFinder from "./PageFinder";
|
|
84
88
|
import Pagination from "./Pagination";
|
|
85
89
|
import ProgressBar from "./ProgressBar";
|
|
86
90
|
import ReorderArrows from "./ReorderArrows";
|
|
@@ -130,10 +134,12 @@ export {
|
|
|
130
134
|
VisualOption,
|
|
131
135
|
VisualUniqueSelection,
|
|
132
136
|
Wysiwyg,
|
|
137
|
+
IntegrationsField,
|
|
133
138
|
//Lists
|
|
134
139
|
ListTitle,
|
|
135
140
|
ListItem,
|
|
136
141
|
//Filters
|
|
142
|
+
CheckGroupFilter,
|
|
137
143
|
DateFilter,
|
|
138
144
|
CategoryFilter,
|
|
139
145
|
CustomizeFilters,
|
|
@@ -143,6 +149,7 @@ export {
|
|
|
143
149
|
StatusFilter,
|
|
144
150
|
TranslationsFilter,
|
|
145
151
|
TypeFilter,
|
|
152
|
+
StateFilter,
|
|
146
153
|
LastAccessFilter,
|
|
147
154
|
// Components
|
|
148
155
|
ActionMenu,
|
|
@@ -179,6 +186,7 @@ export {
|
|
|
179
186
|
Modal,
|
|
180
187
|
Nav,
|
|
181
188
|
Notification,
|
|
189
|
+
PageFinder,
|
|
182
190
|
Pagination,
|
|
183
191
|
ProgressBar,
|
|
184
192
|
ReorderArrows,
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { integrations } from "@ax/api";
|
|
2
|
+
import { appActions } from "@ax/containers/App";
|
|
3
|
+
import { handleRequest } from "@ax/helpers";
|
|
4
|
+
import { IIntegration } from "@ax/types";
|
|
5
|
+
import { Dispatch } from "redux";
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
DEFAULT_PARAMS,
|
|
9
|
+
SET_COPY_INTEGRATION,
|
|
10
|
+
SET_CURRENT_INTEGRATION,
|
|
11
|
+
SET_INTEGRATIONS,
|
|
12
|
+
SET_TOTAL_ITEMS,
|
|
13
|
+
} from "./constants";
|
|
14
|
+
import { ISetCopyIntegration, ISetCurrentIntegration, ISetIntegrations, ISetTotalItems } from "./interfaces";
|
|
15
|
+
|
|
16
|
+
function setIntegrations(integrations: IIntegration[]): ISetIntegrations {
|
|
17
|
+
return { type: SET_INTEGRATIONS, payload: { integrations } };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function setTotalItems(totalItems: number): ISetTotalItems {
|
|
21
|
+
return { type: SET_TOTAL_ITEMS, payload: { totalItems } };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function setCurrentIntegration(currentIntegration: IIntegration | null): ISetCurrentIntegration {
|
|
25
|
+
return { type: SET_CURRENT_INTEGRATION, payload: { currentIntegration } };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function setCopyIntegration(
|
|
29
|
+
integrationCopy: { date: Date; integration: Partial<IIntegration> } | null
|
|
30
|
+
): ISetCopyIntegration {
|
|
31
|
+
return { type: SET_COPY_INTEGRATION, payload: { integrationCopy } };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function getIntegrations(site: number, params?: any, isPage?: boolean): (dispatch: Dispatch) => Promise<void> {
|
|
35
|
+
return async (dispatch) => {
|
|
36
|
+
try {
|
|
37
|
+
const callback = async () => integrations.getIntegrations(site, params);
|
|
38
|
+
const responseActions = {
|
|
39
|
+
handleSuccess: (response: any) => {
|
|
40
|
+
const { items, totalItems } = response;
|
|
41
|
+
dispatch(setIntegrations(items));
|
|
42
|
+
dispatch(setTotalItems(totalItems));
|
|
43
|
+
},
|
|
44
|
+
handleError: (response: any) => appActions.handleError(response)(dispatch),
|
|
45
|
+
};
|
|
46
|
+
await handleRequest(callback, responseActions, isPage ? [] : [appActions.setIsLoading])(dispatch);
|
|
47
|
+
} catch (e) {
|
|
48
|
+
console.log(e);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function resetIntegrations(): (dispatch: Dispatch) => void {
|
|
54
|
+
return (dispatch) => {
|
|
55
|
+
dispatch(setIntegrations([]));
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function deleteIntegration(
|
|
60
|
+
integrationId: number | number[],
|
|
61
|
+
currentParams?: any
|
|
62
|
+
): (dispatch: any, getState: any) => Promise<boolean> {
|
|
63
|
+
return async (dispatch, getState) => {
|
|
64
|
+
try {
|
|
65
|
+
const {
|
|
66
|
+
sites: { currentSiteInfo },
|
|
67
|
+
} = getState();
|
|
68
|
+
|
|
69
|
+
const callback = async () =>
|
|
70
|
+
Array.isArray(integrationId)
|
|
71
|
+
? integrations.deleteIntegrationsBulk(integrationId)
|
|
72
|
+
: integrations.deleteIntegration(integrationId);
|
|
73
|
+
|
|
74
|
+
const responseActions = {
|
|
75
|
+
handleSuccess: () => {
|
|
76
|
+
const params = { ...DEFAULT_PARAMS, ...currentParams };
|
|
77
|
+
dispatch(getIntegrations(currentSiteInfo.id, params));
|
|
78
|
+
},
|
|
79
|
+
handleError: (response: any) => appActions.handleError(response)(dispatch),
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
return await handleRequest(callback, responseActions, [])(dispatch);
|
|
83
|
+
} catch (e) {
|
|
84
|
+
console.log(e);
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function changeIntegrationState(
|
|
91
|
+
integrationId: number | number[],
|
|
92
|
+
active: boolean,
|
|
93
|
+
currentParams?: any
|
|
94
|
+
): (dispatch: any, getState: any) => Promise<boolean> {
|
|
95
|
+
return async (dispatch, getState) => {
|
|
96
|
+
try {
|
|
97
|
+
const {
|
|
98
|
+
sites: { currentSiteInfo },
|
|
99
|
+
} = getState();
|
|
100
|
+
|
|
101
|
+
const state = active ? "enable" : "disable";
|
|
102
|
+
const callback = async () =>
|
|
103
|
+
Array.isArray(integrationId)
|
|
104
|
+
? integrations.changeStateBulk(integrationId, state)
|
|
105
|
+
: integrations.changeState(integrationId, state);
|
|
106
|
+
|
|
107
|
+
const responseActions = {
|
|
108
|
+
handleSuccess: () => {
|
|
109
|
+
const params = { ...DEFAULT_PARAMS, ...currentParams };
|
|
110
|
+
dispatch(getIntegrations(currentSiteInfo.id, params));
|
|
111
|
+
},
|
|
112
|
+
handleError: (response: any) => appActions.handleError(response)(dispatch),
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
return await handleRequest(callback, responseActions, [])(dispatch);
|
|
116
|
+
} catch (e) {
|
|
117
|
+
console.log(e);
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function getIntegration(id: number, siteID: number): (dispatch: Dispatch) => Promise<void> {
|
|
124
|
+
return async (dispatch) => {
|
|
125
|
+
try {
|
|
126
|
+
const callback = async () => integrations.getIntegration(id, siteID);
|
|
127
|
+
const responseActions = {
|
|
128
|
+
handleSuccess: (response: IIntegration) => setCurrentIntegration(response),
|
|
129
|
+
handleError: (response: any) => appActions.handleError(response)(dispatch),
|
|
130
|
+
};
|
|
131
|
+
await handleRequest(callback, responseActions, [appActions.setIsLoading])(dispatch);
|
|
132
|
+
} catch (e) {
|
|
133
|
+
console.log(e);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function createIntegration(data: IIntegration, siteID: number): (dispatch: Dispatch) => Promise<boolean> {
|
|
139
|
+
return async (dispatch) => {
|
|
140
|
+
try {
|
|
141
|
+
const callback = async () => integrations.createIntegration(data, siteID);
|
|
142
|
+
const responseActions = {
|
|
143
|
+
handleSuccess: (response: IIntegration) => dispatch(setCurrentIntegration(response)),
|
|
144
|
+
handleError: (response: any) => appActions.handleError(response)(dispatch),
|
|
145
|
+
};
|
|
146
|
+
return await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
|
|
147
|
+
} catch (e) {
|
|
148
|
+
console.log(e);
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function updateIntegration(data: IIntegration, siteID: number): (dispatch: Dispatch) => Promise<boolean> {
|
|
155
|
+
return async (dispatch) => {
|
|
156
|
+
try {
|
|
157
|
+
const callback = async () => integrations.updateIntegration(data, siteID);
|
|
158
|
+
const responseActions = {
|
|
159
|
+
handleSuccess: (response: IIntegration) => dispatch(setCurrentIntegration(response)),
|
|
160
|
+
handleError: (response: any) => appActions.handleError(response)(dispatch),
|
|
161
|
+
};
|
|
162
|
+
return await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
|
|
163
|
+
} catch (e) {
|
|
164
|
+
console.log(e);
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function copyIntegration(integration: Partial<IIntegration>): (dispatch: Dispatch) => void {
|
|
171
|
+
return (dispatch) => {
|
|
172
|
+
const payload = {
|
|
173
|
+
date: new Date(),
|
|
174
|
+
integration,
|
|
175
|
+
};
|
|
176
|
+
dispatch(setCopyIntegration(payload));
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export {
|
|
181
|
+
getIntegrations,
|
|
182
|
+
resetIntegrations,
|
|
183
|
+
deleteIntegration,
|
|
184
|
+
changeIntegrationState,
|
|
185
|
+
getIntegration,
|
|
186
|
+
createIntegration,
|
|
187
|
+
updateIntegration,
|
|
188
|
+
setCurrentIntegration,
|
|
189
|
+
copyIntegration,
|
|
190
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const NAME = "integrations";
|
|
2
|
+
|
|
3
|
+
const SET_INTEGRATIONS = `${NAME}/SET_INTEGRATIONS`;
|
|
4
|
+
const SET_TOTAL_ITEMS = `${NAME}/SET_TOTAL_ITEMS`;
|
|
5
|
+
const SET_CURRENT_INTEGRATION = `${NAME}/SET_CURRENT_INTEGRATION`;
|
|
6
|
+
const SET_COPY_INTEGRATION = `${NAME}/SET_COPY_INTEGRATION`;
|
|
7
|
+
|
|
8
|
+
const DEFAULT_PARAMS = {
|
|
9
|
+
page: 1,
|
|
10
|
+
itemsPerPage: 50,
|
|
11
|
+
pagination: true,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { NAME, SET_INTEGRATIONS, SET_TOTAL_ITEMS, DEFAULT_PARAMS, SET_CURRENT_INTEGRATION, SET_COPY_INTEGRATION };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IIntegration } from "@ax/types";
|
|
2
|
+
import { SET_CURRENT_INTEGRATION, SET_INTEGRATIONS, SET_TOTAL_ITEMS, SET_COPY_INTEGRATION } from "./constants";
|
|
3
|
+
|
|
4
|
+
export interface ISetIntegrations {
|
|
5
|
+
type: typeof SET_INTEGRATIONS;
|
|
6
|
+
payload: { integrations: IIntegration[] };
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ISetTotalItems {
|
|
10
|
+
type: typeof SET_TOTAL_ITEMS;
|
|
11
|
+
payload: { totalItems: number };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ISetCurrentIntegration {
|
|
15
|
+
type: typeof SET_CURRENT_INTEGRATION;
|
|
16
|
+
payload: { currentIntegration: IIntegration | null };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ISetCopyIntegration {
|
|
20
|
+
type: typeof SET_COPY_INTEGRATION;
|
|
21
|
+
payload: { integrationCopy: { date: Date; integration: Partial<IIntegration> } | null };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type IntegrationsActionsCreators = ISetIntegrations;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { IIntegration } from "@ax/types";
|
|
2
|
+
import { SET_CURRENT_INTEGRATION, SET_INTEGRATIONS, SET_TOTAL_ITEMS, SET_COPY_INTEGRATION } from "./constants";
|
|
3
|
+
import { IntegrationsActionsCreators } from "./interfaces";
|
|
4
|
+
|
|
5
|
+
export interface IIntegrationsState {
|
|
6
|
+
integrations: IIntegration[];
|
|
7
|
+
totalItems: number;
|
|
8
|
+
currentIntegration: IIntegration | null;
|
|
9
|
+
integrationCopy: { date: Date; integration: IIntegration } | null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const initialState = {
|
|
13
|
+
integrations: [],
|
|
14
|
+
totalItems: 0,
|
|
15
|
+
currentIntegration: null,
|
|
16
|
+
integrationCopy: null,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export function reducer(state = initialState, action: IntegrationsActionsCreators): IIntegrationsState {
|
|
20
|
+
switch (action.type) {
|
|
21
|
+
case SET_INTEGRATIONS:
|
|
22
|
+
case SET_TOTAL_ITEMS:
|
|
23
|
+
case SET_CURRENT_INTEGRATION:
|
|
24
|
+
case SET_COPY_INTEGRATION:
|
|
25
|
+
return { ...state, ...action.payload };
|
|
26
|
+
default:
|
|
27
|
+
return state;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { initialState as integrationsInitialState, reducer as integrationsReducer };
|
|
@@ -36,7 +36,13 @@ import { navigationActions } from "@ax/containers/Navigation";
|
|
|
36
36
|
import { structuredDataActions } from "@ax/containers/StructuredData";
|
|
37
37
|
import { setCurrentSiteErrorPages } from "@ax/containers/Sites/actions";
|
|
38
38
|
import { pages, sites, structuredData } from "@ax/api";
|
|
39
|
-
import {
|
|
39
|
+
import {
|
|
40
|
+
getDefaultPageNavigation,
|
|
41
|
+
getDefaultIntegrations,
|
|
42
|
+
getPageData,
|
|
43
|
+
getPageNavigation,
|
|
44
|
+
getStateValues,
|
|
45
|
+
} from "./utils";
|
|
40
46
|
import {
|
|
41
47
|
SET_BREADCRUMB,
|
|
42
48
|
SET_SCHEMA,
|
|
@@ -259,6 +265,8 @@ function generateNewPage(dispatch: Dispatch, getState: any, baseSchema: string)
|
|
|
259
265
|
},
|
|
260
266
|
pageEditor: { template },
|
|
261
267
|
app: { lang },
|
|
268
|
+
dataPacks,
|
|
269
|
+
integrations: { integrations },
|
|
262
270
|
} = getState();
|
|
263
271
|
|
|
264
272
|
let page = getDefaultSchema(baseSchema);
|
|
@@ -269,6 +277,8 @@ function generateNewPage(dispatch: Dispatch, getState: any, baseSchema: string)
|
|
|
269
277
|
|
|
270
278
|
page = { ...parsedPageData, template: currentTemplate, language: lang.id };
|
|
271
279
|
|
|
280
|
+
page.integrations = getDefaultIntegrations(dataPacks, integrations, template);
|
|
281
|
+
|
|
272
282
|
if (structuredData) {
|
|
273
283
|
page.structuredData = structuredData.id;
|
|
274
284
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ISavePageParams } from "@ax/types";
|
|
1
|
+
import { IIntegration, ISavePageParams } from "@ax/types";
|
|
2
2
|
import { cleanContent } from "@ax/forms";
|
|
3
3
|
|
|
4
4
|
const getPageParams = (getState: any): ISavePageParams => {
|
|
@@ -94,6 +94,27 @@ const getPageNavigation = (
|
|
|
94
94
|
return { header, footer };
|
|
95
95
|
};
|
|
96
96
|
|
|
97
|
+
const getDefaultIntegrations = (dataPacks: any, integrations: IIntegration[], template: string): IIntegration[] => {
|
|
98
|
+
const templateIntegrations = dataPacks.activated.find((pack: any) =>
|
|
99
|
+
pack.templates.some((packTemplate: any) => packTemplate.id === template)
|
|
100
|
+
)?.config?.templates?.[template]?.integrations;
|
|
101
|
+
|
|
102
|
+
const availableIntegrations = integrations.filter(
|
|
103
|
+
(integration: IIntegration) =>
|
|
104
|
+
!templateIntegrations?.some((_integration: IIntegration) => Number(_integration.id) === Number(integration.id))
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
const allPagesIntegrations = availableIntegrations.filter(
|
|
108
|
+
(integration: IIntegration) => integration.contentPresence.presenceType === "all" && integration.active
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
const defaultIntegrations: IIntegration[] = [];
|
|
112
|
+
templateIntegrations && defaultIntegrations.push(...templateIntegrations);
|
|
113
|
+
allPagesIntegrations && defaultIntegrations.push(...allPagesIntegrations);
|
|
114
|
+
|
|
115
|
+
return defaultIntegrations;
|
|
116
|
+
};
|
|
117
|
+
|
|
97
118
|
const getDefaultPageNavigation = (defaultsContent: any, type: string) => {
|
|
98
119
|
const navigations: any = defaultsContent.filter((content: any) => content.type === type);
|
|
99
120
|
|
|
@@ -102,4 +123,11 @@ const getDefaultPageNavigation = (defaultsContent: any, type: string) => {
|
|
|
102
123
|
return navitagion;
|
|
103
124
|
};
|
|
104
125
|
|
|
105
|
-
export {
|
|
126
|
+
export {
|
|
127
|
+
getPageParams,
|
|
128
|
+
getPageData,
|
|
129
|
+
getStateValues,
|
|
130
|
+
getPageNavigation,
|
|
131
|
+
getDefaultIntegrations,
|
|
132
|
+
getDefaultPageNavigation,
|
|
133
|
+
};
|
package/src/hooks/content.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { useEffect,
|
|
1
|
+
import { useEffect, useState, useLayoutEffect } from "react";
|
|
2
|
+
import { IEmptyStateProps } from "@ax/types";
|
|
2
3
|
import { useWindowSize } from "./window";
|
|
3
4
|
|
|
4
5
|
const useCategoryColors = (): any => {
|
|
@@ -39,6 +40,49 @@ const useCategoryColors = (): any => {
|
|
|
39
40
|
};
|
|
40
41
|
};
|
|
41
42
|
|
|
43
|
+
const useEmptyState = (
|
|
44
|
+
elements: unknown[],
|
|
45
|
+
fetchState: { isLoading: boolean; isFiltered: boolean },
|
|
46
|
+
emptyStates: IEmptyStates
|
|
47
|
+
): { isEmpty: boolean; emptyStateProps: IEmptyStateProps } => {
|
|
48
|
+
const { isLoading, isFiltered } = fetchState;
|
|
49
|
+
const [isEmpty, setIsEmpty] = useState(false);
|
|
50
|
+
const [emptyStateProps, setEmptyStateProps] = useState<IEmptyStateProps>({});
|
|
51
|
+
const [isLoaded, setIsLoaded] = useState<boolean>();
|
|
52
|
+
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (isLoading || typeof isLoaded !== "undefined") {
|
|
55
|
+
setIsLoaded(!isLoading);
|
|
56
|
+
}
|
|
57
|
+
}, [isLoading, isLoaded]);
|
|
58
|
+
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (isLoaded) {
|
|
61
|
+
setIsEmpty(!elements.length);
|
|
62
|
+
if (!isFiltered) {
|
|
63
|
+
emptyStates.noElementsProps && setEmptyStateProps(emptyStates.noElementsProps);
|
|
64
|
+
} else if (emptyStates.noSearchResultsProps) {
|
|
65
|
+
setEmptyStateProps(emptyStates.noSearchResultsProps);
|
|
66
|
+
} else {
|
|
67
|
+
const emptyProps = {
|
|
68
|
+
icon: "search",
|
|
69
|
+
title: "Oh! No Results Found",
|
|
70
|
+
message: "We couldn’t find what you are looking for. Please, try another search.",
|
|
71
|
+
};
|
|
72
|
+
setEmptyStateProps(emptyProps);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
76
|
+
}, [isLoaded]);
|
|
77
|
+
|
|
78
|
+
return { isEmpty, emptyStateProps };
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
interface IEmptyStates {
|
|
82
|
+
noElementsProps: IEmptyStateProps;
|
|
83
|
+
noSearchResultsProps?: IEmptyStateProps;
|
|
84
|
+
}
|
|
85
|
+
|
|
42
86
|
const useAdaptiveText = (
|
|
43
87
|
containerRef: React.RefObject<HTMLDivElement>,
|
|
44
88
|
fullText: string,
|
|
@@ -63,4 +107,4 @@ const useAdaptiveText = (
|
|
|
63
107
|
return output;
|
|
64
108
|
};
|
|
65
109
|
|
|
66
|
-
export { useCategoryColors, useAdaptiveText };
|
|
110
|
+
export { useCategoryColors, useEmptyState, useAdaptiveText };
|
package/src/hooks/index.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import { useBulkSelection } from "./bulk";
|
|
|
2
2
|
import { useDebounce, useEqualStructured, useIsDirty, usePrevious } from "./forms";
|
|
3
3
|
import { useHandleClickOutside, useModal, useToast } from "./modals";
|
|
4
4
|
import { useURLSearchParam } from "./location";
|
|
5
|
-
import { useCategoryColors, useAdaptiveText } from "./content";
|
|
5
|
+
import { useCategoryColors, useEmptyState, useAdaptiveText } from "./content";
|
|
6
6
|
import { useWindowSize } from "./window";
|
|
7
7
|
import { useOnMessageReceivedFromIframe, useOnMessageReceivedFromOutside } from "./iframe";
|
|
8
8
|
|
|
@@ -17,6 +17,7 @@ export {
|
|
|
17
17
|
useBulkSelection,
|
|
18
18
|
useURLSearchParam,
|
|
19
19
|
useCategoryColors,
|
|
20
|
+
useEmptyState,
|
|
20
21
|
useWindowSize,
|
|
21
22
|
useAdaptiveText,
|
|
22
23
|
useOnMessageReceivedFromIframe,
|
package/src/hooks/modals.tsx
CHANGED
|
@@ -34,18 +34,20 @@ const useHandleClickOutside = (isOpen: boolean, handleClickOutside: any) => {
|
|
|
34
34
|
|
|
35
35
|
const useToast = () => {
|
|
36
36
|
const [isVisible, setIsVisible] = useState(false);
|
|
37
|
+
const [state, setState] = useState<any>(null);
|
|
37
38
|
|
|
38
39
|
let temp: any;
|
|
39
40
|
const setTemp = () => (temp = setTimeout(() => setIsVisible(false), 6000));
|
|
40
41
|
const stopTemp = () => clearTimeout(temp);
|
|
41
42
|
|
|
42
|
-
const toggleToast = () => {
|
|
43
|
+
const toggleToast = (state?: unknown) => {
|
|
43
44
|
setIsVisible(true);
|
|
44
45
|
setTemp();
|
|
45
46
|
stopTemp();
|
|
47
|
+
state && setState(state);
|
|
46
48
|
};
|
|
47
49
|
|
|
48
|
-
return { isVisible, setIsVisible, toggleToast };
|
|
50
|
+
return { isVisible, setIsVisible, toggleToast, state };
|
|
49
51
|
};
|
|
50
52
|
|
|
51
53
|
export { useModal, useHandleClickOutside, useToast };
|
|
@@ -6,17 +6,18 @@ export const Heading = styled.li`
|
|
|
6
6
|
`;
|
|
7
7
|
|
|
8
8
|
export const Dropdown = styled.ul<{ isSubmenu?: boolean; isSubmenuOpen: boolean; type: string }>`
|
|
9
|
-
background-color: ${(p) =>
|
|
9
|
+
background-color: ${(p) =>
|
|
10
|
+
p.type === "multisite" ? p.theme.color.uiMainMenuBackgroundDark : p.theme.color.uiSiteMenuDark};
|
|
10
11
|
color: ${(p) => p.theme.color.textHighEmphasisInverse};
|
|
11
12
|
cursor: default;
|
|
12
13
|
padding-left: ${(p) => p.theme.spacing.s};
|
|
13
14
|
padding-right: ${(p) => p.theme.spacing.s};
|
|
14
|
-
align-items: ${(p) => p.isSubmenu ? "flex-start" : "center"};
|
|
15
|
+
align-items: ${(p) => (p.isSubmenu ? "flex-start" : "center")};
|
|
15
16
|
border-radius: ${(p) => ` 0 ${p.theme.radii.s} ${p.theme.radii.s} 0`};
|
|
16
|
-
flex-direction: ${(p) => p.isSubmenu ? "column" : "row"};
|
|
17
|
+
flex-direction: ${(p) => (p.isSubmenu ? "column" : "row")};
|
|
17
18
|
|
|
18
19
|
${Heading} {
|
|
19
|
-
margin-bottom: ${(p) => p.isSubmenu ? p.theme.spacing.xs : "0"};
|
|
20
|
+
margin-bottom: ${(p) => (p.isSubmenu ? p.theme.spacing.xs : "0")};
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
&.floating {
|
|
@@ -26,20 +27,20 @@ export const Dropdown = styled.ul<{ isSubmenu?: boolean; isSubmenuOpen: boolean;
|
|
|
26
27
|
left: 100%;
|
|
27
28
|
top: 0;
|
|
28
29
|
z-index: 1000;
|
|
29
|
-
height: ${(p) => p.isSubmenu ? "auto" : "40px"};
|
|
30
|
-
width: calc(${(p) => p.theme.spacing.xl} * 3);
|
|
31
|
-
padding: ${(p) => p.isSubmenu ? p.theme.spacing.s : "0"};
|
|
30
|
+
height: ${(p) => (p.isSubmenu ? "auto" : "40px")};
|
|
31
|
+
min-width: calc(${(p) => p.theme.spacing.xl} * 3);
|
|
32
|
+
padding: ${(p) => (p.isSubmenu ? p.theme.spacing.s : "0")};
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
&.inline {
|
|
35
36
|
position: relative;
|
|
36
|
-
display: ${(p) => p.isSubmenuOpen ? "flex" : "none"};
|
|
37
|
+
display: ${(p) => (p.isSubmenuOpen ? "flex" : "none")};
|
|
37
38
|
overflow: hidden;
|
|
38
|
-
transition: all .5s ease-in-out;
|
|
39
|
-
opacity: ${(p) => p.isSubmenuOpen ? "1" : "0"};
|
|
39
|
+
transition: all 0.5s ease-in-out;
|
|
40
|
+
opacity: ${(p) => (p.isSubmenuOpen ? "1" : "0")};
|
|
40
41
|
width: 100%;
|
|
41
|
-
padding-top: ${(p) => p.theme.spacing.xs
|
|
42
|
-
padding-bottom: ${(p) => p.theme.spacing.xs
|
|
42
|
+
padding-top: ${(p) => p.theme.spacing.xs};
|
|
43
|
+
padding-bottom: ${(p) => p.theme.spacing.xs};
|
|
43
44
|
padding-left: ${(p) => `calc(${p.theme.spacing.m} * 2)`};
|
|
44
45
|
|
|
45
46
|
${Heading} {
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
ISetCurrentPageNameAction,
|
|
35
35
|
pageStatus,
|
|
36
36
|
} from "@ax/containers/PageEditor/interfaces";
|
|
37
|
+
import { integrationsActions } from "@ax/containers/Integrations";
|
|
37
38
|
|
|
38
39
|
import { getOptionValues, getOptionFilters, getCurrentFilter, filterByStatus, getSortedListStatus } from "./utils";
|
|
39
40
|
import { useSortedListStatus, useFilterQuery } from "./hooks";
|
|
@@ -98,6 +99,7 @@ const Content = (props: IProps): JSX.Element => {
|
|
|
98
99
|
sitesByLang,
|
|
99
100
|
user,
|
|
100
101
|
skipReviewOnPublish,
|
|
102
|
+
getIntegrations,
|
|
101
103
|
setContentFilters,
|
|
102
104
|
contentFilters,
|
|
103
105
|
deleteAndRemoveFromSiteBulk,
|
|
@@ -277,6 +279,7 @@ const Content = (props: IProps): JSX.Element => {
|
|
|
277
279
|
resetPageEditor();
|
|
278
280
|
resetCurrentSiteErrorPages();
|
|
279
281
|
fetchSitesByLang();
|
|
282
|
+
getIntegrations(currentSiteInfo.id);
|
|
280
283
|
resetForm();
|
|
281
284
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
282
285
|
}, []);
|
|
@@ -866,6 +869,7 @@ interface IDispatchProps {
|
|
|
866
869
|
restorePage(id: number | number[]): Promise<boolean>;
|
|
867
870
|
getDataPack: (id: string) => Promise<void>;
|
|
868
871
|
resetCurrentSiteErrorPages: () => Promise<void>;
|
|
872
|
+
getIntegrations(site: number): Promise<void>;
|
|
869
873
|
getSitesByLang(params: IGetSitesParams): Promise<void>;
|
|
870
874
|
setContentFilters(contentFilters: Record<string, string> | null): void;
|
|
871
875
|
deleteAndRemoveFromSiteBulk(pageIds: number[], globalPageIds: number[]): Promise<boolean>;
|
|
@@ -902,6 +906,7 @@ const mapDispatchToProps = {
|
|
|
902
906
|
getDataPack: dataPacksActions.getSiteDataPack,
|
|
903
907
|
resetCurrentSiteErrorPages: sitesActions.resetCurrentSiteErrorPages,
|
|
904
908
|
getSitesByLang: sitesActions.getSitesByLang,
|
|
909
|
+
getIntegrations: integrationsActions.getIntegrations,
|
|
905
910
|
setContentFilters: sitesActions.setContentFilters,
|
|
906
911
|
deleteAndRemoveFromSiteBulk: sitesActions.deleteAndRemoveFromSiteBulk,
|
|
907
912
|
checkUserSession: appActions.checkUserSession,
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { FieldsBehavior } from "@ax/components";
|
|
4
|
+
import { IIntegration } from "@ax/types";
|
|
5
|
+
|
|
6
|
+
import * as S from "./style";
|
|
7
|
+
|
|
8
|
+
const pageEditorID = 0;
|
|
9
|
+
|
|
10
|
+
const IntegrationsField = (props: IField): JSX.Element => {
|
|
11
|
+
const { template, templateConfig, updateDataPackFormValue, dataPackConfigFormData, updateEditorContent } = props;
|
|
12
|
+
|
|
13
|
+
const handleChange = (integrations: IIntegration[]) => {
|
|
14
|
+
const configFormData = {
|
|
15
|
+
...dataPackConfigFormData,
|
|
16
|
+
templates: {
|
|
17
|
+
...dataPackConfigFormData.templates,
|
|
18
|
+
[template]: {
|
|
19
|
+
...(!!dataPackConfigFormData.templates && dataPackConfigFormData.templates[template]),
|
|
20
|
+
integrations,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
updateDataPackFormValue(configFormData);
|
|
25
|
+
updateEditorContent(pageEditorID, "integrations", integrations);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<S.Wrapper>
|
|
30
|
+
<FieldsBehavior
|
|
31
|
+
fieldType="IntegrationsField"
|
|
32
|
+
value={templateConfig.templates?.[template]?.integrations}
|
|
33
|
+
onChange={handleChange}
|
|
34
|
+
/>
|
|
35
|
+
</S.Wrapper>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
interface IField {
|
|
40
|
+
template: string;
|
|
41
|
+
templateConfig: any;
|
|
42
|
+
dataPackConfigFormData: any;
|
|
43
|
+
updateDataPackFormValue: (value: any) => void;
|
|
44
|
+
updateEditorContent: (selectedEditorID: number, key: string, value: any) => void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { IntegrationsField };
|
|
@@ -7,7 +7,7 @@ import * as S from "./style";
|
|
|
7
7
|
|
|
8
8
|
const pageEditorID = 0;
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const NavigationField = (props: IField): JSX.Element => {
|
|
11
11
|
const {
|
|
12
12
|
type,
|
|
13
13
|
template,
|
|
@@ -115,4 +115,4 @@ interface IField {
|
|
|
115
115
|
updateDataPackFormValue: (value: any) => void;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
export {
|
|
118
|
+
export { NavigationField };
|