@griddo/ax 12.6.0 → 12.6.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.
Files changed (86) hide show
  1. package/config/griddo-config/index.js +1 -0
  2. package/package.json +3 -4
  3. package/src/GlobalStore.tsx +91 -35
  4. package/src/__tests__/modules/ActivityLog/ActivityLog.uc.test.tsx +132 -0
  5. package/src/__tests__/modules/Analytics/Analytics.uc.test.tsx +168 -0
  6. package/src/__tests__/modules/GlobalSettings/Robots/Robots.test.tsx +110 -0
  7. package/src/__tests__/modules/GlobalSettings/Robots/Robots.uc.test.tsx +125 -0
  8. package/src/__tests__/modules/Redirects/Redirects.uc.test.tsx +164 -0
  9. package/src/__tests__/modules/Settings/Languages/Languages.uc.test.tsx +213 -0
  10. package/src/__tests__/modules/Settings/Social/Social.uc.test.tsx +171 -0
  11. package/src/__tests__/store/activityLog.test.ts +301 -0
  12. package/src/__tests__/store/analytics.test.ts +134 -0
  13. package/src/__tests__/store/domains.test.ts +107 -0
  14. package/src/__tests__/store/languages.test.ts +129 -0
  15. package/src/__tests__/store/persist.test.ts +47 -0
  16. package/src/__tests__/store/redirects.test.ts +313 -0
  17. package/src/__tests__/store/social.test.ts +165 -0
  18. package/src/components/MainWrapper/index.tsx +14 -2
  19. package/src/containers/ActivityLog/index.tsx +16 -3
  20. package/src/containers/ActivityLog/slice.ts +45 -0
  21. package/src/containers/ActivityLog/{actions.tsx → thunks.ts} +104 -89
  22. package/src/containers/Analytics/index.tsx +14 -3
  23. package/src/containers/Analytics/slice.ts +48 -0
  24. package/src/containers/Analytics/thunks.ts +103 -0
  25. package/src/containers/Domains/index.tsx +12 -3
  26. package/src/containers/Domains/slice.ts +37 -0
  27. package/src/containers/Domains/thunks.ts +60 -0
  28. package/src/containers/Redirects/constants.tsx +1 -17
  29. package/src/containers/Redirects/index.tsx +14 -3
  30. package/src/containers/Redirects/slice.ts +60 -0
  31. package/src/containers/Redirects/thunks.ts +196 -0
  32. package/src/containers/Settings/Languages/index.tsx +15 -3
  33. package/src/containers/Settings/Languages/slice.ts +48 -0
  34. package/src/containers/Settings/Languages/thunks.ts +83 -0
  35. package/src/containers/Settings/Social/index.tsx +11 -3
  36. package/src/containers/Settings/Social/slice.ts +40 -0
  37. package/src/containers/Settings/Social/thunks.ts +68 -0
  38. package/src/containers/Sites/actions.tsx +6 -2
  39. package/src/index.tsx +7 -6
  40. package/src/modules/ActivityLog/ItemLog/EventItem/index.tsx +13 -27
  41. package/src/modules/ActivityLog/ItemLogUser/UserItem/EventItem/index.tsx +13 -27
  42. package/src/modules/ActivityLog/index.tsx +22 -51
  43. package/src/modules/Analytics/index.tsx +33 -42
  44. package/src/modules/App/Routing/index.tsx +5 -4
  45. package/src/modules/FileDrive/index.tsx +1 -1
  46. package/src/modules/GlobalSettings/Robots/index.tsx +24 -47
  47. package/src/modules/MediaGallery/index.tsx +1 -1
  48. package/src/modules/Redirects/RedirectItem/index.tsx +9 -22
  49. package/src/modules/Redirects/RedirectPanel/index.tsx +13 -14
  50. package/src/modules/Redirects/index.tsx +26 -69
  51. package/src/modules/Settings/ContentTypes/DataPacks/index.tsx +4 -3
  52. package/src/modules/Settings/Languages/LanguagePanel/Form/ConnectedField/index.tsx +11 -18
  53. package/src/modules/Settings/Languages/LanguagePanel/Form/index.tsx +7 -9
  54. package/src/modules/Settings/Languages/LanguagePanel/index.tsx +38 -44
  55. package/src/modules/Settings/Languages/Table/Header/index.tsx +12 -19
  56. package/src/modules/Settings/Languages/Table/Item/index.tsx +21 -36
  57. package/src/modules/Settings/Languages/Table/index.tsx +6 -14
  58. package/src/modules/Settings/Languages/index.tsx +18 -30
  59. package/src/modules/Settings/SeoAnalyticsSettings/Analytics/index.tsx +42 -52
  60. package/src/modules/Settings/Social/index.tsx +17 -12
  61. package/src/modules/StructuredData/StructuredDataList/index.tsx +3 -2
  62. package/src/store/hooks.ts +37 -0
  63. package/src/store/index.ts +2 -0
  64. package/src/types/index.tsx +5 -6
  65. package/tsconfig.paths.json +1 -0
  66. package/src/containers/ActivityLog/constants.tsx +0 -6
  67. package/src/containers/ActivityLog/interfaces.tsx +0 -12
  68. package/src/containers/ActivityLog/reducer.tsx +0 -24
  69. package/src/containers/Analytics/actions.tsx +0 -109
  70. package/src/containers/Analytics/constants.tsx +0 -5
  71. package/src/containers/Analytics/interfaces.tsx +0 -9
  72. package/src/containers/Analytics/reducer.tsx +0 -28
  73. package/src/containers/Domains/actions.tsx +0 -58
  74. package/src/containers/Domains/constants.tsx +0 -5
  75. package/src/containers/Domains/interfaces.tsx +0 -9
  76. package/src/containers/Domains/reducer.tsx +0 -22
  77. package/src/containers/Redirects/actions.tsx +0 -190
  78. package/src/containers/Redirects/interfaces.tsx +0 -23
  79. package/src/containers/Redirects/reducer.tsx +0 -35
  80. package/src/containers/Settings/Languages/actions.tsx +0 -88
  81. package/src/containers/Settings/Languages/constants.tsx +0 -6
  82. package/src/containers/Settings/Languages/reducer.tsx +0 -31
  83. package/src/containers/Settings/Social/actions.tsx +0 -63
  84. package/src/containers/Settings/Social/constants.tsx +0 -3
  85. package/src/containers/Settings/Social/interfaces.tsx +0 -9
  86. package/src/containers/Settings/Social/reducer.tsx +0 -18
@@ -1,190 +0,0 @@
1
- import { redirects } from "@ax/api";
2
- import { appActions } from "@ax/containers/App";
3
- import { handleRequest } from "@ax/helpers";
4
- import {
5
- DEFAULT_PARAMS,
6
- ERROR_CODE,
7
- SET_IMPORTS,
8
- SET_REDIRECTS,
9
- SET_TOTAL_IMPORTS,
10
- SET_TOTAL_ITEMS,
11
- } from "./constants";
12
- import type { ISetImports, ISetRedirects, ISetTotalImports, ISetTotalItems } from "./interfaces";
13
-
14
- function setRedirects(redirects: any[]): ISetRedirects {
15
- return { type: SET_REDIRECTS, payload: { redirects } };
16
- }
17
-
18
- function setTotalItems(totalItems: number): ISetTotalItems {
19
- return { type: SET_TOTAL_ITEMS, payload: { totalItems } };
20
- }
21
-
22
- function setImports(imports: any): ISetImports {
23
- return { type: SET_IMPORTS, payload: { imports } };
24
- }
25
-
26
- function setTotalImports(totalImports: number): ISetTotalImports {
27
- return { type: SET_TOTAL_IMPORTS, payload: { totalImports } };
28
- }
29
-
30
- function getRedirects(params: any, filters?: string): (dispatch: any) => Promise<void> {
31
- return async (dispatch) => {
32
- try {
33
- dispatch(setRedirects([]));
34
- const callback = async () => redirects.getRedirects(params, filters);
35
-
36
- const responseActions = {
37
- handleSuccess: (response: any) => {
38
- const { items, totalItems } = response;
39
- dispatch(setRedirects(items));
40
- dispatch(setTotalItems(totalItems));
41
- },
42
- handleError: (response: any) => appActions.handleError(response)(dispatch),
43
- };
44
-
45
- await handleRequest(callback, responseActions, [appActions.setIsLoading])(dispatch);
46
- } catch (e) {
47
- console.log(e);
48
- }
49
- };
50
- }
51
-
52
- function addRedirect(
53
- redirect: { from: string; to: string | number },
54
- errorAction: () => void,
55
- force?: boolean,
56
- filter?: string,
57
- ): (dispatch: any, getState: any) => Promise<void> {
58
- return async (dispatch, getState) => {
59
- try {
60
- const {
61
- sites: { currentSiteInfo },
62
- } = getState();
63
-
64
- const callback = async () => redirects.createRedirect(redirect, force);
65
-
66
- const responseActions = {
67
- handleSuccess: () => {
68
- const params = { ...DEFAULT_PARAMS };
69
- const siteFilterQuery = currentSiteInfo && currentSiteInfo.id ? `&sites=${currentSiteInfo.id}` : filter;
70
- dispatch(getRedirects(params, siteFilterQuery));
71
- },
72
- handleError: (response: any) => {
73
- const { status } = response;
74
-
75
- status === ERROR_CODE.isBeingUsed ? errorAction() : appActions.handleError(response)(dispatch);
76
- },
77
- };
78
-
79
- await handleRequest(callback, responseActions, [])(dispatch);
80
- } catch (e) {
81
- console.log(e);
82
- }
83
- };
84
- }
85
-
86
- function updateRedirect(
87
- redirect: { from: string; to: string | number },
88
- redirectID: number,
89
- filter?: string,
90
- ): (dispatch: any, getState: any) => Promise<void> {
91
- return async (dispatch, getState) => {
92
- try {
93
- const {
94
- sites: { currentSiteInfo },
95
- } = getState();
96
-
97
- const callback = async () => redirects.updateRedirect(redirect, redirectID);
98
-
99
- const responseActions = {
100
- handleSuccess: () => {
101
- const params = { ...DEFAULT_PARAMS };
102
- const siteFilterQuery = currentSiteInfo && currentSiteInfo.id ? `&sites=${currentSiteInfo.id}` : filter;
103
- dispatch(getRedirects(params, siteFilterQuery));
104
- },
105
- handleError: (response: any) => appActions.handleError(response)(dispatch),
106
- };
107
-
108
- await handleRequest(callback, responseActions, [])(dispatch);
109
- } catch (e) {
110
- console.log(e);
111
- }
112
- };
113
- }
114
-
115
- function deleteRedirect(
116
- redirectID: number | number[],
117
- filter?: string,
118
- ): (dispatch: any, getState: any) => Promise<boolean> {
119
- return async (dispatch, getState) => {
120
- try {
121
- const {
122
- sites: { currentSiteInfo },
123
- } = getState();
124
-
125
- const callback = async () =>
126
- Array.isArray(redirectID) ? redirects.deleteRedirectsBulk(redirectID) : redirects.deleteRedirect(redirectID);
127
-
128
- const responseActions = {
129
- handleSuccess: () => {
130
- const params = { ...DEFAULT_PARAMS };
131
- const siteFilterQuery = currentSiteInfo?.id ? `&sites=${currentSiteInfo.id}` : filter;
132
- dispatch(getRedirects(params, siteFilterQuery));
133
- },
134
- handleError: (response: any) => {
135
- const {
136
- data: { message },
137
- } = response;
138
- const isMultiple = Array.isArray(message) && message.length > 1;
139
- const msg = isMultiple ? `The delete action failed due to ${message.length} errors.` : undefined;
140
- appActions.handleError(response, isMultiple, msg)(dispatch);
141
- },
142
- };
143
-
144
- return await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
145
- } catch (e) {
146
- console.log(e);
147
- return false;
148
- }
149
- };
150
- }
151
-
152
- function importRedirects(
153
- redirect: { from: string; to: string | number }[],
154
- check: boolean,
155
- ): (dispatch: any) => Promise<boolean> {
156
- return async (dispatch) => {
157
- try {
158
- const callback = async () =>
159
- check ? redirects.createRedirectsBulkCheck(redirect) : redirects.createRedirectsBulk(redirect);
160
-
161
- const responseActions = {
162
- handleSuccess: (response: any) => {
163
- if (check) {
164
- const { total, error, existing, ok } = response;
165
- dispatch(setImports({ error, existing, ok }));
166
- dispatch(setTotalImports(total));
167
- } else {
168
- const params = { ...DEFAULT_PARAMS };
169
- dispatch(getRedirects(params));
170
- }
171
- },
172
- handleError: (response: any) => {
173
- const {
174
- data: { message },
175
- } = response;
176
- const isMultiple = Array.isArray(message) && message.length > 1;
177
- const msg = isMultiple ? `The import action failed due to ${message.length} errors.` : undefined;
178
- appActions.handleError(response, isMultiple, msg)(dispatch);
179
- },
180
- };
181
-
182
- return await handleRequest(callback, responseActions, [])(dispatch);
183
- } catch (e) {
184
- console.log(e);
185
- return false;
186
- }
187
- };
188
- }
189
-
190
- export { getRedirects, addRedirect, updateRedirect, deleteRedirect, importRedirects };
@@ -1,23 +0,0 @@
1
- import type { SET_IMPORTS, SET_REDIRECTS, SET_TOTAL_IMPORTS, SET_TOTAL_ITEMS } from "./constants";
2
-
3
- export interface ISetRedirects {
4
- type: typeof SET_REDIRECTS;
5
- payload: { redirects: any[] };
6
- }
7
-
8
- export interface ISetTotalItems {
9
- type: typeof SET_TOTAL_ITEMS;
10
- payload: { totalItems: number };
11
- }
12
-
13
- export interface ISetImports {
14
- type: typeof SET_IMPORTS;
15
- payload: { imports: any };
16
- }
17
-
18
- export interface ISetTotalImports {
19
- type: typeof SET_TOTAL_IMPORTS;
20
- payload: { totalImports: number };
21
- }
22
-
23
- export type RedirectsActionsCreators = ISetRedirects | ISetTotalItems | ISetImports | ISetTotalImports;
@@ -1,35 +0,0 @@
1
- import type { IRedirect } from "@ax/types";
2
- import { SET_IMPORTS, SET_REDIRECTS, SET_TOTAL_IMPORTS, SET_TOTAL_ITEMS } from "./constants";
3
- import type { RedirectsActionsCreators } from "./interfaces";
4
-
5
- export interface IRedirectsState {
6
- redirects: any[];
7
- totalItems: number;
8
- totalImports: number;
9
- imports: null | {
10
- error: IRedirect[];
11
- existing: IRedirect[];
12
- ok: IRedirect[];
13
- };
14
- }
15
-
16
- export const initialState = {
17
- redirects: [],
18
- totalItems: 0,
19
- totalImports: 0,
20
- imports: null,
21
- };
22
-
23
- export function reducer(state = initialState, action: RedirectsActionsCreators): IRedirectsState {
24
- switch (action.type) {
25
- case SET_REDIRECTS:
26
- case SET_TOTAL_ITEMS:
27
- case SET_IMPORTS:
28
- case SET_TOTAL_IMPORTS:
29
- return { ...state, ...action.payload };
30
- default:
31
- return state;
32
- }
33
- }
34
-
35
- export { initialState as redirectsInitialState, reducer as redirectsReducer };
@@ -1,88 +0,0 @@
1
- import type { Dispatch } from "redux";
2
- import type { ISiteLanguage } from "@ax/types";
3
- import { handleRequest } from "@ax/helpers";
4
- import { languages } from "@ax/api";
5
- import { appActions } from "@ax/containers/App";
6
- import { sitesActions } from "@ax/containers/Sites";
7
- import { UPDATE_FORM, CREATE_FORM } from "./constants";
8
- import { languagesInitialState } from "./reducer";
9
-
10
- const { setIsSaving, setIsLoading } = appActions;
11
- const { getSiteLanguages } = sitesActions;
12
- function setForm(form: any) {
13
- return { type: CREATE_FORM, payload: { form } };
14
- }
15
-
16
- function updateForm(form: any) {
17
- return { type: UPDATE_FORM, payload: { form } };
18
- }
19
-
20
- function updateFormValue(valueObj: any): (dispatch: Dispatch, getState: any) => void {
21
- return (dispatch, getState) => {
22
- const {
23
- languages: { form },
24
- } = getState();
25
- const updatedForm = { ...form, ...valueObj };
26
- dispatch(updateForm(updatedForm));
27
- };
28
- }
29
-
30
- function resetForm(): (dispatch: Dispatch) => void {
31
- return (dispatch) => {
32
- const { form } = languagesInitialState;
33
- dispatch(updateForm(form));
34
- };
35
- }
36
-
37
- function createSiteLanguage(siteID: number, data: ISiteLanguage): (dispatch: Dispatch) => Promise<void> {
38
- return async (dispatch) => {
39
- try {
40
- const responseActions = {
41
- handleSuccess: () => getSiteLanguages(siteID)(dispatch),
42
- handleError: (response: any) => appActions.handleError(response)(dispatch),
43
- };
44
-
45
- const callback = async () => languages.createSiteLanguage(siteID, data);
46
-
47
- await handleRequest(callback, responseActions, [setIsSaving])(dispatch);
48
- } catch (e) {
49
- console.log(e); // TODO: capturar error bien
50
- }
51
- };
52
- }
53
-
54
- function updateSiteLanguage(siteID: number, data: ISiteLanguage): (dispatch: Dispatch) => Promise<void> {
55
- return async (dispatch) => {
56
- try {
57
- const responseActions = {
58
- handleSuccess: () => getSiteLanguages(siteID)(dispatch),
59
- handleError: (response: any) => appActions.handleError(response)(dispatch),
60
- };
61
-
62
- const callback = async () => languages.updateSiteLanguage(siteID, data);
63
-
64
- await handleRequest(callback, responseActions, [setIsSaving])(dispatch);
65
- } catch (e) {
66
- console.log(e); // TODO: capturar error bien
67
- }
68
- };
69
- }
70
-
71
- function deleteSiteLanguage(siteID: number, id: number): (dispatch: Dispatch) => Promise<void> {
72
- return async (dispatch) => {
73
- try {
74
- const responseActions = {
75
- handleSuccess: () => getSiteLanguages(siteID)(dispatch),
76
- handleError: (response: any) => appActions.handleError(response)(dispatch),
77
- };
78
-
79
- const callback = async () => languages.deleteSiteLanguage(siteID, id);
80
-
81
- await handleRequest(callback, responseActions, [setIsLoading])(dispatch);
82
- } catch (e) {
83
- console.log(e); // TODO: capturar error bien
84
- }
85
- };
86
- }
87
-
88
- export { createSiteLanguage, updateSiteLanguage, setForm, updateForm, updateFormValue, resetForm, deleteSiteLanguage };
@@ -1,6 +0,0 @@
1
- const NAME = "languages";
2
-
3
- const CREATE_FORM = `${NAME}/CREATE_FORM`;
4
- const UPDATE_FORM = `${NAME}/UPDATE_FORM`;
5
-
6
- export { NAME, CREATE_FORM, UPDATE_FORM };
@@ -1,31 +0,0 @@
1
- import { CREATE_FORM, UPDATE_FORM } from "./constants";
2
-
3
- export interface ILanguageState {
4
- form: {
5
- language: number | null;
6
- path: string;
7
- domain: number | null;
8
- isDefault: boolean;
9
- };
10
- }
11
-
12
- export const initialState = {
13
- form: {
14
- language: null,
15
- path: "",
16
- domain: null,
17
- isDefault: false,
18
- },
19
- };
20
-
21
- export function reducer(state = initialState, action: any): ILanguageState {
22
- switch (action.type) {
23
- case CREATE_FORM:
24
- case UPDATE_FORM:
25
- return { ...state, ...action.payload };
26
- default:
27
- return state;
28
- }
29
- }
30
-
31
- export { initialState as languagesInitialState, reducer as languagesReducer };
@@ -1,63 +0,0 @@
1
- import type { Dispatch } from "redux";
2
-
3
- import { SET_SOCIAL } from "./constants";
4
-
5
- import type { ISetSocialAction } from "./interfaces";
6
-
7
- import { appActions } from "@ax/containers/App";
8
- import { handleRequest } from "@ax/helpers";
9
- import { social } from "@ax/api";
10
-
11
- function setSocial(socialInfo: any): ISetSocialAction {
12
- return { type: SET_SOCIAL, payload: { ...socialInfo } };
13
- }
14
-
15
- function saveSocial(form: Record<string, string>): (dispatch: Dispatch, getState: any) => Promise<boolean> {
16
- return async (dispatch, getState) => {
17
- try {
18
- const {
19
- sites: { currentSiteInfo },
20
- } = getState();
21
-
22
- const responseActions = {
23
- handleSuccess: (data: Record<string, string>) => {
24
- dispatch(setSocial(data));
25
- return true;
26
- },
27
- handleError: (data: any) => appActions.handleError(data)(dispatch),
28
- };
29
-
30
- const callback = async () => social.updateSocial(currentSiteInfo.id, form);
31
-
32
- return await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
33
- } catch (e) {
34
- console.log(e);
35
- return false;
36
- }
37
- };
38
- }
39
-
40
- function getSocial(): (dispatch: any, getState: any) => Promise<void> {
41
- return async (dispatch, getState) => {
42
- try {
43
- const {
44
- sites: { currentSiteInfo },
45
- } = getState();
46
-
47
- const responseActions = {
48
- handleSuccess: (data: Record<string, string>) => {
49
- dispatch(setSocial(data));
50
- },
51
- handleError: () => console.log("Error en getSocial"),
52
- };
53
-
54
- const callback = () => social.getSocial(currentSiteInfo.id);
55
-
56
- await handleRequest(callback, responseActions, [appActions.setIsLoading])(dispatch);
57
- } catch (e) {
58
- console.log(e);
59
- }
60
- };
61
- }
62
-
63
- export { getSocial, saveSocial, setSocial };
@@ -1,3 +0,0 @@
1
- export const NAME = "social";
2
-
3
- export const SET_SOCIAL = `${NAME}/SET_SOCIAL`;
@@ -1,9 +0,0 @@
1
- import type { SET_SOCIAL } from "./constants";
2
- import type { ISocialState } from "@ax/types";
3
-
4
- export interface ISetSocialAction {
5
- type: typeof SET_SOCIAL;
6
- payload: ISocialState;
7
- }
8
-
9
- export type SocialActionsCreators = ISetSocialAction;
@@ -1,18 +0,0 @@
1
- import { SET_SOCIAL } from "./constants";
2
-
3
- import type { ISocialState } from "@ax/types";
4
-
5
- import type { SocialActionsCreators } from "./interfaces";
6
-
7
- export const initialState = {};
8
-
9
- export function reducer(state = initialState, action: SocialActionsCreators): ISocialState {
10
- switch (action.type) {
11
- case SET_SOCIAL:
12
- return { ...action.payload };
13
- default:
14
- return state;
15
- }
16
- }
17
-
18
- export { initialState as socialInitialState, reducer as socialReducer };